├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── emoji_1.png │ │ │ │ ├── emoji_2.png │ │ │ │ ├── emoji_3.png │ │ │ │ ├── emoji_4.png │ │ │ │ ├── emoji_5.png │ │ │ │ ├── emoji_6.png │ │ │ │ ├── emoji_7.png │ │ │ │ ├── emoji_8.png │ │ │ │ ├── emoji_9.png │ │ │ │ ├── emoji_10.png │ │ │ │ ├── emoji_11.png │ │ │ │ ├── emoji_12.png │ │ │ │ ├── emoji_13.png │ │ │ │ ├── emoji_14.png │ │ │ │ ├── emoji_15.png │ │ │ │ ├── emoji_16.png │ │ │ │ ├── emoji_17.png │ │ │ │ ├── emoji_18.png │ │ │ │ ├── emoji_19.png │ │ │ │ ├── emoji_20.png │ │ │ │ ├── emoji_21.png │ │ │ │ ├── emoji_22.png │ │ │ │ ├── emoji_23.png │ │ │ │ ├── emoji_24.png │ │ │ │ ├── emoji_25.png │ │ │ │ ├── emoji_26.png │ │ │ │ ├── emoji_27.png │ │ │ │ ├── emoji_28.png │ │ │ │ ├── emoji_29.png │ │ │ │ ├── emoji_30.png │ │ │ │ ├── emoji_31.png │ │ │ │ ├── emoji_32.png │ │ │ │ ├── emoji_33.png │ │ │ │ ├── emoji_34.png │ │ │ │ ├── emoji_35.png │ │ │ │ ├── emoji_36.png │ │ │ │ ├── emoji_37.png │ │ │ │ ├── emoji_38.png │ │ │ │ ├── emoji_39.png │ │ │ │ ├── emoji_40.png │ │ │ │ ├── emoji_41.png │ │ │ │ ├── emoji_42.png │ │ │ │ ├── emoji_43.png │ │ │ │ ├── emoji_44.png │ │ │ │ ├── emoji_45.png │ │ │ │ ├── emoji_46.png │ │ │ │ ├── emoji_47.png │ │ │ │ ├── emoji_48.png │ │ │ │ ├── emoji_49.png │ │ │ │ ├── emoji_50.png │ │ │ │ ├── emoji_51.png │ │ │ │ ├── emoji_52.png │ │ │ │ ├── emoji_53.png │ │ │ │ ├── emoji_54.png │ │ │ │ ├── emoji_55.png │ │ │ │ ├── emoji_56.png │ │ │ │ ├── emoji_57.png │ │ │ │ ├── emoji_58.png │ │ │ │ ├── emoji_59.png │ │ │ │ ├── emoji_60.png │ │ │ │ ├── emoji_61.png │ │ │ │ ├── emoji_62.png │ │ │ │ ├── emoji_63.png │ │ │ │ ├── emoji_64.png │ │ │ │ ├── emoji_65.png │ │ │ │ ├── emoji_66.png │ │ │ │ ├── emoji_67.png │ │ │ │ ├── emoji_68.png │ │ │ │ ├── emoji_69.png │ │ │ │ ├── emoji_70.png │ │ │ │ ├── emoji_71.png │ │ │ │ ├── emoji_72.png │ │ │ │ ├── emoji_73.png │ │ │ │ ├── emoji_74.png │ │ │ │ ├── emoji_75.png │ │ │ │ ├── emoji_76.png │ │ │ │ ├── emoji_77.png │ │ │ │ ├── emoji_78.png │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── multi_digg_num_0.png │ │ │ │ ├── multi_digg_num_1.png │ │ │ │ ├── multi_digg_num_2.png │ │ │ │ ├── multi_digg_num_3.png │ │ │ │ ├── multi_digg_num_4.png │ │ │ │ ├── multi_digg_num_5.png │ │ │ │ ├── multi_digg_num_6.png │ │ │ │ ├── multi_digg_num_7.png │ │ │ │ ├── multi_digg_num_8.png │ │ │ │ ├── multi_digg_num_9.png │ │ │ │ ├── multi_digg_word_level_1.png │ │ │ │ ├── multi_digg_word_level_2.png │ │ │ │ └── multi_digg_word_level_3.png │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ │ ├── ic_favorite_selector.xml │ │ │ │ ├── ic_favorite_24dp.xml │ │ │ │ ├── ic_favorite_border_24dp.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ │ ├── activity_recycler_view.xml │ │ │ │ ├── item_comment_layout.xml │ │ │ │ ├── activity_main.xml │ │ │ │ └── view_topic_user_header.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── sum │ │ │ └── slike │ │ │ └── simple │ │ │ ├── SimpleActivity.java │ │ │ ├── BitmapProviderFactory.java │ │ │ ├── RecyclerViewActivity.java │ │ │ └── CommentAdapter.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── sum │ │ │ └── slike │ │ │ └── simple │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── sum │ │ └── slike │ │ └── simple │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ ├── values │ │ │ ├── dimens.xml │ │ │ └── slike_attrs.xml │ │ └── drawable │ │ │ └── super_like_default_icon.png │ │ └── java │ │ └── com │ │ └── sum │ │ └── slike │ │ ├── AnimationEndListener.java │ │ ├── Element.java │ │ ├── AnimationFrame.java │ │ ├── BaseAnimationFrame.java │ │ ├── AnimationFramePool.java │ │ ├── TextAnimationFrame.java │ │ ├── EruptionAnimationFrame.java │ │ ├── SuperLikeLayout.java │ │ └── BitmapProvider.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── img ├── Animation.gif ├── custom_style.png ├── default_style.png └── list_like_animation.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── LICENSE ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /img/Animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/img/Animation.gif -------------------------------------------------------------------------------- /img/custom_style.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/img/custom_style.png -------------------------------------------------------------------------------- /img/default_style.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/img/default_style.png -------------------------------------------------------------------------------- /img/list_like_animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/img/list_like_animation.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SuperLike 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_1.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_3.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_4.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_5.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_6.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_7.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_8.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_10.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_11.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_12.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_13.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_14.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_15.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_16.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_17.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_18.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_19.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_20.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_21.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_22.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_23.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_24.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_25.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_26.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_27.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_28.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_29.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_30.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_31.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_32.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_33.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_34.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_35.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_36.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_37.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_38.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_39.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_40.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_41.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_42.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_43.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_44.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_45.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_46.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_47.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_48.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_49.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_50.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_51.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_52.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_53.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_54.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_55.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_56.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_57.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_58.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_59.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_60.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_61.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_62.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_63.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_63.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_64.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_65.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_65.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_66.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_67.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_67.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_68.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_68.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_69.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_69.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_70.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_71.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_72.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_73.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_73.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_74.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_74.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_75.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_76.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_77.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/emoji_78.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/emoji_78.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_0.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_1.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_3.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_4.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_5.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_6.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_7.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_8.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_num_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_num_9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14sp 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_word_level_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_word_level_1.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_word_level_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_word_level_2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/multi_digg_word_level_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/app/src/main/res/mipmap-xhdpi/multi_digg_word_level_3.png -------------------------------------------------------------------------------- /library/src/main/res/drawable/super_like_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qiu800820/SuperLike/HEAD/library/src/main/res/drawable/super_like_default_icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | /.idea 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/AnimationEndListener.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | /** 4 | * Created by Sen on 2018/2/9. 5 | */ 6 | 7 | public interface AnimationEndListener { 8 | 9 | void onAnimationEnd(AnimationFrame animationFrame); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Feb 06 09:39:40 CST 2018 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-4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/values/slike_attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/Element.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Paint; 5 | 6 | /** 7 | * Created by Sen on 2018/3/9. 8 | */ 9 | 10 | public interface Element { 11 | 12 | int getX(); 13 | 14 | int getY(); 15 | 16 | Bitmap getBitmap(); 17 | 18 | void evaluate(int start_x, int start_y, double time); 19 | 20 | Paint getPaint(); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/sum/slike/simple/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike.simple; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/AnimationFrame.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Sen on 2018/3/9. 7 | */ 8 | 9 | public interface AnimationFrame { 10 | 11 | int getType(); 12 | 13 | boolean isRunning(); 14 | 15 | List nextFrame(long interval); 16 | 17 | boolean onlyOne(); 18 | 19 | void setAnimationEndListener(AnimationEndListener animationEndListener); 20 | 21 | void reset(); 22 | 23 | void prepare(int x, int y, BitmapProvider.Provider bitmapProvider); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite_border_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Sun Feb 11 08:59:21 CST 2018 16 | org.gradle.jvmargs=-Xmx1536m 17 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_recycler_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 13 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sum/slike/simple/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike.simple; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sum.slike.simple", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_comment_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2018 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 18 | 19 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.sum.slike.simple" 7 | minSdkVersion 16 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support:recyclerview-v7:26.1.0' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | implementation project(':library') 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/sum/slike/simple/SimpleActivity.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike.simple; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | import com.sum.slike.SuperLikeLayout; 8 | 9 | public class SimpleActivity extends AppCompatActivity { 10 | 11 | SuperLikeLayout superLikeLayout; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | superLikeLayout = findViewById(R.id.super_like_layout); 18 | superLikeLayout.setProvider(BitmapProviderFactory.getHDProvider(this)); 19 | findViewById(R.id.like_btn).setOnClickListener(new View.OnClickListener() { 20 | long duration = 2000; 21 | long lastClickTime; 22 | @Override 23 | public void onClick(View v) { 24 | if(System.currentTimeMillis() - lastClickTime > duration){ // 防抖 25 | v.setSelected(!v.isSelected()); 26 | } 27 | lastClickTime = System.currentTimeMillis(); 28 | if(v.isSelected()){ 29 | int x = (int)(v.getX() + v.getWidth() / 2); 30 | int y = (int)(v.getY() + v.getHeight() / 2); 31 | superLikeLayout.launch(x, y); 32 | } 33 | 34 | } 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/sum/slike/simple/BitmapProviderFactory.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike.simple; 2 | 3 | import android.content.Context; 4 | 5 | import com.sum.slike.BitmapProvider; 6 | 7 | /** 8 | * Created by Sen on 2018/4/26. 9 | */ 10 | 11 | public class BitmapProviderFactory { 12 | 13 | public static BitmapProvider.Provider getHDProvider(Context context) { 14 | return new BitmapProvider.Builder(context) 15 | .setDrawableArray(new int[]{R.mipmap.emoji_1, R.mipmap.emoji_2, R.mipmap.emoji_3, R.mipmap.emoji_4, R.mipmap.emoji_5, R.mipmap.emoji_6, 16 | R.mipmap.emoji_7, R.mipmap.emoji_8, R.mipmap.emoji_9, R.mipmap.emoji_10, R.mipmap.emoji_11, R.mipmap.emoji_12, R.mipmap.emoji_13, 17 | R.mipmap.emoji_14, R.mipmap.emoji_15, R.mipmap.emoji_16, R.mipmap.emoji_17, R.mipmap.emoji_18, R.mipmap.emoji_19, R.mipmap.emoji_20}) 18 | .setNumberDrawableArray(new int[]{R.mipmap.multi_digg_num_0, R.mipmap.multi_digg_num_1, R.mipmap.multi_digg_num_2, R.mipmap.multi_digg_num_3, 19 | R.mipmap.multi_digg_num_4, R.mipmap.multi_digg_num_5, R.mipmap.multi_digg_num_6, R.mipmap.multi_digg_num_7, 20 | R.mipmap.multi_digg_num_8, R.mipmap.multi_digg_num_9}) 21 | .setLevelDrawableArray(new int[]{R.mipmap.multi_digg_word_level_1, R.mipmap.multi_digg_word_level_2, R.mipmap.multi_digg_word_level_3}) 22 | .build(); 23 | } 24 | 25 | 26 | public static BitmapProvider.Provider getSmoothProvider(Context context) { 27 | return new BitmapProvider.Builder(context).build(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/BaseAnimationFrame.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Sen on 2018/3/9. 7 | */ 8 | 9 | public abstract class BaseAnimationFrame implements AnimationFrame{ 10 | 11 | private int x; 12 | private int y; 13 | private double currentTime; 14 | private boolean isRunnable; 15 | List elements; 16 | private AnimationEndListener animationEndListener; 17 | long duration; 18 | 19 | public BaseAnimationFrame(long duration){ 20 | this.duration = duration; 21 | } 22 | 23 | @Override 24 | public boolean isRunning() { 25 | return isRunnable; 26 | } 27 | 28 | @Override 29 | public List nextFrame(long interval) { 30 | currentTime += interval; 31 | if(currentTime >= duration){ 32 | isRunnable = false; 33 | if(animationEndListener != null){ 34 | animationEndListener.onAnimationEnd(this); 35 | } 36 | }else{ 37 | for(Element element : elements){ 38 | element.evaluate(x, y, currentTime); 39 | } 40 | } 41 | return elements; 42 | } 43 | 44 | @Override 45 | public void setAnimationEndListener(AnimationEndListener animationEndListener) { 46 | this.animationEndListener = animationEndListener; 47 | } 48 | 49 | @Override 50 | public void reset() { 51 | currentTime = 0; 52 | if(elements != null){ 53 | elements.clear(); 54 | } 55 | } 56 | 57 | protected abstract List generatedElements(int x, int y, BitmapProvider.Provider bitmapProvider); 58 | 59 | protected void setStartPoint(int x, int y){ 60 | this.x = x; 61 | this.y = y; 62 | } 63 | 64 | @Override 65 | public boolean onlyOne() { 66 | return false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /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/com/sum/slike/simple/RecyclerViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike.simple; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | 10 | import com.sum.slike.SuperLikeLayout; 11 | 12 | import java.util.HashMap; 13 | import java.util.LinkedHashMap; 14 | 15 | /** 16 | * Created by Sen on 2018/4/26. 17 | */ 18 | 19 | public class RecyclerViewActivity extends AppCompatActivity{ 20 | 21 | private SuperLikeLayout superLikeLayout; 22 | private RecyclerView recyclerView; 23 | private CommentAdapter commentAdapter; 24 | 25 | @Override 26 | protected void onCreate(@Nullable Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | 29 | setContentView(R.layout.activity_recycler_view); 30 | 31 | recyclerView = findViewById(R.id.recycler_view); 32 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 33 | commentAdapter = new CommentAdapter(); 34 | commentAdapter.setAdapterItemListener(adapterItemListener); 35 | recyclerView.setAdapter(commentAdapter); 36 | 37 | superLikeLayout = findViewById(R.id.super_like_layout); 38 | superLikeLayout.setProvider(BitmapProviderFactory.getHDProvider(this)); 39 | } 40 | 41 | CommentAdapter.AdapterItemListener adapterItemListener = new CommentAdapter.AdapterItemListener() { 42 | long duration = 1000; 43 | HashMap lastClickTimeMap = new LinkedHashMap<>(); 44 | 45 | @Override 46 | public void onItemClickListener(Boolean isLike, int position, int id, View v) { 47 | Long lastClickTime = lastClickTimeMap.get(position); 48 | if(lastClickTime == null || System.currentTimeMillis() - lastClickTime> duration){ // 防抖 49 | isLike = !isLike; 50 | commentAdapter.updateLikeStatusByPosition(isLike, position); 51 | // 发起改变like状态的网络请求 52 | } 53 | lastClickTimeMap.put(position, System.currentTimeMillis()); 54 | if(isLike){ 55 | int[] itemPosition = new int[2]; 56 | int[] superLikePosition = new int[2]; 57 | v.getLocationOnScreen(itemPosition); 58 | superLikeLayout.getLocationOnScreen(superLikePosition); 59 | int x = itemPosition[0] + v.getWidth() / 2; 60 | int y = (itemPosition[1] - superLikePosition[1]) + v.getHeight() / 2; 61 | superLikeLayout.launch(x, y); 62 | } 63 | 64 | 65 | } 66 | }; 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/sum/slike/simple/CommentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike.simple; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Created by Sen on 2018/4/26. 12 | */ 13 | 14 | public class CommentAdapter extends RecyclerView.Adapter{ 15 | 16 | private boolean[] likeStatusArray = new boolean[10]; 17 | private AdapterItemListener adapterItemListener; 18 | 19 | public void setAdapterItemListener(AdapterItemListener adapterItemListener) { 20 | this.adapterItemListener = adapterItemListener; 21 | } 22 | 23 | @Override 24 | public CommentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 25 | return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_layout, parent, false)); 26 | } 27 | 28 | @Override 29 | public void onBindViewHolder(final CommentViewHolder holder, int position) { 30 | holder.avatar.setImageResource(R.mipmap.ic_launcher); 31 | holder.userName.setText("管理员"); 32 | holder.sendTime.setText("刚刚"); 33 | holder.content.setText("哎哟不错哟"); 34 | holder.likeCount.setText(likeStatusArray[position]?"1":"0"); 35 | holder.likeStatus.setSelected(likeStatusArray[position]); 36 | holder.likeStatus.setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | if(adapterItemListener != null){ 40 | adapterItemListener.onItemClickListener( 41 | likeStatusArray[holder.getAdapterPosition()], holder.getAdapterPosition(), v.getId(), v); 42 | } 43 | } 44 | }); 45 | } 46 | 47 | public void updateLikeStatusByPosition(boolean isLike, int position){ 48 | likeStatusArray[position] = isLike; 49 | notifyItemChanged(position); 50 | } 51 | 52 | 53 | @Override 54 | public int getItemCount() { 55 | return likeStatusArray.length; 56 | } 57 | 58 | public class CommentViewHolder extends RecyclerView.ViewHolder{ 59 | ImageView avatar; 60 | TextView userName; 61 | TextView sendTime; 62 | TextView content; 63 | TextView likeCount; 64 | View likeStatus; 65 | public CommentViewHolder(View itemView) { 66 | super(itemView); 67 | avatar = itemView.findViewById(R.id.avatar); 68 | userName = itemView.findViewById(R.id.user_name); 69 | sendTime = itemView.findViewById(R.id.send_time); 70 | content = itemView.findViewById(R.id.content); 71 | likeCount = itemView.findViewById(R.id.like_count); 72 | likeStatus = itemView.findViewById(R.id.like_status); 73 | } 74 | } 75 | 76 | public interface AdapterItemListener { 77 | void onItemClickListener(T data, int position, int id, View view); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/AnimationFramePool.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Sen on 2018/3/12. 8 | */ 9 | 10 | public class AnimationFramePool { 11 | 12 | private static final int DURATION = 1000; 13 | private List runningFrameList; 14 | private List idleFrameList; 15 | 16 | 17 | private int maxFrameSize; 18 | private int elementAmount; 19 | private int frameCount; 20 | 21 | AnimationFramePool(int maxFrameSize, int elementAmount){ 22 | this.maxFrameSize = maxFrameSize; 23 | this.elementAmount = elementAmount; 24 | runningFrameList = new ArrayList<>(maxFrameSize); 25 | idleFrameList = new ArrayList<>(maxFrameSize); 26 | } 27 | 28 | boolean hasRunningAnimation(){ 29 | return runningFrameList.size() > 0; 30 | } 31 | 32 | AnimationFrame obtain(int type) { 33 | 34 | // RunningAnimationFrame 存在onlyOne直接复用 35 | AnimationFrame animationFrame = getRunningFrameListByOnlyOneAndType(type); 36 | if(animationFrame != null) 37 | return animationFrame; 38 | 39 | // 有空闲AnimationFrame直接使用, 加入runningFrame队列中 40 | animationFrame = removeIdleFrameListDownByType(type); 41 | if (animationFrame == null && frameCount < maxFrameSize) { 42 | frameCount++; 43 | if (type == EruptionAnimationFrame.TYPE) { 44 | animationFrame = new EruptionAnimationFrame(elementAmount, DURATION); 45 | } else { 46 | animationFrame = new TextAnimationFrame(DURATION); 47 | } 48 | } 49 | if (animationFrame != null) { 50 | runningFrameList.add(animationFrame); 51 | } 52 | 53 | return animationFrame; 54 | } 55 | 56 | private AnimationFrame getRunningFrameListByOnlyOneAndType(int type) { 57 | for (int i = runningFrameList.size() - 1; i >= 0; i--) { 58 | AnimationFrame animationFrame = runningFrameList.get(i); 59 | if(type == animationFrame.getType() && animationFrame.onlyOne()) 60 | return animationFrame; 61 | } 62 | return null; 63 | } 64 | 65 | void recycleAll() { 66 | for (int i = runningFrameList.size() - 1; i >= 0; i--) { 67 | AnimationFrame animationFrame = runningFrameList.get(i); 68 | recycle(animationFrame); 69 | animationFrame.reset(); 70 | } 71 | } 72 | 73 | void recycle(AnimationFrame animationFrame) { 74 | runningFrameList.remove(animationFrame); 75 | idleFrameList.add(animationFrame); 76 | } 77 | 78 | List getRunningFrameList() { 79 | return runningFrameList; 80 | } 81 | 82 | private AnimationFrame removeIdleFrameListDownByType(int type){ 83 | for (int i = idleFrameList.size() - 1; i >= 0; i--) { 84 | AnimationFrame animationFrame = idleFrameList.get(i); 85 | if(type == animationFrame.getType()) 86 | return idleFrameList.remove(i); 87 | } 88 | return null; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_topic_user_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 15 | 20 | 21 | 34 | 40 | 47 | 48 | 49 | 50 | 58 | 68 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/TextAnimationFrame.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Paint; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Sen on 2018/2/6. 11 | */ 12 | 13 | public class TextAnimationFrame extends BaseAnimationFrame{ 14 | public static final int TYPE = 2; 15 | private long lastClickTimeMillis; 16 | private int likeCount; 17 | 18 | public TextAnimationFrame(long duration) { 19 | super(duration); 20 | } 21 | 22 | 23 | @Override 24 | public void prepare(int x, int y, BitmapProvider.Provider bitmapProvider) { 25 | reset(); 26 | setStartPoint(x, y); 27 | calculateCombo(); 28 | elements = generatedElements(x, y, bitmapProvider); 29 | } 30 | 31 | private void calculateCombo(){ 32 | if(System.currentTimeMillis() - lastClickTimeMillis < duration){ 33 | likeCount++; 34 | }else{ 35 | likeCount = 1; 36 | } 37 | lastClickTimeMillis = System.currentTimeMillis(); 38 | } 39 | 40 | @Override 41 | public int getType() { 42 | return TYPE; 43 | } 44 | 45 | 46 | @Override 47 | public boolean onlyOne() { 48 | return true; 49 | } 50 | 51 | /** 52 | * 生成N个Element 53 | */ 54 | protected List generatedElements(int x, int y, BitmapProvider.Provider bitmapProvider){ 55 | List elements = new ArrayList<>(); 56 | int count = likeCount; 57 | int offset_x = 0; 58 | while (count > 0){ 59 | int number = count % 10; 60 | Bitmap bitmap = bitmapProvider.getNumberBitmap(number); 61 | offset_x += bitmap.getWidth(); 62 | Element element = new TextElement(bitmap, x - offset_x); 63 | elements.add(element); 64 | count = count / 10; 65 | } 66 | 67 | int level = likeCount / 10; 68 | if(level > 2){ 69 | level = 2; 70 | } 71 | elements.add(new TextElement(bitmapProvider.getLevelBitmap(level), x)); 72 | return elements; 73 | } 74 | 75 | public static class TextElement implements Element{ 76 | private int x; 77 | private int y; 78 | private Bitmap bitmap; 79 | 80 | public TextElement(Bitmap bitmap, int x){ 81 | this.bitmap = bitmap; 82 | this.x = x; 83 | } 84 | 85 | @Override 86 | public int getX() { 87 | return x; 88 | } 89 | 90 | @Override 91 | public int getY() { 92 | return y; 93 | } 94 | 95 | @Override 96 | public Bitmap getBitmap() { 97 | return bitmap; 98 | } 99 | 100 | @Override 101 | public void evaluate(int start_x, int start_y, double time) { 102 | y = start_y - 500 - (bitmap.getHeight() / 2); 103 | } 104 | 105 | @Override 106 | public Paint getPaint() { 107 | return null; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.jfrog.bintray' 3 | apply plugin: 'com.github.dcendents.android-maven' 4 | 5 | version = "0.2.1" 6 | 7 | android { 8 | compileSdkVersion 26 9 | 10 | 11 | 12 | defaultConfig { 13 | minSdkVersion 16 14 | targetSdkVersion 26 15 | versionCode 1 16 | versionName version 17 | 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | 27 | } 28 | 29 | dependencies { 30 | implementation fileTree(dir: 'libs', include: ['*.jar']) 31 | implementation 'com.android.support:appcompat-v7:26.1.0' 32 | } 33 | 34 | 35 | def siteUrl = 'https://github.com/Qiu800820/SuperLike' 36 | def gitUrl = 'https://github.com/Qiu800820/SuperLike.git' 37 | group = "com.sum.slike" // Maven Group ID for the artifact 38 | install { 39 | repositories.mavenInstaller { 40 | // This generates POM.xml with proper parameters 41 | pom { 42 | project { 43 | packaging 'aar' 44 | // Add your description here 45 | name 'like animation' 46 | url siteUrl 47 | // Set your license 48 | licenses { 49 | license { 50 | name 'The Apache Software License, Version 2.0' 51 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 52 | } 53 | } 54 | developers { 55 | developer { 56 | id 'qiu800820' 57 | name 'sum' 58 | email 'qiujunsen@gmail.com' 59 | } 60 | } 61 | scm { 62 | connection gitUrl 63 | developerConnection gitUrl 64 | url siteUrl 65 | } 66 | } 67 | } 68 | } 69 | } 70 | task sourcesJar(type: Jar) { 71 | from android.sourceSets.main.java.srcDirs 72 | classifier = 'sources' 73 | } 74 | 75 | task javadoc(type: Javadoc) { 76 | options.encoding = "UTF-8" 77 | source = android.sourceSets.main.java.srcDirs 78 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 79 | } 80 | 81 | task javadocJar(type: Jar, dependsOn: javadoc) { 82 | classifier = 'javadoc' 83 | from javadoc.destinationDir 84 | } 85 | 86 | artifacts { 87 | archives javadocJar 88 | archives sourcesJar 89 | } 90 | 91 | Properties properties = new Properties() 92 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 93 | bintray { 94 | user = properties.getProperty("bintray.user") 95 | key = properties.getProperty("bintray.apikey") 96 | configurations = ['archives'] 97 | pkg { 98 | repo = "maven" 99 | name = "slike" 100 | websiteUrl = siteUrl 101 | vcsUrl = gitUrl 102 | licenses = ["Apache-2.0"] 103 | publish = true 104 | } 105 | } -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/EruptionAnimationFrame.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Paint; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Sen on 2018/2/6. 11 | */ 12 | 13 | public class EruptionAnimationFrame extends BaseAnimationFrame{ 14 | public static final int TYPE = 1; 15 | private int elementSize; 16 | 17 | public EruptionAnimationFrame(int elementSize, long duration){ 18 | super(duration); 19 | this.elementSize = elementSize; 20 | } 21 | 22 | @Override 23 | public int getType() { 24 | return TYPE; 25 | } 26 | 27 | @Override 28 | public void prepare(int x, int y, BitmapProvider.Provider bitmapProvider) { 29 | reset(); 30 | setStartPoint(x, y); 31 | elements = generatedElements(x, y, bitmapProvider); 32 | } 33 | 34 | /** 35 | * 生成N个Element 36 | */ 37 | protected List generatedElements(int x, int y, BitmapProvider.Provider bitmapProvider){ 38 | List elements = new ArrayList<>(elementSize); 39 | for (int i = 0; i < elementSize; i++) { 40 | double startAngle = Math.random() * 45 + (i * 30); 41 | double speed = 500 + Math.random() * 200; 42 | Element element = new EruptionElement(startAngle, speed, bitmapProvider.getRandomBitmap()); 43 | elements.add(element); 44 | } 45 | return elements; 46 | } 47 | 48 | public static class EruptionElement implements Element{ 49 | private int x; 50 | private int y; 51 | private double angle; 52 | private double speed; 53 | private int alpha; 54 | private Paint paint; 55 | /** 56 | * 重力加速度px/s 57 | */ 58 | private static final float GRAVITY = 800; 59 | private Bitmap bitmap; 60 | 61 | public EruptionElement(double angle, double speed, Bitmap bitmap){ 62 | this.angle = angle; 63 | this.speed = speed; 64 | this.bitmap = bitmap; 65 | this.paint = new Paint(); 66 | } 67 | 68 | @Override 69 | public int getX() { 70 | return x; 71 | } 72 | 73 | @Override 74 | public int getY() { 75 | return y; 76 | } 77 | 78 | @Override 79 | public Bitmap getBitmap() { 80 | return bitmap; 81 | } 82 | 83 | @Override 84 | public void evaluate(int start_x, int start_y, double time) { 85 | time = time / 1000; 86 | alpha = time < 0.65 ? 255 : (int) (255 * (1 - time)); 87 | paint.setAlpha(alpha); 88 | double x_speed = speed * Math.cos(angle * Math.PI / 180); 89 | double y_speed = -speed * Math.sin(angle * Math.PI / 180); 90 | x = (int)(start_x + (x_speed * time) - (bitmap.getWidth() / 2)); 91 | y = (int)(start_y + (y_speed * time) + (GRAVITY * time * time) / 2 - (bitmap.getHeight() / 2)); 92 | } 93 | 94 | @Override 95 | public Paint getPaint() { 96 | return paint; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SuperLike 仿今日头条点赞喷射表情动画 主要用于点赞防抖事件的交互提示,这里只提供交互View 防抖功能可以根据Rx自行实现 ## 演示 ![image](https://github.com/Qiu800820/SuperLike/blob/master/img/Animation.gif) ![image](https://github.com/Qiu800820/SuperLike/blob/master/img/list_like_animation.gif) ## 使用 ```javascript compile 'com.sum.slike:library:0.2.1' ``` ## 参数含义
自定义属性名字 参数含义
eruption_element_amount 一次喷射的element数量
max_eruption_total 最大同时喷射次数
show_emoji 是否显示Emoji表情喷射动画
show_text 是否显示Combo文字
## 代码演示 ### 1.基础样式(666 + 文字) ```java BitmapProvider.Provider provider = new BitmapProvider.Builder(this).build(); superLikeLayout.setProvider(provider); superLikeLayout.launch(x, y); ``` ![image](https://github.com/Qiu800820/SuperLike/blob/master/img/default_style.png) ### 2.自定义样式(随机emoji + 自定义文字) * `DrawableArray`是喷射Emoji的Drawable。 * `NumberDrawableArray`是连续点赞数字Drawable(0~10) * `LevelDrawableArray`是连续点赞等级Drawable(目前分为3个等级 0~10, 10~20, 20~30+) ```java BitmapProvider.Provider provider = new BitmapProvider.Builder(this) .setDrawableArray(new int[]{R.mipmap.emoji_1, R.mipmap.emoji_2, R.mipmap.emoji_3, R.mipmap.emoji_4, R.mipmap.emoji_5, R.mipmap.emoji_6, R.mipmap.emoji_7, R.mipmap.emoji_8, R.mipmap.emoji_9, R.mipmap.emoji_10, R.mipmap.emoji_11, R.mipmap.emoji_12, R.mipmap.emoji_13, R.mipmap.emoji_14, R.mipmap.emoji_15, R.mipmap.emoji_16, R.mipmap.emoji_17, R.mipmap.emoji_18, R.mipmap.emoji_19, R.mipmap.emoji_20}) .setNumberDrawableArray(new int[]{R.mipmap.multi_digg_num_0, R.mipmap.multi_digg_num_1, R.mipmap.multi_digg_num_2, R.mipmap.multi_digg_num_3, R.mipmap.multi_digg_num_4, R.mipmap.multi_digg_num_5, R.mipmap.multi_digg_num_6, R.mipmap.multi_digg_num_7, R.mipmap.multi_digg_num_8, R.mipmap.multi_digg_num_9}) .setLevelDrawableArray(new int[]{R.mipmap.multi_digg_word_level_1, R.mipmap.multi_digg_word_level_2, R.mipmap.multi_digg_word_level_3}) .build(); superLikeLayout.setProvider(provider); superLikeLayout.launch(x, y); ``` ![image](https://github.com/Qiu800820/SuperLike/blob/master/img/custom_style.png) ### 联系方式 * 邮箱地址: qiujunsen@163.com, qiujunsen@gmail.com ### License MIT License Copyright (c) Qiu800820 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /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/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/SuperLikeLayout.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.annotation.NonNull; 9 | import android.support.annotation.Nullable; 10 | import android.util.AttributeSet; 11 | import android.util.Log; 12 | import android.view.View; 13 | 14 | import java.lang.ref.WeakReference; 15 | import java.util.List; 16 | 17 | /** 18 | * Created by Sen on 2018/2/6. 19 | */ 20 | 21 | public class SuperLikeLayout extends View implements AnimationEndListener{ 22 | 23 | private static final String TAG = "SuperLikeLayout"; 24 | 25 | private static final long INTERVAL = 40; 26 | private static final int MAX_FRAME_SIZE = 16; 27 | private static final int ERUPTION_ELEMENT_AMOUNT = 4; 28 | private AnimationFramePool animationFramePool; 29 | 30 | private AnimationHandler animationHandler; 31 | private BitmapProvider.Provider provider; 32 | private boolean hasEruptionAnimation; 33 | private boolean hasTextAnimation; 34 | 35 | 36 | public SuperLikeLayout(@NonNull Context context) { 37 | this(context, null); 38 | } 39 | 40 | public SuperLikeLayout(@NonNull Context context, @Nullable AttributeSet attrs) { 41 | this(context, attrs, 0); 42 | } 43 | 44 | public SuperLikeLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 45 | super(context, attrs, defStyleAttr); 46 | init(context, attrs, defStyleAttr); 47 | } 48 | 49 | private void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 50 | 51 | animationHandler = new AnimationHandler(this); 52 | 53 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuperLikeLayout, defStyleAttr, 0); 54 | int elementAmount = a.getInteger(R.styleable.SuperLikeLayout_eruption_element_amount, ERUPTION_ELEMENT_AMOUNT); 55 | int maxFrameSize = a.getInteger(R.styleable.SuperLikeLayout_max_eruption_total, MAX_FRAME_SIZE); 56 | hasEruptionAnimation = a.getBoolean(R.styleable.SuperLikeLayout_show_emoji, true); 57 | hasTextAnimation = a.getBoolean(R.styleable.SuperLikeLayout_show_text, true); 58 | a.recycle(); 59 | 60 | animationFramePool = new AnimationFramePool(maxFrameSize, elementAmount); 61 | } 62 | 63 | @Override 64 | public void draw(Canvas canvas) { 65 | super.draw(canvas); 66 | if(!animationFramePool.hasRunningAnimation()) 67 | return; 68 | //遍历所有AnimationFrame 并绘制Element 69 | // note: 需要倒序遍历 nextFrame方法可能会改变runningFrameList Size 导致异常 70 | List runningFrameList = animationFramePool.getRunningFrameList(); 71 | for (int i = runningFrameList.size() - 1; i >= 0; i--) { 72 | AnimationFrame animationFrame = runningFrameList.get(i); 73 | List elementList = animationFrame.nextFrame(INTERVAL); 74 | for(Element element : elementList){ 75 | canvas.drawBitmap(element.getBitmap(), element.getX(), element.getY(), element.getPaint()); 76 | } 77 | } 78 | 79 | } 80 | 81 | 82 | public void launch(int x, int y) { 83 | if (!hasEruptionAnimation && !hasTextAnimation) { 84 | return; 85 | } 86 | // 喷射动画 87 | if(hasEruptionAnimation) { 88 | AnimationFrame eruptionAnimationFrame = animationFramePool.obtain(EruptionAnimationFrame.TYPE); 89 | if (eruptionAnimationFrame != null && !eruptionAnimationFrame.isRunning()) { 90 | eruptionAnimationFrame.setAnimationEndListener(this); 91 | eruptionAnimationFrame.prepare(x, y, getProvider()); 92 | } 93 | } 94 | // combo动画 95 | if(hasTextAnimation) { 96 | AnimationFrame textAnimationFrame = animationFramePool.obtain(TextAnimationFrame.TYPE); 97 | if (textAnimationFrame != null) { 98 | textAnimationFrame.setAnimationEndListener(this); 99 | textAnimationFrame.prepare(x, y, getProvider()); 100 | } 101 | } 102 | animationHandler.removeMessages(AnimationHandler.MESSAGE_CODE_REFRESH_ANIMATION); 103 | animationHandler.sendEmptyMessageDelayed(AnimationHandler.MESSAGE_CODE_REFRESH_ANIMATION, INTERVAL); 104 | 105 | } 106 | 107 | public boolean hasAnimation(){ 108 | return animationFramePool.hasRunningAnimation(); 109 | } 110 | 111 | public void setProvider(BitmapProvider.Provider provider){ 112 | this.provider = provider; 113 | } 114 | 115 | public BitmapProvider.Provider getProvider(){ 116 | if(provider == null){ 117 | provider = new BitmapProvider.Builder(getContext()) 118 | .build(); 119 | } 120 | return provider; 121 | } 122 | 123 | 124 | 125 | /** 126 | * 回收SurpriseView 添加至空闲队列方便下次使用 127 | */ 128 | private void onRecycle(AnimationFrame animationFrame) { 129 | Log.v(TAG, "=== AnimationFrame recycle ==="); 130 | animationFrame.reset(); 131 | animationFramePool.recycle(animationFrame); 132 | } 133 | 134 | @Override 135 | protected void onDetachedFromWindow() { 136 | super.onDetachedFromWindow(); 137 | if(!hasAnimation()) 138 | return; 139 | // 回收所有动画 并暂停动画 140 | animationFramePool.recycleAll(); 141 | 142 | animationHandler.removeMessages(AnimationHandler.MESSAGE_CODE_REFRESH_ANIMATION); 143 | } 144 | 145 | @Override 146 | public void onAnimationEnd(AnimationFrame animationFrame) { 147 | onRecycle(animationFrame); 148 | } 149 | 150 | 151 | private static final class AnimationHandler extends Handler{ 152 | public static final int MESSAGE_CODE_REFRESH_ANIMATION = 1001; 153 | private WeakReference weakReference; 154 | 155 | public AnimationHandler(SuperLikeLayout superLikeLayout){ 156 | weakReference = new WeakReference<>(superLikeLayout); 157 | } 158 | 159 | @Override 160 | public void handleMessage(Message msg) { 161 | super.handleMessage(msg); 162 | if(msg.what == MESSAGE_CODE_REFRESH_ANIMATION && weakReference != null && weakReference.get() != null){ 163 | weakReference.get().invalidate(); 164 | // 动画还未结束继续刷新 165 | if(weakReference.get().hasAnimation()){ 166 | sendEmptyMessageDelayed(MESSAGE_CODE_REFRESH_ANIMATION, INTERVAL); 167 | } 168 | } 169 | 170 | } 171 | } 172 | 173 | } 174 | -------------------------------------------------------------------------------- /library/src/main/java/com/sum/slike/BitmapProvider.java: -------------------------------------------------------------------------------- 1 | package com.sum.slike; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.graphics.Canvas; 7 | import android.graphics.Color; 8 | import android.support.annotation.DrawableRes; 9 | import android.support.annotation.NonNull; 10 | import android.text.TextPaint; 11 | import android.util.LruCache; 12 | 13 | /** 14 | * Created by Sen on 2018/3/8. 15 | */ 16 | 17 | public class BitmapProvider { 18 | 19 | static class Default implements Provider{ 20 | 21 | private LruCache bitmapLruCache; 22 | private int NUMBER_PREFIX = 0x70000000; 23 | private int LEVEL_PREFIX = 0x80000000; 24 | private @DrawableRes int[] drawableArray; 25 | private @DrawableRes int[] numberDrawableArray; 26 | private @DrawableRes int[] levelDrawableArray; 27 | private String[] levelStringArray; 28 | private Context context; 29 | private float textSize; 30 | 31 | Default(Context context, int cacheSize, @DrawableRes int[] drawableArray, @DrawableRes int[] numberDrawableArray, 32 | @DrawableRes int[] levelDrawableArray, String[] levelStringArray, float textSize){ 33 | bitmapLruCache = new LruCache<>(cacheSize); 34 | this.drawableArray = drawableArray; 35 | this.numberDrawableArray = numberDrawableArray; 36 | this.levelDrawableArray = levelDrawableArray; 37 | this.levelStringArray = levelStringArray; 38 | this.context = context; 39 | this.textSize = textSize; 40 | } 41 | 42 | @NonNull 43 | @Override 44 | public Bitmap getNumberBitmap(int number) { 45 | Bitmap bitmap; 46 | if(numberDrawableArray != null && numberDrawableArray.length > 0){ 47 | int index = number % numberDrawableArray.length; 48 | bitmap = bitmapLruCache.get(NUMBER_PREFIX|numberDrawableArray[index]); 49 | if(bitmap == null){ 50 | bitmap = BitmapFactory.decodeResource(context.getResources(), numberDrawableArray[index]); 51 | bitmapLruCache.put(NUMBER_PREFIX|numberDrawableArray[index], bitmap); 52 | } 53 | }else{ 54 | bitmap = bitmapLruCache.get(NUMBER_PREFIX|number); 55 | if(bitmap == null){ 56 | bitmap = createBitmapByText(textSize, String.valueOf(number)); 57 | bitmapLruCache.put(NUMBER_PREFIX|number, bitmap); 58 | } 59 | } 60 | return bitmap; 61 | } 62 | 63 | @NonNull 64 | @Override 65 | public Bitmap getLevelBitmap(int level) { 66 | Bitmap bitmap; 67 | if(levelDrawableArray != null && levelDrawableArray.length > 0){ 68 | int index = Math.min(level, levelDrawableArray.length); 69 | bitmap = bitmapLruCache.get(LEVEL_PREFIX|levelDrawableArray[index]); 70 | if(bitmap == null){ 71 | bitmap = BitmapFactory.decodeResource(context.getResources(), levelDrawableArray[index]); 72 | bitmapLruCache.put(LEVEL_PREFIX|levelDrawableArray[index], bitmap); 73 | } 74 | }else{ 75 | bitmap = bitmapLruCache.get(LEVEL_PREFIX|level); 76 | if(bitmap == null){ 77 | int index = Math.min(level, levelStringArray.length); 78 | bitmap = createBitmapByText(textSize, levelStringArray[index]); 79 | bitmapLruCache.put(LEVEL_PREFIX|level, bitmap); 80 | } 81 | } 82 | return bitmap; 83 | } 84 | 85 | @Override 86 | public Bitmap getRandomBitmap(){ 87 | int index = (int)(Math.random() * drawableArray.length); 88 | Bitmap bitmap = bitmapLruCache.get(drawableArray[index]); 89 | if(bitmap == null){ 90 | bitmap = BitmapFactory.decodeResource(context.getResources(), drawableArray[index]); 91 | bitmapLruCache.put(drawableArray[index], bitmap); 92 | } 93 | return bitmap; 94 | } 95 | 96 | public Bitmap createBitmapByText(float textSize, String text){ 97 | TextPaint textPaint = new TextPaint(); 98 | textPaint.setColor(Color.BLACK); 99 | textPaint.setTextSize(textSize); 100 | Bitmap bitmap = Bitmap.createBitmap((int)textPaint.measureText(String.valueOf(text)), 101 | (int)textSize, Bitmap.Config.ARGB_4444); 102 | Canvas canvas = new Canvas(bitmap); 103 | canvas.drawColor(Color.TRANSPARENT); 104 | canvas.drawText(String.valueOf(text), 0 ,textSize, textPaint); 105 | return bitmap; 106 | } 107 | } 108 | 109 | public static class Builder{ 110 | Context context; 111 | private int cacheSize; 112 | private @DrawableRes int[] drawableArray; 113 | private @DrawableRes int[] numberDrawableArray; 114 | private @DrawableRes int[] levelDrawableArray; 115 | private String[] levelStringArray; 116 | private float textSize; 117 | 118 | public Builder(Context context){ 119 | this.context = context; 120 | } 121 | 122 | public Builder setCacheSize(int cacheSize){ 123 | this.cacheSize = cacheSize; 124 | return this; 125 | } 126 | 127 | public Builder setDrawableArray(@DrawableRes int[] drawableArray){ 128 | this.drawableArray = drawableArray; 129 | return this; 130 | } 131 | 132 | public Builder setNumberDrawableArray(@DrawableRes int[] numberDrawableArray){ 133 | this.numberDrawableArray = numberDrawableArray; 134 | return this; 135 | } 136 | 137 | public Builder setLevelDrawableArray(@DrawableRes int[] levelDrawableArray){ 138 | this.levelDrawableArray = levelDrawableArray; 139 | return this; 140 | } 141 | 142 | public Builder setLevelStringArray(String[] levelStringArray){ 143 | this.levelStringArray = levelStringArray; 144 | return this; 145 | } 146 | 147 | public Builder setTextSize(float textSize){ 148 | this.textSize = textSize; 149 | return this; 150 | } 151 | 152 | public Provider build(){ 153 | 154 | if(cacheSize == 0){ 155 | cacheSize = 32; 156 | } 157 | 158 | if(drawableArray == null || drawableArray.length == 0){ 159 | this.drawableArray = new int[]{R.drawable.super_like_default_icon}; 160 | } 161 | 162 | if(levelDrawableArray == null && levelStringArray == null){ 163 | levelStringArray = new String[]{"鼓励!", "加油!!", "太棒了!!!"}; 164 | } 165 | 166 | if(textSize < 24){ 167 | textSize = context.getResources().getDimension(R.dimen.slike_default_text_size); 168 | } 169 | 170 | return new Default(context, cacheSize, drawableArray, numberDrawableArray, 171 | levelDrawableArray, levelStringArray, textSize); 172 | } 173 | } 174 | 175 | 176 | 177 | public interface Provider{ 178 | 179 | Bitmap getRandomBitmap(); 180 | 181 | @NonNull Bitmap getNumberBitmap(int number); 182 | 183 | @NonNull Bitmap getLevelBitmap(int level); 184 | } 185 | } 186 | --------------------------------------------------------------------------------