Skip to content

Commit

Permalink
first submit
Browse files Browse the repository at this point in the history
  • Loading branch information
QDong415 committed Apr 14, 2022
0 parents commit 58e41a4
Show file tree
Hide file tree
Showing 73 changed files with 2,813 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# QDrawGift

## 简介:

仿快手直播间手绘礼物,手绘+播放+底部礼物弹框,Demo非常完整,非常贴合实际开发场景 。
A Gift Painter useful in Living Room. Support paint+play+bottomSheet

## 安装体验:
![](https://upload-images.jianshu.io/upload_images/26002059-83cf0b95754b2466.png)

## 功能(优点):
- ✅Demo包含`手绘View`+`播放View`+`底部礼物弹框View`+转成json传给服务器+模拟服务器推送来json解析队列
- ✅为了兼容底部礼物弹框是基于Dialog或者popupView做的,本Demo的`手绘View`是基于windowManager层
-`手绘View`可以单独撤销一笔
-`播放View`使用LinkedList做礼物队列,可以随意插入到列头或者列尾
- ✅底部礼物弹框兼容手绘礼物和普通礼物,选择不同的礼物,手绘View层可以切换placeHolder
- ✅每个模块都相互解耦,都可以自由替换,也都可以拉出来当做独立的模块
- ✅采用SpareArray做Bitmap缓存,占用内存极低
- ✅无内存泄漏。代码清晰明确,注释量比代码都多

## 效果gif图(Gif图有点卡,实际运行一点都不卡):
![](https://upload-images.jianshu.io/upload_images/26002059-48456ffa60a85222.gif)


## 导入
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.QDong415:QDrawGift:v1.1.1'
}
```

## 使用

```java
//底部的礼物弹框
private BottomGiftSheetBuilder giftSheetBuilder;

//画礼物的背景View(透明的,并不是灰底)
private DrawGiftView drawGiftView;

//播放礼物动画的层
private DrawGiftPlayView playView;
```

```java
//初始化手绘礼物View
drawGiftView = new DrawGiftView(LiveActivity.this);
//设置当前要画的礼物
drawGiftView.setCurrentGift(giftid ,giftBitmap , giftPrice);
//正式显示手绘礼物View,添加它到windowManager层
drawGiftView.showInActivityWindow(LiveActivity.this, giftSheetBuilder.mDialog.getContentView().getHeight());
```

```java
//初始化播放View
playView = new DrawGiftPlayView(this);

//添加播放View到decorView
FrameLayout contentParent = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
contentParent.addView(playView);

//开始播放礼物,insertToFirst = 是否插入到队列靠前位置
playView.addDrawGifts(allDrawGiftArray, insertToFirst);
```


## Author

有问题联系QQ:285275534, 285275534@qq.com
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
46 changes: 46 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
compileSdk 31

defaultConfig {
applicationId "com.dq.dragclosedemo"
minSdk 16
targetSdk 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation 'com.github.bumptech.glide:glide:4.11.0'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8'
implementation project(path: ':dragclose')
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
18 changes: 18 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.dq.dragclosedemo",
"variantName": "processReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.dq.dragclosedemo;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.dq.dragclosedemo", appContext.getPackageName());
}
}
35 changes: 35 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dq.dragclosedemo">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DragCloseDemo">

<activity
android:name=".waterfall.GoodsActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".userdetail.FeedDetailRootActivity"
android:theme="@style/Transparent"></activity>

<activity
android:name=".detail.FeedDetailActivity"
android:theme="@style/Transparent"></activity>

</application>

<uses-permission android:name="android.permission.INTERNET" />

</manifest>

0 comments on commit 58e41a4

Please sign in to comment.