infos = pm.queryIntentActivities(intent, 0);
78 | for (ResolveInfo info : infos) {
79 | if (info.activityInfo.packageName.equals(packageName)) {
80 | return info.activityInfo.name;
81 | }
82 | }
83 | return "no " + packageName;
84 | }
85 |
86 |
87 | /**
88 | * 获取栈顶Activity
89 | *
90 | * @return 栈顶Activity
91 | */
92 | public static Activity getTopActivity() {
93 | try {
94 | Class activityThreadClass = Class.forName("android.app.ActivityThread");
95 | Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
96 | Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
97 | activitiesField.setAccessible(true);
98 | Map activities = null;
99 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
100 | activities = (HashMap) activitiesField.get(activityThread);
101 | } else {
102 | activities = (ArrayMap) activitiesField.get(activityThread);
103 | }
104 | for (Object activityRecord : activities.values()) {
105 | Class activityRecordClass = activityRecord.getClass();
106 | Field pausedField = activityRecordClass.getDeclaredField("paused");
107 | pausedField.setAccessible(true);
108 | if (!pausedField.getBoolean(activityRecord)) {
109 | Field activityField = activityRecordClass.getDeclaredField("activity");
110 | activityField.setAccessible(true);
111 | return (Activity) activityField.get(activityRecord);
112 | }
113 | }
114 | } catch (Exception e) {
115 | e.printStackTrace();
116 | }
117 | return null;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/utils/CleanUtils.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.utils;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | *
7 | * author: Blankj
8 | * blog : http://blankj.com
9 | * time : 2016/9/27
10 | * desc : 清除相关工具类
11 | *
12 | */
13 | public final class CleanUtils {
14 |
15 | private CleanUtils() {
16 | throw new UnsupportedOperationException("u can't instantiate me...");
17 | }
18 |
19 | /**
20 | * 清除内部缓存
21 | * /data/data/com.xxx.xxx/cache
22 | *
23 | * @return {@code true}: 清除成功
{@code false}: 清除失败
24 | */
25 | public static boolean cleanInternalCache() {
26 | return FileUtils.deleteFilesInDir(Utils.getContext().getCacheDir());
27 | }
28 |
29 | /**
30 | * 清除内部文件
31 | * /data/data/com.xxx.xxx/files
32 | *
33 | * @return {@code true}: 清除成功
{@code false}: 清除失败
34 | */
35 | public static boolean cleanInternalFiles() {
36 | return FileUtils.deleteFilesInDir(Utils.getContext().getFilesDir());
37 | }
38 |
39 | /**
40 | * 清除内部数据库
41 | * /data/data/com.xxx.xxx/databases
42 | *
43 | * @return {@code true}: 清除成功
{@code false}: 清除失败
44 | */
45 | public static boolean cleanInternalDbs() {
46 | return FileUtils.deleteFilesInDir(Utils.getContext().getFilesDir().getParent() + File.separator + "databases");
47 | }
48 |
49 | /**
50 | * 根据名称清除数据库
51 | * /data/data/com.xxx.xxx/databases/dbName
52 | *
53 | * @param dbName 数据库名称
54 | * @return {@code true}: 清除成功
{@code false}: 清除失败
55 | */
56 | public static boolean cleanInternalDbByName( String dbName) {
57 | return Utils.getContext().deleteDatabase(dbName);
58 | }
59 |
60 | /**
61 | * 清除内部SP
62 | * /data/data/com.xxx.xxx/shared_prefs
63 | *
64 | * @return {@code true}: 清除成功
{@code false}: 清除失败
65 | */
66 | public static boolean cleanInternalSP() {
67 | return FileUtils.deleteFilesInDir(Utils.getContext().getFilesDir().getParent() + File.separator + "shared_prefs");
68 | }
69 |
70 | /**
71 | * 清除外部缓存
72 | * /storage/emulated/0/android/data/com.xxx.xxx/cache
73 | *
74 | * @return {@code true}: 清除成功
{@code false}: 清除失败
75 | */
76 | public static boolean cleanExternalCache() {
77 | return SDCardUtils.isSDCardEnable() && FileUtils.deleteFilesInDir(Utils.getContext().getExternalCacheDir());
78 | }
79 |
80 | /**
81 | * 清除自定义目录下的文件
82 | *
83 | * @param dirPath 目录路径
84 | * @return {@code true}: 清除成功
{@code false}: 清除失败
85 | */
86 | public static boolean cleanCustomCache(String dirPath) {
87 | return FileUtils.deleteFilesInDir(dirPath);
88 | }
89 |
90 | /**
91 | * 清除自定义目录下的文件
92 | *
93 | * @param dir 目录
94 | * @return {@code true}: 清除成功
{@code false}: 清除失败
95 | */
96 | public static boolean cleanCustomCache(File dir) {
97 | return FileUtils.deleteFilesInDir(dir);
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/utils/CloseUtils.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.utils;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | /**
7 | *
8 | * author: Blankj
9 | * blog : http://blankj.com
10 | * time : 2016/10/9
11 | * desc : 关闭相关工具类
12 | *
13 | */
14 | public final class CloseUtils {
15 |
16 | private CloseUtils() {
17 | throw new UnsupportedOperationException("u can't instantiate me...");
18 | }
19 |
20 | /**
21 | * 关闭IO
22 | *
23 | * @param closeables closeables
24 | */
25 | public static void closeIO(Closeable... closeables) {
26 | if (closeables == null) return;
27 | for (Closeable closeable : closeables) {
28 | if (closeable != null) {
29 | try {
30 | closeable.close();
31 | } catch (IOException e) {
32 | e.printStackTrace();
33 | }
34 | }
35 | }
36 | }
37 |
38 | /**
39 | * 安静关闭IO
40 | *
41 | * @param closeables closeables
42 | */
43 | public static void closeIOQuietly(Closeable... closeables) {
44 | if (closeables == null) return;
45 | for (Closeable closeable : closeables) {
46 | if (closeable != null) {
47 | try {
48 | closeable.close();
49 | } catch (IOException ignored) {
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/utils/EmptyUtils.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.utils;
2 |
3 | import android.os.Build;
4 | import android.util.SparseArray;
5 | import android.util.SparseBooleanArray;
6 | import android.util.SparseIntArray;
7 | import android.util.SparseLongArray;
8 |
9 | import java.lang.reflect.Array;
10 | import java.util.Collection;
11 | import java.util.Map;
12 |
13 | /**
14 | *
15 | * author: Blankj
16 | * blog : http://blankj.com
17 | * time : 2016/9/28
18 | * desc : 判空相关工具类
19 | *
20 | */
21 | public final class EmptyUtils {
22 |
23 | private EmptyUtils() {
24 | throw new UnsupportedOperationException("u can't instantiate me...");
25 | }
26 |
27 | /**
28 | * 判断对象是否为空
29 | *
30 | * @param obj 对象
31 | * @return {@code true}: 为空
{@code false}: 不为空
32 | */
33 | public static boolean isEmpty(Object obj) {
34 | if (obj == null) {
35 | return true;
36 | }
37 | if (obj instanceof String && obj.toString().length() == 0) {
38 | return true;
39 | }
40 | if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
41 | return true;
42 | }
43 | if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
44 | return true;
45 | }
46 | if (obj instanceof Map && ((Map) obj).isEmpty()) {
47 | return true;
48 | }
49 | if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
50 | return true;
51 | }
52 | if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
53 | return true;
54 | }
55 | if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
56 | return true;
57 | }
58 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
59 | if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
60 | return true;
61 | }
62 | }
63 | return false;
64 | }
65 |
66 | /**
67 | * 判断对象是否非空
68 | *
69 | * @param obj 对象
70 | * @return {@code true}: 非空
{@code false}: 空
71 | */
72 | public static boolean isNotEmpty(Object obj) {
73 | return !isEmpty(obj);
74 | }
75 | }
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/utils/KeyboardUtils.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.view.inputmethod.InputMethodManager;
8 | import android.widget.EditText;
9 |
10 | /**
11 | *
12 | * author: Blankj
13 | * blog : http://blankj.com
14 | * time : 2016/8/2
15 | * desc : 键盘相关工具类
16 | *
17 | */
18 | public final class KeyboardUtils {
19 |
20 | private KeyboardUtils() {
21 | throw new UnsupportedOperationException("u can't instantiate me...");
22 | }
23 |
24 | /**
25 | * 避免输入法面板遮挡
26 | * 在manifest.xml中activity中设置
27 | * android:windowSoftInputMode="adjustPan"
28 | */
29 |
30 | /**
31 | * 动态隐藏软键盘
32 | *
33 | * @param activity activity
34 | */
35 | public static void hideSoftInput(Activity activity) {
36 | View view = activity.getCurrentFocus();
37 | if (view == null) view = new View(activity);
38 | InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
39 | if (imm == null) return;
40 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
41 | }
42 |
43 | /**
44 | * 动态隐藏软键盘
45 | *
46 | * @param context 上下文
47 | * @param view 视图
48 | */
49 | public static void hideSoftInput(Context context, View view) {
50 | InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
51 | if (imm == null) return;
52 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
53 | }
54 |
55 | /**
56 | * 点击屏幕空白区域隐藏软键盘
57 | * 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
58 | * 需重写dispatchTouchEvent
59 | * 参照以下注释代码
60 | */
61 | public static void clickBlankArea2HideSoftInput() {
62 | Log.d("tips", "U should copy the following code.");
63 | /*
64 | @Override
65 | public boolean dispatchTouchEvent(MotionEvent ev) {
66 | if (ev.getAction() == MotionEvent.ACTION_DOWN) {
67 | View v = getCurrentFocus();
68 | if (isShouldHideKeyboard(v, ev)) {
69 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
70 | imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
71 | }
72 | }
73 | return super.dispatchTouchEvent(ev);
74 | }
75 |
76 | // 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
77 | private boolean isShouldHideKeyboard(View v, MotionEvent event) {
78 | if (v != null && (v instanceof EditText)) {
79 | int[] l = {0, 0};
80 | v.getLocationInWindow(l);
81 | int left = l[0],
82 | top = l[1],
83 | bottom = top + v.getHeight(),
84 | right = left + v.getWidth();
85 | return !(event.getX() > left && event.getX() < right
86 | && event.getY() > top && event.getY() < bottom);
87 | }
88 | return false;
89 | }
90 | */
91 | }
92 |
93 | /**
94 | * 动态显示软键盘
95 | *
96 | * @param edit 输入框
97 | */
98 | public static void showSoftInput(EditText edit) {
99 | edit.setFocusable(true);
100 | edit.setFocusableInTouchMode(true);
101 | edit.requestFocus();
102 | InputMethodManager imm = (InputMethodManager) Utils.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
103 | if (imm == null) return;
104 | imm.showSoftInput(edit, 0);
105 | }
106 |
107 | /**
108 | * 切换键盘显示与否状态
109 | */
110 | public static void toggleSoftInput() {
111 | InputMethodManager imm = (InputMethodManager) Utils.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
112 | if (imm == null) return;
113 | imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
114 | }
115 | }
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.utils;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | *
7 | * author: Blankj
8 | * blog : http://blankj.com
9 | * time : 16/12/08
10 | * desc : Utils初始化相关
11 | *
12 | */
13 | public final class Utils {
14 |
15 | private static Context context;
16 | private static SPUtils spUtils;
17 |
18 | private Utils() {
19 | throw new UnsupportedOperationException("u can't instantiate me...");
20 | }
21 |
22 | /**
23 | * 初始化工具类
24 | *
25 | * @param context 上下文
26 | */
27 | public static void init(Context context) {
28 | Utils.context = context.getApplicationContext();
29 | spUtils = new SPUtils("utilcode");
30 | }
31 |
32 | /**
33 | * 获取ApplicationContext
34 | *
35 | * @return ApplicationContext
36 | */
37 | public static Context getContext() {
38 | if (context != null) return context;
39 | throw new NullPointerException("u should init first");
40 | }
41 |
42 | public static SPUtils getSpUtils() {
43 | return spUtils;
44 | }
45 | }
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/ClickImageView.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.ColorMatrix;
5 | import android.graphics.ColorMatrixColorFilter;
6 | import android.support.v7.widget.AppCompatImageView;
7 | import android.util.AttributeSet;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 |
11 | public class ClickImageView extends AppCompatImageView {
12 |
13 | public ClickImageView(Context context, AttributeSet attrs, int defStyleAttr) {
14 | super(context, attrs, defStyleAttr);
15 | init();
16 | }
17 |
18 | public ClickImageView(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | init();
21 | }
22 |
23 | public ClickImageView(Context context) {
24 | super(context);
25 | init();
26 | }
27 |
28 | private void init() {
29 | setOnTouchListener(onTouchListener);
30 | }
31 |
32 | private OnTouchListener onTouchListener = new OnTouchListener() {
33 | @Override
34 | public boolean onTouch(View v, MotionEvent event) {
35 | switch (event.getAction()) {
36 | case MotionEvent.ACTION_UP:
37 | setColorFilter(null);
38 | break;
39 | case MotionEvent.ACTION_DOWN:
40 | changeLight();
41 | break;
42 | case MotionEvent.ACTION_MOVE:
43 | break;
44 | case MotionEvent.ACTION_CANCEL:
45 | setColorFilter(null);
46 | break;
47 | default:
48 | break;
49 | }
50 | return false;
51 | }
52 | };
53 |
54 | private void changeLight() {
55 | int brightness = -80;
56 | ColorMatrix matrix = new ColorMatrix();
57 | matrix.set(new float[]{1, 0, 0, 0, brightness, 0, 1, 0, 0,
58 | brightness, 0, 0, 1, 0, brightness, 0, 0, 0, 1, 0});
59 | setColorFilter(new ColorMatrixColorFilter(matrix));
60 | }
61 | }
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/CustomLoadMoreView.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget;
2 |
3 |
4 | import com.chad.library.adapter.base.loadmore.LoadMoreView;
5 | import com.hankkin.xlibrary.R;
6 |
7 | /**
8 | * Created by BlingBling on 2016/10/15.
9 | */
10 |
11 | public final class CustomLoadMoreView extends LoadMoreView {
12 |
13 | @Override public int getLayoutId() {
14 | return R.layout.view_load_more;
15 | }
16 |
17 | @Override protected int getLoadingViewId() {
18 | return R.id.load_more_loading_view;
19 | }
20 |
21 | @Override protected int getLoadFailViewId() {
22 | return R.id.load_more_load_fail_view;
23 | }
24 |
25 | @Override protected int getLoadEndViewId() {
26 | return R.id.load_more_load_end_view;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/CustomView.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.util.AttributeSet;
6 | import android.widget.RelativeLayout;
7 |
8 | public class CustomView extends RelativeLayout {
9 |
10 | final int disabledBackgroundColor = Color.parseColor("#E2E2E2");
11 | int beforeBackground;
12 |
13 | public CustomView(Context context, AttributeSet attrs) {
14 | super(context, attrs);
15 | }
16 |
17 | @Override
18 | public void setEnabled(boolean enabled) {
19 | super.setEnabled(enabled);
20 | if (enabled)
21 | setBackgroundColor(beforeBackground);
22 | else
23 | setBackgroundColor(disabledBackgroundColor);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/ProgressBar.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.PorterDuff;
9 | import android.graphics.PorterDuffXfermode;
10 | import android.graphics.RectF;
11 | import android.util.AttributeSet;
12 |
13 | import com.hankkin.xlibrary.utils.SizeUtils;
14 |
15 |
16 | public class ProgressBar extends CustomView {
17 |
18 | final static String ANDROIDXML = "http://schemas.android.com/apk/res/android";
19 |
20 | int backgroundColor = Color.parseColor("#1E88E5");
21 |
22 | public ProgressBar(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | setAttributes(attrs);
25 |
26 | }
27 |
28 | protected void setAttributes(AttributeSet attrs) {
29 |
30 | setMinimumHeight(SizeUtils.dp2px(32));
31 | setMinimumWidth(SizeUtils.dp2px(32));
32 |
33 | int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,
34 | "background", -1);
35 | if (bacgroundColor != -1) {
36 | setBackgroundColor(getResources().getColor(bacgroundColor));
37 | } else {
38 | int background = attrs.getAttributeIntValue(ANDROIDXML,
39 | "background", -1);
40 | if (background != -1)
41 | setBackgroundColor(background);
42 | else
43 | setBackgroundColor(Color.parseColor("#1E88E5"));
44 | }
45 |
46 | setMinimumHeight(SizeUtils.dp2px(3));
47 |
48 | }
49 |
50 | protected int makePressColor() {
51 | int r = (this.backgroundColor >> 16) & 0xFF;
52 | int g = (this.backgroundColor >> 8) & 0xFF;
53 | int b = (this.backgroundColor >> 0) & 0xFF;
54 | return Color.argb(128, r, g, b);
55 | }
56 |
57 | @Override
58 | protected void onDraw(Canvas canvas) {
59 | super.onDraw(canvas);
60 | drawAnimation(canvas);
61 | invalidate();
62 |
63 | }
64 |
65 | int arcD = 1;
66 | int arcO = 0;
67 | float rotateAngle = 0;
68 | int limite = 0;
69 |
70 | private void drawAnimation(Canvas canvas) {
71 | if (arcO == limite)
72 | arcD += 6;
73 | if (arcD >= 290 || arcO > limite) {
74 | arcO += 6;
75 | arcD -= 6;
76 | }
77 | if (arcO > limite + 290) {
78 | limite = arcO;
79 | arcO = limite;
80 | arcD = 1;
81 | }
82 | rotateAngle += 4;
83 | canvas.rotate(rotateAngle, getWidth() / 2, getHeight() / 2);
84 |
85 | Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(),
86 | canvas.getHeight(), Bitmap.Config.ARGB_8888);
87 | Canvas temp = new Canvas(bitmap);
88 | Paint paint = new Paint();
89 | paint.setAntiAlias(true);
90 | paint.setColor(backgroundColor);
91 | temp.drawArc(new RectF(0, 0, getWidth(), getHeight()), arcO, arcD,
92 | true, paint);
93 | Paint transparentPaint = new Paint();
94 | transparentPaint.setAntiAlias(true);
95 | transparentPaint.setColor(getResources().getColor(
96 | android.R.color.transparent));
97 | transparentPaint.setXfermode(new PorterDuffXfermode(
98 | PorterDuff.Mode.CLEAR));
99 | temp.drawCircle(getWidth() / 2, getHeight() / 2, (getWidth() / 2)
100 | - SizeUtils.dp2px(4), transparentPaint);
101 |
102 | canvas.drawBitmap(bitmap, 0, 0, new Paint());
103 | }
104 |
105 | public void setBackgroundColor(int color) {
106 | super.setBackgroundColor(getResources().getColor(
107 | android.R.color.transparent));
108 | if (isEnabled())
109 | beforeBackground = backgroundColor;
110 | this.backgroundColor = color;
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/ProgressDialog.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.view.Window;
6 |
7 | import com.hankkin.xlibrary.R;
8 |
9 | import butterknife.ButterKnife;
10 |
11 |
12 | /**
13 | * Created by Hankkin on 16/4/8.
14 | */
15 | public class ProgressDialog extends Dialog {
16 | private Context context;
17 |
18 |
19 |
20 | public ProgressDialog(Context context) {
21 | super(context, R.style.progress);
22 | this.context = context;
23 | init();
24 | }
25 |
26 | private void init(){
27 | requestWindowFeature(Window.FEATURE_NO_TITLE);
28 | setContentView(R.layout.dialog_progress);
29 | ButterKnife.bind(this);
30 |
31 | //设置SelectPicPopupWindow弹出窗体的背景
32 | getWindow().setBackgroundDrawableResource(R.color.transparent);
33 | }
34 |
35 |
36 | @Override
37 | public void onBackPressed() {
38 | dismiss();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/HLoading.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.support.annotation.NonNull;
6 | import android.view.Window;
7 |
8 | import com.hankkin.xlibrary.R;
9 |
10 | import butterknife.ButterKnife;
11 |
12 | /**
13 | * Created by hankkin on 2017/9/30.
14 | * Blog: http://hankkin.cn
15 | * Mail: 1019283569@qq.com
16 | */
17 |
18 | public class HLoading extends Dialog {
19 |
20 |
21 | private Context context;
22 | AVLoadingIndicatorView avi;
23 | private int color;
24 |
25 | public HLoading(@NonNull Context context,int color) {
26 | super(context, R.style.progress);
27 | this.context = context;
28 | this.color = color;
29 | init();
30 | }
31 |
32 | private void init(){
33 | requestWindowFeature(Window.FEATURE_NO_TITLE);
34 | setContentView(R.layout.dialog_hloading);
35 | ButterKnife.bind(this);
36 |
37 | avi = (AVLoadingIndicatorView) findViewById(R.id.avi);
38 | //设置SelectPicPopupWindow弹出窗体的背景
39 | getWindow().setBackgroundDrawableResource(R.color.transparent);
40 | avi.setIndicatorColor(color);
41 |
42 | avi.setIndicator("BallSpinFadeLoaderIndicator");
43 | }
44 |
45 |
46 | @Override
47 | public void onBackPressed() {
48 | dismiss();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallBeatIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.hankkin.xlibrary.widget.view.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/19.
13 | */
14 | public class BallBeatIndicator extends Indicator {
15 |
16 | public static final float SCALE=1.0f;
17 |
18 | public static final int ALPHA=255;
19 |
20 | private float[] scaleFloats=new float[]{SCALE,
21 | SCALE,
22 | SCALE};
23 |
24 | int[] alphas=new int[]{ALPHA,
25 | ALPHA,
26 | ALPHA,};
27 |
28 | @Override
29 | public void draw(Canvas canvas, Paint paint) {
30 | float circleSpacing=4;
31 | float radius=(getWidth()-circleSpacing*2)/6;
32 | float x = getWidth()/ 2-(radius*2+circleSpacing);
33 | float y=getHeight() / 2;
34 | for (int i = 0; i < 3; i++) {
35 | canvas.save();
36 | float translateX=x+(radius*2)*i+circleSpacing*i;
37 | canvas.translate(translateX, y);
38 | canvas.scale(scaleFloats[i], scaleFloats[i]);
39 | paint.setAlpha(alphas[i]);
40 | canvas.drawCircle(0, 0, radius, paint);
41 | canvas.restore();
42 | }
43 | }
44 |
45 | @Override
46 | public ArrayList onCreateAnimators() {
47 | ArrayList animators=new ArrayList<>();
48 | int[] delays=new int[]{350,0,350};
49 | for (int i = 0; i < 3; i++) {
50 | final int index=i;
51 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.75f,1);
52 | scaleAnim.setDuration(700);
53 | scaleAnim.setRepeatCount(-1);
54 | scaleAnim.setStartDelay(delays[i]);
55 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
56 | @Override
57 | public void onAnimationUpdate(ValueAnimator animation) {
58 | scaleFloats[index] = (float) animation.getAnimatedValue();
59 | postInvalidate();
60 | }
61 | });
62 |
63 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255,51,255);
64 | alphaAnim.setDuration(700);
65 | alphaAnim.setRepeatCount(-1);
66 | alphaAnim.setStartDelay(delays[i]);
67 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
68 | @Override
69 | public void onAnimationUpdate(ValueAnimator animation) {
70 | alphas[index] = (int) animation.getAnimatedValue();
71 | postInvalidate();
72 | }
73 | });
74 | animators.add(scaleAnim);
75 | animators.add(alphaAnim);
76 | }
77 | return animators;
78 | }
79 |
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallClipRotateIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/16.
14 | */
15 | public class BallClipRotateIndicator extends Indicator {
16 |
17 | float scaleFloat=1,degrees;
18 |
19 | @Override
20 | public void draw(Canvas canvas, Paint paint) {
21 | paint.setStyle(Paint.Style.STROKE);
22 | paint.setStrokeWidth(3);
23 |
24 | float circleSpacing=12;
25 | float x = (getWidth()) / 2;
26 | float y=(getHeight()) / 2;
27 | canvas.translate(x, y);
28 | canvas.scale(scaleFloat, scaleFloat);
29 | canvas.rotate(degrees);
30 | RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,0+x-circleSpacing,0+y-circleSpacing);
31 | canvas.drawArc(rectF, -45, 270, false, paint);
32 | }
33 |
34 | @Override
35 | public ArrayList onCreateAnimators() {
36 | ArrayList animators=new ArrayList<>();
37 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.6f,0.5f,1);
38 | scaleAnim.setDuration(750);
39 | scaleAnim.setRepeatCount(-1);
40 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
41 | @Override
42 | public void onAnimationUpdate(ValueAnimator animation) {
43 | scaleFloat = (float) animation.getAnimatedValue();
44 | postInvalidate();
45 | }
46 | });
47 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360);
48 | rotateAnim.setDuration(750);
49 | rotateAnim.setRepeatCount(-1);
50 | addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
51 | @Override
52 | public void onAnimationUpdate(ValueAnimator animation) {
53 | degrees = (float) animation.getAnimatedValue();
54 | postInvalidate();
55 | }
56 | });
57 | animators.add(scaleAnim);
58 | animators.add(rotateAnim);
59 | return animators;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallClipRotateMultipleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/17.
14 | */
15 | public class BallClipRotateMultipleIndicator extends Indicator {
16 |
17 | float scaleFloat=1,degrees;
18 |
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | paint.setStrokeWidth(3);
23 | paint.setStyle(Paint.Style.STROKE);
24 |
25 | float circleSpacing=12;
26 | float x=getWidth()/2;
27 | float y=getHeight()/2;
28 |
29 | canvas.save();
30 |
31 | canvas.translate(x, y);
32 | canvas.scale(scaleFloat, scaleFloat);
33 | canvas.rotate(degrees);
34 |
35 | //draw two big arc
36 | float[] bStartAngles=new float[]{135,-45};
37 | for (int i = 0; i < 2; i++) {
38 | RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing);
39 | canvas.drawArc(rectF, bStartAngles[i], 90, false, paint);
40 | }
41 |
42 | canvas.restore();
43 | canvas.translate(x, y);
44 | canvas.scale(scaleFloat, scaleFloat);
45 | canvas.rotate(-degrees);
46 | //draw two small arc
47 | float[] sStartAngles=new float[]{225,45};
48 | for (int i = 0; i < 2; i++) {
49 | RectF rectF=new RectF(-x/1.8f+circleSpacing,-y/1.8f+circleSpacing,x/1.8f-circleSpacing,y/1.8f-circleSpacing);
50 | canvas.drawArc(rectF, sStartAngles[i], 90, false, paint);
51 | }
52 | }
53 |
54 | @Override
55 | public ArrayList onCreateAnimators() {
56 | ArrayList animators=new ArrayList<>();
57 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.6f,1);
58 | scaleAnim.setDuration(1000);
59 | scaleAnim.setRepeatCount(-1);
60 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
61 | @Override
62 | public void onAnimationUpdate(ValueAnimator animation) {
63 | scaleFloat = (float) animation.getAnimatedValue();
64 | postInvalidate();
65 | }
66 | });
67 |
68 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0, 180,360);
69 | rotateAnim.setDuration(1000);
70 | rotateAnim.setRepeatCount(-1);
71 | addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
72 | @Override
73 | public void onAnimationUpdate(ValueAnimator animation) {
74 | degrees = (float) animation.getAnimatedValue();
75 | postInvalidate();
76 | }
77 | });
78 | animators.add(scaleAnim);
79 | animators.add(rotateAnim);
80 | return animators;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallClipRotatePulseIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/16.
14 | */
15 | public class BallClipRotatePulseIndicator extends Indicator {
16 |
17 | float scaleFloat1,scaleFloat2,degrees;
18 |
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | float circleSpacing=12;
23 | float x=getWidth()/2;
24 | float y=getHeight()/2;
25 |
26 | //draw fill circle
27 | canvas.save();
28 | canvas.translate(x, y);
29 | canvas.scale(scaleFloat1, scaleFloat1);
30 | paint.setStyle(Paint.Style.FILL);
31 | canvas.drawCircle(0, 0, x / 2.5f, paint);
32 |
33 | canvas.restore();
34 |
35 | canvas.translate(x, y);
36 | canvas.scale(scaleFloat2, scaleFloat2);
37 | canvas.rotate(degrees);
38 |
39 | paint.setStrokeWidth(3);
40 | paint.setStyle(Paint.Style.STROKE);
41 |
42 | //draw two arc
43 | float[] startAngles=new float[]{225,45};
44 | for (int i = 0; i < 2; i++) {
45 | RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing);
46 | canvas.drawArc(rectF, startAngles[i], 90, false, paint);
47 | }
48 | }
49 |
50 | @Override
51 | public ArrayList onCreateAnimators() {
52 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
53 | scaleAnim.setDuration(1000);
54 | scaleAnim.setRepeatCount(-1);
55 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
56 | @Override
57 | public void onAnimationUpdate(ValueAnimator animation) {
58 | scaleFloat1 = (float) animation.getAnimatedValue();
59 | postInvalidate();
60 | }
61 | });
62 |
63 | ValueAnimator scaleAnim2=ValueAnimator.ofFloat(1,0.6f,1);
64 | scaleAnim2.setDuration(1000);
65 | scaleAnim2.setRepeatCount(-1);
66 | addUpdateListener(scaleAnim2,new ValueAnimator.AnimatorUpdateListener() {
67 | @Override
68 | public void onAnimationUpdate(ValueAnimator animation) {
69 | scaleFloat2 = (float) animation.getAnimatedValue();
70 | postInvalidate();
71 | }
72 | });
73 |
74 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0, 180,360);
75 | rotateAnim.setDuration(1000);
76 | rotateAnim.setRepeatCount(-1);
77 | addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
78 | @Override
79 | public void onAnimationUpdate(ValueAnimator animation) {
80 | degrees = (float) animation.getAnimatedValue();
81 | postInvalidate();
82 | }
83 | });
84 | ArrayList animators=new ArrayList<>();
85 | animators.add(scaleAnim);
86 | animators.add(scaleAnim2);
87 | animators.add(rotateAnim);
88 | return animators;
89 | }
90 |
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallGridBeatIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.hankkin.xlibrary.widget.view.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/20.
13 | */
14 | public class BallGridBeatIndicator extends Indicator {
15 |
16 | public static final int ALPHA=255;
17 |
18 | int[] alphas=new int[]{ALPHA,
19 | ALPHA,
20 | ALPHA,
21 | ALPHA,
22 | ALPHA,
23 | ALPHA,
24 | ALPHA,
25 | ALPHA,
26 | ALPHA};
27 |
28 | @Override
29 | public void draw(Canvas canvas, Paint paint) {
30 | float circleSpacing=4;
31 | float radius=(getWidth()-circleSpacing*4)/6;
32 | float x = getWidth()/ 2-(radius*2+circleSpacing);
33 | float y = getWidth()/ 2-(radius*2+circleSpacing);
34 |
35 | for (int i = 0; i < 3; i++) {
36 | for (int j = 0; j < 3; j++) {
37 | canvas.save();
38 | float translateX=x+(radius*2)*j+circleSpacing*j;
39 | float translateY=y+(radius*2)*i+circleSpacing*i;
40 | canvas.translate(translateX, translateY);
41 | paint.setAlpha(alphas[3 * i + j]);
42 | canvas.drawCircle(0, 0, radius, paint);
43 | canvas.restore();
44 | }
45 | }
46 | }
47 |
48 | @Override
49 | public ArrayList onCreateAnimators() {
50 | ArrayList animators=new ArrayList<>();
51 |
52 | int[] durations={960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
53 | int[] delays= {360, 400, 680, 410, 710, -150, -120, 10, 320};
54 |
55 | for (int i = 0; i < 9; i++) {
56 | final int index=i;
57 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 168,255);
58 | alphaAnim.setDuration(durations[i]);
59 | alphaAnim.setRepeatCount(-1);
60 | alphaAnim.setStartDelay(delays[i]);
61 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
62 | @Override
63 | public void onAnimationUpdate(ValueAnimator animation) {
64 | alphas[index] = (int) animation.getAnimatedValue();
65 | postInvalidate();
66 | }
67 | });
68 | animators.add(alphaAnim);
69 | }
70 | return animators;
71 | }
72 |
73 |
74 |
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallGridPulseIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.hankkin.xlibrary.widget.view.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/16.
13 | */
14 | public class BallGridPulseIndicator extends Indicator {
15 |
16 | public static final int ALPHA=255;
17 |
18 | public static final float SCALE=1.0f;
19 |
20 | int[] alphas=new int[]{ALPHA,
21 | ALPHA,
22 | ALPHA,
23 | ALPHA,
24 | ALPHA,
25 | ALPHA,
26 | ALPHA,
27 | ALPHA,
28 | ALPHA};
29 |
30 | float[] scaleFloats=new float[]{SCALE,
31 | SCALE,
32 | SCALE,
33 | SCALE,
34 | SCALE,
35 | SCALE,
36 | SCALE,
37 | SCALE,
38 | SCALE};
39 |
40 |
41 |
42 | @Override
43 | public void draw(Canvas canvas, Paint paint) {
44 | float circleSpacing=4;
45 | float radius=(getWidth()-circleSpacing*4)/6;
46 | float x = getWidth()/ 2-(radius*2+circleSpacing);
47 | float y = getWidth()/ 2-(radius*2+circleSpacing);
48 |
49 | for (int i = 0; i < 3; i++) {
50 | for (int j = 0; j < 3; j++) {
51 | canvas.save();
52 | float translateX=x+(radius*2)*j+circleSpacing*j;
53 | float translateY=y+(radius*2)*i+circleSpacing*i;
54 | canvas.translate(translateX, translateY);
55 | canvas.scale(scaleFloats[3 * i + j], scaleFloats[3 * i + j]);
56 | paint.setAlpha(alphas[3 * i + j]);
57 | canvas.drawCircle(0, 0, radius, paint);
58 | canvas.restore();
59 | }
60 | }
61 | }
62 |
63 | @Override
64 | public ArrayList onCreateAnimators() {
65 | ArrayList animators=new ArrayList<>();
66 | int[] durations={720, 1020, 1280, 1420, 1450, 1180, 870, 1450, 1060};
67 | int[] delays= {-60, 250, -170, 480, 310, 30, 460, 780, 450};
68 |
69 | for (int i = 0; i < 9; i++) {
70 | final int index=i;
71 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.5f,1);
72 | scaleAnim.setDuration(durations[i]);
73 | scaleAnim.setRepeatCount(-1);
74 | scaleAnim.setStartDelay(delays[i]);
75 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
76 | @Override
77 | public void onAnimationUpdate(ValueAnimator animation) {
78 | scaleFloats[index] = (float) animation.getAnimatedValue();
79 | postInvalidate();
80 | }
81 | });
82 |
83 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 210, 122, 255);
84 | alphaAnim.setDuration(durations[i]);
85 | alphaAnim.setRepeatCount(-1);
86 | alphaAnim.setStartDelay(delays[i]);
87 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
88 | @Override
89 | public void onAnimationUpdate(ValueAnimator animation) {
90 | alphas[index] = (int) animation.getAnimatedValue();
91 | postInvalidate();
92 | }
93 | });
94 | animators.add(scaleAnim);
95 | animators.add(alphaAnim);
96 | }
97 | return animators;
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallPulseIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.hankkin.xlibrary.widget.view.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/16.
13 | */
14 | public class BallPulseIndicator extends Indicator {
15 |
16 | public static final float SCALE=1.0f;
17 |
18 | //scale x ,y
19 | private float[] scaleFloats=new float[]{SCALE,
20 | SCALE,
21 | SCALE};
22 |
23 |
24 |
25 | @Override
26 | public void draw(Canvas canvas, Paint paint) {
27 | float circleSpacing=4;
28 | float radius=(Math.min(getWidth(),getHeight())-circleSpacing*2)/6;
29 | float x = getWidth()/ 2-(radius*2+circleSpacing);
30 | float y=getHeight() / 2;
31 | for (int i = 0; i < 3; i++) {
32 | canvas.save();
33 | float translateX=x+(radius*2)*i+circleSpacing*i;
34 | canvas.translate(translateX, y);
35 | canvas.scale(scaleFloats[i], scaleFloats[i]);
36 | canvas.drawCircle(0, 0, radius, paint);
37 | canvas.restore();
38 | }
39 | }
40 |
41 | @Override
42 | public ArrayList onCreateAnimators() {
43 | ArrayList animators=new ArrayList<>();
44 | int[] delays=new int[]{120,240,360};
45 | for (int i = 0; i < 3; i++) {
46 | final int index=i;
47 |
48 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
49 |
50 | scaleAnim.setDuration(750);
51 | scaleAnim.setRepeatCount(-1);
52 | scaleAnim.setStartDelay(delays[i]);
53 |
54 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
55 | @Override
56 | public void onAnimationUpdate(ValueAnimator animation) {
57 | scaleFloats[index] = (float) animation.getAnimatedValue();
58 | postInvalidate();
59 | }
60 | });
61 | animators.add(scaleAnim);
62 | }
63 | return animators;
64 | }
65 |
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallPulseRiseIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Camera;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.view.animation.LinearInterpolator;
9 |
10 | import com.hankkin.xlibrary.widget.view.Indicator;
11 |
12 | import java.util.ArrayList;
13 |
14 | /**
15 | * Created by Jack on 2015/10/17.
16 | */
17 | public class BallPulseRiseIndicator extends Indicator {
18 |
19 | private Camera mCamera;
20 | private Matrix mMatrix;
21 |
22 | private float degress;
23 |
24 | public BallPulseRiseIndicator(){
25 | mCamera=new Camera();
26 | mMatrix=new Matrix();
27 | }
28 |
29 | @Override
30 | public void draw(Canvas canvas, Paint paint) {
31 |
32 | mMatrix.reset();
33 | mCamera.save();
34 | mCamera.rotateX(degress);
35 | mCamera.getMatrix(mMatrix);
36 | mCamera.restore();
37 |
38 | mMatrix.preTranslate(-centerX(), -centerY());
39 | mMatrix.postTranslate(centerX(), centerY());
40 | canvas.concat(mMatrix);
41 |
42 | float radius=getWidth()/10;
43 | canvas.drawCircle(getWidth()/4,radius*2,radius,paint);
44 | canvas.drawCircle(getWidth()*3/4,radius*2,radius,paint);
45 |
46 | canvas.drawCircle(radius,getHeight()-2*radius,radius,paint);
47 | canvas.drawCircle(getWidth()/2,getHeight()-2*radius,radius,paint);
48 | canvas.drawCircle(getWidth()-radius,getHeight()-2*radius,radius,paint);
49 | }
50 |
51 | @Override
52 | public ArrayList onCreateAnimators() {
53 | ArrayList animators=new ArrayList<>();
54 | ValueAnimator animator=ValueAnimator.ofFloat(0,360);
55 | addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() {
56 | @Override
57 | public void onAnimationUpdate(ValueAnimator animation) {
58 | degress = (float) animation.getAnimatedValue();
59 | postInvalidate();
60 | }
61 | });
62 | animator.setInterpolator(new LinearInterpolator());
63 | animator.setRepeatCount(-1);
64 | animator.setDuration(1500);
65 | animators.add(animator);
66 | return animators;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallPulseSyncIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.hankkin.xlibrary.widget.view.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/19.
13 | */
14 | public class BallPulseSyncIndicator extends Indicator {
15 |
16 | float[] translateYFloats=new float[3];
17 |
18 | @Override
19 | public void draw(Canvas canvas, Paint paint) {
20 | float circleSpacing=4;
21 | float radius=(getWidth()-circleSpacing*2)/6;
22 | float x = getWidth()/ 2-(radius*2+circleSpacing);
23 | for (int i = 0; i < 3; i++) {
24 | canvas.save();
25 | float translateX=x+(radius*2)*i+circleSpacing*i;
26 | canvas.translate(translateX, translateYFloats[i]);
27 | canvas.drawCircle(0, 0, radius, paint);
28 | canvas.restore();
29 | }
30 | }
31 |
32 | @Override
33 | public ArrayList onCreateAnimators() {
34 | ArrayList animators=new ArrayList<>();
35 | float circleSpacing=4;
36 | float radius=(getWidth()-circleSpacing*2)/6;
37 | int[] delays=new int[]{70,140,210};
38 | for (int i = 0; i < 3; i++) {
39 | final int index=i;
40 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(getHeight()/2,getHeight()/2-radius*2,getHeight()/2);
41 | scaleAnim.setDuration(600);
42 | scaleAnim.setRepeatCount(-1);
43 | scaleAnim.setStartDelay(delays[i]);
44 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
45 | @Override
46 | public void onAnimationUpdate(ValueAnimator animation) {
47 | translateYFloats[index] = (float) animation.getAnimatedValue();
48 | postInvalidate();
49 | }
50 | });
51 | animators.add(scaleAnim);
52 | }
53 | return animators;
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallRotateIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Matrix;
6 | import android.graphics.Paint;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/17.
14 | */
15 | public class BallRotateIndicator extends Indicator {
16 |
17 | float scaleFloat=0.5f;
18 |
19 | float degress;
20 |
21 | private Matrix mMatrix;
22 |
23 | public BallRotateIndicator(){
24 | mMatrix=new Matrix();
25 | }
26 |
27 | @Override
28 | public void draw(Canvas canvas, Paint paint) {
29 | float radius=getWidth()/10;
30 | float x = getWidth()/ 2;
31 | float y=getHeight()/2;
32 |
33 | /*mMatrix.preTranslate(-centerX(), -centerY());
34 | mMatrix.preRotate(degress,centerX(),centerY());
35 | mMatrix.postTranslate(centerX(), centerY());
36 | canvas.concat(mMatrix);*/
37 |
38 | canvas.rotate(degress,centerX(),centerY());
39 |
40 | canvas.save();
41 | canvas.translate(x - radius * 2 - radius, y);
42 | canvas.scale(scaleFloat, scaleFloat);
43 | canvas.drawCircle(0, 0, radius, paint);
44 | canvas.restore();
45 |
46 | canvas.save();
47 | canvas.translate(x, y);
48 | canvas.scale(scaleFloat, scaleFloat);
49 | canvas.drawCircle(0, 0, radius, paint);
50 | canvas.restore();
51 |
52 | canvas.save();
53 | canvas.translate(x + radius * 2 + radius, y);
54 | canvas.scale(scaleFloat, scaleFloat);
55 | canvas.drawCircle(0,0,radius, paint);
56 | canvas.restore();
57 | }
58 |
59 | @Override
60 | public ArrayList onCreateAnimators() {
61 | ArrayList animators=new ArrayList<>();
62 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0.5f,1,0.5f);
63 | scaleAnim.setDuration(1000);
64 | scaleAnim.setRepeatCount(-1);
65 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
66 | @Override
67 | public void onAnimationUpdate(ValueAnimator animation) {
68 | scaleFloat = (float) animation.getAnimatedValue();
69 | postInvalidate();
70 | }
71 | });
72 |
73 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360);
74 | addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
75 | @Override
76 | public void onAnimationUpdate(ValueAnimator animation) {
77 | degress = (float) animation.getAnimatedValue();
78 | postInvalidate();
79 | }
80 | });
81 | rotateAnim.setDuration(1000);
82 | rotateAnim.setRepeatCount(-1);
83 |
84 | animators.add(scaleAnim);
85 | animators.add(rotateAnim);
86 | return animators;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallScaleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class BallScaleIndicator extends Indicator {
16 |
17 | float scale=1;
18 | int alpha=255;
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | float circleSpacing=4;
23 | paint.setAlpha(alpha);
24 | canvas.scale(scale,scale,getWidth()/2,getHeight()/2);
25 | paint.setAlpha(alpha);
26 | canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint);
27 | }
28 |
29 | @Override
30 | public ArrayList onCreateAnimators() {
31 | ArrayList animators=new ArrayList<>();
32 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
33 | scaleAnim.setInterpolator(new LinearInterpolator());
34 | scaleAnim.setDuration(1000);
35 | scaleAnim.setRepeatCount(-1);
36 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator animation) {
39 | scale = (float) animation.getAnimatedValue();
40 | postInvalidate();
41 | }
42 | });
43 |
44 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 0);
45 | alphaAnim.setInterpolator(new LinearInterpolator());
46 | alphaAnim.setDuration(1000);
47 | alphaAnim.setRepeatCount(-1);
48 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
49 | @Override
50 | public void onAnimationUpdate(ValueAnimator animation) {
51 | alpha = (int) animation.getAnimatedValue();
52 | postInvalidate();
53 | }
54 | });
55 | animators.add(scaleAnim);
56 | animators.add(alphaAnim);
57 | return animators;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallScaleMultipleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class BallScaleMultipleIndicator extends Indicator {
16 |
17 | float[] scaleFloats=new float[]{1,1,1};
18 | int[] alphaInts=new int[]{255,255,255};
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | float circleSpacing=4;
23 | for (int i = 0; i < 3; i++) {
24 | paint.setAlpha(alphaInts[i]);
25 | canvas.scale(scaleFloats[i],scaleFloats[i],getWidth()/2,getHeight()/2);
26 | canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint);
27 | }
28 | }
29 |
30 | @Override
31 | public ArrayList onCreateAnimators() {
32 | ArrayList animators=new ArrayList<>();
33 | long[] delays=new long[]{0, 200, 400};
34 | for (int i = 0; i < 3; i++) {
35 | final int index=i;
36 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
37 | scaleAnim.setInterpolator(new LinearInterpolator());
38 | scaleAnim.setDuration(1000);
39 | scaleAnim.setRepeatCount(-1);
40 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
41 | @Override
42 | public void onAnimationUpdate(ValueAnimator animation) {
43 | scaleFloats[index] = (float) animation.getAnimatedValue();
44 | postInvalidate();
45 | }
46 | });
47 | scaleAnim.setStartDelay(delays[i]);
48 |
49 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255,0);
50 | alphaAnim.setInterpolator(new LinearInterpolator());
51 | alphaAnim.setDuration(1000);
52 | alphaAnim.setRepeatCount(-1);
53 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
54 | @Override
55 | public void onAnimationUpdate(ValueAnimator animation) {
56 | alphaInts[index] = (int) animation.getAnimatedValue();
57 | postInvalidate();
58 | }
59 | });
60 | scaleAnim.setStartDelay(delays[i]);
61 |
62 | animators.add(scaleAnim);
63 | animators.add(alphaAnim);
64 | }
65 | return animators;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallScaleRippleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Created by Jack on 2015/10/19.
12 | */
13 | public class BallScaleRippleIndicator extends BallScaleIndicator {
14 |
15 |
16 | @Override
17 | public void draw(Canvas canvas, Paint paint) {
18 | paint.setStyle(Paint.Style.STROKE);
19 | paint.setStrokeWidth(3);
20 | super.draw(canvas, paint);
21 | }
22 |
23 | @Override
24 | public ArrayList onCreateAnimators() {
25 | ArrayList animators=new ArrayList<>();
26 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
27 | scaleAnim.setInterpolator(new LinearInterpolator());
28 | scaleAnim.setDuration(1000);
29 | scaleAnim.setRepeatCount(-1);
30 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
31 | @Override
32 | public void onAnimationUpdate(ValueAnimator animation) {
33 | scale = (float) animation.getAnimatedValue();
34 | postInvalidate();
35 | }
36 | });
37 |
38 | ValueAnimator alphaAnim=ValueAnimator.ofInt(0, 255);
39 | alphaAnim.setInterpolator(new LinearInterpolator());
40 | alphaAnim.setDuration(1000);
41 | alphaAnim.setRepeatCount(-1);
42 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
43 | @Override
44 | public void onAnimationUpdate(ValueAnimator animation) {
45 | alpha = (int) animation.getAnimatedValue();
46 | postInvalidate();
47 | }
48 | });
49 |
50 | animators.add(scaleAnim);
51 | animators.add(alphaAnim);
52 | return animators;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallScaleRippleMultipleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Created by Jack on 2015/10/19.
12 | */
13 | public class BallScaleRippleMultipleIndicator extends BallScaleMultipleIndicator {
14 |
15 |
16 | @Override
17 | public void draw(Canvas canvas, Paint paint) {
18 | paint.setStyle(Paint.Style.STROKE);
19 | paint.setStrokeWidth(3);
20 | super.draw(canvas, paint);
21 | }
22 |
23 | @Override
24 | public ArrayList onCreateAnimators() {
25 | ArrayList animators=new ArrayList<>();
26 | long[] delays=new long[]{0, 200, 400};
27 | for (int i = 0; i < 3; i++) {
28 | final int index=i;
29 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
30 | scaleAnim.setInterpolator(new LinearInterpolator());
31 | scaleAnim.setDuration(1000);
32 | scaleAnim.setRepeatCount(-1);
33 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
34 | @Override
35 | public void onAnimationUpdate(ValueAnimator animation) {
36 | scaleFloats[index] = (float) animation.getAnimatedValue();
37 | postInvalidate();
38 | }
39 | });
40 | scaleAnim.setStartDelay(delays[i]);
41 |
42 | ValueAnimator alphaAnim=ValueAnimator.ofInt(0,255);
43 | scaleAnim.setInterpolator(new LinearInterpolator());
44 | alphaAnim.setDuration(1000);
45 | alphaAnim.setRepeatCount(-1);
46 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
47 | @Override
48 | public void onAnimationUpdate(ValueAnimator animation) {
49 | alphaInts[index] = (int) animation.getAnimatedValue();
50 | postInvalidate();
51 | }
52 | });
53 | scaleAnim.setStartDelay(delays[i]);
54 |
55 | animators.add(scaleAnim);
56 | animators.add(alphaAnim);
57 | }
58 | return animators;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallSpinFadeLoaderIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 |
7 | import com.hankkin.xlibrary.widget.view.Indicator;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jack on 2015/10/20.
13 | */
14 | public class BallSpinFadeLoaderIndicator extends Indicator {
15 |
16 | public static final float SCALE=1.0f;
17 |
18 | public static final int ALPHA=255;
19 |
20 | float[] scaleFloats=new float[]{SCALE,
21 | SCALE,
22 | SCALE,
23 | SCALE,
24 | SCALE,
25 | SCALE,
26 | SCALE,
27 | SCALE};
28 |
29 | int[] alphas=new int[]{ALPHA,
30 | ALPHA,
31 | ALPHA,
32 | ALPHA,
33 | ALPHA,
34 | ALPHA,
35 | ALPHA,
36 | ALPHA};
37 |
38 |
39 | @Override
40 | public void draw(Canvas canvas, Paint paint) {
41 | float radius=getWidth()/10;
42 | for (int i = 0; i < 8; i++) {
43 | canvas.save();
44 | Point point=circleAt(getWidth(),getHeight(),getWidth()/2-radius,i*(Math.PI/4));
45 | canvas.translate(point.x,point.y);
46 | canvas.scale(scaleFloats[i],scaleFloats[i]);
47 | paint.setAlpha(alphas[i]);
48 | canvas.drawCircle(0,0,radius,paint);
49 | canvas.restore();
50 | }
51 | }
52 |
53 | @Override
54 | public ArrayList onCreateAnimators() {
55 | ArrayList animators=new ArrayList<>();
56 | int[] delays= {0, 120, 240, 360, 480, 600, 720, 780, 840};
57 | for (int i = 0; i < 8; i++) {
58 | final int index=i;
59 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
60 | scaleAnim.setDuration(1000);
61 | scaleAnim.setRepeatCount(-1);
62 | scaleAnim.setStartDelay(delays[i]);
63 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
64 | @Override
65 | public void onAnimationUpdate(ValueAnimator animation) {
66 | scaleFloats[index] = (float) animation.getAnimatedValue();
67 | postInvalidate();
68 | }
69 | });
70 |
71 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 77, 255);
72 | alphaAnim.setDuration(1000);
73 | alphaAnim.setRepeatCount(-1);
74 | alphaAnim.setStartDelay(delays[i]);
75 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
76 | @Override
77 | public void onAnimationUpdate(ValueAnimator animation) {
78 | alphas[index] = (int) animation.getAnimatedValue();
79 | postInvalidate();
80 | }
81 | });
82 | animators.add(scaleAnim);
83 | animators.add(alphaAnim);
84 | }
85 | return animators;
86 | }
87 |
88 | /**
89 | * 圆O的圆心为(a,b),半径为R,点A与到X轴的为角α.
90 | *则点A的坐标为(a+R*cosα,b+R*sinα)
91 | * @param width
92 | * @param height
93 | * @param radius
94 | * @param angle
95 | * @return
96 | */
97 | Point circleAt(int width,int height,float radius,double angle){
98 | float x= (float) (width/2+radius*(Math.cos(angle)));
99 | float y= (float) (height/2+radius*(Math.sin(angle)));
100 | return new Point(x,y);
101 | }
102 |
103 | final class Point{
104 | public float x;
105 | public float y;
106 |
107 | public Point(float x, float y){
108 | this.x=x;
109 | this.y=y;
110 | }
111 | }
112 |
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallTrianglePathIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class BallTrianglePathIndicator extends Indicator {
16 |
17 | float[] translateX=new float[3],translateY=new float[3];
18 |
19 | @Override
20 | public void draw(Canvas canvas, Paint paint) {
21 | paint.setStrokeWidth(3);
22 | paint.setStyle(Paint.Style.STROKE);
23 | for (int i = 0; i < 3; i++) {
24 | canvas.save();
25 | canvas.translate(translateX[i], translateY[i]);
26 | canvas.drawCircle(0, 0, getWidth() / 10, paint);
27 | canvas.restore();
28 | }
29 | }
30 |
31 | @Override
32 | public ArrayList onCreateAnimators() {
33 | ArrayList animators=new ArrayList<>();
34 | float startX=getWidth()/5;
35 | float startY=getWidth()/5;
36 | for (int i = 0; i < 3; i++) {
37 | final int index=i;
38 | ValueAnimator translateXAnim=ValueAnimator.ofFloat(getWidth()/2,getWidth()-startX,startX,getWidth()/2);
39 | if (i==1){
40 | translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()/2,getWidth()-startX);
41 | }else if (i==2){
42 | translateXAnim=ValueAnimator.ofFloat(startX,getWidth()/2,getWidth()-startX,startX);
43 | }
44 | ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,getHeight()-startY,getHeight()-startY,startY);
45 | if (i==1){
46 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,getHeight()-startY);
47 | }else if (i==2){
48 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,startY,getHeight()-startY,getHeight()-startY);
49 | }
50 |
51 | translateXAnim.setDuration(2000);
52 | translateXAnim.setInterpolator(new LinearInterpolator());
53 | translateXAnim.setRepeatCount(-1);
54 | addUpdateListener(translateXAnim,new ValueAnimator.AnimatorUpdateListener() {
55 | @Override
56 | public void onAnimationUpdate(ValueAnimator animation) {
57 | translateX [index]= (float) animation.getAnimatedValue();
58 | postInvalidate();
59 | }
60 | });
61 |
62 | translateYAnim.setDuration(2000);
63 | translateYAnim.setInterpolator(new LinearInterpolator());
64 | translateYAnim.setRepeatCount(-1);
65 | addUpdateListener(translateYAnim,new ValueAnimator.AnimatorUpdateListener() {
66 | @Override
67 | public void onAnimationUpdate(ValueAnimator animation) {
68 | translateY [index]= (float) animation.getAnimatedValue();
69 | postInvalidate();
70 | }
71 | });
72 |
73 | animators.add(translateXAnim);
74 | animators.add(translateYAnim);
75 | }
76 | return animators;
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallZigZagDeflectIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 |
4 | import android.animation.ValueAnimator;
5 | import android.view.animation.LinearInterpolator;
6 |
7 | import java.util.ArrayList;
8 |
9 | /**
10 | * Created by Jack on 2015/10/19.
11 | */
12 | public class BallZigZagDeflectIndicator extends BallZigZagIndicator {
13 |
14 |
15 |
16 |
17 | @Override
18 | public ArrayList onCreateAnimators() {
19 | ArrayList animators=new ArrayList<>();
20 | float startX=getWidth()/6;
21 | float startY=getWidth()/6;
22 | for (int i = 0; i < 2; i++) {
23 | final int index=i;
24 | ValueAnimator translateXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,startX,getWidth()-startX,startX);
25 | if (i==1){
26 | translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()-startX,startX,getWidth()-startX);
27 | }
28 | ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()-startY,getHeight()-startY,startY);
29 | if (i==1){
30 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,startY,getHeight()-startY);
31 | }
32 |
33 | translateXAnim.setDuration(2000);
34 | translateXAnim.setInterpolator(new LinearInterpolator());
35 | translateXAnim.setRepeatCount(-1);
36 | addUpdateListener(translateXAnim,new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator animation) {
39 | translateX [index]= (float) animation.getAnimatedValue();
40 | postInvalidate();
41 | }
42 | });
43 |
44 | translateYAnim.setDuration(2000);
45 | translateYAnim.setInterpolator(new LinearInterpolator());
46 | translateYAnim.setRepeatCount(-1);
47 | addUpdateListener(translateYAnim,new ValueAnimator.AnimatorUpdateListener() {
48 | @Override
49 | public void onAnimationUpdate(ValueAnimator animation) {
50 | translateY [index]= (float) animation.getAnimatedValue();
51 | postInvalidate();
52 | }
53 | });
54 |
55 | animators.add(translateXAnim);
56 | animators.add(translateYAnim);
57 | }
58 | return animators;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/BallZigZagIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.view.animation.LinearInterpolator;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class BallZigZagIndicator extends Indicator {
16 |
17 | float[] translateX=new float[2],translateY=new float[2];
18 |
19 |
20 | @Override
21 | public void draw(Canvas canvas, Paint paint) {
22 | for (int i = 0; i < 2; i++) {
23 | canvas.save();
24 | canvas.translate(translateX[i], translateY[i]);
25 | canvas.drawCircle(0, 0, getWidth() / 10, paint);
26 | canvas.restore();
27 | }
28 | }
29 |
30 | @Override
31 | public ArrayList onCreateAnimators() {
32 | ArrayList animators=new ArrayList<>();
33 | float startX=getWidth()/6;
34 | float startY=getWidth()/6;
35 | for (int i = 0; i < 2; i++) {
36 | final int index=i;
37 | ValueAnimator translateXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,getWidth()/2,startX);
38 | if (i==1){
39 | translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()/2,getWidth()-startX);
40 | }
41 | ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()/2,startY);
42 | if (i==1){
43 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,getHeight()/2,getHeight()-startY);
44 | }
45 |
46 | translateXAnim.setDuration(1000);
47 | translateXAnim.setInterpolator(new LinearInterpolator());
48 | translateXAnim.setRepeatCount(-1);
49 | addUpdateListener(translateXAnim,new ValueAnimator.AnimatorUpdateListener() {
50 | @Override
51 | public void onAnimationUpdate(ValueAnimator animation) {
52 | translateX[index] = (float) animation.getAnimatedValue();
53 | postInvalidate();
54 | }
55 | });
56 |
57 | translateYAnim.setDuration(1000);
58 | translateYAnim.setInterpolator(new LinearInterpolator());
59 | translateYAnim.setRepeatCount(-1);
60 | addUpdateListener(translateYAnim,new ValueAnimator.AnimatorUpdateListener() {
61 | @Override
62 | public void onAnimationUpdate(ValueAnimator animation) {
63 | translateY[index] = (float) animation.getAnimatedValue();
64 | postInvalidate();
65 | }
66 | });
67 | animators.add(translateXAnim);
68 | animators.add(translateYAnim);
69 | }
70 | return animators;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/CubeTransitionIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 | import android.view.animation.LinearInterpolator;
8 |
9 | import com.hankkin.xlibrary.widget.view.Indicator;
10 |
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Created by Jack on 2015/10/18.
15 | */
16 | public class CubeTransitionIndicator extends Indicator {
17 |
18 | float[] translateX=new float[2],translateY=new float[2];
19 | float degrees,scaleFloat=1.0f;
20 |
21 | @Override
22 | public void draw(Canvas canvas, Paint paint) {
23 | float rWidth=getWidth()/5;
24 | float rHeight=getHeight()/5;
25 | for (int i = 0; i < 2; i++) {
26 | canvas.save();
27 | canvas.translate(translateX[i], translateY[i]);
28 | canvas.rotate(degrees);
29 | canvas.scale(scaleFloat,scaleFloat);
30 | RectF rectF=new RectF(-rWidth/2,-rHeight/2,rWidth/2,rHeight/2);
31 | canvas.drawRect(rectF,paint);
32 | canvas.restore();
33 | }
34 | }
35 |
36 | @Override
37 | public ArrayList onCreateAnimators() {
38 | ArrayList animators=new ArrayList<>();
39 | float startX=getWidth()/5;
40 | float startY=getHeight()/5;
41 | for (int i = 0; i < 2; i++) {
42 | final int index=i;
43 | translateX[index]=startX;
44 | ValueAnimator translationXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,getWidth()-startX, startX,startX);
45 | if (i==1){
46 | translationXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,startX, getWidth()-startX,getWidth()-startX);
47 | }
48 | translationXAnim.setInterpolator(new LinearInterpolator());
49 | translationXAnim.setDuration(1600);
50 | translationXAnim.setRepeatCount(-1);
51 | translationXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
52 | @Override
53 | public void onAnimationUpdate(ValueAnimator animation) {
54 | translateX[index] = (float) animation.getAnimatedValue();
55 | postInvalidate();
56 | }
57 | });
58 | translateY[index]=startY;
59 | ValueAnimator translationYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()-startY,getHeight()- startY,startY);
60 | if (i==1){
61 | translationYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,startY,getHeight()-startY);
62 | }
63 | translationYAnim.setDuration(1600);
64 | translationYAnim.setInterpolator(new LinearInterpolator());
65 | translationYAnim.setRepeatCount(-1);
66 | addUpdateListener(translationYAnim,new ValueAnimator.AnimatorUpdateListener() {
67 | @Override
68 | public void onAnimationUpdate(ValueAnimator animation) {
69 | translateY[index] = (float) animation.getAnimatedValue();
70 | postInvalidate();
71 | }
72 | });
73 |
74 | animators.add(translationXAnim);
75 | animators.add(translationYAnim);
76 | }
77 |
78 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.5f,1,0.5f,1);
79 | scaleAnim.setDuration(1600);
80 | scaleAnim.setInterpolator(new LinearInterpolator());
81 | scaleAnim.setRepeatCount(-1);
82 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
83 | @Override
84 | public void onAnimationUpdate(ValueAnimator animation) {
85 | scaleFloat = (float) animation.getAnimatedValue();
86 | postInvalidate();
87 | }
88 | });
89 |
90 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360,1.5f*360,2*360);
91 | rotateAnim.setDuration(1600);
92 | rotateAnim.setInterpolator(new LinearInterpolator());
93 | rotateAnim.setRepeatCount(-1);
94 | addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
95 | @Override
96 | public void onAnimationUpdate(ValueAnimator animation) {
97 | degrees = (float) animation.getAnimatedValue();
98 | postInvalidate();
99 | }
100 | });
101 |
102 | animators.add(scaleAnim);
103 | animators.add(rotateAnim);
104 | return animators;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/LineScaleIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class LineScaleIndicator extends Indicator {
16 |
17 | public static final float SCALE=1.0f;
18 |
19 | float[] scaleYFloats=new float[]{SCALE,
20 | SCALE,
21 | SCALE,
22 | SCALE,
23 | SCALE,};
24 |
25 | @Override
26 | public void draw(Canvas canvas, Paint paint) {
27 | float translateX=getWidth()/11;
28 | float translateY=getHeight()/2;
29 | for (int i = 0; i < 5; i++) {
30 | canvas.save();
31 | canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
32 | canvas.scale(SCALE, scaleYFloats[i]);
33 | RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f);
34 | canvas.drawRoundRect(rectF, 5, 5, paint);
35 | canvas.restore();
36 | }
37 | }
38 |
39 | @Override
40 | public ArrayList onCreateAnimators() {
41 | ArrayList animators=new ArrayList<>();
42 | long[] delays=new long[]{100,200,300,400,500};
43 | for (int i = 0; i < 5; i++) {
44 | final int index=i;
45 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1, 0.4f, 1);
46 | scaleAnim.setDuration(1000);
47 | scaleAnim.setRepeatCount(-1);
48 | scaleAnim.setStartDelay(delays[i]);
49 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
50 | @Override
51 | public void onAnimationUpdate(ValueAnimator animation) {
52 | scaleYFloats[index] = (float) animation.getAnimatedValue();
53 | postInvalidate();
54 | }
55 | });
56 | animators.add(scaleAnim);
57 | }
58 | return animators;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/LineScalePartyIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/19.
14 | */
15 | public class LineScalePartyIndicator extends Indicator {
16 |
17 | public static final float SCALE=1.0f;
18 |
19 | float[] scaleFloats=new float[]{SCALE,
20 | SCALE,
21 | SCALE,
22 | SCALE,
23 | SCALE,};
24 |
25 | @Override
26 | public void draw(Canvas canvas, Paint paint) {
27 | float translateX=getWidth()/9;
28 | float translateY=getHeight()/2;
29 | for (int i = 0; i < 4; i++) {
30 | canvas.save();
31 | canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
32 | canvas.scale(scaleFloats[i], scaleFloats[i]);
33 | RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f);
34 | canvas.drawRoundRect(rectF,5,5,paint);
35 | canvas.restore();
36 | }
37 | }
38 |
39 |
40 | @Override
41 | public ArrayList onCreateAnimators() {
42 | ArrayList animators=new ArrayList<>();
43 | long[] durations=new long[]{1260, 430, 1010, 730};
44 | long[] delays=new long[]{770, 290, 280, 740};
45 | for (int i = 0; i < 4; i++) {
46 | final int index=i;
47 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
48 | scaleAnim.setDuration(durations[i]);
49 | scaleAnim.setRepeatCount(-1);
50 | scaleAnim.setStartDelay(delays[i]);
51 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
52 | @Override
53 | public void onAnimationUpdate(ValueAnimator animation) {
54 | scaleFloats[index] = (float) animation.getAnimatedValue();
55 | postInvalidate();
56 | }
57 | });
58 | animators.add(scaleAnim);
59 | }
60 | return animators;
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/LineScalePulseOutIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 |
4 | import android.animation.ValueAnimator;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by Jack on 2015/10/19.
10 | */
11 | public class LineScalePulseOutIndicator extends LineScaleIndicator {
12 |
13 | @Override
14 | public ArrayList onCreateAnimators() {
15 | ArrayList animators=new ArrayList<>();
16 | long[] delays=new long[]{500,250,0,250,500};
17 | for (int i = 0; i < 5; i++) {
18 | final int index=i;
19 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
20 | scaleAnim.setDuration(900);
21 | scaleAnim.setRepeatCount(-1);
22 | scaleAnim.setStartDelay(delays[i]);
23 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
24 | @Override
25 | public void onAnimationUpdate(ValueAnimator animation) {
26 | scaleYFloats[index] = (float) animation.getAnimatedValue();
27 | postInvalidate();
28 | }
29 | });
30 | animators.add(scaleAnim);
31 | }
32 | return animators;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/LineScalePulseOutRapidIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 |
4 | import android.animation.ValueAnimator;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by Jack on 2015/10/19.
10 | */
11 | public class LineScalePulseOutRapidIndicator extends LineScaleIndicator {
12 |
13 | @Override
14 | public ArrayList onCreateAnimators() {
15 | ArrayList animators=new ArrayList<>();
16 | long[] delays=new long[]{400,200,0,200,400};
17 | for (int i = 0; i < 5; i++) {
18 | final int index=i;
19 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
20 | scaleAnim.setDuration(1000);
21 | scaleAnim.setRepeatCount(-1);
22 | scaleAnim.setStartDelay(delays[i]);
23 | addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
24 | @Override
25 | public void onAnimationUpdate(ValueAnimator animation) {
26 | scaleYFloats[index] = (float) animation.getAnimatedValue();
27 | postInvalidate();
28 | }
29 | });
30 | animators.add(scaleAnim);
31 | }
32 | return animators;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/LineSpinFadeLoaderIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 |
7 | /**
8 | * Created by Jack on 2015/10/24.
9 | * Email:81813780@qq.com
10 | */
11 | public class LineSpinFadeLoaderIndicator extends BallSpinFadeLoaderIndicator {
12 |
13 |
14 | @Override
15 | public void draw(Canvas canvas, Paint paint) {
16 | float radius=getWidth()/10;
17 | for (int i = 0; i < 8; i++) {
18 | canvas.save();
19 | Point point=circleAt(getWidth(),getHeight(),getWidth()/2.5f-radius,i*(Math.PI/4));
20 | canvas.translate(point.x, point.y);
21 | canvas.scale(scaleFloats[i], scaleFloats[i]);
22 | canvas.rotate(i*45);
23 | paint.setAlpha(alphas[i]);
24 | RectF rectF=new RectF(-radius,-radius/1.5f,1.5f*radius,radius/1.5f);
25 | canvas.drawRoundRect(rectF,5,5,paint);
26 | canvas.restore();
27 | }
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/PacmanIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 | import android.view.animation.LinearInterpolator;
8 |
9 | import com.hankkin.xlibrary.widget.view.Indicator;
10 |
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Created by Jack on 2015/10/16.
15 | */
16 | public class PacmanIndicator extends Indicator {
17 |
18 | private float translateX;
19 |
20 | private int alpha;
21 |
22 | private float degrees1,degrees2;
23 |
24 | @Override
25 | public void draw(Canvas canvas, Paint paint) {
26 | drawPacman(canvas,paint);
27 | drawCircle(canvas,paint);
28 | }
29 |
30 | private void drawPacman(Canvas canvas,Paint paint){
31 | float x=getWidth()/2;
32 | float y=getHeight()/2;
33 |
34 | canvas.save();
35 |
36 | canvas.translate(x, y);
37 | canvas.rotate(degrees1);
38 | paint.setAlpha(255);
39 | RectF rectF1=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
40 | canvas.drawArc(rectF1, 0, 270, true, paint);
41 |
42 | canvas.restore();
43 |
44 | canvas.save();
45 | canvas.translate(x, y);
46 | canvas.rotate(degrees2);
47 | paint.setAlpha(255);
48 | RectF rectF2=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
49 | canvas.drawArc(rectF2,90,270,true,paint);
50 | canvas.restore();
51 | }
52 |
53 |
54 | private void drawCircle(Canvas canvas, Paint paint) {
55 | float radius=getWidth()/11;
56 | paint.setAlpha(alpha);
57 | canvas.drawCircle(translateX, getHeight() / 2, radius, paint);
58 | }
59 |
60 | @Override
61 | public ArrayList onCreateAnimators() {
62 | ArrayList animators=new ArrayList<>();
63 | float startT=getWidth()/11;
64 | ValueAnimator translationAnim=ValueAnimator.ofFloat(getWidth()-startT,getWidth()/2);
65 | translationAnim.setDuration(650);
66 | translationAnim.setInterpolator(new LinearInterpolator());
67 | translationAnim.setRepeatCount(-1);
68 | addUpdateListener(translationAnim,new ValueAnimator.AnimatorUpdateListener() {
69 | @Override
70 | public void onAnimationUpdate(ValueAnimator animation) {
71 | translateX = (float) animation.getAnimatedValue();
72 | postInvalidate();
73 | }
74 | });
75 |
76 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255,122);
77 | alphaAnim.setDuration(650);
78 | alphaAnim.setRepeatCount(-1);
79 | addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
80 | @Override
81 | public void onAnimationUpdate(ValueAnimator animation) {
82 | alpha = (int) animation.getAnimatedValue();
83 | postInvalidate();
84 | }
85 | });
86 |
87 | ValueAnimator rotateAnim1=ValueAnimator.ofFloat(0, 45, 0);
88 | rotateAnim1.setDuration(650);
89 | rotateAnim1.setRepeatCount(-1);
90 | addUpdateListener(rotateAnim1,new ValueAnimator.AnimatorUpdateListener() {
91 | @Override
92 | public void onAnimationUpdate(ValueAnimator animation) {
93 | degrees1 = (float) animation.getAnimatedValue();
94 | postInvalidate();
95 | }
96 | });
97 |
98 | ValueAnimator rotateAnim2=ValueAnimator.ofFloat(0,-45,0);
99 | rotateAnim2.setDuration(650);
100 | rotateAnim2.setRepeatCount(-1);
101 | addUpdateListener(rotateAnim2,new ValueAnimator.AnimatorUpdateListener() {
102 | @Override
103 | public void onAnimationUpdate(ValueAnimator animation) {
104 | degrees2 = (float) animation.getAnimatedValue();
105 | postInvalidate();
106 | }
107 | });
108 |
109 | animators.add(translationAnim);
110 | animators.add(alphaAnim);
111 | animators.add(rotateAnim1);
112 | animators.add(rotateAnim2);
113 | return animators;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/SemiCircleSpinIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 |
8 | import com.hankkin.xlibrary.widget.view.Indicator;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by Jack on 2015/10/20.
14 | */
15 | public class SemiCircleSpinIndicator extends Indicator {
16 |
17 | private float degress;
18 |
19 | @Override
20 | public void draw(Canvas canvas, Paint paint) {
21 | canvas.rotate(degress,centerX(),centerY());
22 | RectF rectF=new RectF(0,0,getWidth(),getHeight());
23 | canvas.drawArc(rectF,-60,120,false,paint);
24 | }
25 |
26 | @Override
27 | public ArrayList onCreateAnimators() {
28 | ArrayList animators=new ArrayList<>();
29 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360);
30 | addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
31 | @Override
32 | public void onAnimationUpdate(ValueAnimator animation) {
33 | degress= (float) animation.getAnimatedValue();
34 | postInvalidate();
35 | }
36 | });
37 | rotateAnim.setDuration(600);
38 | rotateAnim.setRepeatCount(-1);
39 | animators.add(rotateAnim);
40 | return animators;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/SquareSpinIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Camera;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.graphics.RectF;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.hankkin.xlibrary.widget.view.Indicator;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by Jack on 2015/10/16.
17 | */
18 | public class SquareSpinIndicator extends Indicator {
19 |
20 | private float rotateX;
21 | private float rotateY;
22 |
23 | private Camera mCamera;
24 | private Matrix mMatrix;
25 |
26 | public SquareSpinIndicator(){
27 | mCamera=new Camera();
28 | mMatrix=new Matrix();
29 | }
30 |
31 | @Override
32 | public void draw(Canvas canvas, Paint paint) {
33 |
34 | mMatrix.reset();
35 | mCamera.save();
36 | mCamera.rotateX(rotateX);
37 | mCamera.rotateY(rotateY);
38 | mCamera.getMatrix(mMatrix);
39 | mCamera.restore();
40 |
41 | mMatrix.preTranslate(-centerX(), -centerY());
42 | mMatrix.postTranslate(centerX(), centerY());
43 | canvas.concat(mMatrix);
44 |
45 | canvas.drawRect(new RectF(getWidth()/5,getHeight()/5,getWidth()*4/5,getHeight()*4/5),paint);
46 | }
47 |
48 | @Override
49 | public ArrayList onCreateAnimators() {
50 | ArrayList animators=new ArrayList<>();
51 | ValueAnimator animator=ValueAnimator.ofFloat(0,180,180,0,0);
52 | addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() {
53 | @Override
54 | public void onAnimationUpdate(ValueAnimator animation) {
55 | rotateX= (float) animation.getAnimatedValue();
56 | postInvalidate();
57 | }
58 | });
59 | animator.setInterpolator(new LinearInterpolator());
60 | animator.setRepeatCount(-1);
61 | animator.setDuration(2500);
62 |
63 | ValueAnimator animator1=ValueAnimator.ofFloat(0,0,180,180,0);
64 | addUpdateListener(animator1,new ValueAnimator.AnimatorUpdateListener() {
65 | @Override
66 | public void onAnimationUpdate(ValueAnimator animation) {
67 | rotateY= (float) animation.getAnimatedValue();
68 | postInvalidate();
69 | }
70 | });
71 | animator1.setInterpolator(new LinearInterpolator());
72 | animator1.setRepeatCount(-1);
73 | animator1.setDuration(2500);
74 |
75 | animators.add(animator);
76 | animators.add(animator1);
77 | return animators;
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/hlibrary/src/main/java/com/hankkin/xlibrary/widget/view/indicators/TriangleSkewSpinIndicator.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary.widget.view.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Camera;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.graphics.Path;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.hankkin.xlibrary.widget.view.Indicator;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by Jack on 2015/10/20.
17 | */
18 | public class TriangleSkewSpinIndicator extends Indicator {
19 |
20 | private float rotateX;
21 | private float rotateY;
22 |
23 | private Camera mCamera;
24 | private Matrix mMatrix;
25 |
26 | public TriangleSkewSpinIndicator(){
27 | mCamera=new Camera();
28 | mMatrix=new Matrix();
29 | }
30 |
31 | @Override
32 | public void draw(Canvas canvas, Paint paint) {
33 |
34 |
35 | mMatrix.reset();
36 | mCamera.save();
37 | mCamera.rotateX(rotateX);
38 | mCamera.rotateY(rotateY);
39 | mCamera.getMatrix(mMatrix);
40 | mCamera.restore();
41 |
42 | mMatrix.preTranslate(-centerX(), -centerY());
43 | mMatrix.postTranslate(centerX(), centerY());
44 | canvas.concat(mMatrix);
45 |
46 | Path path=new Path();
47 | path.moveTo(getWidth()/5,getHeight()*4/5);
48 | path.lineTo(getWidth()*4/5, getHeight()*4/5);
49 | path.lineTo(getWidth()/2,getHeight()/5);
50 | path.close();
51 | canvas.drawPath(path, paint);
52 | }
53 |
54 | @Override
55 | public ArrayList onCreateAnimators() {
56 | ArrayList animators=new ArrayList<>();
57 | ValueAnimator animator=ValueAnimator.ofFloat(0,180,180,0,0);
58 | addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() {
59 | @Override
60 | public void onAnimationUpdate(ValueAnimator animation) {
61 | rotateX= (float) animation.getAnimatedValue();
62 | postInvalidate();
63 | }
64 | });
65 | animator.setInterpolator(new LinearInterpolator());
66 | animator.setRepeatCount(-1);
67 | animator.setDuration(2500);
68 |
69 | ValueAnimator animator1=ValueAnimator.ofFloat(0,0,180,180,0);
70 | addUpdateListener(animator1,new ValueAnimator.AnimatorUpdateListener() {
71 | @Override
72 | public void onAnimationUpdate(ValueAnimator animation) {
73 | rotateY= (float) animation.getAnimatedValue();
74 | postInvalidate();
75 | }
76 | });
77 | animator1.setInterpolator(new LinearInterpolator());
78 | animator1.setRepeatCount(-1);
79 | animator1.setDuration(2500);
80 |
81 | animators.add(animator);
82 | animators.add(animator1);
83 | return animators;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/anim/pickerview_dialog_scale_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/anim/pickerview_dialog_scale_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
18 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/anim/pickerview_slide_in_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/anim/pickerview_slide_out_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/anim/push_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/anim/push_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/layout/dialog_hloading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/layout/dialog_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
20 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/layout/layout_title_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
17 |
18 |
25 |
26 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/layout/layout_title_bar_right_img.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
17 |
18 |
25 |
26 |
33 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/layout/layout_title_bar_right_txt.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
17 |
18 |
25 |
26 |
33 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/layout/view_load_more.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
30 |
31 |
32 |
37 |
38 |
39 |
46 |
47 |
48 |
49 |
54 |
55 |
61 |
62 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/mipmap-xxhdpi/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hankkin/HBase/e276f0702e71c19e68f641047ae43a14ec8a780c/hlibrary/src/main/res/mipmap-xxhdpi/back.png
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00000000
4 | #bb000000
5 | #584F60
6 | #000000
7 | #584F60
8 | #584F60
9 | #FFFFFF
10 | #33ccff
11 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2dp
4 | 4dp
5 | 6dp
6 | 8dp
7 | 10dp
8 | 12dp
9 | 14dp
10 | 16dp
11 | 18dp
12 | 20dp
13 | 48dp
14 |
15 | 10sp
16 | 11sp
17 | 12sp
18 | 13sp
19 | 14sp
20 | 15sp
21 | 16sp
22 | 17sp
23 | 18sp
24 | 20sp
25 | 22sp
26 | 24sp
27 |
28 | 40dp
29 |
30 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @android:integer/config_shortAnimTime
4 | @android:integer/config_longAnimTime
5 |
6 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | XLibrary
3 |
4 |
5 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/styleconfigs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
14 |
15 |
19 |
20 |
24 |
25 |
29 |
30 |
34 |
35 |
39 |
40 |
44 |
45 |
46 |
53 |
54 |
61 |
62 |
69 |
70 |
--------------------------------------------------------------------------------
/hlibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/hlibrary/src/test/java/com/hankkin/xlibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hankkin.xlibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':hlibrary'
2 |
--------------------------------------------------------------------------------