├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable-xhdpi
│ │ │ ├── ic_leaf.png
│ │ │ ├── ic_loading.png
│ │ │ └── ic_eletric_fan.png
│ │ ├── layout
│ │ │ ├── item_image_view.xml
│ │ │ └── activity_main.xml
│ │ ├── anim
│ │ │ ├── delete_btn_hide.xml
│ │ │ ├── delete_btn_show.xml
│ │ │ ├── slide_out_bottom.xml
│ │ │ └── slide_in_bottom.xml
│ │ └── values
│ │ │ ├── strings.xml
│ │ │ ├── dimens.xml
│ │ │ ├── styles.xml
│ │ │ ├── attrs.xml
│ │ │ └── colors.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── user
│ │ │ └── utils
│ │ │ ├── util
│ │ │ ├── VibrationUtils.java
│ │ │ ├── ToastUtils.java
│ │ │ ├── ServiceUtils.java
│ │ │ ├── ActivityUtils.java
│ │ │ ├── CrashUtils.java
│ │ │ ├── DeviceUtils.java
│ │ │ ├── CleanUtils.java
│ │ │ ├── ClipboardUtils.java
│ │ │ ├── EmptyUtils.java
│ │ │ ├── ConstUtils.java
│ │ │ ├── RegexUtils.java
│ │ │ ├── BarUtils.java
│ │ │ └── SizeUtils.java
│ │ │ ├── weight
│ │ │ ├── animator
│ │ │ │ ├── AnimatorValue.java
│ │ │ │ ├── AnimationFactory.java
│ │ │ │ └── AnimatorValueImplements.java
│ │ │ ├── swipyrefresh
│ │ │ │ ├── SwipyRefreshLayoutDirection.java
│ │ │ │ └── CircleImageView.java
│ │ │ ├── numal
│ │ │ │ ├── SelectTextView.java
│ │ │ │ ├── CustomView.java
│ │ │ │ ├── ProcessImageView.java
│ │ │ │ └── SwipeSlideListener.java
│ │ │ └── webView
│ │ │ │ ├── ScrollWebView.java
│ │ │ │ ├── MyWebChromeClient.java
│ │ │ │ └── MyWebViewClient.java
│ │ │ ├── ktutils
│ │ │ ├── download
│ │ │ │ ├── ProgressCallBack.kt
│ │ │ │ └── DownloadObserver.kt
│ │ │ ├── interfaces
│ │ │ │ ├── ISubscriber.kt
│ │ │ │ ├── IStringSubscriber.kt
│ │ │ │ └── IBaseResultSubscriber.kt
│ │ │ ├── base
│ │ │ │ ├── BaseDownLoadObserver.kt
│ │ │ │ ├── BaseStringObserver.kt
│ │ │ │ └── BaseBaseResultObserver.kt
│ │ │ ├── BaseObserver.kt
│ │ │ └── bean
│ │ │ │ └── BaseResult.kt
│ │ │ ├── media
│ │ │ ├── CustomGallery.java
│ │ │ ├── DrawableUtils.java
│ │ │ ├── GildeTools
│ │ │ │ ├── GlideCircleTransform.java
│ │ │ │ ├── GlideRoundTransform.java
│ │ │ │ └── GlideUtils.java
│ │ │ ├── VolleyTools
│ │ │ │ └── ImageLoaderUtil.java
│ │ │ ├── GLFont.java
│ │ │ └── SampleSizeUtil.java
│ │ │ ├── permission
│ │ │ ├── annotation
│ │ │ │ ├── OnMPermissionGranted.java
│ │ │ │ ├── OnMPermissionDenied.java
│ │ │ │ └── OnMPermissionNeverAskAgain.java
│ │ │ └── util
│ │ │ │ └── MPermissionUtil.java
│ │ │ ├── request
│ │ │ ├── okhttp
│ │ │ │ └── Param.java
│ │ │ ├── volley
│ │ │ │ ├── BitmapCache.java
│ │ │ │ ├── GsonRequest.java
│ │ │ │ ├── XMLRequest.java
│ │ │ │ ├── MyJsonObjectRequest.java
│ │ │ │ ├── VolleyJsonObjectListenerInterface.java
│ │ │ │ ├── VolleyListenerInterface.java
│ │ │ │ └── VolleyErrorHelper.java
│ │ │ └── xutils
│ │ │ │ └── HttpUtilsOfxUtils.java
│ │ │ ├── view
│ │ │ ├── CommonUtils.java
│ │ │ ├── ViewFindUtils.java
│ │ │ ├── OpenQToChat.java
│ │ │ ├── ComparatorUtil.java
│ │ │ ├── AutoSpliText.java
│ │ │ └── NumberFormat.java
│ │ │ ├── sys
│ │ │ ├── StatusBarView.java
│ │ │ ├── DemoCache.java
│ │ │ ├── SetTelCountTimer.java
│ │ │ ├── ReflectionUtil.java
│ │ │ ├── ObjectUtils.java
│ │ │ └── ScreenUtil.java
│ │ │ ├── storage
│ │ │ ├── StorageType.java
│ │ │ └── StorageUtil.java
│ │ │ ├── string
│ │ │ ├── MD5.java
│ │ │ ├── AnimUtils.java
│ │ │ ├── StringUtil.java
│ │ │ ├── TextFormater.java
│ │ │ ├── CyptoUtils.java
│ │ │ └── HexDump.java
│ │ │ ├── acache
│ │ │ ├── UserUtils.java
│ │ │ └── DataCacheManager.java
│ │ │ ├── log
│ │ │ └── LogUtil.java
│ │ │ └── loaddrawable
│ │ │ ├── LoadingView.java
│ │ │ ├── LoadingDrawable.java
│ │ │ ├── LoadingRendererFactory.java
│ │ │ └── LoadingRenderer.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── img
├── how.png
└── how2.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
└── vcs.xml
├── android
└── content
│ └── annotations.xml
├── .gitignore
├── gradle.properties
└── gradlew.bat
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/img/how.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaysLater/AndroidUtils/HEAD/img/how.png
--------------------------------------------------------------------------------
/img/how2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaysLater/AndroidUtils/HEAD/img/how2.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaysLater/AndroidUtils/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_leaf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaysLater/AndroidUtils/HEAD/app/src/main/res/drawable-xhdpi/ic_leaf.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaysLater/AndroidUtils/HEAD/app/src/main/res/drawable-xhdpi/ic_loading.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_eletric_fan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaysLater/AndroidUtils/HEAD/app/src/main/res/drawable-xhdpi/ic_eletric_fan.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/content/annotations.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_image_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 21 15:56: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.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/util/VibrationUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.util;
2 |
3 | /**
4 | *
{
15 | /**
16 | * doOnSubscribe 回调
17 | *
18 | * @param d Disposable
19 | */
20 | fun doOnSubscribe(d: Disposable)
21 |
22 | /**
23 | * 错误回调
24 | *
25 | * @param errorMsg 错误信息
26 | */
27 | fun doOnError(errorMsg: String?)
28 |
29 | /**
30 | * 成功回调
31 | *
32 | * @param t 泛型
33 | */
34 | fun doOnNext(t: T)
35 |
36 | /**
37 | * 请求完成回调
38 | */
39 | fun doOnCompleted()
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/sys/StatusBarView.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.sys;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | /**
8 | * ========================================
9 | *
10 | * 版 权:dou361.com 版权所有 (C) 2015
11 | *
12 | * 作 者:陈冠明
13 | *
14 | * 个人网站:http://www.dou361.com
15 | *
16 | * 版 本:1.0
17 | *
18 | * 创建日期:2016/8/14 16:15
19 | *
20 | * 描 述:
21 | *
22 | *
23 | * 修订历史:
24 | *
25 | * ========================================
26 | */
27 | public class StatusBarView extends View {
28 | public StatusBarView(Context context, AttributeSet attrs) {
29 | super(context, attrs);
30 | }
31 |
32 | public StatusBarView(Context context) {
33 | super(context);
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/interfaces/IStringSubscriber.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils.interfaces
2 |
3 | import io.reactivex.disposables.Disposable
4 |
5 |
6 | /**
7 | * 项目名称:AndroidUtils
8 | * 类描述:IStringSubscriber 描述:
9 | * 创建人:songlijie
10 | * 创建时间:2018/9/21 16:02
11 | * 邮箱:814326663@qq.com
12 | */
13 | interface IStringSubscriber {
14 | /**
15 | * doOnSubscribe 回调
16 | *
17 | * @param d Disposable
18 | */
19 | fun doOnSubscribe(d: Disposable)
20 |
21 | /**
22 | * 错误回调
23 | *
24 | * @param errorMsg 错误信息
25 | */
26 | fun doOnError(errorMsg: String?)
27 |
28 | /**
29 | * 成功回调
30 | *
31 | * @param string data
32 | */
33 | fun doOnNext(string: String)
34 |
35 | /**
36 | * 请求完成回调
37 | */
38 | fun doOnCompleted()
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/sys/DemoCache.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.sys;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by jezhee on 2/20/15.
7 | */
8 | public class DemoCache {
9 |
10 | private static Context context;
11 |
12 | private static String account;
13 |
14 | public static void clear() {
15 | account = null;
16 | }
17 |
18 | public static String getAccount() {
19 | return account;
20 | }
21 |
22 | public static void setAccount(String account) {
23 | DemoCache.account = account;
24 | }
25 |
26 | public static Context getContext() {
27 | if (context == null) {
28 | throw new RuntimeException("please setContext first!");
29 | }
30 | return context;
31 | }
32 |
33 | public static void setContext(Context context) {
34 | DemoCache.context = context.getApplicationContext();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/interfaces/IBaseResultSubscriber.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils.interfaces
2 |
3 | import com.alibaba.fastjson.JSONObject
4 | import com.example.user.utils.ktutils.bean.BaseResult
5 | import io.reactivex.disposables.Disposable
6 |
7 | /**
8 | * 项目名称:AndroidUtils
9 | * 类描述:IBaseResultSubscriber 描述:
10 | * 创建人:songlijie
11 | * 创建时间:2018/9/21 16:00
12 | * 邮箱:814326663@qq.com
13 | */
14 | interface IBaseResultSubscriber {
15 | /**
16 | * doOnSubscribe 回调
17 | *
18 | * @param d Disposable
19 | */
20 | fun doOnSubscribe(d: Disposable)
21 |
22 | /**
23 | * 错误回调
24 | *
25 | * @param errorMsg 错误信息
26 | */
27 | fun doOnError(errorMsg: String?)
28 |
29 | /**
30 | * 成功回调
31 | *
32 | * @param baseData 基础泛型
33 | */
34 | fun doOnNext(baseData: BaseResult)
35 |
36 | /**
37 | * 请求完成回调
38 | */
39 | fun doOnCompleted()
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/request/volley/BitmapCache.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.request.volley;
2 |
3 | import android.graphics.Bitmap;
4 | import android.support.v4.util.LruCache;
5 |
6 | import com.android.volley.toolbox.ImageLoader.ImageCache;
7 |
8 | public class BitmapCache implements ImageCache {
9 | private LruCache mCache;
10 |
11 | public BitmapCache() {
12 | int maxSize = 10 * 1024 * 1024;
13 | mCache = new LruCache(maxSize) {
14 | @Override
15 | protected int sizeOf(String key, Bitmap value) {
16 | return value.getRowBytes() * value.getHeight();
17 | }
18 | };
19 | }
20 |
21 | @Override
22 | public Bitmap getBitmap(String url) {
23 | return mCache.get(url);
24 | }
25 |
26 | @Override
27 | public void putBitmap(String url, Bitmap bitmap) {
28 | mCache.put(url, bitmap);
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/base/BaseDownLoadObserver.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils.base
2 |
3 | import com.example.user.utils.ktutils.excertioncode.AllExcertion
4 | import io.reactivex.Observer
5 | import io.reactivex.disposables.Disposable
6 | import okhttp3.ResponseBody
7 |
8 | /**
9 | * 项目名称:AndroidUtils
10 | * 类描述:BaseDownLoadObserver 描述:
11 | * 创建人:songlijie
12 | * 创建时间:2018/9/21 17:07
13 | * 邮箱:814326663@qq.com
14 | */
15 | abstract class BaseDownLoadObserver : Observer {
16 | override fun onComplete() {
17 |
18 | }
19 |
20 | override fun onSubscribe(d: Disposable) {
21 | }
22 |
23 | override fun onNext(t: ResponseBody) {
24 | }
25 |
26 | override fun onError(e: Throwable) {
27 | val message = AllExcertion().handleException(e).getErorMessage()
28 | setError(message)
29 | }
30 |
31 | /**
32 | * 失败回调
33 | *
34 | * @param errorMsg 错误信息
35 | */
36 | protected abstract fun doOnError(errorMsg: String?)
37 |
38 | private fun setError(errorMsg: String?) {
39 | doOnError(errorMsg)
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/BaseObserver.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils
2 |
3 | import com.example.user.utils.ktutils.excertioncode.AllExcertion
4 | import com.example.user.utils.ktutils.interfaces.ISubscriber
5 | import io.reactivex.Observer
6 | import io.reactivex.disposables.Disposable
7 |
8 | /**
9 | * 项目名称:AndroidUtils
10 | * 类描述:BaseObserver 描述:
11 | * 创建人:songlijie
12 | * 创建时间:2018/9/21 15:23
13 | * 邮箱:814326663@qq.com
14 | */
15 | abstract class BaseObserver : Observer, ISubscriber {
16 | /**
17 | * 是否隐藏toast
18 | *
19 | * @return
20 | */
21 | protected fun isHideToast(): Boolean {
22 | return false
23 | }
24 |
25 |
26 | override fun onComplete() {
27 | doOnCompleted()
28 | }
29 |
30 | override fun onSubscribe(d: Disposable) {
31 | doOnSubscribe(d)
32 | }
33 |
34 | override fun onNext(t: T) {
35 | doOnNext(t)
36 | }
37 |
38 | override fun onError(e: Throwable) {
39 | showError(e)
40 | }
41 |
42 | private fun showError(e: Throwable?) {
43 | val message = AllExcertion().handleException(e).getErorMessage()
44 | doOnError(message)
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/base/BaseStringObserver.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils.base
2 |
3 | import com.example.user.utils.ktutils.excertioncode.AllExcertion
4 | import com.example.user.utils.ktutils.interfaces.IStringSubscriber
5 | import io.reactivex.Observer
6 | import io.reactivex.disposables.Disposable
7 |
8 | /**
9 | * 项目名称:AndroidUtils
10 | * 类描述:BaseStringObserver 描述:
11 | * 创建人:songlijie
12 | * 创建时间:2018/9/21 16:56
13 | * 邮箱:814326663@qq.com
14 | */
15 | abstract class BaseStringObserver : Observer, IStringSubscriber {
16 |
17 | /**
18 | * 是否隐藏toast
19 | *
20 | * @return
21 | */
22 | protected fun isHideToast(): Boolean {
23 | return false
24 | }
25 |
26 |
27 | override fun onComplete() {
28 | doOnCompleted()
29 | }
30 |
31 | override fun onSubscribe(d: Disposable) {
32 | doOnSubscribe(d)
33 | }
34 |
35 | override fun onNext(t: String) {
36 | doOnNext(t)
37 | }
38 |
39 | override fun onError(e: Throwable) {
40 | showError(e)
41 | }
42 |
43 | private fun showError(e: Throwable?) {
44 | val message = AllExcertion().handleException(e).getErorMessage()
45 | doOnError(message)
46 | }
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/bean/BaseResult.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils.bean
2 |
3 | import android.icu.lang.UCharacter.GraphemeClusterBreak.T
4 |
5 |
6 | /**
7 | * 项目名称:AndroidUtils
8 | * 类描述:BaseResult 描述: 基础数据格式
9 | * 创建人:songlijie
10 | * 创建时间:2018/9/21 17:00
11 | * 邮箱:814326663@qq.com
12 | */
13 | class BaseResult {
14 |
15 | /**
16 | * 错误码
17 | */
18 | private var code: Int = 0
19 | /**
20 | * 错误描述
21 | */
22 | private var msg: String? = null
23 |
24 | /**
25 | * 数据
26 | */
27 | private var data: T? = null
28 |
29 | fun getCode(): Int {
30 | return code
31 | }
32 |
33 | fun setCode(code: Int) {
34 | this.code = code
35 | }
36 |
37 | fun getMsg(): String? {
38 | return msg
39 | }
40 |
41 | fun setMsg(msg: String) {
42 | this.msg = msg
43 | }
44 |
45 | fun getData(): T? {
46 | return data
47 | }
48 |
49 | fun setData(data: T) {
50 | this.data = data
51 | }
52 |
53 | override fun toString(): String {
54 | return "BaseResult:{" +
55 | "code=" + code +
56 | ", msg='" + msg + '\''.toString() +
57 | ", data=" + data +
58 | '}'.toString()
59 | }
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/ktutils/base/BaseBaseResultObserver.kt:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.ktutils.base
2 |
3 | import com.alibaba.fastjson.JSONObject
4 | import com.example.user.utils.ktutils.bean.BaseResult
5 | import com.example.user.utils.ktutils.excertioncode.AllExcertion
6 | import com.example.user.utils.ktutils.interfaces.IBaseResultSubscriber
7 | import io.reactivex.Observer
8 | import io.reactivex.disposables.Disposable
9 |
10 | /**
11 | * 项目名称:AndroidUtils
12 | * 类描述:BaseBaseResultObserver 描述:
13 | * 创建人:songlijie
14 | * 创建时间:2018/9/21 16:06
15 | * 邮箱:814326663@qq.com
16 | */
17 | abstract class BaseBaseResultObserver: IBaseResultSubscriber, Observer> {
18 |
19 | /**
20 | * 是否隐藏toast
21 | *
22 | * @return
23 | */
24 | protected fun isHideToast(): Boolean {
25 | return false
26 | }
27 |
28 | override fun onComplete() {
29 | doOnCompleted()
30 | }
31 |
32 |
33 | override fun onSubscribe(d: Disposable) {
34 | doOnSubscribe(d)
35 | }
36 |
37 | override fun onNext(t: BaseResult) {
38 | doOnNext(t)
39 | }
40 |
41 | override fun onError(e: Throwable) {
42 | showError(e)
43 | }
44 |
45 | private fun showError(e: Throwable?) {
46 | val message = AllExcertion().handleException(e).getErorMessage()
47 | doOnError(message)
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
11 |
18 |
19 |
23 |
24 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/util/ServiceUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.util;
2 |
3 | import android.app.ActivityManager;
4 | import android.app.ActivityManager.RunningServiceInfo;
5 | import android.content.ComponentName;
6 | import android.content.Context;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | *
12 | * author: Blankj
13 | * blog : http://blankj.com
14 | * time : 2016/8/2
15 | * desc : 服务工具类
16 | *
17 | */
18 | public class ServiceUtils {
19 |
20 | private ServiceUtils() {
21 | throw new UnsupportedOperationException("u can't instantiate me...");
22 | }
23 |
24 | /**
25 | * 获取服务是否开启
26 | *
27 | * @param context 上下文
28 | * @param className 完整包名的服务类名
29 | * @return {@code true}: 是
{@code false}: 否
30 | */
31 | public static boolean isRunningService(Context context, String className) {
32 | // 进程的管理者,活动的管理者
33 | ActivityManager activityManager = (ActivityManager)
34 | context.getSystemService(Context.ACTIVITY_SERVICE);
35 | // 获取正在运行的服务,最多获取1000个
36 | List runningServices = activityManager.getRunningServices(1000);
37 | // 遍历集合
38 | for (RunningServiceInfo runningServiceInfo : runningServices) {
39 | ComponentName service = runningServiceInfo.service;
40 | if (className.equals(service.getClassName())) {
41 | return true;
42 | }
43 | }
44 | return false;
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/weight/numal/SelectTextView.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.weight.numal;
2 |
3 | import android.content.Context;
4 | import android.text.Selection;
5 | import android.text.Spannable;
6 | import android.util.AttributeSet;
7 | import android.view.MotionEvent;
8 | import android.widget.TextView;
9 |
10 | /**
11 | * Created by Mr.Yangxiufeng
12 | * DATE 2016/8/16
13 | * owspace 超字数显示的textview 点击显示/隐藏
14 | */
15 | public class SelectTextView extends TextView{
16 | public SelectTextView(Context context) {
17 | super(context);
18 | }
19 |
20 | public SelectTextView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public SelectTextView(Context context, AttributeSet attrs, int defStyleAttr) {
25 | super(context, attrs, defStyleAttr);
26 | }
27 | @Override
28 | public boolean dispatchTouchEvent(final MotionEvent event) {
29 | // FIXME simple workaround to https://code.google.com/p/android/issues/detail?id=191430
30 | int startSelection = getSelectionStart();
31 | int endSelection = getSelectionEnd();
32 | if (startSelection < 0 || endSelection < 0){
33 | Selection.setSelection((Spannable) getText(), getText().length());
34 | } else if (startSelection != endSelection) {
35 | if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
36 | final CharSequence text = getText();
37 | setText(null);
38 | setText(text);
39 | }
40 | }
41 | return super.dispatchTouchEvent(event);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/storage/StorageType.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.storage;
2 |
3 | public enum StorageType {
4 | TYPE_LOG(DirectoryName.LOG_DIRECTORY_NAME),
5 | TYPE_TEMP(DirectoryName.TEMP_DIRECTORY_NAME),
6 | TYPE_FILE(DirectoryName.FILE_DIRECTORY_NAME),
7 | TYPE_AUDIO(DirectoryName.AUDIO_DIRECTORY_NAME),
8 | TYPE_IMAGE(DirectoryName.IMAGE_DIRECTORY_NAME),
9 | TYPE_VIDEO(DirectoryName.VIDEO_DIRECTORY_NAME),
10 | TYPE_THUMB_IMAGE(DirectoryName.THUMB_DIRECTORY_NAME),
11 | TYPE_THUMB_VIDEO(DirectoryName.THUMB_DIRECTORY_NAME),
12 | ;
13 | private DirectoryName storageDirectoryName;
14 | private long storageMinSize;
15 |
16 | public String getStoragePath() {
17 | return storageDirectoryName.getPath();
18 | }
19 |
20 | public long getStorageMinSize() {
21 | return storageMinSize;
22 | }
23 |
24 | StorageType(DirectoryName dirName) {
25 | this(dirName, StorageUtil.THRESHOLD_MIN_SPCAE);
26 | }
27 |
28 | StorageType(DirectoryName dirName, long storageMinSize) {
29 | this.storageDirectoryName = dirName;
30 | this.storageMinSize = storageMinSize;
31 | }
32 |
33 | enum DirectoryName {
34 | AUDIO_DIRECTORY_NAME("audio/"),
35 | DATA_DIRECTORY_NAME("data/"),
36 | FILE_DIRECTORY_NAME("file/"),
37 | LOG_DIRECTORY_NAME("log/"),
38 | TEMP_DIRECTORY_NAME("temp/"),
39 | IMAGE_DIRECTORY_NAME("image/"),
40 | THUMB_DIRECTORY_NAME("thumb/"),
41 | VIDEO_DIRECTORY_NAME("video/"),
42 | ;
43 |
44 | private String path;
45 |
46 | public String getPath() {
47 | return path;
48 | }
49 |
50 | private DirectoryName(String path) {
51 | this.path = path;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/string/MD5.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.string;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.FileInputStream;
5 | import java.io.UnsupportedEncodingException;
6 | import java.security.MessageDigest;
7 |
8 | public class MD5 {
9 |
10 | public static String getStringMD5(String value) {
11 | if (value == null || value.trim().length() < 1) {
12 | return null;
13 | }
14 | try {
15 | return getMD5(value.getBytes("UTF-8"));
16 | } catch (UnsupportedEncodingException e) {
17 | throw new RuntimeException(e.getMessage(), e);
18 | }
19 | }
20 |
21 | public static String getMD5(byte[] source) {
22 | try {
23 | MessageDigest md5 = MessageDigest.getInstance("MD5");
24 | return HexDump.toHex(md5.digest(source));
25 | } catch (Exception e) {
26 | throw new RuntimeException(e.getMessage(), e);
27 | }
28 | }
29 | public static String getStreamMD5(String filePath) {
30 | String hash=null;
31 | byte[] buffer = new byte[4096];
32 | BufferedInputStream in=null;
33 | try
34 | {
35 | MessageDigest md5 = MessageDigest.getInstance("MD5");
36 | in = new BufferedInputStream(new FileInputStream(filePath));
37 | int numRead = 0;
38 | while ((numRead = in.read(buffer)) > 0) {
39 | md5.update(buffer, 0, numRead);
40 | }
41 | in.close();
42 | hash = HexDump.toHex(md5.digest());
43 | } catch (Exception e) {
44 | e.printStackTrace();
45 | } finally {
46 | if (in != null) {
47 | try {
48 | in.close();
49 | } catch (Exception ex) {
50 | ex.printStackTrace();
51 | }
52 | }
53 | }
54 | return hash;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/sys/SetTelCountTimer.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.sys;
2 |
3 |
4 | import android.os.CountDownTimer;
5 | import android.widget.Button;
6 |
7 | public class SetTelCountTimer extends CountDownTimer {
8 | public static final int TIME_COUNT = 61000;// 时间防止从100s开始显示(以倒计时120s为例子)
9 | private Button btn;
10 | private String endStrRid;
11 | /**
12 | * 参数 millisInFuture 倒计时总时间(如60S,120s等) 参数 countDownInterval 渐变时间(每次倒计1s)
13 | *
14 | * 参数 btn 点击的按钮(因为Button是Button子类,为了通用我的参数设置为Button)
15 | *
16 | * 参数 endStrRid 倒计时结束后,按钮对应显示的文字
17 | */
18 | public SetTelCountTimer(long millisInFuture, long countDownInterval,
19 | Button btn, String endStrRid) {
20 | super(millisInFuture, countDownInterval);
21 | this.btn = btn;
22 |
23 | this.endStrRid = endStrRid;
24 | }
25 |
26 | /**
27 | *
28 | * 参数上面有注释
29 | */
30 | public SetTelCountTimer(Button btn, String endStrRid) {
31 | super(TIME_COUNT, 1000);
32 | this.btn = btn;
33 | this.endStrRid = endStrRid;
34 | }
35 |
36 | public SetTelCountTimer(Button btn) {
37 | super(TIME_COUNT, 1000);
38 | this.btn = btn;
39 |
40 | this.endStrRid ="点击重新获取";
41 | }
42 |
43 | public SetTelCountTimer(Button tv_varify, int normalColor, int timingColor) {
44 | this(tv_varify);
45 |
46 | }
47 |
48 | // 计时完毕时触发
49 | @Override
50 | public void onFinish() {
51 |
52 | btn.setText(endStrRid);
53 | btn.setEnabled(true);
54 | }
55 |
56 | // 计时过程显示
57 | @Override
58 | public void onTick(long millisUntilFinished) {
59 |
60 | btn.setEnabled(false);
61 | btn.setText("剩余"+millisUntilFinished / 1000 + "秒");
62 | }
63 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/acache/UserUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.acache;
2 |
3 | import android.content.Context;
4 |
5 | import java.io.BufferedReader;
6 | import java.io.File;
7 | import java.io.FileInputStream;
8 | import java.io.FileOutputStream;
9 | import java.io.InputStreamReader;
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | public class UserUtils {
14 | // 保存用户信息的业务方法
15 | public static boolean saveInfo(Context context, String name,
16 | String word) {
17 | try {
18 | //得到nanme和word
19 | String result = name + "###" + word;
20 | //得到路徑
21 | String path = context.getFilesDir().getPath();
22 | //创建file对象
23 | File file = new File(path, "user.text");
24 | //获取文件输出流
25 | FileOutputStream fos = new FileOutputStream(file);
26 | //写入结果
27 | fos.write(result.getBytes());
28 | //关闭流
29 | fos.close();
30 | return true;
31 | } catch (Exception e) {
32 | e.printStackTrace();
33 | return false;
34 | }
35 | }
36 | //读取用户信息的方法
37 | public static Map readInfo(Context context){
38 | try{//创建map对象
39 | Map map = new HashMap();
40 | //获取文件路径
41 | String path = context.getFilesDir().getPath();
42 | //创建file对象
43 | File file = new File(path,"user.text");
44 | //创建输入流
45 | FileInputStream fis = new FileInputStream(file);
46 | //创建读取方法
47 | BufferedReader br = new BufferedReader(new InputStreamReader(fis));
48 | //获取读取的内容
49 | String line = br.readLine();
50 | String[] split = line.split("###");
51 | //获取name
52 | String name = split[0];
53 | //获取password
54 | String word = split[1];
55 | //把name和password存到map中
56 | map.put("name", name);
57 | map.put("word", word);
58 | //返回map
59 | return map;
60 | }catch(Exception e){
61 | e.printStackTrace();
62 | return null;
63 | }
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/weight/webView/ScrollWebView.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.weight.webView;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.webkit.WebView;
7 |
8 | /**
9 | * 项目名称:QianShan
10 | * 类描述:ScrollWebView 可滑动的webview
11 | * 创建人:slj
12 | * 创建时间:2016-8-22 11:58
13 | * 修改人:slj
14 | * 修改时间:2016-8-22 11:58
15 | * 修改备注:
16 | * 邮箱:slj@bjlingzhuo.com
17 | */
18 | public class ScrollWebView extends WebView {
19 | public OnScrollChangeListener listener;
20 |
21 | public ScrollWebView(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | }
24 |
25 | public ScrollWebView(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public ScrollWebView(Context context) {
30 | super(context);
31 | }
32 |
33 | @Override
34 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
35 |
36 | super.onScrollChanged(l, t, oldl, oldt);
37 |
38 | float webcontent = getContentHeight() * getScale();// webview的高度
39 | float webnow = getHeight() + getScrollY();// 当前webview的高度
40 | Log.i("TAG1", "webview.getScrollY()====>>" + getScrollY());
41 | if (Math.abs(webcontent - webnow) < 1) {
42 | // 已经处于底端
43 | listener.onPageEnd(l, t, oldl, oldt);
44 | } else if (getScrollY() == 0) {
45 | // 已经处于顶端
46 | listener.onPageTop(l, t, oldl, oldt);
47 | } else {
48 | listener.onScrollChanged(l, t, oldl, oldt);
49 | }
50 |
51 | }
52 |
53 | public void setOnScrollChangeListener(OnScrollChangeListener listener) {
54 |
55 | this.listener = listener;
56 |
57 | }
58 |
59 | public interface OnScrollChangeListener {
60 | public void onPageEnd(int l, int t, int oldl, int oldt);
61 | public void onPageTop(int l, int t, int oldl, int oldt);
62 | public void onScrollChanged(int l, int t, int oldl, int oldt);
63 |
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/media/DrawableUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.media;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.drawable.BitmapDrawable;
5 | import android.graphics.drawable.Drawable;
6 | import android.graphics.drawable.GradientDrawable;
7 | import android.graphics.drawable.StateListDrawable;
8 | import android.os.Build;
9 |
10 | public class DrawableUtils {
11 |
12 | /**
13 | * 创建一个图片
14 | * @param contentColor 内部填充颜色
15 | * @param strokeColor 描边颜色
16 | * @param radius 圆角
17 | */
18 | public static GradientDrawable createDrawable(int contentColor, int strokeColor, int radius) {
19 | GradientDrawable drawable = new GradientDrawable(); // 生成Shape
20 | drawable.setGradientType(GradientDrawable.RECTANGLE); // 设置矩形
21 | drawable.setColor(contentColor);// 内容区域的颜色
22 | drawable.setStroke(1, strokeColor); // 四周描边,描边后四角真正为圆角,不会出现黑色阴影。如果父窗体是可以滑动的,需要把父View设置setScrollCache(false)
23 | drawable.setCornerRadius(radius); // 设置四角都为圆角
24 | return drawable;
25 | }
26 |
27 | /**
28 | * 创建一个图片选择器
29 | * @param normalState 普通状态的图片
30 | * @param pressedState 按压状态的图片
31 | */
32 | public static StateListDrawable createSelector(Drawable normalState, Drawable pressedState) {
33 | StateListDrawable bg = new StateListDrawable();
34 | bg.addState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled}, pressedState);
35 | bg.addState(new int[]{android.R.attr.state_enabled}, normalState);
36 | bg.addState(new int[]{}, normalState);
37 | return bg;
38 | }
39 |
40 | /** 获取图片的大小 */
41 | public static int getDrawableSize(Drawable drawable) {
42 | if (drawable == null) {
43 | return 0;
44 | }
45 | Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
46 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
47 | return bitmap.getByteCount();
48 | } else {
49 | return bitmap.getRowBytes() * bitmap.getHeight();
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/media/GildeTools/GlideCircleTransform.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.media.GildeTools;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapShader;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 |
9 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
10 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
11 |
12 | /**
13 | * Glide下载圆形图片的方法
14 | */
15 | public class GlideCircleTransform extends BitmapTransformation {
16 | public GlideCircleTransform(Context context) {
17 | super(context);
18 | }
19 |
20 | @Override
21 | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
22 | return circleCrop(pool, toTransform);
23 | }
24 |
25 | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
26 | if (source == null) return null;
27 |
28 | int size = Math.min(source.getWidth(), source.getHeight());
29 | int x = (source.getWidth() - size) / 2;
30 | int y = (source.getHeight() - size) / 2;
31 |
32 | // TODO this could be acquired from the pool too
33 | Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
34 |
35 | Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
36 | if (result == null) {
37 | result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
38 | }
39 |
40 | Canvas canvas = new Canvas(result);
41 | Paint paint = new Paint();
42 | paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
43 | paint.setAntiAlias(true);
44 | float r = size / 2f;
45 | canvas.drawCircle(r, r, r, paint);
46 | return result;
47 | }
48 |
49 | @Override
50 | public String getId() {
51 | return getClass().getName();
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/request/volley/GsonRequest.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.request.volley;
2 |
3 | import com.android.volley.NetworkResponse;
4 | import com.android.volley.ParseError;
5 | import com.android.volley.Request;
6 | import com.android.volley.Response;
7 | import com.android.volley.toolbox.HttpHeaderParser;
8 | import com.google.gson.Gson;
9 |
10 | import java.io.UnsupportedEncodingException;
11 |
12 | /**
13 | * Gson方式请求类
14 | * @param
15 | */
16 | public class GsonRequest extends Request {
17 |
18 | private final Response.Listener mListener;
19 |
20 | private Gson mGson;
21 |
22 | private Class mClass;
23 |
24 | public GsonRequest(int method, String url, Class clazz, Response.Listener listener,
25 | Response.ErrorListener errorListener) {
26 | super(method, url, errorListener);
27 | mGson = new Gson();
28 | mClass = clazz;
29 | mListener = listener;
30 | }
31 |
32 | @Override
33 | public String getBodyContentType() {
34 | return super.getBodyContentType();
35 | }
36 |
37 | public GsonRequest(String url, Class clazz, Response.Listener listener,
38 | Response.ErrorListener errorListener) {
39 | this(Method.GET, url, clazz, listener, errorListener);
40 | }
41 |
42 | @Override
43 | protected Response parseNetworkResponse(NetworkResponse response) {
44 | try {
45 | String jsonString = new String(response.data,
46 | HttpHeaderParser.parseCharset(response.headers));
47 | return Response.success(mGson.fromJson(jsonString, mClass),
48 | HttpHeaderParser.parseCacheHeaders(response));
49 | } catch (UnsupportedEncodingException e) {
50 | return Response.error(new ParseError(e));
51 | }
52 | }
53 |
54 | @Override
55 | protected void deliverResponse(T response) {
56 | mListener.onResponse(response);
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/view/ViewFindUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.view;
2 |
3 | import android.util.SparseArray;
4 | import android.view.View;
5 |
6 | @SuppressWarnings({"unchecked"})
7 | public class ViewFindUtils {
8 | /**
9 | * ViewHolder简洁写法,避免适配器中重复定义ViewHolder,减少代码量 用法:
10 | *
11 | *
12 | * if (convertView == null)
13 | * {
14 | * convertView = View.inflate(context, R.layout.ad_demo, null);
15 | * }
16 | * TextView tv_demo = ViewHolderUtils.get(convertView, R.id.tv_demo);
17 | * ImageView iv_demo = ViewHolderUtils.get(convertView, R.id.iv_demo);
18 | *
19 | */
20 | public static T hold(View view, int id) {
21 | SparseArray viewHolder = (SparseArray) view.getTag();
22 | if (viewHolder == null) {
23 | viewHolder = new SparseArray();
24 | view.setTag(viewHolder);
25 | }
26 | View childView = viewHolder.get(id);
27 | if (childView == null) {
28 | childView = view.findViewById(id);
29 | viewHolder.put(id, childView);
30 | }
31 | return (T) childView;
32 | }
33 | /**
34 | * 替换holder里面的onClick方法
35 | * @param view
36 | * @param listener
37 | * @param ids
38 | */
39 | public static void setOnHolderViewClickListener(View view, View.OnClickListener listener,int... ids){
40 | for (int id: ids) {
41 | hold(view,id).setOnClickListener(listener);
42 | }
43 | }
44 | /**
45 | * 替代findviewById方法
46 | */
47 | public static T find(View view, int id) {
48 | return (T) view.findViewById(id);
49 | }
50 |
51 | /**
52 | * 替换setonClick方法
53 | * @param view
54 | * @param listener
55 | * @param ids
56 | */
57 | public static void setOnClickListener(View view, View.OnClickListener listener,int... ids){
58 | for (int id: ids) {
59 | find(view,id).setOnClickListener(listener);
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/log/LogUtil.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.log;
2 |
3 | public class LogUtil {
4 | public static final void init(String logFile, int level) {
5 | LogImpl.init(logFile, level);
6 | }
7 |
8 | public static final void v(String tag, String msg) {
9 | LogImpl.v(tag, buildMessage(msg));
10 | }
11 |
12 | public static final void v(String tag, String msg, Throwable thr) {
13 | LogImpl.v(tag, buildMessage(msg), thr);
14 | }
15 |
16 | public static final void d(String tag, String msg) {
17 | LogImpl.d(tag, buildMessage(msg));
18 | }
19 |
20 | public static final void d(String tag, String msg, Throwable thr) {
21 | LogImpl.d(tag, buildMessage(msg), thr);
22 | }
23 |
24 | public static final void i(String tag, String msg) {
25 | LogImpl.i(tag, buildMessage(msg));
26 | }
27 |
28 | public static final void i(String tag, String msg, Throwable thr) {
29 | LogImpl.i(tag, buildMessage(msg), thr);
30 | }
31 |
32 | public static final void w(String tag, String msg) {
33 | LogImpl.w(tag, buildMessage(msg));
34 | }
35 |
36 | public static final void w(String tag, String msg, Throwable thr) {
37 | LogImpl.w(tag, buildMessage(msg), thr);
38 | }
39 |
40 | public static final void w(String tag, Throwable thr) {
41 | LogImpl.w(tag, buildMessage(""), thr);
42 | }
43 |
44 | public static final void e(String tag, String msg) {
45 | LogImpl.e(tag, buildMessage(msg));
46 | }
47 |
48 | public static final void e(String tag, String msg, Throwable thr) {
49 | LogImpl.e(tag, buildMessage(msg), thr);
50 | }
51 |
52 | public static final void ui(String msg) {
53 | LogImpl.i("ui", buildMessage(msg));
54 | }
55 |
56 | public static final void res(String msg) {
57 | LogImpl.i("RES", buildMessage(msg));
58 | }
59 |
60 | public static final void audio(String msg) {
61 | LogImpl.i("AudioRecorder", buildMessage(msg));
62 | }
63 |
64 | public static String getLogFileName(String cat) {
65 | return LogImpl.getLogFileName(cat);
66 | }
67 |
68 | private static String buildMessage(String msg) {
69 | return msg;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/media/GildeTools/GlideRoundTransform.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.media.GildeTools;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapShader;
7 | import android.graphics.Canvas;
8 | import android.graphics.Paint;
9 | import android.graphics.RectF;
10 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
11 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
12 |
13 | /**
14 | * Gilde下载转换圆角的方法 默认圆角为4dp 可自定义圆角dp
15 | */
16 | public class GlideRoundTransform extends BitmapTransformation {
17 |
18 | private static float radius = 0f;
19 |
20 | public GlideRoundTransform(Context context) {
21 | this(context, 4);
22 | }
23 |
24 | public GlideRoundTransform(Context context, int dp) {
25 | super(context);
26 | radius = Resources.getSystem().getDisplayMetrics().density * dp;
27 | }
28 |
29 | @Override
30 | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
31 | return roundCrop(pool, toTransform);
32 | }
33 |
34 | private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
35 | if (source == null) return null;
36 |
37 | Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
38 | if (result == null) {
39 | result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
40 | }
41 |
42 | Canvas canvas = new Canvas(result);
43 | Paint paint = new Paint();
44 | paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
45 | paint.setAntiAlias(true);
46 | RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
47 | canvas.drawRoundRect(rectF, radius, radius, paint);
48 | return result;
49 | }
50 |
51 | @Override
52 | public String getId() {
53 | return getClass().getName() + Math.round(radius);
54 | }
55 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/user/utils/weight/animator/AnimatorValueImplements.java:
--------------------------------------------------------------------------------
1 | package com.example.user.utils.weight.animator;
2 |
3 | import android.view.View;
4 | import com.nineoldandroids.animation.ObjectAnimator;
5 | import com.nineoldandroids.animation.TypeEvaluator;
6 |
7 | public class AnimatorValueImplements implements AnimatorValue{
8 |
9 | private ObjectAnimator objectAnimator;
10 | private AnimatorValue beforeAnimatorValue;
11 |
12 | public AnimatorValueImplements(View view, String proName, int... values){
13 | createProNameInt(view, proName,values);
14 | }
15 |
16 | public AnimatorValueImplements(View view, String proName, float... values){
17 | createProNameFloat(view, proName,values);
18 | }
19 |
20 | public AnimatorValueImplements(Object object, TypeEvaluator