├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── sample_head.gif
│ │ │ │ ├── live_im_heart.png
│ │ │ │ ├── live_im_good_type1.png
│ │ │ │ ├── live_im_good_type10.png
│ │ │ │ ├── live_im_good_type11.png
│ │ │ │ ├── live_im_good_type12.png
│ │ │ │ ├── live_im_good_type13.png
│ │ │ │ ├── live_im_good_type14.png
│ │ │ │ ├── live_im_good_type2.png
│ │ │ │ ├── live_im_good_type3.png
│ │ │ │ ├── live_im_good_type4.png
│ │ │ │ ├── live_im_good_type5.png
│ │ │ │ ├── live_im_good_type6.png
│ │ │ │ ├── live_im_good_type7.png
│ │ │ │ ├── live_im_good_type8.png
│ │ │ │ ├── live_im_good_type9.png
│ │ │ │ └── live_im_comment_head_circle.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── live_shape_im_msg_join_bg.xml
│ │ │ │ └── live_im_msg_tv_shap.xml
│ │ │ ├── anim
│ │ │ │ ├── live_im_hide_in.xml
│ │ │ │ ├── live_im_hide_out.xml
│ │ │ │ ├── live_im_hide_out3.xml
│ │ │ │ ├── live_im_hide_in3.xml
│ │ │ │ ├── live_im_users_bg_show.xml
│ │ │ │ ├── live_im_goodmsg_scale.xml
│ │ │ │ ├── live_im_goodmsg_base.xml
│ │ │ │ ├── live_message_out.xml
│ │ │ │ ├── live_im_hide_in2.xml
│ │ │ │ ├── live_im_hide_out2.xml
│ │ │ │ └── live_im_msgv_scal_in.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ └── layout
│ │ │ │ ├── live_im_join_view.xml
│ │ │ │ ├── content_main.xml
│ │ │ │ ├── live_im_rceive_msg_view.xml
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── dev
│ │ │ └── journey
│ │ │ └── auotodismiss
│ │ │ ├── view
│ │ │ ├── GoodsInitUtile.java
│ │ │ ├── GoodAnimationUtile.java
│ │ │ └── MessagQuenView.java
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── journey
│ │ │ └── autodismiss
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── dev
│ │ └── journey
│ │ └── auotodismiss
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
└── gradle.xml
├── settings.gradle
├── images
├── 1.jpeg
└── 2.jpeg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | AutoMissingMessage
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/images/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/images/1.jpeg
--------------------------------------------------------------------------------
/images/2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/images/2.jpeg
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/sample_head.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/sample_head.gif
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | /.idea
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_heart.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type10.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type11.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type12.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type13.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type14.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type4.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type5.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type6.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type7.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type8.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_good_type9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_good_type9.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AutoDismiss
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/live_im_comment_head_circle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/journey-M/AutoMissingMessage/HEAD/app/src/main/res/mipmap-xxhdpi/live_im_comment_head_circle.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 仿花椒直播交互页面
2 | 仿花椒直播聊天的时候消息向上弹出,一定时间后自动消失的效果。仿花椒气泡式点赞效果
3 |
4 | 
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #101010
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/live_shape_im_msg_join_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/live_im_msg_tv_shap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_hide_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_hide_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_hide_out3.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_hide_in3.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/journey/autodismiss/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.journey.autodismiss;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_users_bg_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/dev/journey/auotodismiss/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package dev.journey.auotodismiss;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
4 |
5 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_goodmsg_scale.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/live_im_join_view.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.example.journey.autodismiss"
9 | minSdkVersion 11
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 | compile 'com.android.support:design:23.1.1'
27 | compile 'com.facebook.fresco:fresco:0.9.0+'
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_goodmsg_base.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
14 |
15 |
16 |
22 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/live_im_rceive_msg_view.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
19 |
20 |
27 |
28 |
35 |
36 |
37 |
44 |
45 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_message_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_hide_in2.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_hide_out2.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/live_im_msgv_scal_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
72 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/journey/auotodismiss/view/GoodsInitUtile.java:
--------------------------------------------------------------------------------
1 | package dev.journey.auotodismiss.view;
2 |
3 |
4 | import dev.journey.autodismiss.R;
5 |
6 | public class GoodsInitUtile {
7 |
8 | private static int goodType1 = R.mipmap.live_im_good_type1;
9 | private static int goodType2 = R.mipmap.live_im_good_type2;
10 | private static int goodType3 = R.mipmap.live_im_good_type3;
11 | private static int goodType4 = R.mipmap.live_im_good_type4;
12 | private static int goodType5 = R.mipmap.live_im_good_type5;
13 | private static int goodType6 = R.mipmap.live_im_good_type6;
14 | private static int goodType7 = R.mipmap.live_im_good_type7;
15 | private static int goodType8 = R.mipmap.live_im_good_type8;
16 | private static int goodType9 = R.mipmap.live_im_good_type9;
17 | private static int goodType10 = R.mipmap.live_im_good_type10;
18 | private static int goodType11 = R.mipmap.live_im_good_type11;
19 | private static int goodType12 = R.mipmap.live_im_good_type12;
20 | private static int goodType13 = R.mipmap.live_im_good_type13;
21 | private static int goodType14 = R.mipmap.live_im_good_type14;
22 |
23 | private static int TYPECOUNT = 14;
24 |
25 | /*
26 | * 不同用户的标识id
27 | */
28 | public static int fromGoodID(int _id) {
29 | int rint = (int) (_id % TYPECOUNT);
30 | return rint;
31 | }
32 |
33 | /*
34 | * 获取点赞的类型
35 | */
36 | public static int getGoodsType(int type) {
37 | int rType = goodType1;
38 | switch (type) {
39 | case 1:
40 | rType = goodType1;
41 | break;
42 | case 2:
43 | rType = goodType2;
44 | break;
45 | case 3:
46 | rType = goodType3;
47 | break;
48 | case 4:
49 | rType = goodType4;
50 | break;
51 | case 5:
52 | rType = goodType5;
53 | break;
54 | case 6:
55 | rType = goodType6;
56 | break;
57 | case 7:
58 | rType = goodType7;
59 | break;
60 | case 8:
61 | rType = goodType8;
62 | break;
63 | case 9:
64 | rType = goodType9;
65 | break;
66 | case 10:
67 | rType = goodType10;
68 | break;
69 | case 11:
70 | rType = goodType11;
71 | break;
72 | case 12:
73 | rType = goodType12;
74 | break;
75 | case 13:
76 | rType = goodType13;
77 | break;
78 | case 14:
79 | rType = goodType14;
80 | break;
81 | }
82 | return rType;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/journey/auotodismiss/view/GoodAnimationUtile.java:
--------------------------------------------------------------------------------
1 | package dev.journey.auotodismiss.view;
2 |
3 | import java.text.NumberFormat;
4 |
5 | import android.content.Context;
6 | import android.view.animation.Animation;
7 | import android.view.animation.AnimationSet;
8 | import android.view.animation.AnimationUtils;
9 | import android.view.animation.TranslateAnimation;
10 |
11 | import dev.journey.autodismiss.R;
12 |
13 |
14 | public class GoodAnimationUtile {
15 |
16 | /*
17 | * 动画逻辑
18 | * 动画时长分为 3.5秒 ,
19 | *
20 | * 0-3.5 秒 向上 位移
21 | *
22 | * 0- 0.8 秒 放大 位移 0.5
23 | *
24 | * 1-2 秒 左右 位移
25 | *
26 | * 2-3 秒 左右位移
27 | *
28 | * 2.6-3.5秒 渐隐消失
29 | *
30 | */
31 |
32 | public static AnimationSet createAnimation(Context context) {
33 |
34 | AnimationSet animSet = new AnimationSet(false);
35 |
36 | Animation anim = AnimationUtils.loadAnimation(context, R.anim.live_im_goodmsg_base);
37 | animSet.addAnimation(anim);
38 |
39 | animSet.addAnimation(getTranceAnim01(context));
40 | animSet.addAnimation(getTranceAnim12(context));
41 | animSet.addAnimation(getTranceAnim23(context));
42 | animSet.addAnimation(getTranceAnim34(context));
43 |
44 | return animSet;
45 |
46 | }
47 |
48 | public static Animation getTranceAnim01(Context context) {
49 |
50 | TranslateAnimation inAnim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, getRandParam(), TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0f);
51 | inAnim.setDuration(700);
52 | inAnim.setStartOffset(300);
53 |
54 | return inAnim;
55 | }
56 |
57 | public static Animation getTranceAnim12(Context context) {
58 |
59 | TranslateAnimation inAnim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, getRandParam(), TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0f);
60 | inAnim.setDuration(1000);
61 | inAnim.setStartOffset(1000);
62 | return inAnim;
63 | }
64 |
65 | public static Animation getTranceAnim23(Context context) {
66 |
67 | TranslateAnimation inAnim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, getRandParam(), TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0f);
68 | inAnim.setDuration(1000);
69 | inAnim.setStartOffset(2000);
70 | return inAnim;
71 | }
72 |
73 | public static Animation getTranceAnim34(Context context) {
74 |
75 | TranslateAnimation inAnim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, getRandParam(), TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0f);
76 | inAnim.setDuration(1000);
77 | inAnim.setStartOffset(3000);
78 | return inAnim;
79 | }
80 |
81 | public static float getRandParm01() {
82 | NumberFormat n = NumberFormat.getInstance();
83 | n.setMaximumFractionDigits(1);
84 | float f = Float.parseFloat(n.format(Math.random()));
85 | float fre = (float) ((f - 0.5) * 0.5);
86 | return fre;
87 | }
88 |
89 | public static float getRandParam() {
90 | NumberFormat n = NumberFormat.getInstance();
91 | n.setMaximumFractionDigits(1);
92 | float f = Float.parseFloat(n.format(Math.random()));
93 | float fre = (float) (f - 0.5);
94 | return fre;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
36 |
37 |
43 |
44 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
77 |
78 |
79 |
80 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/journey/auotodismiss/MainActivity.java:
--------------------------------------------------------------------------------
1 | package dev.journey.auotodismiss;
2 |
3 | import android.os.Bundle;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.support.design.widget.TextInputLayout;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.animation.Animation;
13 | import android.widget.Button;
14 | import android.widget.EditText;
15 | import android.widget.ImageView;
16 | import android.widget.RelativeLayout;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 |
20 | import com.facebook.drawee.backends.pipeline.Fresco;
21 | import com.facebook.drawee.view.SimpleDraweeView;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | import dev.journey.auotodismiss.view.GoodAnimationUtile;
27 | import dev.journey.auotodismiss.view.GoodsInitUtile;
28 | import dev.journey.auotodismiss.view.MessagQuenView;
29 | import dev.journey.autodismiss.R;
30 |
31 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
32 | private MessagQuenView msgweQueeView;
33 | private RelativeLayout thumbContainer;
34 | private Button btnSendMsg, btnThumbs, btnJoin;
35 | private TextInputLayout txtLayout;
36 | private EditText mEdMsg;
37 | private List lsImgGoods = new ArrayList();
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | Fresco.initialize(this);
43 | setContentView(R.layout.activity_main);
44 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
45 | setSupportActionBar(toolbar);
46 | initView();
47 | initParams();
48 | }
49 |
50 | private void initView() {
51 | msgweQueeView = (MessagQuenView) findViewById(R.id.msgQuenView);
52 | thumbContainer = (RelativeLayout) findViewById(R.id.thumbContainer);
53 | txtLayout = (TextInputLayout) findViewById(R.id.txtLayout);
54 | mEdMsg = txtLayout.getEditText();
55 | txtLayout.setHint("输入要发送的消息内容");
56 | btnSendMsg = (Button) findViewById(R.id.btn_sendmsg);
57 | btnThumbs = (Button) findViewById(R.id.btn_thumb);
58 | btnJoin = (Button) findViewById(R.id.btn_join);
59 |
60 | btnThumbs.setOnClickListener(this);
61 | btnSendMsg.setOnClickListener(this);
62 | btnJoin.setOnClickListener(this);
63 |
64 |
65 | Toast.makeText(this, "a", Toast.LENGTH_SHORT).show();
66 | }
67 |
68 |
69 | private void initParams() {
70 |
71 | initGoodImageViews();
72 |
73 | }
74 |
75 | @Override
76 | public void onClick(View v) {
77 | if (v == btnJoin) {
78 | joinRoom();
79 | }
80 | if (v == btnSendMsg) {
81 | sendMessages();
82 | }
83 | if (v == btnThumbs) {
84 | sendThumbs();
85 | }
86 | }
87 |
88 | private final Handler msgReceivHandle = new Handler() {
89 |
90 | @Override
91 | public void handleMessage(android.os.Message msg) {
92 | super.handleMessage(msg);
93 |
94 | if (msg.what == 1) {
95 | View addView = null;
96 | if (msg.arg1 == 1) {
97 | setGoodsUiTouch(GoodsInitUtile.getGoodsType(msg.arg2));
98 | } else if (msg.arg1 == 2) {
99 | // 加入 消息
100 | addView = getLayoutInflater().inflate(R.layout.live_im_join_view, null);
101 | // String msgtxt = user == null ? "" : user.getName() + "加入了聊天室";
102 | String msgtxt = (String) msg.obj;
103 | ((TextView) addView.findViewById(R.id.live_im_comes_tv)).setText(msgtxt);
104 |
105 | } else if (msg.arg1 == 3) {
106 | // 文字到消息
107 | addView = getLayoutInflater().inflate(R.layout.live_im_rceive_msg_view, null);
108 |
109 | SimpleDraweeView simDrawView = (SimpleDraweeView) addView.findViewById(R.id.live_user_header_icon);
110 | ((TextView) addView.findViewById(R.id.live_user_name)).setText("小五哥");
111 | ((TextView) addView.findViewById(R.id.live_user_msg_txt)).setText((String) msg.obj);
112 | addView.findViewById(R.id.live_message_container).setOnClickListener(new View.OnClickListener() {
113 | @Override
114 | public void onClick(View v) {
115 | Toast.makeText(MainActivity.this, "点击头像", Toast.LENGTH_SHORT).show();
116 | }
117 | });
118 | }
119 |
120 | if (addView != null) {
121 | msgweQueeView.addNewView(addView);
122 | }
123 | }
124 | }
125 |
126 | };
127 |
128 |
129 | /**
130 | * 触发发送消息的事件
131 | */
132 | private void sendMessages() {
133 | Message msgMsg = msgReceivHandle.obtainMessage();
134 | msgMsg.what = 1;
135 | msgMsg.arg1 = 3;
136 | msgMsg.obj = mEdMsg.getText().toString();
137 |
138 | msgReceivHandle.sendMessage(msgMsg);
139 | }
140 |
141 | /**
142 | * 触发点赞的事件
143 | */
144 | private void sendThumbs() {
145 | Message msgMsg = msgReceivHandle.obtainMessage();
146 | msgMsg.what = 1;
147 | msgMsg.arg1 = 1;//点赞
148 | int random = (int) (Math.random() * 100 + 1) % 14;
149 | msgMsg.arg2 = random;
150 | msgMsg.obj = mEdMsg.getText().toString();
151 |
152 | msgReceivHandle.sendMessage(msgMsg);
153 | }
154 |
155 | /**
156 | * 加入聊天室
157 | */
158 | private void joinRoom() {
159 | Message msgMsg = msgReceivHandle.obtainMessage();
160 | msgMsg.what = 1;
161 | msgMsg.arg1 = 2;
162 | msgMsg.obj = "李大娇加入了聊天室";
163 |
164 | msgReceivHandle.sendMessage(msgMsg);
165 | }
166 |
167 | class GoodHolder {
168 | public boolean isAdd = false;
169 | public long time;
170 | }
171 |
172 |
173 | /**
174 | * 点赞的话,开始设置赞的效果
175 | */
176 | public void setGoodsUiTouch(int resource) {
177 | ImageView goodImgView = getGoodImageView();
178 | if (goodImgView == null) {
179 | return;
180 | }
181 | ((GoodHolder) goodImgView.getTag()).isAdd = true;
182 | ((GoodHolder) goodImgView.getTag()).time = System.currentTimeMillis();
183 | goodImgView.setImageResource(resource);
184 | thumbContainer.addView(goodImgView);
185 | goodImgView.setVisibility(View.INVISIBLE);
186 |
187 | Animation anim = GoodAnimationUtile.createAnimation(this);
188 | anim.setAnimationListener(new GoodMsgAnimaionList(goodImgView));
189 | goodImgView.startAnimation(anim);
190 | }
191 |
192 | private ImageView getGoodImageView() {
193 | for (int i = 0; i < lsImgGoods.size(); i++) {
194 | ImageView imgtem = lsImgGoods.get(i);
195 | GoodHolder tag = (GoodHolder) imgtem.getTag();
196 | if (tag.isAdd == false) {
197 | return imgtem;
198 | }
199 | }
200 | return null;
201 | }
202 |
203 | /*
204 | * 初始化赞的数量, 并设置赞的位置
205 | * 设置赞的出现位置 居中 还是靠右
206 | */
207 | private void initGoodImageViews() {
208 | for (int i = 0; i < 25; i++) {
209 | ImageView img = new ImageView(this);
210 | RelativeLayout.LayoutParams rlPram = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
211 | rlPram.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
212 | // 水平居中
213 | rlPram.addRule(RelativeLayout.CENTER_HORIZONTAL);
214 | img.setLayoutParams(rlPram);
215 | img.setImageResource(R.mipmap.live_im_heart);
216 | GoodHolder holderTag = new GoodHolder();
217 | holderTag.time = System.currentTimeMillis();
218 | img.setTag(holderTag);
219 | img.setScaleX(0.1f);
220 | img.setScaleY(0.1f);
221 | lsImgGoods.add(img);
222 |
223 | }
224 | }
225 |
226 | /**
227 | * 回收点赞的view
228 | */
229 | private Handler moveHandler = new Handler() {
230 | @Override
231 | public void handleMessage(Message msg) {
232 | super.handleMessage(msg);
233 | for (int i = 0; i < thumbContainer.getChildCount(); i++) {
234 | ImageView imgv = null;
235 | try {
236 | imgv = (ImageView) thumbContainer.getChildAt(i);
237 | } catch (Exception e) {
238 | imgv = null;
239 | }
240 | if (imgv == null) {
241 | continue;
242 | }
243 |
244 | long time = ((GoodHolder) imgv.getTag()).time;
245 | long before = (Long) msg.obj;
246 |
247 | if (time == before) {
248 | ((GoodHolder) imgv.getTag()).isAdd = false;
249 | thumbContainer.removeView(imgv);
250 | }
251 | }
252 | }
253 |
254 | };
255 |
256 | class GoodMsgAnimaionList implements Animation.AnimationListener {
257 | private ImageView imgv;
258 |
259 | public GoodMsgAnimaionList(ImageView imgv) {
260 | this.imgv = imgv;
261 | }
262 |
263 | @Override
264 | public void onAnimationEnd(Animation arg0) {
265 | imgv.clearAnimation();
266 | imgv.setVisibility(View.INVISIBLE);
267 |
268 | Message msg = moveHandler.obtainMessage();
269 | msg.what = 1;
270 | msg.obj = ((GoodHolder) (imgv.getTag())).time;
271 | moveHandler.sendMessage(msg);
272 |
273 | }
274 |
275 | @Override
276 | public void onAnimationRepeat(Animation arg0) {
277 | }
278 |
279 | @Override
280 | public void onAnimationStart(Animation arg0) {
281 | }
282 |
283 | }
284 |
285 | @Override
286 | public boolean onCreateOptionsMenu(Menu menu) {
287 | getMenuInflater().inflate(R.menu.menu_main, menu);
288 | return true;
289 | }
290 |
291 | @Override
292 | public boolean onOptionsItemSelected(MenuItem item) {
293 | int id = item.getItemId();
294 | if (id == R.id.action_settings) {
295 | return true;
296 | }
297 | return super.onOptionsItemSelected(item);
298 | }
299 | }
300 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/journey/auotodismiss/view/MessagQuenView.java:
--------------------------------------------------------------------------------
1 | package dev.journey.auotodismiss.view;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 | import android.view.MotionEvent;
9 | import android.view.VelocityTracker;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.animation.Animation;
13 | import android.view.animation.AnimationUtils;
14 | import android.widget.Scroller;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Iterator;
18 | import java.util.List;
19 | import java.util.Stack;
20 | import java.util.concurrent.Executors;
21 | import java.util.concurrent.ScheduledExecutorService;
22 | import java.util.concurrent.TimeUnit;
23 |
24 | import dev.journey.autodismiss.R;
25 |
26 | /**
27 | * gwj
28 | * 自定义控件 实现自动消失 控件 回收
29 | */
30 |
31 | public class MessagQuenView extends ViewGroup {
32 | private Context context;
33 | private Scroller mScroller;
34 | private VelocityTracker mVelocityTracker;
35 | private int viewHeight = 0;
36 | private int childViewHeight = 0;
37 | private float lastDownY;
38 | private String TAG = "tag";
39 |
40 | public MessagQuenView(Context context, AttributeSet attrs) {
41 | super(context, attrs);
42 | this.context = context;
43 | init();
44 | }
45 |
46 | public MessagQuenView(Context context) {
47 | super(context);
48 | }
49 |
50 | /*
51 | * 回收线程, 每隔一段时间去检查过期的View 触发回收事件
52 | */
53 | private ScheduledExecutorService mservice = Executors.newSingleThreadScheduledExecutor();
54 |
55 | private void setSchedule() {
56 |
57 | if (mservice.isShutdown()) {
58 | mservice = Executors.newSingleThreadScheduledExecutor();
59 | }
60 | mservice.scheduleAtFixedRate(new Runnable() {
61 | @Override
62 | public void run() {
63 | schedualRemove();
64 | }
65 | }, 0, 1200, TimeUnit.MILLISECONDS);
66 | }
67 |
68 | public void shutDownSchedulSeervice() {
69 | mservice.shutdownNow();
70 | }
71 |
72 | private void init() {
73 | setSchedule();
74 | //初始化滑动的类
75 | mScroller = new Scroller(context);
76 | }
77 |
78 | @Override
79 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
80 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
81 | int count = getChildCount();
82 | int measureTempHeight = 0;
83 | for (int i = 0; i < count; i++) {
84 | measureChild(getChildAt(i), widthMeasureSpec, heightMeasureSpec);
85 | measureTempHeight = measureTempHeight + getChildAt(i).getMeasuredHeight();
86 | }
87 | childViewHeight = measureTempHeight;
88 | setMeasuredDimension(measureWidthSize(widthMeasureSpec), measureSize(heightMeasureSpec));
89 | viewHeight = getHeight();
90 | Log.e(TAG, "childViewHeight=" + childViewHeight);
91 | Log.e(TAG, "viewHeight == " + viewHeight);
92 | }
93 |
94 | private int measureWidthSize(int widthMeasureSpec) {
95 | int result = 0; // 结果
96 | int specMode = MeasureSpec.getMode(widthMeasureSpec);
97 | int specSize = MeasureSpec.getSize(widthMeasureSpec);
98 | switch (specMode) {
99 | case MeasureSpec.AT_MOST: // 子容器可以是声明大小内的任意大小
100 | result = specSize;
101 | break;
102 | case MeasureSpec.EXACTLY: // 父容器已经为子容器设置了尺寸,子容器应当服从这些边界,不论子容器想要多大的空间.
103 | // 比如EditTextView中的DrawLeft
104 | result = specSize;
105 | break;
106 | case MeasureSpec.UNSPECIFIED: // 父容器对于子容器没有任何限制,子容器想要多大就多大.
107 | // 所以完全取决于子view的大小
108 | result = 1500;
109 | break;
110 | default:
111 | break;
112 | }
113 | return result * 2 / 3;
114 | }
115 |
116 | private int measureSize(int heightMeasureSpec) {
117 | // TODO Auto-generated method stub
118 | int result = 0; // 结果
119 | int specMode = MeasureSpec.getMode(heightMeasureSpec);
120 | int specSize = MeasureSpec.getSize(heightMeasureSpec);
121 | switch (specMode) {
122 | case MeasureSpec.AT_MOST: // 子容器可以是声明大小内的任意大小
123 | result = specSize;
124 | break;
125 | case MeasureSpec.EXACTLY: // 父容器已经为子容器设置了尺寸,子容器应当服从这些边界,不论子容器想要多大的空间.
126 | // 比如EditTextView中的DrawLeft
127 | result = specSize;
128 | break;
129 | case MeasureSpec.UNSPECIFIED: // 父容器对于子容器没有任何限制,子容器想要多大就多大.
130 | // 所以完全取决于子view的大小
131 | result = 1500;
132 | break;
133 | default:
134 | break;
135 | }
136 | return result;
137 | }
138 |
139 | @Override
140 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
141 | /*
142 | * 设置 左右的 padding
143 | */
144 | l = l + getPaddingLeft();
145 | r = r - getPaddingRight();
146 | t = t + getPaddingTop();
147 | b = b - getPaddingBottom();
148 |
149 | Stack drawChild = new Stack();
150 | drawChild.clear();
151 | for (Iterator itrator = childQueue.iterator(); itrator.hasNext(); ) {
152 | View child = itrator.next();
153 | drawChild.add(child);
154 | }
155 | // 设置 绘制最顶层的高度
156 | int dHeight = b;
157 | while (drawChild.size() >= 1) {
158 | View child = drawChild.pop();
159 | child.layout(l, dHeight - child.getMeasuredHeight(), r, dHeight);
160 | dHeight = dHeight - child.getHeight();
161 | }
162 | }
163 |
164 | /*
165 | * 所有子View的List容器
166 | */
167 | private List childQueue = new ArrayList();
168 |
169 | /*
170 | * 通知View 移除控件操作
171 | */
172 | private final Handler handlerAnim = new Handler() {
173 | public void handleMessage(Message msg) {
174 | removeView((View) msg.obj);
175 | childQueue.remove((View) msg.obj);
176 |
177 | }
178 | };
179 |
180 | /*
181 | * 通知View 移除控件操作
182 | */
183 | private final Handler handlerCallRemove = new Handler() {
184 | public void handleMessage(Message msg) {
185 |
186 | final View child = (View) msg.obj;
187 | child.setVisibility(View.VISIBLE);
188 |
189 | Animation anim = AnimationUtils.loadAnimation(context, R.anim.live_message_out);
190 | anim.setAnimationListener(new Animation.AnimationListener() {
191 | @Override
192 | public void onAnimationStart(Animation animation) {
193 | }
194 |
195 | @Override
196 | public void onAnimationRepeat(Animation animation) {
197 | }
198 |
199 | @Override
200 | public void onAnimationEnd(Animation animation) {
201 | Message msg = handlerAnim.obtainMessage();
202 | msg.obj = child;
203 | handlerAnim.sendMessage(msg);
204 | }
205 | });
206 | child.startAnimation(anim);
207 |
208 | }
209 |
210 | };
211 |
212 | public void schedualRemove() {
213 | for (int i = 0; i < getChildCount(); i++) {
214 | final View child = getChildAt(i);
215 | if (child != null) {
216 | ItemTag tag = (ItemTag) child.getTag();
217 | if (!tag.isMove) {
218 | int delt = (int) ((System.currentTimeMillis() - tag.time) / 1000);
219 | if (delt > 2) {
220 | // 重新设置 tag 标签
221 | tag.isMove = true;
222 | child.setTag(tag);
223 |
224 | Message msg = handlerCallRemove.obtainMessage();
225 | msg.obj = child;
226 | handlerCallRemove.sendMessage(msg);
227 | }
228 | } else {
229 | // tag 设置 wei true
230 |
231 | }
232 |
233 | }
234 | }
235 | }
236 |
237 | // 添加View 控件
238 | public void addNewView(View childv) {
239 | ItemTag tag = new ItemTag();
240 | tag.time = System.currentTimeMillis();
241 | childv.setTag(tag);
242 | childQueue.add(childv);
243 | // Animation anim = AnimationUtils.loadAnimation(context, R.anim.live_im_msgv_scal_in);
244 | // childv.startAnimation(anim);
245 | this.addView(childv);
246 | }
247 |
248 |
249 | @Override
250 | public boolean onTouchEvent(MotionEvent event) {
251 |
252 | if (mVelocityTracker == null) {
253 | mVelocityTracker = VelocityTracker.obtain();
254 | }
255 | mVelocityTracker.addMovement(event);
256 | switch (event.getAction()) {
257 | case MotionEvent.ACTION_DOWN:
258 | lastDownY = event.getY();
259 | mVelocityTracker.clear();
260 | mVelocityTracker.addMovement(event);
261 | break;
262 | case MotionEvent.ACTION_MOVE:
263 | float currentY = event.getY();
264 | float dy;
265 | dy = lastDownY - currentY;
266 | lastDownY = event.getY();
267 | mVelocityTracker.addMovement(event);
268 | //dy>0向上滑动 超过水平线 getScrollY <0 低于最低水平
269 | // if (dy >= 0 && getScrollY() > 0) {
270 | // Log.e(TAG, "dy >===0");
271 | // return true;
272 | // }
273 | // //dy<0向下滑动 低于水平线 getScrollY >0 超过最高水平
274 | // if (dy <= 0 && getScrollY() < viewHeight - childViewHeight) {
275 | // Log.e(TAG, "dy <====0");
276 | // return true;
277 | // }
278 |
279 | if (childViewHeight > viewHeight) {
280 | scrollBy(0, (int) dy);
281 | }
282 | Log.e(TAG, "scrollY =" + getScrollY());
283 | break;
284 | case MotionEvent.ACTION_UP:
285 | // if (childViewHeight > viewHeight) {
286 | // if (getScrollY() > 0) {
287 | // mScroller.startScroll(0, getScrollY(), 0, -getScrollY());
288 | // } else if (getScrollY() < viewHeight - childViewHeight) {
289 | // int temp = (viewHeight - childViewHeight);
290 | // mScroller.startScroll(0, getScrollY(), 0, temp - getScrollY());
291 | // }
292 | // }
293 | if (childViewHeight > viewHeight) {
294 | mVelocityTracker.computeCurrentVelocity(1000);
295 | float velocityY = mVelocityTracker.getYVelocity();
296 | mScroller.fling(0, getScrollY(), 0, (int) -velocityY, 0, 0, viewHeight - childViewHeight, 0);
297 | postInvalidate();
298 | } else {
299 | // mScroller.startScroll();
300 | mScroller.startScroll(0, getScrollY(), 0, -getScrollY());
301 |
302 | }
303 |
304 | break;
305 | }
306 | return true;
307 | }
308 |
309 |
310 | @Override
311 | public void computeScroll() {
312 | if (mScroller.computeScrollOffset()) {//是否已经滚动完成
313 | scrollTo(0, mScroller.getCurrY());//获取当前值,startScroll()初始化后,调用就能获取区间值
314 | postInvalidate();
315 | }
316 | }
317 |
318 | /*
319 | * View的tag标记
320 | */
321 | class ItemTag {
322 | public long time;
323 | public boolean isMove = false;
324 | }
325 |
326 | }
327 |
--------------------------------------------------------------------------------