├── .gitignore ├── README.md ├── app ├── .gitignore ├── asset │ ├── profile.png │ └── screenshot.png ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── cxmax │ │ └── floatingview │ │ ├── MainActivity.java │ │ └── recyclerview │ │ ├── DividerItemDecoration.java │ │ └── RecyclerAdapter.java │ └── res │ ├── layout │ ├── activity_main.xml │ └── item_recyclerview.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ ├── float_ad_default.png │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── gif │ └── com │ │ └── cxmax │ │ └── library │ │ ├── gifloader │ │ ├── GifDecoder.java │ │ ├── GifDrawer.java │ │ ├── GifLoaderTask.java │ │ └── HttpLoader.java │ │ └── glide │ │ ├── GifDrawableByteTranscoder.java │ │ ├── GifDrawableResource.java │ │ ├── Glides.java │ │ └── StreamByteArrayResourceDecoder.java │ ├── java │ └── com │ │ └── cxmax │ │ └── library │ │ ├── FloatingView.java │ │ ├── IFloatingView.java │ │ ├── drag │ │ └── DragLayout.java │ │ └── utils │ │ ├── DisplayUtils.java │ │ └── ImageUtils.java │ └── res │ ├── drawable │ ├── float_ad_close.png │ └── float_ad_close_background.png │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.ap_ 3 | 4 | # files for the dex VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # generated files 11 | bin/ 12 | gen/ 13 | 14 | # Local configuration file (sdk path, etc) 15 | local.properties 16 | 17 | # Proguard folder generated by Eclipse 18 | proguard/ 19 | 20 | # Ignore gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | .settings/ 28 | 29 | # Intellij project files 30 | *.iml 31 | *.ipr 32 | *.iws 33 | .idea/ 34 | 35 | # Mac system files 36 | .DS_Store 37 | 38 | *.keystore 39 | 将删除 src/main/java/com/cxmax/library/utils/ 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FloatingView 2 | 3 | ### 介绍 4 | Android 首页悬浮广告,可任意拖拽, 支持Gif图片的播放(不使用Gilde播放 / 使用glide播放优化gif内存占用问题) 5 | 继承ImageView, 拥有与ImageView一样的api 6 | 7 | ### 功能 8 | * 显示/隐藏 9 | * 拖拽 - 只需在xml布局文件中设置app:draggable="true",即可。 10 | 11 | ### 用法: 12 | ```java 13 | 20 | ``` 21 | ### 关于Gif图片的播放 22 | * 不使用Gilde: 23 | ps : gif图的播放在java层实现, 内存和性能表现并不好. 24 | ```java 25 | GifDecoder.with(getActivity()).load(current_appAdStructItem.img_url, new GifDecoder.OnLoadGifListener() { 26 | @Override 27 | public void loadGifSuccess(File file) { 28 | GifDecoder.with(getActivity()).load(file).into(mFloatingView); 29 | } 30 | 31 | @Override 32 | public void loadGifFailed() { 33 | // fail 34 | } 35 | }).into(mFloatingView); 36 | 37 | ``` 38 | * 使用Glide 39 | 1. 引用第三方库, 让gif播放在Native层实现, 避免java层内存增长和性能问题 40 | ``` 41 | compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7' 42 | ``` 43 | 2. 引用Glide, 并改写Glide做了上层封装, 用法跟glide网络加载普通图片一样. 44 | 使用第三方库的GifDrawable(native层实现)替换Glide的GifDrawable(java层实现) , 具体做了封装, 有兴趣的话看library的实现; 45 | ``` 46 | Glide 47 | .with(context) 48 | .using(new StreamStringLoader(context), InputStream.class) 49 | .from(String.class) 50 | .as(byte[].class) 51 | .transcode(new GifDrawableByteTranscoder(), GifDrawable.class) 52 | .diskCacheStrategy(DiskCacheStrategy.SOURCE) 53 | .decoder(new StreamByteArrayResourceDecoder()) 54 | .sourceEncoder(new StreamEncoder()) 55 | .cacheDecoder(new FileToStreamDecoder(new StreamByteArrayResourceDecoder())) 56 | .load(gifUrl) 57 | .error(placeholder) 58 | .fallback(placeholder) 59 |                .into(imageView); 60 | ``` 61 | 62 | ### 效果图: 63 | 64 | ![image](https://raw.githubusercontent.com/cxMax/FloatingView/master/app/asset/profile.png) 65 | 66 | ### License MIT 67 | Copyright (C) 2016 cxMax 68 | Copyright (C) 2016 FloatingView 69 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.ap_ 3 | 4 | # files for the dex VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # generated files 11 | bin/ 12 | gen/ 13 | 14 | # Local configuration file (sdk path, etc) 15 | local.properties 16 | 17 | # Proguard folder generated by Eclipse 18 | proguard/ 19 | 20 | # Ignore gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | .settings/ 28 | 29 | # Intellij project files 30 | *.iml 31 | *.ipr 32 | *.iws 33 | .idea/ 34 | 35 | # Mac system files 36 | .DS_Store 37 | 38 | *.keystore -------------------------------------------------------------------------------- /app/asset/profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/asset/profile.png -------------------------------------------------------------------------------- /app/asset/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/asset/screenshot.png -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion '26.0.2' 6 | 7 | defaultConfig { 8 | applicationId "com.cxmax.floatingview" 9 | minSdkVersion 21 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | compile project(':library') 25 | compile 'com.android.support:recyclerview-v7:26.0.2' 26 | } 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\android\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/cxmax/floatingview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.floatingview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.view.PagerAdapter; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.DefaultItemAnimator; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.Toast; 12 | 13 | import com.cxmax.floatingview.R; 14 | import com.cxmax.floatingview.recyclerview.DividerItemDecoration; 15 | import com.cxmax.floatingview.recyclerview.RecyclerAdapter; 16 | import com.cxmax.library.FloatingView; 17 | import com.cxmax.library.IFloatingView; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | public class MainActivity extends AppCompatActivity implements IFloatingView.OnClickListener{ 23 | private RecyclerView recyclerView; 24 | private List data; 25 | private FloatingView floatingView; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | initFloatView(); 32 | initData(); 33 | initRecyclerView(); 34 | } 35 | private void initFloatView() { 36 | floatingView = (FloatingView) findViewById(R.id.float_view); 37 | floatingView.setClickListener(this); 38 | } 39 | 40 | @Override 41 | public void onFloatClick(View v) { 42 | Toast.makeText(this,"点击悬浮广告",Toast.LENGTH_SHORT).show(); 43 | } 44 | 45 | @Override 46 | public void onCloseClick() { 47 | Toast.makeText(this,"关闭悬浮广告",Toast.LENGTH_SHORT).show(); 48 | 49 | } 50 | 51 | private void initRecyclerView() { 52 | recyclerView = (RecyclerView) findViewById(R.id.recyclerview); 53 | recyclerView.setHasFixedSize(true); 54 | recyclerView.setItemAnimator(new DefaultItemAnimator()); 55 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 56 | recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); 57 | recyclerView.setAdapter(new RecyclerAdapter(data,this)); 58 | } 59 | 60 | /** 61 | * 初始化数据 62 | */ 63 | private void initData() { 64 | data = new ArrayList<>(); 65 | for (int i = 'A'; i < 'z'; i++) 66 | { 67 | data.add("这是" + (char) i + "项"); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/cxmax/floatingview/recyclerview/DividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.floatingview.recyclerview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Rect; 7 | import android.graphics.drawable.Drawable; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.view.View; 11 | 12 | /** 13 | * Created by cxMax on 2016/6/4. 14 | */ 15 | public class DividerItemDecoration extends RecyclerView.ItemDecoration{ 16 | private static final int[] ATTRS = new int[]{ 17 | android.R.attr.listDivider 18 | }; 19 | 20 | public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; 21 | 22 | public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; 23 | 24 | private Drawable mDivider; 25 | 26 | private int mOrientation; 27 | 28 | public DividerItemDecoration(Context context,int orientation){ 29 | final TypedArray a = context.obtainStyledAttributes(ATTRS); 30 | mDivider = a.getDrawable(0); 31 | a.recycle(); 32 | setOrientation(orientation); 33 | } 34 | 35 | public void setOrientation(int orientation) { 36 | if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) { 37 | throw new IllegalArgumentException("invalid orientation"); 38 | } 39 | mOrientation = orientation; 40 | } 41 | 42 | @Override 43 | public void onDraw(Canvas c, RecyclerView parent) { 44 | if (mOrientation == VERTICAL_LIST) { 45 | drawVertical(c, parent); 46 | } else { 47 | drawHorizontal(c, parent); 48 | } 49 | } 50 | 51 | public void drawVertical(Canvas c, RecyclerView parent) { 52 | final int left = parent.getPaddingLeft(); 53 | final int right = parent.getWidth() - parent.getPaddingRight(); 54 | 55 | final int childCount = parent.getChildCount(); 56 | for (int i = 0; i < childCount; i++) { 57 | final View child = parent.getChildAt(i); 58 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 59 | .getLayoutParams(); 60 | final int top = child.getBottom() + params.bottomMargin; 61 | final int bottom = top + mDivider.getIntrinsicHeight(); 62 | mDivider.setBounds(left, top, right, bottom); 63 | mDivider.draw(c); 64 | } 65 | } 66 | 67 | public void drawHorizontal(Canvas c, RecyclerView parent) { 68 | final int top = parent.getPaddingTop(); 69 | final int bottom = parent.getHeight() - parent.getPaddingBottom(); 70 | 71 | final int childCount = parent.getChildCount(); 72 | for (int i = 0; i < childCount; i++) { 73 | final View child = parent.getChildAt(i); 74 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 75 | .getLayoutParams(); 76 | final int left = child.getRight() + params.rightMargin; 77 | final int right = left + mDivider.getIntrinsicHeight(); 78 | mDivider.setBounds(left, top, right, bottom); 79 | mDivider.draw(c); 80 | } 81 | } 82 | 83 | @Override 84 | public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) { 85 | if (mOrientation == VERTICAL_LIST) { 86 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); 87 | } else { 88 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/cxmax/floatingview/recyclerview/RecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.floatingview.recyclerview; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | 10 | import com.cxmax.floatingview.R; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by Administrator on 2016/6/7. 16 | */ 17 | public class RecyclerAdapter extends RecyclerView.Adapter{ 18 | private List datas; 19 | private Context mContext; 20 | 21 | public RecyclerAdapter(List datas, Context context) { 22 | this.datas = datas; 23 | this.mContext = context; 24 | } 25 | 26 | @Override 27 | public RecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) { 28 | RecyclerHolder holder = new RecyclerHolder(LayoutInflater.from(mContext) 29 | .inflate(R.layout.item_recyclerview,parent,false)); 30 | return holder; 31 | } 32 | 33 | @Override 34 | public void onBindViewHolder(RecyclerHolder holder, int position) { 35 | holder.tv.setText(datas.get(position)); 36 | } 37 | 38 | 39 | @Override 40 | public int getItemCount() { 41 | return datas.size(); 42 | } 43 | 44 | class RecyclerHolder extends RecyclerView.ViewHolder{ 45 | 46 | TextView tv; 47 | 48 | public RecyclerHolder(View view) { 49 | super(view); 50 | tv = (TextView) view.findViewById(R.id.item_recyclerview_tv); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recyclerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/float_ad_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/src/main/res/mipmap-xxhdpi/float_ad_default.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #3f51b5 8 | #303f9f 9 | #F06292 10 | #E91E63 11 | #C2185B 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FloatingView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.0.1' 10 | 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | jcenter() 17 | google() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 23 13:40:26 CST 2017 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.ap_ 3 | 4 | # files for the dex VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # generated files 11 | bin/ 12 | gen/ 13 | 14 | # Local configuration file (sdk path, etc) 15 | local.properties 16 | 17 | # Proguard folder generated by Eclipse 18 | proguard/ 19 | 20 | # Ignore gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | .settings/ 28 | 29 | # Intellij project files 30 | *.iml 31 | *.ipr 32 | *.iws 33 | .idea/ 34 | 35 | # Mac system files 36 | .DS_Store 37 | 38 | *.keystore -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion '26.0.2' 6 | 7 | defaultConfig { 8 | minSdkVersion 21 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/gif'] } } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | compile 'com.android.support:appcompat-v7:26.0.2' 25 | compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7' // Gif support 26 | compile 'com.github.bumptech.glide:glide:3.8.0' 27 | } 28 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\android\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/gifloader/GifDecoder.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.gifloader; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | import android.text.TextUtils; 6 | 7 | import java.io.File; 8 | import java.io.FileInputStream; 9 | import java.io.FileNotFoundException; 10 | import java.io.InputStream; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * Created by CaiXi on 16/5/23. 16 | * 加载gif 17 | */ 18 | public class GifDecoder { 19 | 20 | public static Context context; 21 | private static final String GIF_IMAGE_PATH_NAME = "FloatAdCache"; 22 | private String mUrl; 23 | private HashMap mMap = new HashMap(); 24 | private GifDrawer mFloatAdDrawer;//悬浮广告GIF实例 25 | private boolean isFloatAd; 26 | private boolean isFirstTime = true; 27 | 28 | public static class Gif { 29 | public static GifDecoder instance = new GifDecoder(); 30 | } 31 | 32 | public static GifDecoder with(Context c) { 33 | context = c; 34 | return Gif.instance; 35 | } 36 | 37 | 38 | /** 39 | * load gif file form inputstream 40 | */ 41 | public GifDrawer load(InputStream is) { 42 | if (isFloatAd && isFirstTime){ 43 | mFloatAdDrawer = new GifDrawer(); 44 | mFloatAdDrawer.setIs(is); 45 | isFirstTime = false; 46 | return mFloatAdDrawer; 47 | }else{ 48 | GifDrawer drawer = new GifDrawer(); 49 | if (mUrl != null && !"".equals(mUrl) && !mMap.containsKey(mUrl)){ 50 | mMap.put(mUrl,drawer); 51 | } 52 | drawer.setIs(is); 53 | return drawer; 54 | } 55 | } 56 | 57 | public HashMap getMap(){ 58 | return mMap; 59 | } 60 | 61 | /** 62 | * load gif file form uri 63 | */ 64 | public GifDrawer load(Uri uri) { 65 | InputStream is = null; 66 | try { 67 | is = context.getContentResolver().openInputStream(uri); 68 | } catch (FileNotFoundException e) { 69 | e.printStackTrace(); 70 | } 71 | return load(is); 72 | } 73 | 74 | /** 75 | * load gif file form sdcard 76 | */ 77 | public GifDrawer load(File file) { 78 | FileInputStream is = null; 79 | try { 80 | is = new FileInputStream(file); 81 | } catch (FileNotFoundException e) { 82 | e.printStackTrace(); 83 | } 84 | return load(is); 85 | } 86 | 87 | /** 88 | * 这个是使用Volley等下载,物理缓存 89 | */ 90 | public GifDrawer load(final String url ,final OnLoadGifListener onLoadGifListener) { 91 | this.isFloatAd = true; 92 | this.mUrl = null; 93 | FileInputStream is = null; 94 | final String path = context.getCacheDir().getPath() + File.separator + getGifImagePath(url); 95 | final File file = new File(path); 96 | if (file.exists()) { 97 | try { 98 | is = new FileInputStream(file); 99 | return load(is); 100 | } catch (FileNotFoundException e) { 101 | e.printStackTrace(); 102 | } 103 | } else { 104 | /**不存在 先下载下来,具体可使用OkHttp,Volley等三方库来实现物理缓存**/ 105 | // ImageLoaderManager.getInstance(context , ImageLoaderManager.GIF_IMAGE_PATH_NAME).getFileLoader().get(url, new FileLoader.FileListener() { 106 | // @Override 107 | // public void onResponse(FileLoader.FileContainer fileContainer, boolean isImmediate) { 108 | // onLoadGifListener.loadGifSuccess(file); 109 | // } 110 | // 111 | // @Override 112 | // public void onErrorResponse(VolleyError error) { 113 | // onLoadGifListener.loadGifFailed(); 114 | // } 115 | // }); 116 | } 117 | 118 | return load(file); 119 | } 120 | 121 | 122 | /** 123 | * load gif file form url 124 | * 这个是在子线程去下载 125 | */ 126 | public GifDrawer load(String url) { 127 | this.mUrl = url; 128 | FileInputStream is = null; 129 | String path = context.getCacheDir().getPath() + File.separator + getGifImagePath(url); 130 | 131 | File file = new File(path); 132 | if (file.exists()) { 133 | try { 134 | is = new FileInputStream(file); 135 | return load(is); 136 | } catch (FileNotFoundException e) { 137 | e.printStackTrace(); 138 | } 139 | } else { 140 | // 不存在 先下载下来 141 | GifDrawer gifDrawer = new GifDrawer(); 142 | GifLoaderTask loadGifTask = new GifLoaderTask(gifDrawer, context); 143 | loadGifTask.execute(url); 144 | return gifDrawer; 145 | } 146 | 147 | return load(is); 148 | } 149 | 150 | public interface OnLoadGifListener{ 151 | void loadGifSuccess(File file); 152 | void loadGifFailed(); 153 | } 154 | 155 | public GifDrawer getFloatAdDrawer(){ 156 | return mFloatAdDrawer; 157 | } 158 | 159 | public void pauseGif() { 160 | HashMap map = getMap(); 161 | if (!map.isEmpty()) { 162 | for (Map.Entry entry : map.entrySet()) { 163 | if (entry.getValue().getCanvas() != null){ 164 | entry.getValue().pauseMovie(); 165 | } 166 | } 167 | } 168 | } 169 | 170 | public void awakeGif() { 171 | HashMap map = getMap(); 172 | if (!map.isEmpty()) { 173 | for (Map.Entry entry : map.entrySet()) { 174 | if (entry.getValue().getRunnable() != null){ 175 | entry.getValue().awakeMovie(); 176 | } 177 | } 178 | } 179 | } 180 | 181 | public void closeGif(){ 182 | HashMap map = getMap(); 183 | if (!map.isEmpty()) { 184 | for (Map.Entry entry : map.entrySet()) { 185 | if (entry.getValue().getCanvas() != null){ 186 | entry.getValue().closeMovie(); 187 | } 188 | } 189 | } 190 | } 191 | 192 | public static String getGifImagePath(String url){ 193 | if (TextUtils.isEmpty(url)){ 194 | return GIF_IMAGE_PATH_NAME + File.separator; 195 | } 196 | return GIF_IMAGE_PATH_NAME + File.separator + String.valueOf(url.hashCode()) + ".0" ; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/gifloader/GifDrawer.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.gifloader; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Movie; 6 | import android.os.Handler; 7 | import android.widget.ImageView; 8 | 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | 12 | /** 13 | * Created by CaiXi on 16/5/23. 14 | * gif的绘制 15 | */ 16 | public class GifDrawer { 17 | private static final String TAG = "GifDrawer"; 18 | private InputStream is; 19 | private ImageView imageView; 20 | private Movie movie; 21 | private Bitmap bitmap; 22 | private Canvas canvas; 23 | private Handler handler = new Handler(); 24 | private final long delayMills = 16; 25 | private Runnable runnable = new Runnable() { 26 | @Override 27 | public void run() { 28 | draw(); 29 | handler.postDelayed(runnable, delayMills); 30 | } 31 | }; 32 | 33 | private void draw() { 34 | canvas.save(); 35 | movie.setTime((int) (System.currentTimeMillis() % movie.duration()));//这个是获取movie的某一帧,我们就不断地循环它 36 | movie.draw(canvas, 0, 0); 37 | imageView.setImageBitmap(bitmap); 38 | canvas.restore(); 39 | } 40 | 41 | /** 42 | * 传递imagerview,将gif放到gif中去 43 | * 44 | * @param imageView 45 | */ 46 | public void into(ImageView imageView) { 47 | this.imageView = imageView; 48 | if (is == null) { 49 | return; 50 | } else if (imageView == null) { 51 | 52 | throw new RuntimeException("imagetView can not be null"); 53 | } else { 54 | 55 | // 开始在imageview里面绘制电影 56 | movie = Movie.decodeStream(is);//gif小电影 57 | if (movie == null) { 58 | throw new IllegalArgumentException("Illegal gif file"); 59 | 60 | } 61 | if (movie.width() <= 0 || movie.height() <= 0) { 62 | return; 63 | } 64 | if (bitmap != null){ 65 | bitmap.recycle(); 66 | bitmap = null; 67 | } 68 | bitmap = Bitmap.createBitmap(movie.width(), movie.height(), Bitmap.Config.RGB_565); 69 | canvas = new Canvas(bitmap); 70 | handler.post(runnable); 71 | } 72 | } 73 | 74 | public void pauseMovie() { 75 | if (runnable != null){ 76 | handler.removeCallbacks(runnable); 77 | } 78 | } 79 | 80 | public void closeMovie(){ 81 | if (is != null){ 82 | try { 83 | is.close(); 84 | } catch (IOException e) { 85 | e.printStackTrace(); 86 | } 87 | } 88 | } 89 | 90 | public void awakeMovie() { 91 | handler.postDelayed(runnable, delayMills); 92 | } 93 | 94 | public InputStream getIs() { 95 | return is; 96 | } 97 | 98 | public void setIs(InputStream is) { 99 | this.is = is; 100 | } 101 | 102 | public ImageView getImageView() { 103 | return imageView; 104 | } 105 | 106 | public void setImageView(ImageView imageView) { 107 | this.imageView = imageView; 108 | } 109 | 110 | public Canvas getCanvas() { 111 | return canvas; 112 | } 113 | 114 | public Runnable getRunnable(){ 115 | return runnable; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/gifloader/GifLoaderTask.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.gifloader; 2 | 3 | import android.content.Context; 4 | import android.os.AsyncTask; 5 | 6 | import java.io.File; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | 11 | /** 12 | * Created by CaiXi on 16/5/23. 13 | */ 14 | class GifLoaderTask extends AsyncTask { 15 | private final Context context; 16 | 17 | private GifDrawer gifDrawer; 18 | 19 | public GifLoaderTask(GifDrawer gifDrawer, Context context) { 20 | this.gifDrawer = gifDrawer; 21 | this.context = context; 22 | } 23 | 24 | @Override 25 | protected String doInBackground(String... params) { 26 | FileOutputStream fops = null; 27 | InputStream is = null; 28 | try { 29 | is = HttpLoader.getInputStreanFormUrl(params[0]); 30 | String path = context.getCacheDir().getPath() + File.separator + GifDecoder.getGifImagePath(params[0]); 31 | File file = new File(path); 32 | fops = new FileOutputStream(file); 33 | int len = 0; 34 | byte[] buffer = new byte[1024]; 35 | while ((len = is.read(buffer)) != -1) { 36 | fops.write(buffer, 0, len); 37 | } 38 | return params[0]; 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | return null; 42 | } finally { 43 | try { 44 | if (fops != null) { 45 | fops.close(); 46 | } 47 | } catch (IOException e) { 48 | e.printStackTrace(); 49 | } 50 | try { 51 | if (is != null) { 52 | is.close(); 53 | } 54 | } catch (IOException e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | } 59 | 60 | @Override 61 | protected void onPostExecute(String s) { 62 | super.onPostExecute(s); 63 | if (s != null) { 64 | GifDecoder.with(context).load(s).into(gifDrawer.getImageView()); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/gifloader/HttpLoader.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.gifloader; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.HttpURLConnection; 6 | import java.net.URL; 7 | 8 | /** 9 | * Created by CaiXi on 16/5/23. 10 | */ 11 | public class HttpLoader { 12 | 13 | public static InputStream getInputStreanFormUrl(String param) throws IOException { 14 | HttpURLConnection conn = (HttpURLConnection) new URL(param).openConnection(); 15 | return conn.getInputStream(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/glide/GifDrawableByteTranscoder.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.glide; 2 | 3 | import com.bumptech.glide.load.engine.Resource; 4 | import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; 5 | 6 | import java.io.IOException; 7 | 8 | import pl.droidsonroids.gif.GifDrawable; 9 | 10 | /** 11 | * @describe : 12 | * @usage : 13 | *

14 | *

15 | * Created by caixi on 17-12-23. 16 | */ 17 | 18 | public class GifDrawableByteTranscoder implements ResourceTranscoder { 19 | @Override 20 | public Resource transcode(Resource toTranscode) { 21 | try { 22 | return new GifDrawableResource(new GifDrawable(toTranscode.get())); 23 | } catch (IOException ex) { 24 | return null; 25 | } 26 | } 27 | 28 | @Override 29 | public String getId() { 30 | return getClass().getName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/glide/GifDrawableResource.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.glide; 2 | 3 | import android.graphics.drawable.Drawable; 4 | import android.view.View; 5 | 6 | import com.bumptech.glide.load.engine.Resource; 7 | 8 | import pl.droidsonroids.gif.GifDrawable; 9 | 10 | /** 11 | * @describe : 12 | * @usage : 13 | *

14 | *

15 | * Created by caixi on 17-12-23. 16 | */ 17 | 18 | public class GifDrawableResource implements Resource { 19 | 20 | private GifDrawable drawable; 21 | 22 | GifDrawableResource(GifDrawable gifDrawable) { 23 | this.drawable = gifDrawable; 24 | } 25 | 26 | @Override 27 | public GifDrawable get() { 28 | return drawable; 29 | } 30 | 31 | @Override 32 | public int getSize() { 33 | return (int) drawable.getInputSourceByteCount(); 34 | } 35 | 36 | @Override 37 | public void recycle() { 38 | drawable.stop(); 39 | drawable.recycle(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/glide/Glides.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.glide; 2 | 3 | import android.content.Context; 4 | 5 | import com.bumptech.glide.GenericRequestBuilder; 6 | import com.bumptech.glide.Glide; 7 | import com.bumptech.glide.Priority; 8 | import com.bumptech.glide.load.data.DataFetcher; 9 | import com.bumptech.glide.load.engine.DiskCacheStrategy; 10 | import com.bumptech.glide.load.model.StreamEncoder; 11 | import com.bumptech.glide.load.model.stream.StreamModelLoader; 12 | import com.bumptech.glide.load.model.stream.StreamStringLoader; 13 | import com.bumptech.glide.load.resource.file.FileToStreamDecoder; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | 18 | import pl.droidsonroids.gif.GifDrawable; 19 | 20 | /** 21 | * @describe : 22 | * @usage : 23 | *

24 | *

25 | * Created by caixi on 17-12-23. 26 | */ 27 | 28 | public class Glides { 29 | 30 | public static final StreamModelLoader CACHE_ONLY = new StreamModelLoader() { 31 | @Override 32 | public DataFetcher getResourceFetcher(final String model, int i, int i1) { 33 | return new DataFetcher() { 34 | @Override 35 | public InputStream loadData(Priority priority) throws Exception { 36 | throw new IOException(); 37 | } 38 | 39 | @Override 40 | public void cleanup() { 41 | 42 | } 43 | 44 | @Override 45 | public String getId() { 46 | return model; 47 | } 48 | 49 | @Override 50 | public void cancel() { 51 | 52 | } 53 | }; 54 | } 55 | }; 56 | 57 | public static GenericRequestBuilder gif(Context context) { 58 | return Glide 59 | .with(context) 60 | .using(new StreamStringLoader(context), InputStream.class) 61 | .from(String.class) // change this if you have a different model like a File and use StreamFileLoader above 62 | .as(byte[].class) 63 | .transcode(new GifDrawableByteTranscoder(), GifDrawable.class) // pass it on 64 | .diskCacheStrategy(DiskCacheStrategy.SOURCE) // cache original 65 | .decoder(new StreamByteArrayResourceDecoder()) // load original 66 | .sourceEncoder(new StreamEncoder()) 67 | .cacheDecoder(new FileToStreamDecoder(new StreamByteArrayResourceDecoder())); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /library/src/main/gif/com/cxmax/library/glide/StreamByteArrayResourceDecoder.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.glide; 2 | 3 | import com.bumptech.glide.load.ResourceDecoder; 4 | import com.bumptech.glide.load.engine.Resource; 5 | import com.bumptech.glide.load.resource.bytes.BytesResource; 6 | 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | 11 | /** 12 | * @describe : 13 | * @usage : 14 | *

15 | *

16 | * Created by caixi on 17-12-23. 17 | */ 18 | 19 | public class StreamByteArrayResourceDecoder implements ResourceDecoder { 20 | 21 | @Override 22 | public Resource decode(InputStream source, int width, int height) throws IOException { 23 | ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 24 | byte[] buffer = new byte[1024]; 25 | int count; 26 | while ((count = source.read(buffer)) != -1) { 27 | bytes.write(buffer, 0, count); 28 | } 29 | return new BytesResource(bytes.toByteArray()); 30 | } 31 | 32 | @Override 33 | public String getId() { 34 | return getClass().getName(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /library/src/main/java/com/cxmax/library/FloatingView.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Bitmap; 6 | import android.graphics.Canvas; 7 | import android.graphics.Matrix; 8 | import android.graphics.Paint; 9 | import android.graphics.drawable.Drawable; 10 | import android.graphics.drawable.LayerDrawable; 11 | import android.support.annotation.ColorInt; 12 | import android.support.v4.content.ContextCompat; 13 | import android.support.v7.widget.AppCompatImageView; 14 | import android.util.AttributeSet; 15 | import android.view.MotionEvent; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.view.ViewTreeObserver; 19 | 20 | import com.cxmax.library.utils.ImageUtils; 21 | 22 | import pl.droidsonroids.gif.GifDrawable; 23 | 24 | /** 25 | * 1.绑定滑动监听,View在滑动过程中显示隐藏的动画效果。 26 | * 2.自定义View的绘制,主要用了Bitmap的绘制,在目标广告图的右上角用遮罩绘制删除按钮 27 | * 3.View的点击事件OnTouchEvent的处理 28 | * Created by CaiXi on 2016/8/23 29 | */ 30 | public class FloatingView extends AppCompatImageView implements IFloatingView,ViewTreeObserver.OnGlobalLayoutListener { 31 | 32 | private final static String TAG = FloatingView.class.getSimpleName(); 33 | 34 | private Context context; 35 | private Paint paint; 36 | private int width, height; 37 | private boolean hasMargin; 38 | private Matrix matrix; 39 | private float pointX, pointY; 40 | 41 | /* close bitmap */ 42 | private Bitmap closeBitmap; 43 | private LayerDrawable closeDrawable; 44 | private int closeWidth, closeHeight, closePadding; 45 | /* custom params */ 46 | private boolean draggable; 47 | 48 | IFloatingView.OnClickListener clickListener; 49 | 50 | public FloatingView(Context context) { 51 | this(context, null); 52 | } 53 | 54 | public FloatingView(Context context, AttributeSet attrs) { 55 | this(context, attrs, 0); 56 | } 57 | 58 | public FloatingView(Context context, AttributeSet attrs, int defStyleAttr) { 59 | super(context, attrs, defStyleAttr); 60 | initializeCustomAttrs(context, attrs); 61 | initialize(context); 62 | initializeCloseBitmap(context); 63 | } 64 | 65 | private void initialize(Context context) { 66 | this.context = context; 67 | paint = new Paint(Paint.ANTI_ALIAS_FLAG); 68 | matrix = new Matrix(); 69 | width = context.getResources().getDimensionPixelSize(R.dimen.floating_view_max_width); 70 | height = context.getResources().getDimensionPixelSize(R.dimen.floating_view_max_height); 71 | } 72 | 73 | private void initializeCloseBitmap(Context context) { 74 | closeWidth = context.getResources().getDimensionPixelSize(R.dimen.close_view_width); 75 | closeHeight = context.getResources().getDimensionPixelSize(R.dimen.close_view_height); 76 | closePadding = context.getResources().getDimensionPixelSize(R.dimen.close_view_padding); 77 | closeDrawable = ImageUtils.createLayerDrawable(ContextCompat.getDrawable(context, R.drawable.float_ad_close), 78 | ContextCompat.getDrawable(context, R.drawable.float_ad_close_background)); 79 | closeBitmap = ImageUtils.drawableToBitmap(closeDrawable, closeWidth, closeHeight, Bitmap.Config.ARGB_4444); 80 | } 81 | 82 | private void initializeCustomAttrs(Context context, AttributeSet attrs) { 83 | if (attrs != null) { 84 | TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingView, 0, 0); 85 | if (attr != null) { 86 | draggable = attr.getBoolean(R.styleable.FloatingView_draggable, false); 87 | attr.recycle(); 88 | } 89 | } 90 | } 91 | 92 | @Override 93 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 94 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 95 | int w = measureSize(widthMeasureSpec, width); 96 | int h = measureSize(heightMeasureSpec, height); 97 | setMargin(); 98 | setMeasuredDimension(w, h); 99 | } 100 | 101 | @Override 102 | protected void onDraw(Canvas canvas) { 103 | super.onDraw(canvas); 104 | matrix.setTranslate(width - closeWidth - closePadding, closePadding); 105 | if (closeBitmap != null) { 106 | canvas.drawBitmap(closeBitmap, matrix, paint); 107 | } 108 | } 109 | 110 | @Override 111 | public boolean onTouchEvent(MotionEvent event) { 112 | switch (event.getAction()){ 113 | case MotionEvent.ACTION_UP: 114 | if (closeBitmap != null){ 115 | boolean touchable = (pointX > (width - closeWidth) && pointY < closeHeight); 116 | if (touchable){ 117 | setVisibility(GONE); 118 | if (clickListener != null) { 119 | clickListener.onCloseClick(); 120 | } 121 | release(); 122 | setImageDrawable(null); 123 | }else{ 124 | if (clickListener != null) { 125 | clickListener.onFloatClick(this); 126 | } 127 | } 128 | pointX = 0; 129 | pointY = 0; 130 | } 131 | break; 132 | case MotionEvent.ACTION_MOVE: 133 | if (draggable) { 134 | final float distanceX = event.getX() - pointX; 135 | final float distanceY = event.getY() - pointY; 136 | if (distanceX != 0 && distanceY != 0) { 137 | int l = (int) (getLeft() + distanceX); 138 | int r = (int) (getRight() + distanceX); 139 | int t = (int) (getTop() + distanceY); 140 | int b = (int) (getBottom() + distanceY); 141 | this.layout(l, t, r, b); 142 | } 143 | } else { 144 | pointX = event.getX(); 145 | pointY = event.getY(); 146 | } 147 | break; 148 | case MotionEvent.ACTION_CANCEL: 149 | break; 150 | case MotionEvent.ACTION_DOWN: 151 | pointX = event.getX(); 152 | pointY = event.getY(); 153 | break; 154 | default: 155 | break; 156 | } 157 | return true; 158 | } 159 | 160 | @Override 161 | public void onGlobalLayout() { 162 | if (getVisibility() == GONE){ 163 | release(); 164 | } 165 | } 166 | 167 | @Override 168 | public void setCloseColor(@ColorInt int color) { 169 | recycleClose(); 170 | closeDrawable = ImageUtils.drawColorOnLayer(closeDrawable, color); 171 | closeBitmap = ImageUtils.drawableToBitmap(closeDrawable, closeWidth, closeHeight, Bitmap.Config.ARGB_4444); 172 | invalidate(); 173 | } 174 | 175 | @Override 176 | public void release() { 177 | recycleClose(); 178 | recycleDrawableIfGif(); 179 | } 180 | 181 | public void setClickListener(IFloatingView.OnClickListener clickListener) { 182 | this.clickListener = clickListener; 183 | } 184 | 185 | private void recycleClose() { 186 | if (closeBitmap != null && !closeBitmap.isRecycled()) { 187 | closeBitmap.recycle(); 188 | closeBitmap = null; 189 | } 190 | } 191 | 192 | private void recycleDrawableIfGif() { 193 | // recycle gif if set 194 | Drawable pic = this.getDrawable(); 195 | if (pic instanceof GifDrawable) { 196 | GifDrawable recycle = (GifDrawable) pic; 197 | if (!recycle.isRecycled()) { 198 | recycle.recycle(); 199 | } 200 | } 201 | } 202 | 203 | private static int measureSize(int measureSpec, int defaultSize) { 204 | int result = defaultSize; 205 | int specMode = View.MeasureSpec.getMode(measureSpec); 206 | int specSize = View.MeasureSpec.getSize(measureSpec); 207 | switch (specMode) { 208 | case View.MeasureSpec.UNSPECIFIED: 209 | case View.MeasureSpec.AT_MOST: 210 | break; 211 | case View.MeasureSpec.EXACTLY: 212 | result = specSize; 213 | result = Math.max(result, defaultSize); 214 | break; 215 | } 216 | return result; 217 | } 218 | 219 | private void setMargin() { 220 | if (!hasMargin){ 221 | if (getLayoutParams() != null){ 222 | ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) getLayoutParams(); 223 | int leftMargin = lp.leftMargin; 224 | int topMargin = lp.topMargin; 225 | int rightMargin = lp.rightMargin; 226 | int bottomMargin = lp.bottomMargin; 227 | lp.setMargins(leftMargin, topMargin, rightMargin, bottomMargin); 228 | requestLayout(); 229 | hasMargin = true; 230 | } 231 | } 232 | } 233 | 234 | } 235 | -------------------------------------------------------------------------------- /library/src/main/java/com/cxmax/library/IFloatingView.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library; 2 | 3 | import android.support.annotation.ColorInt; 4 | import android.view.View; 5 | 6 | /** 7 | * @describe : 8 | * @usage : 9 | *

10 | *

11 | * Created by caixi on 17-12-23. 12 | */ 13 | 14 | public interface IFloatingView { 15 | 16 | void setCloseColor(@ColorInt int color); 17 | 18 | void release(); 19 | 20 | public interface OnClickListener { 21 | void onFloatClick(View v); 22 | 23 | void onCloseClick(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/java/com/cxmax/library/drag/DragLayout.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.drag; 2 | 3 | import android.content.Context; 4 | import android.support.v4.widget.ViewDragHelper; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.widget.RelativeLayout; 9 | 10 | /** 11 | * 可拖拽的父容器Layout,只需要将内容图片在xml布局文件中设置在父容器内即可 12 | * 1.主要利用ViewDragHelper这个类来实现拖拽 13 | * Created by CaiXi on 2016/8/23. 14 | */ 15 | public class DragLayout extends RelativeLayout{ 16 | private ViewDragHelper drag; 17 | 18 | public DragLayout(Context context) { 19 | this(context, null); 20 | } 21 | 22 | public DragLayout(Context context, AttributeSet attrs) { 23 | this(context, attrs, 0); 24 | } 25 | 26 | public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) { 27 | super(context, attrs, defStyleAttr); 28 | drag = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() { 29 | @Override 30 | public boolean tryCaptureView(View child, int pointerId) { 31 | return true; 32 | } 33 | 34 | @Override 35 | public int clampViewPositionHorizontal(View child, int left, int dx) { 36 | final int leftBound = getPaddingLeft(); 37 | final int rightBound = getWidth() - child.getWidth() - leftBound; 38 | final int newLeft = Math.min(Math.max(left, leftBound), rightBound); 39 | return newLeft; 40 | } 41 | 42 | @Override 43 | public int clampViewPositionVertical(View child, int top, int dy) { 44 | final int topBound = getPaddingTop(); 45 | final int bottomBound = getHeight() - child.getHeight(); 46 | final int newTop = Math.min(Math.max(top, topBound), bottomBound); 47 | return newTop; 48 | } 49 | 50 | @Override 51 | public int getViewHorizontalDragRange(View child) { 52 | return getMeasuredWidth() - child.getMeasuredWidth(); 53 | } 54 | 55 | @Override 56 | public int getViewVerticalDragRange(View child) { 57 | return getMeasuredHeight() - child.getMeasuredHeight(); 58 | } 59 | 60 | @Override 61 | public void onViewReleased(View releasedChild, float xvel, float yvel) { 62 | moveToSide(releasedChild); 63 | invalidate(); 64 | } 65 | }); 66 | } 67 | 68 | private void moveToSide(View view) { 69 | float top = view.getTop(); 70 | float bottom = getMeasuredHeight() - view.getBottom(); 71 | float right = getMeasuredWidth() - view.getRight(); 72 | float left = view.getLeft(); 73 | //上下滑动 74 | if ((top < bottom ? top : bottom) / getMeasuredHeight() < (right < left ? right : left) / getMeasuredWidth()) { 75 | drag.settleCapturedViewAt(view.getLeft(), top < bottom ? 0 : getMeasuredHeight() - view.getMeasuredHeight()); 76 | } else { 77 | //左右滑动 78 | drag.settleCapturedViewAt(left < right ? 0 : getMeasuredWidth() - view.getMeasuredWidth(), view.getTop()); 79 | } 80 | } 81 | 82 | @Override 83 | public boolean onInterceptTouchEvent(MotionEvent ev) { 84 | return drag.shouldInterceptTouchEvent(ev); 85 | } 86 | 87 | @Override 88 | public boolean onTouchEvent(MotionEvent event) { 89 | drag.processTouchEvent(event); 90 | return false; 91 | } 92 | 93 | @Override 94 | public void computeScroll() { 95 | if (drag.continueSettling(true)) { 96 | invalidate(); 97 | } 98 | } 99 | 100 | @Override 101 | protected void onFinishInflate() { 102 | super.onFinishInflate(); 103 | for (int i = 0; i < getChildCount(); i++) { 104 | getChildAt(i).setClickable(true); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /library/src/main/java/com/cxmax/library/utils/DisplayUtils.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.utils; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | import android.util.DisplayMetrics; 6 | import android.view.WindowManager; 7 | 8 | /** 9 | * @describe : 10 | * @usage : 11 | *

12 | *

13 | * Created by caixi on 17-12-23. 14 | */ 15 | 16 | public class DisplayUtils { 17 | 18 | @NonNull 19 | public static DisplayMetrics getDisplayMetrics(@NonNull Context context) { 20 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 21 | DisplayMetrics dm = new DisplayMetrics(); 22 | if (wm != null) { 23 | wm.getDefaultDisplay().getMetrics(dm); 24 | } 25 | return dm; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/com/cxmax/library/utils/ImageUtils.java: -------------------------------------------------------------------------------- 1 | package com.cxmax.library.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.PorterDuff; 6 | import android.graphics.drawable.BitmapDrawable; 7 | import android.graphics.drawable.Drawable; 8 | import android.graphics.drawable.LayerDrawable; 9 | import android.support.annotation.ColorInt; 10 | import android.support.annotation.NonNull; 11 | 12 | /** 13 | * @describe : 14 | * @usage : 15 | *

16 | *

17 | * Created by caixi on 17-12-23. 18 | */ 19 | 20 | public class ImageUtils { 21 | 22 | public static LayerDrawable createLayerDrawable(@NonNull Drawable upper, @NonNull Drawable lower) { 23 | Drawable[] layers = new Drawable[2]; 24 | layers[0] = lower; 25 | layers[1] = upper; 26 | return new LayerDrawable(layers); 27 | } 28 | 29 | public static LayerDrawable drawColorOnLayer(LayerDrawable transform, @ColorInt int color) { 30 | Drawable background = transform.getDrawable(0); 31 | background.setColorFilter(color, PorterDuff.Mode.SRC_IN); 32 | return transform; 33 | } 34 | 35 | public static Bitmap drawableToBitmap(@NonNull Drawable drawable, int width, int height, @NonNull Bitmap.Config config) { 36 | Bitmap bitmap = null; 37 | if (drawable instanceof BitmapDrawable) { 38 | BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; 39 | if (bitmapDrawable.getBitmap() != null) { 40 | return bitmapDrawable.getBitmap(); 41 | } 42 | } 43 | if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { 44 | bitmap = Bitmap.createBitmap(1, 1, config); 45 | } else { 46 | bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), config); 47 | } 48 | Canvas canvas = new Canvas(bitmap); 49 | drawable.setBounds(0, 0, width, height); 50 | drawable.draw(canvas); 51 | return bitmap; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/float_ad_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/library/src/main/res/drawable/float_ad_close.png -------------------------------------------------------------------------------- /library/src/main/res/drawable/float_ad_close_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxMax/FloatingView/f5ab75799cf5bd1edf88212083b579579aa97ea9/library/src/main/res/drawable/float_ad_close_background.png -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #5677fc 5 | -------------------------------------------------------------------------------- /library/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 40dp 3 | 78dp 4 | 78dp 5 | 20dp 6 | 20dp 7 | 3dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | --------------------------------------------------------------------------------