implements Serializable, MultiItemEntity {
9 |
10 | public boolean isHeader;
11 | public T t;
12 | public String header;
13 |
14 | public SectionMultiEntity(boolean isHeader, String header) {
15 | this.isHeader = isHeader;
16 | this.header = header;
17 | this.t = null;
18 | }
19 |
20 | public SectionMultiEntity(T t) {
21 | this.isHeader = false;
22 | this.header = null;
23 | this.t = t;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnItemChildClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 |
7 | /**
8 | * Created by AllenCoder on 2016/8/03.
9 | * A convenience class to extend when you only want to OnItemChildClickListener for a subset
10 | * of all the SimpleClickListener. This implements all methods in the
11 | * {@link SimpleClickListener}
12 | **/
13 |
14 | public abstract class OnItemChildClickListener extends SimpleClickListener {
15 | @Override
16 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
17 |
18 | }
19 |
20 | @Override
21 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
22 |
23 | }
24 |
25 | @Override
26 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
27 | onSimpleItemChildClick(adapter, view, position);
28 | }
29 |
30 | @Override
31 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
32 |
33 | }
34 |
35 | public abstract void onSimpleItemChildClick(BaseQuickAdapter adapter, View view, int position);
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnItemChildLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 |
7 | /**
8 | * Created by AllenCoder on 2016/8/03.
9 | * A convenience class to extend when you only want to OnItemChildLongClickListener for a subset
10 | * of all the SimpleClickListener. This implements all methods in the
11 | * {@link SimpleClickListener}
12 | **/
13 | public abstract class OnItemChildLongClickListener extends SimpleClickListener {
14 | @Override
15 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
16 |
17 | }
18 |
19 | @Override
20 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
21 |
22 | }
23 |
24 | @Override
25 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
26 |
27 | }
28 |
29 | @Override
30 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
31 | onSimpleItemChildLongClick(adapter, view, position);
32 | }
33 |
34 | public abstract void onSimpleItemChildLongClick(BaseQuickAdapter adapter, View view, int position);
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 |
7 | /**
8 | * Created by AllenCoder on 2016/8/03.
9 | *
10 | *
11 | * A convenience class to extend when you only want to OnItemClickListener for a subset
12 | * of all the SimpleClickListener. This implements all methods in the
13 | * {@link SimpleClickListener}
14 | */
15 | public abstract class OnItemClickListener extends SimpleClickListener {
16 | @Override
17 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
18 | onSimpleItemClick(adapter, view, position);
19 | }
20 |
21 | @Override
22 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
23 |
24 | }
25 |
26 | @Override
27 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
28 |
29 | }
30 |
31 | @Override
32 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
33 |
34 | }
35 |
36 | public abstract void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position);
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnItemDragListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 |
5 | /**
6 | * Created by luoxw on 2016/6/20.
7 | */
8 | public interface OnItemDragListener {
9 | void onItemDragStart(RecyclerView.ViewHolder viewHolder, int pos);
10 |
11 | void onItemDragMoving(RecyclerView.ViewHolder source, int from, RecyclerView.ViewHolder target, int to);
12 |
13 | void onItemDragEnd(RecyclerView.ViewHolder viewHolder, int pos);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnItemLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 |
7 | /**
8 | * create by: allen on 16/8/3.
9 | */
10 |
11 | public abstract class OnItemLongClickListener extends SimpleClickListener {
12 | @Override
13 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
14 |
15 | }
16 |
17 | @Override
18 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
19 | onSimpleItemLongClick(adapter, view, position);
20 | }
21 |
22 | @Override
23 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
24 |
25 | }
26 |
27 | @Override
28 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
29 | }
30 |
31 | public abstract void onSimpleItemLongClick(BaseQuickAdapter adapter, View view, int position);
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnItemSwipeListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import android.graphics.Canvas;
4 | import androidx.recyclerview.widget.RecyclerView;
5 |
6 | /**
7 | * Created by luoxw on 2016/6/23.
8 | */
9 | public interface OnItemSwipeListener {
10 | /**
11 | * Called when the swipe action start.
12 | */
13 | void onItemSwipeStart(RecyclerView.ViewHolder viewHolder, int pos);
14 |
15 | /**
16 | * Called when the swipe action is over.
17 | * If you change the view on the start, you should reset is here, no matter the item has swiped or not.
18 | *
19 | * @param pos If the view is swiped, pos will be negative.
20 | */
21 | void clearView(RecyclerView.ViewHolder viewHolder, int pos);
22 |
23 | /**
24 | * Called when item is swiped, the view is going to be removed from the adapter.
25 | */
26 | void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos);
27 |
28 | /**
29 | * Draw on the empty edge when swipe moving
30 | *
31 | * @param canvas the empty edge's canvas
32 | * @param viewHolder The ViewHolder which is being interacted by the User or it was
33 | * interacted and simply animating to its original position
34 | * @param dX The amount of horizontal displacement caused by user's action
35 | * @param dY The amount of vertical displacement caused by user's action
36 | * @param isCurrentlyActive True if this view is currently being controlled by the user or
37 | * false it is simply animating back to its original state.
38 | */
39 | void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive);
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/listener/OnRecyclerItemClickEventListener.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 |
7 | /**
8 | * User: fee(1176610771@qq.com)
9 | * Date: 2016-12-16
10 | * Time: 16:55
11 | * DESC: 提供给RecyclerView item的各点击事件,也可以直接使用SimpleClickListener
12 | * 包含的监听的事件类型为:
13 | * 1、onItemClick()整个item布局的点击事件
14 | * 2、onItemLongClick() 整个item布局的长按事件
15 | * 3、onItemChildClick() item布局内的各子类View的点击事件
16 | * 4、onItemChildLongClick() item布局内的各子类View的长按事件
17 | * 本类抽象出onItemClick(),即为主要用来监听整个Item布局的点击事件
18 | * 也可以重写剩下其他的click事件来处理item中的所有view的click事件
19 | */
20 | public abstract class OnRecyclerItemClickEventListener extends SimpleClickListener{
21 | /**
22 | * callback method to be invoked when an item in this view has been
23 | * click and held
24 | *
25 | * @param adapter
26 | * @param view The view whihin the AbsListView that was clicked
27 | * @param position The position of the view int the adapter
28 | * @return true if the callback consumed the long click ,false otherwise
29 | */
30 | @Override
31 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
32 |
33 | }
34 |
35 | @Override
36 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
37 |
38 | }
39 |
40 | @Override
41 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/loadmore/SimpleLoadMoreView.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.loadmore;
2 |
3 |
4 | import common.base.R;
5 |
6 | /**
7 | * Created by BlingBling on 2016/10/11.
8 | */
9 |
10 | public final class SimpleLoadMoreView extends LoadMoreView {
11 |
12 | @Override
13 | public int getLayoutId() {
14 | return R.layout.quick_view_load_more;
15 | }
16 |
17 | @Override
18 | protected int getLoadingViewId() {
19 | return R.id.load_more_loading_view;
20 | }
21 |
22 | @Override
23 | protected int getLoadFailViewId() {
24 | return R.id.load_more_load_fail_view;
25 | }
26 |
27 | @Override
28 | protected int getLoadEndViewId() {
29 | return R.id.load_more_load_end_view;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/provider/BaseItemProvider.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.provider;
2 |
3 | import android.content.Context;
4 |
5 | import com.chad.library.adapter.base.BaseViewHolder;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * https://github.com/chaychan
11 | * @author ChayChan
12 | * @description: The base class of ItemProvider
13 | * @date 2018/3/21 10:41
14 | */
15 |
16 | public abstract class BaseItemProvider {
17 |
18 | public Context mContext;
19 | public List mData;
20 |
21 | //子类须重写该方法返回viewType
22 | //Rewrite this method to return viewType
23 | public abstract int viewType();
24 |
25 | //子类须重写该方法返回layout
26 | //Rewrite this method to return layout
27 | public abstract int layout();
28 |
29 | public abstract void convert(V helper, T data, int position);
30 |
31 | //子类若想实现条目点击事件则重写该方法
32 | //Subclasses override this method if you want to implement an item click event
33 | public void onClick(V helper, T data, int position){};
34 |
35 | //子类若想实现条目长按事件则重写该方法
36 | //Subclasses override this method if you want to implement an item long press event
37 | public boolean onLongClick(V helper, T data, int position){return false;};
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/util/ItemProviderException.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.util;
2 |
3 | /**
4 | * @author ChayChan
5 | * @description: ItemProviderException
6 | * @date 2018/4/12 9:10
7 | */
8 |
9 | public class ItemProviderException extends NullPointerException {
10 |
11 | public ItemProviderException(String message) {
12 | super(message);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/util/ProviderDelegate.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.util;
2 |
3 | import android.util.SparseArray;
4 |
5 | import com.chad.library.adapter.base.provider.BaseItemProvider;
6 |
7 | /**
8 | * https://github.com/chaychan
9 | * @author ChayChan
10 | * @date 2018/3/21 11:04
11 | */
12 |
13 | public class ProviderDelegate {
14 |
15 | private SparseArray mItemProviders = new SparseArray<>();
16 |
17 | public void registerProvider(BaseItemProvider provider){
18 | if (provider == null){
19 | throw new ItemProviderException("ItemProvider can not be null");
20 | }
21 |
22 | int viewType = provider.viewType();
23 |
24 | if (mItemProviders.get(viewType) == null){
25 | mItemProviders.put(viewType,provider);
26 | }
27 | }
28 |
29 | public SparseArray getItemProviders(){
30 | return mItemProviders;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/chad/library/adapter/base/util/TouchEventUtil.java:
--------------------------------------------------------------------------------
1 | package com.chad.library.adapter.base.util;
2 |
3 | import android.view.MotionEvent;
4 |
5 | public class TouchEventUtil {
6 |
7 | public static String getTouchAction(int actionId) {
8 | String actionName = "Unknow:id=" + actionId;
9 | switch (actionId) {
10 | case MotionEvent.ACTION_DOWN:
11 | actionName = "ACTION_DOWN";
12 | break;
13 | case MotionEvent.ACTION_MOVE:
14 | actionName = "ACTION_MOVE";
15 | break;
16 | case MotionEvent.ACTION_UP:
17 | actionName = "ACTION_UP";
18 | break;
19 | case MotionEvent.ACTION_CANCEL:
20 | actionName = "ACTION_CANCEL";
21 | break;
22 | case MotionEvent.ACTION_OUTSIDE:
23 | actionName = "ACTION_OUTSIDE";
24 | break;
25 | }
26 | return actionName;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/anim/BaseAnimator.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.anim;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.view.View;
6 | import android.view.animation.Interpolator;
7 |
8 |
9 | public abstract class BaseAnimator {
10 | protected long mDuration = 500;
11 |
12 | protected AnimatorSet mAnimatorSet = new AnimatorSet();
13 | private Interpolator mInterpolator;
14 | private long mDelay;
15 | public abstract void setAnimation(View view);
16 |
17 | protected void start(final View view) {
18 | reset(view);
19 | setAnimation(view);
20 |
21 | mAnimatorSet.setDuration(mDuration);
22 | if (mInterpolator != null) {
23 | mAnimatorSet.setInterpolator(mInterpolator);
24 | }
25 | if (mDelay > 0) {
26 | mAnimatorSet.setStartDelay(mDelay);
27 | }
28 | mAnimatorSet.start();
29 | }
30 |
31 | public static void reset(View view) {
32 | if (view == null) {
33 | return;
34 | }
35 | view.setAlpha(1);
36 | view.setScaleX(1);
37 | view.setScaleY(1);
38 | view.setTranslationX(0);
39 | view.setTranslationY(0);
40 | view.setRotation(0);
41 | view.setRotationY(0);
42 | view.setRotationX(0);
43 | }
44 |
45 | public BaseAnimator duration(long duration) {
46 | this.mDuration = duration;
47 | return this;
48 | }
49 |
50 | public BaseAnimator delay(long delay) {
51 | this.mDelay = delay;
52 | return this;
53 | }
54 |
55 | public BaseAnimator interpolator(Interpolator interpolator) {
56 | this.mInterpolator = interpolator;
57 | return this;
58 | }
59 |
60 | public BaseAnimator listener(Animator.AnimatorListener listener) {
61 | if (mAnimatorSet != null) {
62 | mAnimatorSet.addListener(listener);
63 | }
64 | return this;
65 | }
66 |
67 | public void playOn(View view) {
68 | start(view);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/anim/select/RotateEnter.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.anim.select;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.view.View;
5 | import com.flyco.banner.anim.BaseAnimator;
6 |
7 | public class RotateEnter extends BaseAnimator {
8 | public RotateEnter() {
9 | this.mDuration = 200;
10 | }
11 |
12 | public void setAnimation(View view) {
13 | this.mAnimatorSet.playTogether(ObjectAnimator.ofFloat(view, "rotation", 0, 180)
14 | );
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/anim/select/ZoomInEnter.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.anim.select;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.view.View;
5 |
6 | import com.flyco.banner.anim.BaseAnimator;
7 |
8 | public class ZoomInEnter extends BaseAnimator {
9 | public ZoomInEnter() {
10 | this.mDuration = 200;
11 | }
12 |
13 | public void setAnimation(View view) {
14 | this.mAnimatorSet.playTogether(
15 | ObjectAnimator.ofFloat(view, "scaleX",
16 | 1.0F, 1.5F
17 | ),
18 | ObjectAnimator.ofFloat(view, "scaleY", 1.0F, 1.5F)
19 | );
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/anim/unselect/NoAnimExist.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.anim.unselect;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.view.View;
5 |
6 | import com.flyco.banner.anim.BaseAnimator;
7 |
8 | public class NoAnimExist extends BaseAnimator {
9 | public NoAnimExist() {
10 | this.mDuration = 200;
11 | }
12 |
13 | public void setAnimation(View view) {
14 | this.mAnimatorSet.playTogether(
15 | ObjectAnimator.ofFloat(view, "alpha", 1, 1));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/transform/DepthTransformer.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.transform;
2 |
3 | import android.view.View;
4 | import androidx.viewpager.widget.ViewPager;
5 |
6 |
7 | public class DepthTransformer implements ViewPager.PageTransformer {
8 | private static final float MIN_SCALE_DEPTH = 0.75f;
9 |
10 | @Override
11 | public void transformPage(View page, float position) {
12 | float alpha, scale, translationX;
13 | if (position > 0 && position < 1) {
14 | // moving to the right
15 | alpha = (1 - position);
16 | scale = MIN_SCALE_DEPTH + (1 - MIN_SCALE_DEPTH) * (1 - Math.abs(position));
17 | translationX = (page.getWidth() * -position);
18 | } else {
19 | // use default for all other cases
20 | alpha = 1;
21 | scale = 1;
22 | translationX = 0;
23 | }
24 |
25 | page.setAlpha(alpha);
26 | page.setTranslationX(translationX);
27 | page.setScaleX(scale);
28 | page.setScaleY(scale);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/transform/FadeSlideTransformer.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.transform;
2 |
3 | import android.view.View;
4 | import androidx.viewpager.widget.ViewPager;
5 |
6 | public class FadeSlideTransformer implements ViewPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(0);
11 |
12 | if (position <= -1.0F || position >= 1.0F) {
13 | page.setAlpha( 0.0F);
14 | } else if (position == 0.0F) {
15 | page.setAlpha( 1.0F);
16 | } else {
17 | // position is between -1.0F & 0.0F OR 0.0F & 1.0F
18 | page.setAlpha( 1.0F - Math.abs(position));
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/transform/FlowTransformer.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.transform;
2 |
3 | import androidx.viewpager.widget.ViewPager;
4 | import android.view.View;
5 |
6 | public class FlowTransformer implements ViewPager.PageTransformer {
7 |
8 | @Override
9 | public void transformPage(View page, float position) {
10 | page.setRotationY( position * -30f);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/transform/RotateDownTransformer.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.transform;
2 |
3 | import androidx.viewpager.widget.ViewPager;
4 | import android.view.View;
5 |
6 | public class RotateDownTransformer implements ViewPager.PageTransformer {
7 |
8 | private static final float ROT_MOD = -15f;
9 |
10 | @Override
11 | public void transformPage(View page, float position) {
12 | final float width = page.getWidth();
13 | final float height = page.getHeight();
14 | final float rotation = ROT_MOD * position * -1.25f;
15 |
16 | page.setPivotX(width * 0.5f);
17 | page.setPivotY(height);
18 | page.setRotation(rotation);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/transform/RotateUpTransformer.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.transform;
2 |
3 | import androidx.viewpager.widget.ViewPager;
4 | import android.view.View;
5 |
6 | public class RotateUpTransformer implements ViewPager.PageTransformer {
7 |
8 | private static final float ROT_MOD = -15f;
9 |
10 | @Override
11 | public void transformPage(View page, float position) {
12 | final float width = page.getWidth();
13 | final float rotation = ROT_MOD * position;
14 |
15 | page.setPivotX(width * 0.5f);
16 | page.setPivotY(0f);
17 | page.setTranslationX(0f);
18 | page.setRotation(rotation);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/transform/ZoomOutSlideTransformer.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.transform;
2 |
3 | import androidx.viewpager.widget.ViewPager;
4 | import android.view.View;
5 |
6 | public class ZoomOutSlideTransformer implements ViewPager.PageTransformer {
7 |
8 | private static final float MIN_SCALE = 0.85f;
9 | private static final float MIN_ALPHA = 0.9f;
10 |
11 | @Override
12 | public void transformPage(View page, float position) {
13 | if (position >= -1 || position <= 1) {
14 | // Modify the default slide transition to shrink the page as well
15 | final float height = page.getHeight();
16 | final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
17 | final float vertMargin = height * (1 - scaleFactor) / 2;
18 | final float horzMargin = page.getWidth() * (1 - scaleFactor) / 2;
19 |
20 | // Center vertically
21 | page.setPivotY(0.5f * height);
22 |
23 |
24 | if (position < 0) {
25 | page.setTranslationX(horzMargin - vertMargin / 2);
26 | } else {
27 | page.setTranslationX(-horzMargin + vertMargin / 2);
28 | }
29 |
30 | // Scale the page down (between MIN_SCALE and 1)
31 | page.setScaleX(scaleFactor);
32 | page.setScaleY(scaleFactor);
33 |
34 | // Fade the page relative to its size.
35 | page.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/widget/Banner/BaseGuideBanner.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.widget.Banner;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import common.base.R;
7 |
8 | /**
9 | * ******************(^_^)***********************
10 | * User: 11776610771@qq.com
11 | * Date: 2017/4/6
12 | * Time: 14:18
13 | * DESC: 泛型X,为继承基类的数据集的类型,可以是任意的类型
14 | * ******************(^_^)***********************
15 | */
16 |
17 | public abstract class BaseGuideBanner extends BaseIndicatorBanner {
18 |
19 | public BaseGuideBanner(Context context) {
20 | this(context, null);
21 | }
22 |
23 | public BaseGuideBanner(Context context, AttributeSet attrs) {
24 | this(context, attrs, R.style.base_guide_banner);
25 | }
26 | public BaseGuideBanner(Context context, AttributeSet attrs, int defStyle) {
27 | super(context, attrs, defStyle);
28 | setBarShowWhenLast(false);//在滑动到最后一页时不显示指示器布局
29 | }
30 |
31 | /**
32 | * 于基类的PagerAdapter中初始化Item布局时调用
33 | * @param position
34 | * @return
35 | */
36 | @Override
37 | public final View onCreateItemView(int position) {
38 | View curItemView;
39 | X itemData = mDatas.get(position);
40 | if (itemData instanceof View) {//可以直接装入各导航页(视图View)的Item数据集
41 | curItemView = (View) itemData;
42 | } else {
43 | curItemView = getItemViewBaseData(itemData, position);
44 | }
45 | initGuideView(curItemView, position);
46 | return curItemView;
47 | }
48 |
49 | /**
50 | * 根据提供的数据集来获取每一页的视图
51 | * @param itemData
52 | * @param itemPosition
53 | * @return
54 | */
55 | protected abstract View getItemViewBaseData(X itemData,int itemPosition);
56 |
57 | /**
58 | * 初始化当前的导航页的视图,这个要交给具体子类去实现,因为本基类不知道,滑动导航到各页时,需要初始化哪些子View,并且不知道要做什么
59 | * @param curView 当前的导航页(视图)
60 | * @param curViewPosition 当前导航页(视图)的位置
61 | */
62 | public abstract void initGuideView(View curView, int curViewPosition);
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/widget/Banner/JustImageViewBanner.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.widget.Banner;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 |
11 | /**
12 | * ******************(^_^)***********************
13 | * User: 11776610771@qq.com
14 | * Date: 2017/4/25
15 | * Time: 16:08
16 | * DESC:
17 | * ******************(^_^)***********************
18 | */
19 |
20 | public class JustImageViewBanner extends BaseIndicatorBanner{
21 | /**
22 | * 默认的占位Drawable
23 | */
24 | protected ColorDrawable defHolderColorDrawable;
25 | public JustImageViewBanner(Context context) {
26 | this(context,null);
27 | }
28 |
29 | public JustImageViewBanner(Context context, AttributeSet attrs) {
30 | this(context, attrs,0);
31 | }
32 |
33 | public JustImageViewBanner(Context context, AttributeSet attrs, int defStyle) {
34 | super(context, attrs, defStyle);
35 | defHolderColorDrawable = new ColorDrawable(Color.parseColor("#555555"));
36 | }
37 |
38 | /**
39 | * 创建ViewPager的Item布局
40 | *
41 | * @param position
42 | */
43 | @Override
44 | public View onCreateItemView(int position) {
45 | ImageView ivBanner = new ImageView(mContext);
46 | ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
47 | ivBanner.setLayoutParams(vlp);
48 | bindImage2BannerView(ivBanner,position);
49 | return ivBanner;
50 | }
51 |
52 | protected void bindImage2BannerView(ImageView theJustImageView,int curInitPosition) {
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/flyco/banner/widget/LoopViewPager/FixedSpeedScroller.java:
--------------------------------------------------------------------------------
1 | package com.flyco.banner.widget.LoopViewPager;
2 |
3 | import android.content.Context;
4 | import android.view.animation.Interpolator;
5 | import android.widget.Scroller;
6 |
7 | public class FixedSpeedScroller extends Scroller {
8 | private int mScrollSpeed = 450;
9 |
10 | public FixedSpeedScroller(Context context) {
11 | super(context);
12 | }
13 |
14 | public FixedSpeedScroller(Context context, Interpolator interpolator, int scrollSpeed) {
15 | super(context, interpolator);
16 | this.mScrollSpeed = scrollSpeed;
17 | }
18 |
19 | @Override
20 | public void startScroll(int startX, int startY, int dx, int dy, int duration) {
21 | super.startScroll(startX, startY, dx, dy, this.mScrollSpeed);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/adapter/AdapterParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.adapter;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:2017/5/26
23 | * 描 述:
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public class AdapterParam {
28 | public boolean isAsync;
29 |
30 | public AdapterParam() {
31 | isAsync = true;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/adapter/Call.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.adapter;
17 |
18 | import com.lzy.okgo.callback.Callback;
19 | import com.lzy.okgo.model.Response;
20 | import com.lzy.okgo.request.base.Request;
21 |
22 | /**
23 | * ================================================
24 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
25 | * 版 本:1.0
26 | * 创建日期:2016/9/11
27 | * 描 述:请求的包装类
28 | * 修订历史:
29 | * ================================================
30 | */
31 | public interface Call {
32 | /** 同步执行 */
33 | Response execute() throws Exception;
34 |
35 | /** 异步回调执行 */
36 | void execute(Callback callback);
37 |
38 | /** 是否已经执行 */
39 | boolean isExecuted();
40 |
41 | /** 取消 */
42 | void cancel();
43 |
44 | /** 是否取消 */
45 | boolean isCanceled();
46 |
47 | Call clone();
48 |
49 | Request getRequest();
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/adapter/CallAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.adapter;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:16/9/11
23 | * 描 述:返回值的适配器
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public interface CallAdapter {
28 |
29 | /** call执行的代理方法 */
30 | R adapt(Call call, AdapterParam param);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/adapter/DefaultCallAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.adapter;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:2016/9/11
23 | * 描 述:默认的工厂处理,不对返回值做任何操作
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public class DefaultCallAdapter implements CallAdapter> {
28 |
29 | @Override
30 | public Call adapt(Call call, AdapterParam param) {
31 | return call;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/cache/CacheMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.cache;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:16/9/11
23 | * 描 述:
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public enum CacheMode {
28 | /** 按照HTTP协议的默认缓存规则,例如有304响应头时缓存 */
29 | DEFAULT,
30 |
31 | /** 不使用缓存 */
32 | NO_CACHE,
33 |
34 | /** 请求网络失败后,读取缓存 */
35 | REQUEST_FAILED_READ_CACHE,
36 |
37 | /** 如果缓存不存在才请求网络,否则使用缓存 */
38 | IF_NONE_CACHE_REQUEST,
39 |
40 | /** 先使用缓存,不管是否存在,仍然请求网络 */
41 | FIRST_CACHE_THEN_REQUEST,
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/cache/policy/CommonCachePolicy.java:
--------------------------------------------------------------------------------
1 | package com.lzy.okgo.cache.policy;
2 |
3 | import com.lzy.okgo.model.Response;
4 | import com.lzy.okgo.request.base.Request;
5 |
6 | /**
7 | * ******************(^_^)***********************
8 | * User: fee(QQ/WeiXin:1176610771)
9 | * Date: 2020/4/7
10 | * Time: 20:00
11 | * DESC:
12 | * 通用的缓存策略
13 | *
14 | * ******************(^_^)***********************
15 | */
16 | public abstract class CommonCachePolicy extends BaseCachePolicy {
17 |
18 | public CommonCachePolicy(Request request) {
19 | super(request);
20 | }
21 |
22 | /**
23 | * 获取数据成功的回调
24 | *
25 | * @param success 获取的数据,可是是缓存或者网络
26 | */
27 | @Override
28 | public void onSuccess(final Response success) {
29 | if (mCallback != null) {
30 | runOnUiThread(new Runnable() {
31 | @Override
32 | public void run() {
33 | callbackOnSuccess(success);
34 | callbackOnFinish();
35 | }
36 | });
37 | }
38 | }
39 |
40 | /**
41 | * 获取数据失败的回调
42 | *
43 | * @param error 失败的信息,可是是缓存或者网络
44 | */
45 | @Override
46 | public void onError(final Response error) {
47 | if (mCallback != null) {
48 | runOnUiThread(new Runnable() {
49 | @Override
50 | public void run() {
51 | callbackOnError(error);
52 | callbackOnFinish();
53 | }
54 | });
55 | }
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/callback/AbsCallbackWrapper.java:
--------------------------------------------------------------------------------
1 | package com.lzy.okgo.callback;
2 |
3 | import okhttp3.Response;
4 |
5 | /**
6 | * ================================================
7 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
8 | * 版 本:1.0
9 | * 创建日期:16/9/11
10 | * 描 述:所有回调的包装类,空实现
11 | * 修订历史:
12 | * ================================================
13 | */
14 | public class AbsCallbackWrapper extends AbsCallback {
15 | /**
16 | * 拿到响应后,将数据转换成需要的格式,子线程中执行,可以是耗时操作
17 | *
18 | * @param response 需要转换的对象
19 | * @return 转换后的结果
20 | * @throws Exception 转换过程发生的异常
21 | */
22 | @Override
23 | public T convertResponse(Response response) throws Throwable {
24 | if (response != null) {
25 | response.close();
26 | return (T) response;
27 | }
28 | return null;
29 | }
30 |
31 | //deleted since OkGo ver 3.0
32 | // @Override
33 | // public T convertSuccess(Response value) throws Exception {
34 | // value.close();
35 | // return (T) value;
36 | // }
37 |
38 | //deleted since OkGo ver 3.0
39 | // @Override
40 | // public void onSuccess(T t, Call call, Response response) {
41 | // }
42 |
43 | /**
44 | * 对返回数据进行操作的回调, UI线程
45 | *
46 | * @param response
47 | */
48 | @Override
49 | public void onSuccess(com.lzy.okgo.model.Response response) {
50 |
51 | }
52 |
53 |
54 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/callback/BitmapCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.callback;
17 |
18 | import android.graphics.Bitmap;
19 | import android.widget.ImageView;
20 |
21 | import com.lzy.okgo.convert.BitmapConvert;
22 |
23 | import okhttp3.Response;
24 |
25 | /**
26 | * ================================================
27 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
28 | * 版 本:1.0
29 | * 创建日期:2016/1/12
30 | * 描 述:返回图片的Bitmap,这里没有进行图片的缩放,可能会发生 OOM
31 | * 修订历史:
32 | * ================================================
33 | */
34 | public abstract class BitmapCallback extends AbsCallback {
35 |
36 | private BitmapConvert convert;
37 |
38 | public BitmapCallback() {
39 | convert = new BitmapConvert();
40 | }
41 |
42 | public BitmapCallback(int maxWidth, int maxHeight) {
43 | convert = new BitmapConvert(maxWidth, maxHeight);
44 | }
45 |
46 | public BitmapCallback(int maxWidth, int maxHeight, Bitmap.Config decodeConfig, ImageView.ScaleType scaleType) {
47 | convert = new BitmapConvert(maxWidth, maxHeight, decodeConfig, scaleType);
48 | }
49 |
50 | @Override
51 | public Bitmap convertResponse(Response response) throws Throwable {
52 | Bitmap bitmap = convert.convertResponse(response);
53 | response.close();
54 | return bitmap;
55 | }
56 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/callback/FileCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.callback;
17 |
18 | import com.lzy.okgo.convert.FileConvert;
19 |
20 | import java.io.File;
21 |
22 | import okhttp3.Response;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/12
29 | * 描 述:文件的回调下载进度监听
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public abstract class FileCallback extends AbsCallback {
34 |
35 | private FileConvert convert; //文件转换类
36 |
37 | public FileCallback() {
38 | this(null);
39 | }
40 |
41 | public FileCallback(String destFileName) {
42 | this(null, destFileName);
43 | }
44 |
45 | public FileCallback(String destFileDir, String destFileName) {
46 | convert = new FileConvert(destFileDir, destFileName);
47 | convert.setCallback(this);
48 | }
49 |
50 | @Override
51 | public File convertResponse(Response response) throws Throwable {
52 | File file = convert.convertResponse(response);
53 | response.close();
54 | return file;
55 | }
56 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/callback/JustStringCallback.java:
--------------------------------------------------------------------------------
1 | package com.lzy.okgo.callback;
2 |
3 | import java.lang.ref.WeakReference;
4 |
5 | import common.base.netAbout.INetEvent;
6 | import okhttp3.Response;
7 |
8 | /**
9 | * ******************(^_^)***********************
10 | * User: fee(QQ/WeiXin:1176610771)
11 | * Date: 2019/1/17
12 | * Time: 20:24
13 | * DESC:
14 | *
15 | * ******************(^_^)***********************
16 | */
17 | public class JustStringCallback extends StringCallback {
18 | protected WeakReference> weakRefNetEvent;
19 |
20 | public JustStringCallback(INetEvent event) {
21 | if (event != null) {
22 | weakRefNetEvent = new WeakReference<>(event);
23 | }
24 | }
25 |
26 |
27 |
28 |
29 | @Override
30 | public void onSuccess(String s, Response response) {
31 | INetEvent netEvent = getNetEvent();
32 | if (netEvent != null) {
33 | netEvent.onResponse(requestType,s);
34 | }
35 | // if (getNetEvent() != null) {
36 | // getNetEvent().onResponse(requestType,s);
37 | // }
38 | }
39 |
40 | @Override
41 | public void onError(Exception e) {
42 | if (getNetEvent() != null) {
43 | String errorInfo = INetEvent.ERR_UNKNOW;
44 | if (e != null) {
45 | errorInfo = e.toString();
46 | }
47 | getNetEvent().onErrorResponse(requestType,errorInfo);
48 | }
49 | }
50 |
51 | private INetEvent getNetEvent() {
52 | if (weakRefNetEvent != null) {
53 | return weakRefNetEvent.get();
54 | }
55 | return null;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/callback/StringCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.callback;
17 |
18 | import com.lzy.okgo.convert.StringConvert;
19 |
20 | import okhttp3.Response;
21 |
22 | /**
23 | * ================================================
24 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
25 | * 版 本:1.0
26 | * 创建日期:2016/9/11
27 | * 描 述:返回字符串类型的数据
28 | * 修订历史:
29 | * ================================================
30 | */
31 | public abstract class StringCallback extends AbsCallback {
32 |
33 | private StringConvert convert;
34 |
35 | public StringCallback() {
36 | convert = new StringConvert();
37 | }
38 |
39 | @Override
40 | public String convertResponse(Response response) throws Throwable {
41 | String s = convert.convertResponse(response);
42 | response.close();
43 | return s;
44 | }
45 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/convert/Converter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.convert;
17 |
18 | import okhttp3.Response;
19 |
20 | /**
21 | * ================================================
22 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
23 | * 版 本:1.0
24 | * 创建日期:2016/9/11
25 | * 描 述:网络数据的转换接口
26 | * 修订历史:
27 | * ================================================
28 | */
29 | public interface Converter {
30 |
31 | /**
32 | * 拿到响应后,将数据转换成需要的格式,子线程中执行,可以是耗时操作
33 | *
34 | * @param response 需要转换的对象
35 | * @return 转换后的结果
36 | * @throws Exception 转换过程发生的异常
37 | */
38 | T convertResponse(Response response) throws Throwable;
39 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/convert/StringConvert.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.convert;
17 |
18 | import okhttp3.Response;
19 | import okhttp3.ResponseBody;
20 |
21 | /**
22 | * ================================================
23 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
24 | * 版 本:1.0
25 | * 创建日期:16/9/11
26 | * 描 述:字符串的转换器
27 | * 修订历史:
28 | * ================================================
29 | */
30 | public class StringConvert implements Converter {
31 |
32 | @Override
33 | public String convertResponse(Response response) throws Throwable {
34 | ResponseBody body = response.body();
35 | if (body == null) return null;
36 | return body.string();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/cookie/CookieJarImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.cookie;
17 |
18 | import com.lzy.okgo.cookie.store.CookieStore;
19 |
20 | import java.util.List;
21 |
22 | import okhttp3.Cookie;
23 | import okhttp3.CookieJar;
24 | import okhttp3.HttpUrl;
25 |
26 | /**
27 | * ================================================
28 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
29 | * 版 本:1.0
30 | * 创建日期:2016/1/12
31 | * 描 述:CookieJar的实现类,默认管理了用户自己维护的cookie
32 | * 修订历史:
33 | * ================================================
34 | */
35 | public class CookieJarImpl implements CookieJar {
36 |
37 | private CookieStore cookieStore;
38 |
39 | public CookieJarImpl(CookieStore cookieStore) {
40 | if (cookieStore == null) {
41 | throw new IllegalArgumentException("cookieStore can not be null!");
42 | }
43 | this.cookieStore = cookieStore;
44 | }
45 |
46 | @Override
47 | public synchronized void saveFromResponse(HttpUrl url, List cookies) {
48 | cookieStore.saveCookie(url, cookies);
49 | }
50 |
51 | @Override
52 | public synchronized List loadForRequest(HttpUrl url) {
53 | return cookieStore.loadCookie(url);
54 | }
55 |
56 | public CookieStore getCookieStore() {
57 | return cookieStore;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/cookie/store/CookieStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.cookie.store;
17 |
18 | import java.util.List;
19 |
20 | import okhttp3.Cookie;
21 | import okhttp3.HttpUrl;
22 |
23 | /**
24 | * ================================================
25 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
26 | * 版 本:1.0
27 | * 创建日期:2016/1/14
28 | * 描 述:CookieStore 的公共接口
29 | * 修订历史:
30 | * ================================================
31 | */
32 | public interface CookieStore {
33 |
34 | /** 保存url对应所有cookie */
35 | void saveCookie(HttpUrl url, List cookie);
36 |
37 | /** 保存url对应所有cookie */
38 | void saveCookie(HttpUrl url, Cookie cookie);
39 |
40 | /** 加载url所有的cookie */
41 | List loadCookie(HttpUrl url);
42 |
43 | /** 获取当前所有保存的cookie */
44 | List getAllCookie();
45 |
46 | /** 获取当前url对应的所有的cookie */
47 | List getCookie(HttpUrl url);
48 |
49 | /** 根据url和cookie移除对应的cookie */
50 | boolean removeCookie(HttpUrl url, Cookie cookie);
51 |
52 | /** 根据url移除所有的cookie */
53 | boolean removeCookie(HttpUrl url);
54 |
55 | /** 移除所有的cookie */
56 | boolean removeAllCookie();
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/exception/CacheException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.exception;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:16/8/28
23 | * 描 述:
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public class CacheException extends Exception {
28 | private static final long serialVersionUID = 845628123701073013L;
29 |
30 | public CacheException(String detailMessage) {
31 | super(detailMessage);
32 | }
33 |
34 | public static CacheException NON_OR_EXPIRE(String cacheKey) {
35 | return new CacheException("cacheKey = " + cacheKey + " ,can't find cache by cacheKey, or cache has expired!");
36 | }
37 |
38 | public static CacheException NON_AND_304(String cacheKey) {
39 | return new CacheException("the http response code is 304, but the cache with cacheKey = " + cacheKey + " is null or expired!");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/exception/OkGoException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.exception;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:16/8/28
23 | * 描 述:
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public class OkGoException extends Exception {
28 | private static final long serialVersionUID = -8641198158155821498L;
29 |
30 | public OkGoException(String detailMessage) {
31 | super(detailMessage);
32 | }
33 |
34 | public static OkGoException UNKNOWN() {
35 | return new OkGoException("unknown exception!");
36 | }
37 |
38 | public static OkGoException BREAKPOINT_NOT_EXIST() {
39 | return new OkGoException("breakpoint file does not exist!");
40 | }
41 |
42 | public static OkGoException BREAKPOINT_EXPIRED() {
43 | return new OkGoException("breakpoint file has expired!");
44 | }
45 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/exception/StorageException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.exception;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:16/9/11
23 | * 描 述:
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public class StorageException extends Exception {
28 |
29 | private static final long serialVersionUID = 178946465L;
30 |
31 | public StorageException() {
32 | }
33 |
34 | public StorageException(String detailMessage) {
35 | super(detailMessage);
36 | }
37 |
38 | public StorageException(String detailMessage, Throwable throwable) {
39 | super(detailMessage, throwable);
40 | }
41 |
42 | public StorageException(Throwable throwable) {
43 | super(throwable);
44 | }
45 |
46 | public static StorageException NOT_AVAILABLE() {
47 | return new StorageException("SDCard isn't available, please check SD card and permission: WRITE_EXTERNAL_STORAGE, and you must pay attention to Android6.0 RunTime Permissions!");
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/model/HttpMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.model;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:2017/5/24
23 | * 描 述:
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public enum HttpMethod {
28 | GET("GET"),
29 |
30 | POST("POST"),
31 |
32 | PUT("PUT"),
33 |
34 | DELETE("DELETE"),
35 |
36 | HEAD("HEAD"),
37 |
38 | PATCH("PATCH"),
39 |
40 | OPTIONS("OPTIONS"),
41 |
42 | TRACE("TRACE");
43 |
44 | private final String value;
45 |
46 | HttpMethod(String value) {
47 | this.value = value;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | return this.value;
53 | }
54 |
55 | public boolean hasBody() {
56 | switch (this) {
57 | case POST:
58 | case PUT:
59 | case PATCH:
60 | case DELETE:
61 | case OPTIONS:
62 | return true;
63 | default:
64 | return false;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/model/Priority.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.model;
17 |
18 | /**
19 | * ================================================
20 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
21 | * 版 本:1.0
22 | * 创建日期:2016/1/19
23 | * 描 述:优先级的枚举类
24 | * 修订历史:
25 | * ================================================
26 | */
27 | public interface Priority {
28 | int UI_TOP = Integer.MAX_VALUE;
29 | int UI_NORMAL = 1000;
30 | int UI_LOW = 100;
31 | int DEFAULT = 0;
32 | int BG_TOP = -100;
33 | int BG_NORMAL = -1000;
34 | int BG_LOW = Integer.MIN_VALUE;
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/DeleteRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.BodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/16
29 | * 描 述:
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class DeleteRequest extends BodyRequest> {
34 |
35 | public DeleteRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.DELETE;
42 | }
43 |
44 | @Override
45 | public Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.delete(requestBody).url(url).tag(tag).build();
48 | }
49 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/GetRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.NoBodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/12
29 | * 描 述:Get请求的实现类,注意需要传入本类的泛型
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class GetRequest extends NoBodyRequest> {
34 |
35 | public GetRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.GET;
42 | }
43 |
44 | @Override
45 | public okhttp3.Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.get().url(url).tag(tag).build();
48 | }
49 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/HeadRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.NoBodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/16
29 | * 描 述:
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class HeadRequest extends NoBodyRequest> {
34 |
35 | public HeadRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.HEAD;
42 | }
43 |
44 | @Override
45 | public okhttp3.Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.head().url(url).tag(tag).build();
48 | }
49 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/OptionsRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.BodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/16
29 | * 描 述:Options请求
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class OptionsRequest extends BodyRequest> {
34 |
35 | public OptionsRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.OPTIONS;
42 | }
43 |
44 | @Override
45 | public Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.method("OPTIONS", requestBody).url(url).tag(tag).build();
48 | }
49 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/PatchRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.BodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/16
29 | * 描 述:
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class PatchRequest extends BodyRequest> {
34 |
35 | public PatchRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.PATCH;
42 | }
43 |
44 | @Override
45 | public Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.patch(requestBody).url(url).tag(tag).build();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/PostRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.BodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/12
29 | * 描 述:Post请求的实现类,注意需要传入本类的泛型
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class PostRequest extends BodyRequest> {
34 |
35 | public PostRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.POST;
42 | }
43 |
44 | @Override
45 | public Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.post(requestBody).url(url).tag(tag).build();
48 | }
49 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/PutRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.BodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/16
29 | * 描 述:
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class PutRequest extends BodyRequest> {
34 |
35 | public PutRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.PUT;
42 | }
43 |
44 | @Override
45 | public Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.put(requestBody).url(url).tag(tag).build();
48 | }
49 | }
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/TraceRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 jeasonlzy(廖子尧)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.lzy.okgo.request;
17 |
18 | import com.lzy.okgo.model.HttpMethod;
19 | import com.lzy.okgo.request.base.NoBodyRequest;
20 |
21 | import okhttp3.Request;
22 | import okhttp3.RequestBody;
23 |
24 | /**
25 | * ================================================
26 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
27 | * 版 本:1.0
28 | * 创建日期:2016/1/12
29 | * 描 述:Trace请求的实现类,注意需要传入本类的泛型
30 | * 修订历史:
31 | * ================================================
32 | */
33 | public class TraceRequest extends NoBodyRequest> {
34 |
35 | public TraceRequest(String url) {
36 | super(url);
37 | }
38 |
39 | @Override
40 | public HttpMethod getMethod() {
41 | return HttpMethod.TRACE;
42 | }
43 |
44 | @Override
45 | public okhttp3.Request generateRequest(RequestBody requestBody) {
46 | Request.Builder requestBuilder = generateRequestBuilder(requestBody);
47 | return requestBuilder.method("TRACE", requestBody).url(url).tag(tag).build();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/lzy/okgo/request/base/NoBodyRequest.java:
--------------------------------------------------------------------------------
1 | package com.lzy.okgo.request.base;
2 |
3 | import com.lzy.okgo.utils.HttpUtils;
4 |
5 | import okhttp3.RequestBody;
6 |
7 | /**
8 | * ================================================
9 | * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy
10 | * 版 本:1.0
11 | * 创建日期:2017/6/21
12 | * 描 述:
13 | * 修订历史:
14 | * ================================================
15 | */
16 | public abstract class NoBodyRequest extends Request {
17 | private static final long serialVersionUID = 1200621102761691196L;
18 |
19 | public NoBodyRequest(String url) {
20 | super(url);
21 | }
22 |
23 | @Override
24 | public RequestBody generateRequestBody() {
25 | return null;
26 | }
27 |
28 | protected okhttp3.Request.Builder generateRequestBuilder(RequestBody requestBody) {
29 | url = HttpUtils.createUrlFromParams(baseUrl, params.urlParamsMap);
30 | okhttp3.Request.Builder requestBuilder = new okhttp3.Request.Builder();
31 | return HttpUtils.appendHeaders(requestBuilder, headers);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/common/base/activitys/CommonViewpagerFragmentViewActivity.java:
--------------------------------------------------------------------------------
1 | package common.base.activitys;
2 |
3 | import androidx.viewpager.widget.PagerAdapter;
4 | import common.base.adapters.ViewPagerFragmentAdapter;
5 |
6 | /**
7 | * User: fee(1176610771@qq.com)
8 | * Date: 2016-06-27
9 | * Time: 13:47
10 | * DESC: 通用的布局界面,只是ViewPager中的内容视图指定为装载Fragment 布局,即指定了ViewPager的适配器为ViewPagerFragmentAdapter
11 | */
12 | public abstract class CommonViewpagerFragmentViewActivity extends CommonTabstripViewPagerActivity{
13 | protected ViewPagerFragmentAdapter adapter4ViewPagerFragmentInner;
14 | /**
15 | * 为ViewPager提供适配器
16 | *
17 | * @return
18 | */
19 | @Override
20 | protected final PagerAdapter getAdapter4ViewPager() {
21 | adapter4ViewPagerFragmentInner = new ViewPagerFragmentAdapter(getSupportFragmentManager(), mContext);
22 | return adapter4ViewPagerFragmentInner;
23 | }
24 |
25 | /**
26 | * 初始伦ViewPager 的适配器中的数据
27 | */
28 | @Override
29 | protected final void setupAdapter() {
30 | setupViewPagerFragmentAdapter(adapter4ViewPagerFragmentInner);
31 | }
32 |
33 | /**
34 | * 在该方法中给适配器添加子视图(Fragment类型)
35 | * @param adapter4ViewPagerFragmentInner 当前界面中为ViewPager提供碎片界面视图的适配器
36 | */
37 | protected abstract void setupViewPagerFragmentAdapter(ViewPagerFragmentAdapter adapter4ViewPagerFragmentInner);
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/common/base/activitys/IProxyCallback.java:
--------------------------------------------------------------------------------
1 | package common.base.activitys;
2 |
3 |
4 | import common.base.netAbout.BaseServerResult;
5 |
6 | /**
7 | * 代理者处理事件回调接口
8 | *
9 | * 2015年9月8日-下午9:28:16
10 | * @author lifei
11 | */
12 | public interface IProxyCallback {
13 |
14 | /**
15 | * 被代理者(雇佣代理者)是否处理服务正常响应结果,如果被代理者处理了,则代理者不处理
16 | * @param requestDataType 处理的当前是何种请求
17 | * @param result
18 | * @return true:[被代理者]处理了 false:交由[代理者]处理
19 | */
20 | boolean ownerDealWithServerResult(int requestDataType, BaseServerResult result);
21 |
22 |
23 | /**
24 | * 被代理者(雇佣代理者)是否处理连接服务端异常结果,如果被代理者处理了,则代理者不处理
25 | * @param requestDataType 处理的当前是何种请求
26 | * @param errorInfo
27 | * @return true:[被代理者]处理了 false:交由[代理者]处理
28 | */
29 | boolean ownerDealWithServerError(int requestDataType, String errorInfo);
30 | /**
31 | * 被代理者(宿主)主动取消了Loading Dialog的方法回调
32 | * (eg.:此Loading Dialog正在提示网络数据的请求,用户主动取消后,该方法回调
33 | * ,则需要在各自实现中实现各网络请求的取消并标志好该请求已取消)
34 | */
35 | void ownerToCancelLoadingRequest();
36 |
37 | /**
38 | * 被代理者(宿主)主动取消了提示性Dialog的回调,各实现类可在此处理当前具体的提示性Dialog被取消了后的逻辑
39 | */
40 | void ownerToCancelHintDialog();
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/AbsSelectableLocalViewHolderAdapter.kt:
--------------------------------------------------------------------------------
1 | package common.base.adapters
2 |
3 | import android.graphics.Color
4 | import android.view.View
5 | import androidx.annotation.ColorInt
6 | import common.base.adapters.viewholders.LocalViewHolder
7 | import common.base.utils.CheckUtil
8 |
9 | /**
10 | * ******************(^_^)***********************
11 | * User: fee(QQ/WeiXin:1176610771)
12 | * DESC:
13 | *
14 | * ******************(^_^)***********************
15 | */
16 | abstract class AbsSelectableLocalViewHolderAdapter : AbsSelectableAdapter(null) {
17 | /**
18 | * 如果使用了 [BaseViewHolder]的子类,则
19 | * 一般重写该方法,返回
20 | */
21 | override fun createBaseViewHolder(view: View?): LocalViewHolder {
22 | return LocalViewHolder(view)
23 | }
24 |
25 | fun parseStrColor(colorFormatStr: String?,@ColorInt fallbackColorIntAtFail: Int): Int {
26 | return try {
27 | if (colorFormatStr.isNullOrBlank()) {
28 | fallbackColorIntAtFail
29 | }
30 | else{
31 | Color.parseColor(colorFormatStr)
32 | }
33 | } catch (ex: Exception) {
34 | fallbackColorIntAtFail
35 | }
36 | }
37 | fun parseStrColor(colorFormatStr: String?, fallbackColorStr: String): Int {
38 | return if (!colorFormatStr.isNullOrBlank()) {
39 | try {
40 | Color.parseColor(colorFormatStr)
41 | } catch (ex: Exception) {
42 | parseStrColor(fallbackColorStr, 0)
43 | }
44 | }else{
45 | parseStrColor(fallbackColorStr,0)
46 | }
47 | }
48 |
49 | fun judgeVisibleByText(contentText: CharSequence?, willGoneAtNoText: Boolean = true): Int {
50 | return if (CheckUtil.isEmpty(contentText)) {
51 | if(willGoneAtNoText){
52 | View.GONE
53 | }
54 | else{
55 | View.INVISIBLE
56 | }
57 | }else(View.VISIBLE)
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/BaseCustomViewHolderAdapter.kt:
--------------------------------------------------------------------------------
1 | package common.base.adapters
2 |
3 | import android.view.ViewGroup
4 | import com.chad.library.adapter.base.BaseQuickAdapter
5 | import com.chad.library.adapter.base.BaseViewHolder
6 |
7 | /**
8 | * ******************(^_^)***********************
9 | * User: fee(QQ/WeiXin:1176610771)
10 | * DESC:
11 | * 需要 创建自定义 ViewHolder 的 Adapter 基类
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | abstract class BaseCustomViewHolderAdapter : BaseQuickAdapter(null) {
16 | /**
17 | * 因为子类可能需要 根据具体的 item data 数据,来返回 当前 item data的数据类型
18 | */
19 | abstract override fun getDefItemViewType(position: Int): Int
20 |
21 | /**
22 | * 因为要使用自定义 的ViewHolder,所以本类把该方法再 变更为[abstract]
23 | */
24 | abstract override fun onCreateDefViewHolder(parent: ViewGroup?, viewType: Int): VH
25 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/JustHasTextDataSelectableAdapter.java:
--------------------------------------------------------------------------------
1 | package common.base.adapters;
2 |
3 | import com.chad.library.adapter.base.BaseViewHolder;
4 |
5 | import common.base.beans.IHasTextData;
6 |
7 | /**
8 | * ******************(^_^)***********************
9 | * User: fee(QQ/WeiXin:1176610771)
10 | * Date: 2019/4/13
11 | * Time: 17:26
12 | * DESC:
13 | *
14 | * ******************(^_^)***********************
15 | */
16 | public class JustHasTextDataSelectableAdapter extends JustTextSelectableAdapter {
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/JustViewDataPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package common.base.adapters;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 |
6 | /**
7 | * ******************(^_^)***********************
8 | * User: fee(QQ/WeiXin:1176610771)
9 | * Date: 2019/2/18
10 | * Time: 17:13
11 | * DESC:
12 | * 给ViewPager直接提供itemData为View的PagerAdapter
13 | *
14 | * ******************(^_^)***********************
15 | */
16 | public class JustViewDataPagerAdapter extends AbsPagerAdapter {
17 |
18 | @Override
19 | protected Object convertAndInitItem(View itemData, ViewGroup container, int position) {
20 | container.addView(itemData);
21 | return itemData;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/ViewPagerFragmentInfo.java:
--------------------------------------------------------------------------------
1 | package common.base.adapters;
2 |
3 | import android.os.Bundle;
4 |
5 | /**
6 | * 提供给ViewPager的每个碎片的信息
7 | *
8 | * 2015年10月27日-下午3:45:51
9 | *
10 | * @author fee
11 | */
12 | public final class ViewPagerFragmentInfo {
13 | public String fragmentTitle;
14 | public String tag;
15 | public Class> fragmentClass;
16 | public Bundle extraBundleData;
17 |
18 | public ViewPagerFragmentInfo(String fragmentTitle, String tag, Class> fragmentClass, Bundle extraData) {
19 | this.fragmentTitle = fragmentTitle;
20 | this.tag = tag;
21 | this.fragmentClass = fragmentClass;
22 | this.extraBundleData = extraData;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/viewholders/ACommonViewHolder.kt:
--------------------------------------------------------------------------------
1 | package common.base.adapters.viewholders
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.annotation.LayoutRes
7 |
8 | /**
9 | * ******************(^_^)***********************
10 | * User: fee(QQ/WeiXin:1176610771)
11 | * DESC:
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | abstract class ACommonViewHolder : LocalViewHolder {
16 | constructor(itemView: View) : super(itemView){
17 | initViews()
18 | }
19 | constructor(context: Context, @LayoutRes itemViewLayoutRes: Int) : this(View.inflate(context, itemViewLayoutRes, null)) {
20 | }
21 | constructor(context: Context, @LayoutRes itemViewLayoutRes: Int, parentView: ViewGroup?) : this(View.inflate(context, itemViewLayoutRes, parentView))
22 |
23 | fun initViews() {
24 | //can do nothing...
25 | }
26 | abstract fun convertByItemData(curItemData: ItemData)
27 |
28 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/adapters/viewholders/WithRecyclerViewViewHolder.kt:
--------------------------------------------------------------------------------
1 | package common.base.adapters.viewholders
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 |
8 | /**
9 | * ******************(^_^)***********************
10 | * User: fee(QQ/WeiXin:1176610771)
11 | * DESC:
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | abstract class WithRecyclerViewViewHolder : ACommonViewHolder {
16 | protected lateinit var recyclerView: RecyclerView
17 |
18 | constructor(itemView: View) : super(itemView)
19 | constructor(context: Context, itemViewLayoutRes: Int) : super(context, itemViewLayoutRes)
20 | constructor(context: Context, itemViewLayoutRes: Int, parentView: ViewGroup?) : super(context, itemViewLayoutRes, parentView)
21 |
22 |
23 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/animators/BezierPointValuer.java:
--------------------------------------------------------------------------------
1 | package common.base.animators;
2 |
3 | import android.animation.TypeEvaluator;
4 | import android.graphics.PointF;
5 |
6 | /**
7 | * USER: fee(1176610771@qq.com)
8 | * DATE: 2017/3/9
9 | * TIME: 17:01
10 | * DESC: 贝塞尔曲线 上轨迹 的估值点
11 | */
12 |
13 | public class BezierPointValuer implements TypeEvaluator {
14 | //贝塞尔曲线上的主要四个点中的中间的确定曲线的两个点
15 | private PointF point1;
16 | private PointF point2;
17 |
18 | public BezierPointValuer(PointF point1, PointF point2) {
19 | this.point1 = point1;
20 | this.point2 = point2;
21 | }
22 |
23 | /**
24 | * This function returns the result of linearly interpolating the start and end values, with
25 | * fraction
representing the proportion between the start and end values. The
26 | * calculation is a simple parametric calculation: result = x0 + t * (x1 - x0)
,
27 | * where x0
is startValue
, x1
is endValue
,
28 | * and t
is fraction
.
29 | *
30 | * @param t The fraction from the starting to the ending values
31 | * @param p0 The start value. 贝塞尔曲线的开始点
32 | * @param p3 The end value. 贝塞尔曲线的结束点这里为第三个点
33 | * @return A linear interpolation between the start and end values, given the
34 | * fraction
parameter.
35 | * 贝塞尔曲线 公式:B(t) = P0*(1-t)^3 + 3*p1*t*(1-t)^2 + 3*p2*t^2*(1-t) + p3*t^3, t{0~1}
36 | */
37 | @Override
38 | public PointF evaluate(float t, PointF p0, PointF p3) {
39 | PointF transitionPoint = new PointF();
40 | transitionPoint.x = p0.x * (1 - t) * (1 - t) * (1 - t)
41 | + 3 * point1.x * t * (1 - t) * (1 - t) + 3 * point2.x * t * t * (1 - t)
42 | + p3.x * t * t * t;
43 | transitionPoint.y = p0.y * (1 - t) * (1 - t) * (1 - t)
44 | + 3 * point1.y * t * (1 - t) * (1 - t) + 3 * point2.y * t * t * (1 - t)
45 | + p3.y * t * t * t;
46 |
47 | return transitionPoint;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/common/base/annotations/InvokeStep.java:
--------------------------------------------------------------------------------
1 | package common.base.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * @author fee
10 | * DESC:
11 | * 提示 调用步骤/顺序的 注解类
12 | *
13 | */
14 | @Retention(RetentionPolicy.SOURCE)
15 | @Target({ElementType.METHOD,ElementType.TYPE,ElementType.CONSTRUCTOR})
16 | public @interface InvokeStep {
17 | String desc();
18 | int value();
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/common/base/beans/BaseBannerItem.java:
--------------------------------------------------------------------------------
1 | package common.base.beans;
2 |
3 | /**
4 | * ******************(^_^)***********************
5 | * User: 11776610771@qq.com
6 | * Date: 2017/4/25
7 | * Time: 16:20
8 | * DESC:
9 | * ******************(^_^)***********************
10 | */
11 |
12 | public class BaseBannerItem extends BaseData {
13 | /**
14 | * 描述、标题
15 | */
16 | private String bannerItemTitle;
17 | /**
18 | * 如果是广告,则点击跳转的Url地址
19 | */
20 | private String bannerItemUrl;
21 | /**
22 | * banner的图片、封面
23 | */
24 | private String bannerItemCoverUrl;
25 | /**
26 | * banner的图片、封面在本地的资源ID,即本地[广告]图片
27 | */
28 | private int bannerCoverLocalResId;
29 |
30 | public String getBannerItemTitle() {
31 | return bannerItemTitle;
32 | }
33 |
34 | public String getBannerItemUrl() {
35 | return bannerItemUrl;
36 | }
37 |
38 | public String getBannerItemCoverUrl() {
39 | return bannerItemCoverUrl;
40 | }
41 |
42 | public int getBannerCoverLocalResId() {
43 | return bannerCoverLocalResId;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/common/base/beans/BaseData.java:
--------------------------------------------------------------------------------
1 | package common.base.beans;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * User: fee(lifei@cloudtone.com.cn)
7 | * Date: 2016-05-16
8 | * Time: 15:24
9 | * DESC: 基础数据
10 | */
11 | public class BaseData implements Serializable{
12 | private static final long serialVersionUID = 4410080819054865875L;
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/common/base/beans/BaseListEntity.java:
--------------------------------------------------------------------------------
1 | package common.base.beans;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * User: fee(lifei@cloudtone.com.cn)
7 | * Date: 2016-05-16
8 | * Time: 15:25
9 | * DESC: 带有列表数据的实体基类接口
10 | */
11 | public interface BaseListEntity{
12 | List getListData();
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/common/base/beans/IHasTextData.java:
--------------------------------------------------------------------------------
1 | package common.base.beans;
2 |
3 | /**
4 | * ******************(^_^)***********************
5 | * User: fee(QQ/WeiXin:1176610771)
6 | * Date: 2018/12/11
7 | * Time: 11:13
8 | * DESC:
9 | * 具有文本属性的数据实体
10 | *
11 | * ******************(^_^)***********************
12 | */
13 | public interface IHasTextData {
14 | CharSequence getTextData();
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/common/base/dialogs/IDialogLifeCircleListener.java:
--------------------------------------------------------------------------------
1 | package common.base.dialogs;
2 |
3 | import android.app.Dialog;
4 |
5 | /**
6 | * ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2020/5/28
9 | * Time: 21:25
10 | * DESC:
11 | * 一个Dialog的生命周期的监听者
12 | * 一般生命周期流程为:显示线: show() --> [如果没创建过则-->onCreate()] --> onStart()
13 | * 消失线: [cancel()] --> dismiss() --> onStop()
14 | * "[]"表示可有无
15 | * ******************(^_^)***********************
16 | */
17 | public interface IDialogLifeCircleListener {
18 |
19 | /**
20 | * 当前Dialog 将要创建
21 | * 一般只有一次
22 | * @param theDialog 当前Dialog
23 | */
24 | void onDialogCreate(Dialog theDialog/*,Bundle savedInstanceState*/);
25 |
26 | /**
27 | * 当前Dialog 将要show()
28 | * @param theDialog 当前Dialog
29 | * @param titleHintOtherTexts [0] title; [1] hint text;[2] cancel btn text; [3] submit btn text... 使用者需要判断长度 ^~^
30 | */
31 | void onDialogShow(Dialog theDialog, CharSequence... titleHintOtherTexts);
32 |
33 | /**
34 | * 当前Dialog 将要消失
35 | * @param theDialog 当前Dialog
36 | * // * @param dueToCancel true:是由于调用了 cancel()消失的;false:一般为 dismiss()方法的调用
37 | */
38 | void onDialogDismiss(Dialog theDialog/*, boolean dueToCancel*/);
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/common/base/glide/BaseGlide.java:
--------------------------------------------------------------------------------
1 | package common.base.glide;
2 |
3 | import android.content.Context;
4 |
5 | import com.bumptech.glide.Glide;
6 | import com.bumptech.glide.Registry;
7 | import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
8 | import com.bumptech.glide.load.model.GlideUrl;
9 | import com.bumptech.glide.module.LibraryGlideModule;
10 |
11 | import java.io.InputStream;
12 |
13 | import common.base.glide.progress.ProgressManager;
14 |
15 | /**
16 | * ******************(^_^)***********************
17 | * User: 11776610771@qq.com
18 | * Date: 2017/10/25
19 | * Time: 17:08
20 | *
DESC:
21 | *
22 | * ******************(^_^)***********************
23 | */
24 |
25 | public class BaseGlide extends LibraryGlideModule {
26 | @Override
27 | public void registerComponents(Context context, Glide glide, Registry registry) {
28 | super.registerComponents(context, glide, registry);
29 | registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(ProgressManager.getOkHttpClient()));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/common/base/glide/GlideCircleTransformation.java:
--------------------------------------------------------------------------------
1 | package common.base.glide;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapShader;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 |
8 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
9 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
10 |
11 | import java.security.MessageDigest;
12 |
13 |
14 | public class GlideCircleTransformation extends BitmapTransformation {
15 |
16 | public GlideCircleTransformation() {
17 | }
18 |
19 | @Override
20 | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
21 | return circleCrop(pool, toTransform);
22 | }
23 |
24 | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
25 | if (source == null) return null;
26 |
27 | int size = Math.min(source.getWidth(), source.getHeight());
28 | int x = (source.getWidth() - size) / 2;
29 | int y = (source.getHeight() - size) / 2;
30 |
31 | Bitmap square = Bitmap.createBitmap(source, x, y, size, size);
32 | Bitmap circle = pool.get(size, size, Bitmap.Config.ARGB_8888);
33 |
34 | Canvas canvas = new Canvas(circle);
35 | Paint paint = new Paint();
36 | paint.setShader(new BitmapShader(square, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
37 | paint.setAntiAlias(true);
38 | float r = size / 2f;
39 | canvas.drawCircle(r, r, r, paint);
40 | return circle;
41 | }
42 |
43 | @Override
44 | public void updateDiskCacheKey(MessageDigest messageDigest) {
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/common/base/glide/WrapUrlTarget.java:
--------------------------------------------------------------------------------
1 | package common.base.glide;
2 |
3 | import com.bumptech.glide.request.target.SimpleTarget;
4 |
5 | /**
6 | * ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2019/4/10
9 | * Time: 15:32
10 | * DESC:
11 | * Glide加载图片到的Target,携带当前所加载的图片url地址
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | public abstract class WrapUrlTarget extends SimpleTarget {
16 | private String targetUrl;
17 | public WrapUrlTarget(String targetUrl) {
18 | this.targetUrl = targetUrl;
19 | }
20 | public void setTargetUrl(String urlInfo) {
21 | this.targetUrl = urlInfo;
22 | }
23 |
24 |
25 | public String getTargetUrl() {
26 | return targetUrl;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/common/base/glide/progress/OnGlideImageViewListener.java:
--------------------------------------------------------------------------------
1 | package common.base.glide.progress;
2 |
3 | import com.bumptech.glide.load.engine.GlideException;
4 |
5 | /**
6 | * Created by sunfusheng on 2017/6/14.
7 | */
8 | public interface OnGlideImageViewListener {
9 |
10 | void onProgress(int percent, boolean isDone, GlideException exception);
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/common/base/glide/progress/OnProgressListener.java:
--------------------------------------------------------------------------------
1 | package common.base.glide.progress;
2 |
3 | import com.bumptech.glide.load.engine.GlideException;
4 |
5 | /**
6 | * Created by sunfusheng on 2017/6/14.
7 | */
8 | public interface OnProgressListener {
9 |
10 | void onProgress(String imageUrl, long bytesRead, long totalBytes, boolean isDone, GlideException exception);
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/ICommonActionsInListUi.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 | import com.chad.library.adapter.base.BaseQuickAdapter;
3 | import com.chad.library.adapter.base.BaseViewHolder;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * User: fee(1176610771@qq.com)
9 | * Date: 2016-06-25
10 | * Time: 15:03
11 | * DESC: 对于有列表数据界面的共同方法的接口
12 | */
13 | public interface ICommonActionsInListUi {
14 | /**
15 | * 获取或者初始化RecyclerView的适配器
16 | * @return
17 | */
18 | BaseQuickAdapter getRecyclerViewAdapter();
19 |
20 | /**
21 | * 列表数据请求成功,在此方法中做填充新增数据的逻辑
22 | * @param newData
23 | */
24 | void listDataRequestSuccess(List newData);
25 |
26 | /**
27 | * 通过比较要新添加的数据与老列表数据,判断是否重复的数据
28 | * 如果重复的数据一般就不添加进原来的列表
29 | * @param oldDatas
30 | * @param willAddedOne
31 | * @return
32 | */
33 | boolean compareData(List oldDatas, TListData willAddedOne);
34 |
35 | /**
36 | * 列表数据请求结束,实现此方法,通过判断一次请求数据后是否有列表数据来决定UI的显示逻辑等
37 | * @param hasListDataResult
38 | * @param errorInfoIfRequestFail
39 | */
40 | void listDataRequestFinish(boolean hasListDataResult, String errorInfoIfRequestFail);
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/ICommonBehaviors.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 |
3 | /**
4 | * User: fee(1176610771@qq.com)
5 | * Date: 2016-05-18
6 | * Time: 11:29
7 | * DESC: 相同的通用的一些行为的接口
8 | */
9 | public interface ICommonBehaviors {
10 | /**
11 | * 获取当前Activity需要填充、展示的内容视图,如果各子类提供,则由基类来填充,如果不提供,各子类也可自行处理
12 | * @return 当前Activity需要展示的内容视图资源ID
13 | */
14 | int getProvideContentViewResID();
15 | /**
16 | * 如果子类在getProvideContentViewResID()方法提供了视图资源,那么子类的初始化视图可在此方法中完成
17 | */
18 | abstract void initViews();
19 |
20 | /**
21 | * 初始化数据
22 | */
23 | void initData();
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/ICommonUiHintActions.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 |
3 | /**
4 | * User: fee(1176610771@qq.com)
5 | * Date: 2016-06-25
6 | * Time: 16:21
7 | * DESC: 一些通用的UI提示类方法的接口
8 | */
9 | public interface ICommonUiHintActions {
10 |
11 |
12 | void showCommonLoading(String hintMsg);
13 |
14 | void showCommonLoading(int hintMsgResID);
15 |
16 | void dialogHint(String dialogTitle, String hintMsg, String cancelBtnName, String sureBtnName, int dialogInCase);
17 |
18 | void dialogHint(int titleResID, int hintMsgResID, int cancelBtnNameResID, int sureBtnNameResID, int dialogInCase);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/IDoTaskCallback.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 |
3 | import androidx.annotation.MainThread;
4 |
5 | /**
6 | * ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2018/12/6
9 | * Time: 17:18
10 | * DESC:
11 | * 关于任务执行的回调接口
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | public interface IDoTaskCallback {
16 |
17 | /**
18 | * 正在执行任务
19 | * @param whatTask 要执行的什么类型的任务
20 | * @param taskObj 要执行的任务体
21 | */
22 | boolean onDoTask(int whatTask, Object taskObj);
23 | /**
24 | * 任务执行结果
25 | * 注:回调在主线程
26 | * @param whatTask 什么任务类型
27 | * @param taskResult 任务结果
28 | */
29 | @MainThread
30 | void onDoTaskResult(int whatTask, Object taskResult);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/IRecyclerViewItemClickEventsListener.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 |
3 | import android.view.View;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 |
7 | /**
8 | * User: fee(1176610771@qq.com)
9 | * Date: 2016-12-16
10 | * Time: 17:11
11 | * DESC: 该接口是为了兼容BRVAH中把RecyclerView的item各点击事件的监听都变为抽象类后,用来转接回调出去,
12 | * 方便子类实现
13 | */
14 | public interface IRecyclerViewItemClickEventsListener {
15 | /**
16 | * Callback method to be invoked when an item in this AdapterView has
17 | * been clicked.
18 | *
19 | * @param view The view within the AdapterView that was clicked (this
20 | * will be a view provided by the adapter)
21 | * @param position The position of the view in the adapter.
22 | */
23 | void onItemClick(BaseQuickAdapter adapter, View view, int position);
24 | /**
25 | * callback method to be invoked when an item in this view has been
26 | * click and held
27 | * @param adapter
28 | * @param view The view whihin the AbsListView that was clicked
29 | * @param position The position of the view int the adapter
30 | * @return true if the callback consumed the long click ,false otherwise
31 | */
32 | void onItemLongClick(BaseQuickAdapter adapter, View view, int position);
33 |
34 | /**
35 | * RecyclerView中的item布局内各子View的点击事件
36 | * @param adapter 当前的适配器
37 | * @param view 当前被点击的视图View,用id来switch区分
38 | * @param position 被点击的子View在RecyclerView中的位置
39 | */
40 | void onItemChildClick(BaseQuickAdapter adapter, View view, int position);
41 |
42 | /**
43 | * RecyclerView中的item布局内各子View的长按事件
44 | * @param adapter 当前的适配器
45 | * @param view 当前被点击的视图View,用id来switch区分
46 | * @param position 被长按的子View在RecyclerView中的位置
47 | */
48 | void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position);
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/ITextWatcher.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 |
3 | import android.widget.TextView;
4 |
5 | /**
6 | * User: fee(1176610771@qq.com)
7 | * Date: 2016-06-29
8 | * Time: 11:35
9 | * DESC: 针对EditText的文本变化的监听
10 | */
11 | public interface ITextWatcher {
12 | /***
13 | * 文本变化中的回调
14 | * @param curEditText changed by fee 2017-08-23 TextWatcher是TextView中的接口,故把参数对象提升到TextView
15 | */
16 | void onTextChanged(TextView curEditText);
17 |
18 | /**
19 | * 文本变化后的回调
20 | * @param curEditTextView
21 | */
22 | void onAfterTextChanged(TextView curEditTextView);
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/common/base/interfaces/NotUse.java:
--------------------------------------------------------------------------------
1 | package common.base.interfaces;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * ******************(^_^)***********************
10 | * User: fee(QQ/WeiXin:1176610771)
11 | * Date: 2019/12/4
12 | * Time: 14:37
13 | * DESC:
14 | * 自定义注解
15 | * 该注解用来标记某个类、属性、方法不使用
16 | *
17 | * ******************(^_^)***********************
18 | */
19 | @Retention(RetentionPolicy.SOURCE)
20 | @Target({ElementType.CONSTRUCTOR,ElementType.FIELD,ElementType.METHOD,ElementType.LOCAL_VARIABLE,ElementType.TYPE})
21 | public @interface NotUse {
22 | String value();
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/fragments/CommonViewDelegateFragment.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.fragments
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import common.base.mvx.v.BaseViewDelegate
6 | import common.base.mvx.v.IView
7 |
8 | /**
9 | ******************(^_^)***********************
10 | * User: fee(QQ/WeiXin:1176610771)
11 | * Date: 2021/3/20
12 | * Time: 12:31
13 | * DESC:
14 | * 一个通用的加载 视图层代理的 Fragment,
15 | * 从而可以不用写各个Fragment,而只写 相应的 ViewDelegate
16 | *
17 | * ******************(^_^)***********************
18 | */
19 | open class CommonViewDelegateFragment : BaseViewDelegateFragment() {
20 |
21 | companion object Builder{
22 | fun buildAFragment(
23 | theViewDelegateClass: Class,
24 | extraDataConfigs: (Bundle) -> Unit
25 | ): CommonViewDelegateFragment {
26 | val theFragment = CommonViewDelegateFragment()
27 | val dataBundle = Bundle()
28 | dataBundle.putSerializable("theViewDelegateClass", theViewDelegateClass)
29 | extraDataConfigs(dataBundle)
30 | theFragment.arguments = dataBundle
31 | return theFragment
32 | }
33 | }
34 | /**
35 | * 子类所提供的 视图[V]层的 对象
36 | */
37 | override fun provideVModule(): IView? {
38 | return arguments?.let {
39 | it.getSerializable("theViewDelegateClass")?.let {
40 | ser->
41 | try {
42 | val viewDelegateClass: Class =
43 | ser as Class
44 | val declaredConstructor =
45 | viewDelegateClass.getDeclaredConstructor(Context::class.java)
46 | return declaredConstructor.newInstance(context)
47 | } catch (ex: Exception) {
48 | ex.printStackTrace()
49 | }
50 | }
51 | null
52 | }
53 | }
54 |
55 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/interfaces/IHostActions.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.interfaces
2 |
3 | import android.content.Intent
4 | import android.content.res.Configuration
5 | import android.os.Bundle
6 | import androidx.lifecycle.LifecycleOwner
7 | import androidx.lifecycle.ViewModelStoreOwner
8 |
9 | /**
10 | * @author fee
11 | * DESC:
12 | * 宿主相关的 动作
13 | *
14 | */
15 | interface IHostActions {
16 |
17 | /**
18 | * 当系统的相关配置 eg.: 字体大小变更、方向变更、等,有变更时的回调
19 | */
20 | fun onConfigurationChanged(newConfig: Configuration?){
21 |
22 | }
23 |
24 | /**
25 | * 当宿主 接收到用户按下 [返回键]时,视图层是否需要消费
26 | * def: false 不消费,直接让宿主消费
27 | * @return true: 视图层需要消费掉 [返回键]事件,则宿主不消费; false:本视图层不消费 [返回键]事件
28 | */
29 | fun onConsumeBackPressed(): Boolean = false
30 |
31 | /**
32 | * 当宿主 有数据从其他界面 响应返回时的回调
33 | *
34 | */
35 | fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
36 |
37 | }
38 |
39 | /**
40 | * 当宿主 为当前/恢复可见/前台 状态时
41 | */
42 | fun onResume() {
43 |
44 | }
45 |
46 | /**
47 | * 宿主的 生命周期 [onPause] 回调
48 | */
49 | fun onPause(){
50 |
51 | }
52 | /**
53 | * 当宿主 将处于后台状态时
54 | */
55 | fun onStop() {
56 |
57 | }
58 |
59 | /**
60 | * 当宿主 将要处于后台时,需要临时存储相关状态、数据的回调
61 | */
62 | fun onSaveInstanceState(outState: Bundle?) {
63 |
64 | }
65 |
66 | /**
67 | * 当宿主将要销毁时回调
68 | * 注:需要 视图层作释放相关逻辑
69 | */
70 | fun onHostFinish() {
71 |
72 | }
73 |
74 | /**
75 | * 当宿主处于销毁流程阶段时回调
76 | */
77 | fun onDetach() {
78 |
79 | }
80 |
81 | /**
82 | * 关联 宿主的 ViewModelStoreOwner
83 | */
84 | fun attachViewModelStoreOwner(theViewModelStoreOwner: ViewModelStoreOwner?)
85 |
86 | /**
87 | * 关联 宿主的 LifecycleOwner
88 | */
89 | fun attachLifecycleOwner(theLifecycleOwner: LifecycleOwner?)
90 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/ABizResult.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 |
4 | /**
5 | ******************(^_^)***********************
6 | * User: fee(QQ/WeiXin:1176610771)
7 | * Date: 2021/4/4
8 | * Time: 22:08
9 | * DESC:
10 | * 通用的一个响应 结果 实体对象
11 | * 注:可用于 [MutableLiveData]的 value
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | open class ABizResult(
16 | var dataType: DataType,
17 | var data: R?,
18 | var isNeedShowLoading: Boolean = false,
19 | var errorMsg: String? = null,
20 | var exception: Exception? = null,
21 | var extraInfo:Any? = null
22 | )
23 |
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/AbsDataObserver.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | import java.lang.ref.WeakReference
4 |
5 | /**
6 | ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2021/4/4
9 | * Time: 11:52
10 | * DESC:
11 | * [IDataObserver] 的一个实现类
12 | * 可赋值 被观察的 数据类型;
13 | * 可赋值,外部的 [IDataObserver]接口实现类,目的为再回调外部
14 | *
15 | * ******************(^_^)***********************
16 | */
17 | open class AbsDataObserver(
18 | var curDataType: DataType?,
19 | iDataObserver: IDataObserver?
20 | ) : IDataObserver {
21 |
22 | //todo 这里是否需要变成 弱引用??
23 | private var weakRefDataObserver: WeakReference>? = null
24 |
25 | init {
26 | if (iDataObserver != null) {
27 | weakRefDataObserver = WeakReference(iDataObserver)
28 | }
29 | }
30 | override fun onChanged(t: Data?) {
31 | onDataChanged(curDataType,t)
32 | }
33 |
34 | override fun onDataChanged(dataType: DataType?, theData: Data?) {
35 | // iDataObserver?.onDataChanged(dataType, theData)
36 | weakRefDataObserver?.get()?.onDataChanged(dataType, theData)
37 |
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/BaseRepository.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 |
4 | import common.base.utils.CommonLog
5 |
6 | /**
7 | * @author fee
8 | * DESC:
9 | * 业务[M]
10 | * 网络接口请求/数据库查询/IO流操作...
11 | *
12 | */
13 | abstract class BaseRepository : IRepository {
14 | protected val TAG = javaClass.simpleName
15 |
16 | /**
17 | * 是否使能Log输出
18 | * def: false
19 | */
20 | var isEnableLogDebug: Boolean = false
21 | var extraInfosInDebug: String = ""
22 |
23 | open fun e(tag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
24 | CommonLog.e(tag ?: "$TAG[$extraInfosInDebug]", *logBodys)
25 | }
26 |
27 | open fun v(tag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
28 | CommonLog.fullLog('v', tag ?: "$TAG[$extraInfosInDebug]", CommonLog.getInfo(*logBodys))
29 | }
30 |
31 | open fun i(tag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
32 | CommonLog.iFullLog(tag ?: "$TAG[$extraInfosInDebug]", *logBodys)
33 | }
34 |
35 | open fun d(logTag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
36 | CommonLog.d(logTag ?: "$TAG[$extraInfosInDebug]", *logBodys)
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/DoResult.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | import java.lang.Exception
4 | import javax.xml.transform.dom.DOMResult
5 |
6 | /**
7 | * @author fee
8 | * DESC:
9 | * 一次业务执行的结果对象
10 | *
11 | */
12 | @Deprecated(message = "",replaceWith = ReplaceWith(""))
13 | sealed class DoResult{
14 |
15 | fun isError() = this is Error
16 |
17 | fun isSuccess() = this is Success
18 |
19 | fun isLoading() = this is Loading
20 | data class Success(val resultData: R?) : DoResult()
21 |
22 | data class Error(val exceptionMsg: String?, val exception: Exception?) : DoResult()
23 |
24 | data class Loading(val isNeedShowLoading: Boolean = true) : DoResult() {
25 |
26 | }
27 |
28 | override fun toString(): String {
29 | return when (this) {
30 | is Success -> "Success[data = $resultData]"
31 | is Error -> "Error[errorMsg = $exceptionMsg,exception = $exception]"
32 | is Loading -> "Loading[isNeedShowLoading = $isNeedShowLoading]"
33 | else -> {
34 | ""
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/IDataBinder.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | import common.base.mvx.v.IView
4 |
5 | /**
6 | * @author fee
7 | * DESC:
8 | * 视图层绑定 数据层
9 | *
10 | */
11 | interface IDataBinder {
12 | fun viewBindData(v: V, data: M?)
13 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/IDataObserver.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | import androidx.lifecycle.Observer
4 |
5 | /**
6 | ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2021/4/4
9 | * Time: 11:46
10 | * DESC:
11 | * [Observer] 的子接口,目的为增加 当前数据被观察到改变时增加回调当前的数据类型
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | interface IDataObserver : Observer {
16 |
17 | override fun onChanged(t: D?) {
18 | onDataChanged(null,t)
19 | }
20 |
21 | fun onDataChanged(dataType: DataType?, theData: D?)
22 |
23 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/IModel.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | /**
4 | * @author fee
5 | * DESC:
6 | * 仅声明的一个接口
7 | *
8 | */
9 | interface IModel {
10 |
11 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/IObserver.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | import androidx.lifecycle.Observer
4 |
5 | /**
6 | ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2021/4/4
9 | * Time: 23:05
10 | * DESC:
11 | * 接口:[Observer] 的子接口,默认重写 [Observer]的接口方法
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | interface IObserver : Observer {
16 |
17 | override fun onChanged(t: D?) {
18 | onDataChange(t)
19 | }
20 |
21 | /**
22 | * 当前数据/响应数据 的回调
23 | * @param data nullable;
24 | */
25 | fun onDataChange(data: D?)
26 |
27 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/m/IRepository.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.m
2 |
3 | /**
4 | * @author fee
5 | * DESC:
6 | * 数据层/业务层/数据仓库 的接口
7 | *
8 | */
9 | interface IRepository {
10 |
11 | /**
12 | * 对仓库的初始化或者初始化需要的数据
13 | */
14 | fun init()
15 |
16 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/v/IView.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.v
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.annotation.IdRes
8 | import androidx.annotation.LayoutRes
9 | import common.base.annotations.InvokeStep
10 | import common.base.mvx.interfaces.IHostActions
11 |
12 | /**
13 | * @author fee
14 | * DESC:
15 | * 不管是 MVP 框架还是 MVVM框架,
16 | * V层尽量需要写成 可复用V层:1、方便独立维护不与Activity、Fragment强偶合; 2、方便通用:比如如果项目中由Activity 变更成 Fragment方案,则直接V层的
17 | * 挪用过来就行;
18 | *
19 | */
20 | interface IView : IHostActions {
21 |
22 | /**
23 | * @param container 将装载 本 视图层的容器 View; eg.: 当本视图层是提供给 [Fragment]时
24 | * @param savedInstanceState [Activity] 重绘时临时存储了状态数据的 对象
25 | * @return 本视图层最终创建的 视图 View
26 | */
27 | @InvokeStep(1, desc = "init")
28 | fun onCreateView(container: ViewGroup?, savedInstanceState: Bundle?): View?
29 |
30 | /**
31 | * 提供 的视图/布局资源 ID
32 | */
33 | @LayoutRes
34 | fun provideVLayoutRes(): Int
35 |
36 | /**
37 | * 在该方法回调里初始化 Views
38 | * @param isInitState 是否为初始化状态,eg.: [Activity]的[onCreate]生命周期方法回调时;
39 | * @param dataIntent 从其他地方 跳转/路由 过来时所携带的 [Intent]
40 | * @param extraData 从其他地方 跳转/路由 过来时所携带的 [Bundle]数据; eg.: [Fragment]的初始化
41 | */
42 | @InvokeStep(2,desc = "init")
43 | fun initViews(isInitState: Boolean, dataIntent: Intent?, extraData: Bundle?)
44 |
45 | /**
46 | * 本 接口View 的根View,可以提供给 [Activity] 或者 [Fragment]
47 | */
48 | fun peekRootView(): View?
49 |
50 |
51 |
52 |
53 | /**
54 | * 根据 指定的 View的 ID来查找对应的View
55 | * @param targetViewId View所声明的ID
56 | * @return null or View
57 | */
58 | fun findView(@IdRes targetViewId: Int): V? =
59 | peekRootView()?.findViewById(targetViewId)
60 |
61 | /**
62 | * 本 View 层的 调试信息
63 | * @return def = ""
64 | */
65 | fun theDebugInfo(): String = ""
66 |
67 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/v/UiEx.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.v
2 |
3 | import android.os.SystemClock
4 | import android.view.View
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import common.base.R
8 | import kotlinx.coroutines.CoroutineScope
9 | import kotlinx.coroutines.Job
10 | import kotlinx.coroutines.launch
11 |
12 | /**
13 | ******************(^_^)***********************
14 | * Author: fee(QQ/WeiXin:1176610771)
15 | * Date: 2023/7/2
16 | * Time: 19:55
17 | * DESC:
18 | * 对 UI 的一些通用扩展
19 | *
20 | * ******************(^_^)***********************
21 | */
22 |
23 | var theViewClickGapTs = 1500L
24 |
25 | /**
26 | * 扩展 [View]的快速点击场景下的 判断是否为有效的点击 以防重复点击
27 | */
28 | fun View?.isValidClick(theGapTs: Long = theViewClickGapTs): Boolean {
29 | if (null == this){
30 | return false
31 | }
32 | val tagId = R.id.view_double_click_tag_id
33 | val lastClickTime = getTag(tagId)
34 | val now = SystemClock.elapsedRealtime()
35 | if (lastClickTime == null){
36 | setTag(tagId,now)
37 | } else {
38 | lastClickTime as Long
39 | //两次点击的时间间隔小于限制的间隔时间,则认为最后一次点击为无效点击
40 | if (now - lastClickTime < theGapTs){
41 | return false
42 | }
43 | setTag(tagId,now)
44 | }
45 | return true
46 | }
47 |
48 | /**
49 | * 延迟初始化之:默认不进行 sync 的初始化
50 | */
51 | fun defNonSyncLazy(mode: LazyThreadSafetyMode = LazyThreadSafetyMode.NONE, initializer: () -> T) =
52 | lazy(mode = mode,initializer)
53 |
54 |
55 | fun ViewModel.launch(block: suspend CoroutineScope.() -> Unit): Job {
56 | return viewModelScope.launch { block() }
57 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/vm/BaseViewModel.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.vm
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import common.base.utils.CommonLog
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.launch
8 |
9 | /**
10 | * @author fee
11 | * DESC:
12 | * ViewModel的基类
13 | * 在[MVC]框架下,可以作为[M]
14 | * 在[MVP]框架下,可以作为[M]
15 | * 在[MVVM]框架下,作为[VM]
16 | *
17 | */
18 | open class BaseViewModel : ViewModel() {
19 | protected val TAG = javaClass.simpleName
20 |
21 | /**
22 | * Log 输出时的 额外信息
23 | */
24 | var extraInfosInDebug: String? = ""
25 |
26 | /**
27 | * 是否使能Log输出
28 | * def: false
29 | */
30 | var isEnableLogDebug: Boolean = false
31 |
32 | open fun e(tag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
33 | CommonLog.e(tag ?: "$TAG[$extraInfosInDebug]", *logBodys)
34 | }
35 |
36 | open fun v(tag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
37 | CommonLog.fullLog('v', tag ?: "$TAG[$extraInfosInDebug]", CommonLog.getInfo(*logBodys))
38 | }
39 |
40 | open fun i(tag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
41 | CommonLog.iFullLog(tag ?: "$TAG[$extraInfosInDebug]", *logBodys)
42 | }
43 |
44 | open fun d(logTag: String? = "$TAG[$extraInfosInDebug]", vararg logBodys: Any?) {
45 | CommonLog.d(logTag ?: "$TAG[$extraInfosInDebug]", *logBodys)
46 | }
47 |
48 |
49 | fun lanchOnUi(block: suspend CoroutineScope.() -> Unit) {
50 | viewModelScope.launch {
51 | block()
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/vm/BaseViewModelWithAppContext.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.vm
2 |
3 | import android.app.Application
4 | import common.base.mvx.m.IRepository
5 |
6 | /**
7 | ******************(^_^)***********************
8 | * User: fee(QQ/WeiXin:1176610771)
9 | * Date: 2021/4/4
10 | * Time: 10:20
11 | * DESC:
12 | * 拥有和 Application 同生命周期的 ViewModel
13 | *
14 | * ******************(^_^)***********************
15 | */
16 |
17 | abstract class BaseViewModelWithAppContext(val application: Application) : BaseViewModelWithRepository() {
18 |
19 |
20 | fun getApp(): App = application as App
21 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/mvx/vm/BaseViewModelWithRepository.kt:
--------------------------------------------------------------------------------
1 | package common.base.mvx.vm
2 |
3 | import common.base.mvx.m.IRepository
4 |
5 | /**
6 | ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2021/4/4
9 | * Time: 10:26
10 | * DESC:
11 | * 框架为 ViewModel has IRepository 的架构模式
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | abstract class BaseViewModelWithRepository : BaseViewModel() {
16 |
17 | protected val mMainRepository: REPO? by lazy {
18 | provideMainRepository()
19 | }
20 |
21 | /**
22 | * 提供当前 [M]业务层 的主仓库,因为有可能 一个 [ViewModel] 会需要多个[M]层的业务仓库
23 | */
24 | protected abstract fun provideMainRepository(): REPO?
25 |
26 | public fun getMainBizRepo(): REPO? = mMainRepository
27 |
28 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/netAbout/INetEvent.java:
--------------------------------------------------------------------------------
1 | package common.base.netAbout;
2 |
3 | /**
4 | * User: fee(1176610771@qq.com)
5 | * Date: 2016-05-17
6 | * Time: 15:25
7 | * DESC: 网络事件接口;主要指网络请求后的结果回调
8 | */
9 | public interface INetEvent {
10 | /**
11 | * 错误之:未知
12 | */
13 | String ERR_UNKNOW = "unknow_error";
14 | /**
15 | * 手动设置的超时错误
16 | */
17 | String MANULLY_TIME_OUT = "manully_set_time_out";
18 | /**
19 | * 人工延迟 结束(Loading)
20 | */
21 | String MANULLY_DELAY_OVER = "manully_delay_over";
22 | /**
23 | * 错误之:未知host(解析不出主机地址),可能是由于没有网络引起
24 | */
25 | String ERR_UNKNOW_HOST = "unknow_host";
26 | /**
27 | * 网络请求失败
28 | *
29 | * @param requestDataType 当前请求类型
30 | * @param errorInfo 错误信息
31 | */
32 | void onErrorResponse(int requestDataType, String errorInfo);
33 | // abstract void initNetEventListener();
34 |
35 | /**
36 | * 网络请求的响应
37 | *
38 | * @param requestDataType 当前网络请求数据类型
39 | * @param result 响应实体:即表示将网络响应的结果转化成指定的数据实体bean
40 | */
41 | void onResponse(int requestDataType, T result);
42 |
43 | /**
44 | * 错误回调,在还没有开始请求之前,比如:一些参数错误
45 | *
46 | * @param curRequestDataType 当前网络请求类型
47 | * @param errorType 错误类型
48 | */
49 | void onErrorBeforeRequest(int curRequestDataType, int errorType);
50 |
51 | // /**
52 | // * 当前请求是否可以回调结果
53 | // * 目的:为了避免Activity已经finish的情况下,仍有网络回调的问题
54 | // * 注:一般要为true
55 | // * @param curRequestDataType 当前请求类型,为了兼容可以某个请求有特殊需求
56 | // * @return true:正常响应、异常响应,可以回调;false:不能回调
57 | // */
58 | // boolean canCallbackResult(int curRequestDataType);
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/common/base/netAbout/INetEventWithResponse.java:
--------------------------------------------------------------------------------
1 | package common.base.netAbout;
2 |
3 | import okhttp3.Response;
4 |
5 | /**
6 | * ******************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2018/8/29
9 | * Time: 15:06
10 | * DESC:
11 | *
12 | * ******************(^_^)***********************
13 | */
14 | public interface INetEventWithResponse extends INetEvent {
15 | /**
16 | * 网络请求的响应
17 | *
18 | * @param requestDataType 当前网络请求数据类型
19 | * @param result 响应实体
20 | * @param response 整个请求的响应,一般用来有些接口可能
21 | */
22 | void onResponse(int requestDataType, T result, Response response);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/common/base/netAbout/WrapperRespData.kt:
--------------------------------------------------------------------------------
1 | package common.base.netAbout
2 |
3 | /**
4 | * ******************(^_^)***********************
5 | * User: fee(QQ/WeiXin:1176610771)
6 | * DESC:
7 | * 相关数据结果 对象的包裹类
8 | *
9 | * ******************(^_^)***********************
10 | */
11 | open class WrapperRespData(val data: D?, val dataType: Int = 0, val errorInfos: String? = null) {
12 |
13 | // val dataType: Int = 0
14 | // val errorInfos: String? = null
15 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/popupwindow/ARecyclerViewPopWindow.kt:
--------------------------------------------------------------------------------
1 | package common.base.popupwindow
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import androidx.recyclerview.widget.RecyclerView
6 |
7 | /**
8 | * @author fee
9 | * DESC:
10 | *
11 | */
12 | class ARecyclerViewPopWindow(context: Context) : BasePopupWindow(context) {
13 | protected var mRecyclerView: RecyclerView? = null
14 |
15 | init {
16 | }
17 | override fun providerContentLayoutRes(): Int? {
18 | return null
19 | }
20 |
21 | override fun providerContentView(): View? {
22 | mRecyclerView = RecyclerView(mContext)
23 | return mRecyclerView
24 | }
25 |
26 |
27 | fun setAdapter(adapter: RecyclerView.Adapter?) {
28 | mRecyclerView?.adapter = adapter
29 | }
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/popupwindow/DefPopupWindow.kt:
--------------------------------------------------------------------------------
1 | package common.base.popupwindow
2 |
3 | import android.content.Context
4 |
5 | /**
6 | * DESC:
7 | * 目的是为了让该类的使用 和原生[PopupWindow]类似,消除 BasePopupWindow 的泛型参数
8 | *
9 | */
10 | class DefPopupWindow(context: Context) : BasePopupWindow(context) {
11 | override fun providerContentLayoutRes(): Int? {
12 | return null
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/retrofitCase/JsonConvert.java:
--------------------------------------------------------------------------------
1 | package common.base.retrofitCase;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import java.io.IOException;
7 | import java.lang.reflect.Type;
8 |
9 | import okhttp3.ResponseBody;
10 | import retrofit2.Converter;
11 |
12 | /**
13 | * User: fee(1176610771@qq.com)
14 | * Date: 2016-05-16
15 | * Time: 18:09
16 | * DESC: JsonObject 转换器,即将Retrofit的响应结果转换成JsonObject数据
17 | */
18 | public class JsonConvert implements Converter{
19 | private Type mType;
20 | public JsonConvert(Type type) {
21 | this.mType = type;
22 | }
23 | @Override
24 | public JSONObject convert(ResponseBody value) throws IOException {
25 | if (mType == JSONObject.class) {
26 | JSONObject result = null;
27 | try {
28 | String respStr = value.string();
29 | result = new JSONObject(respStr);
30 | } catch (JSONException e) {
31 | e.printStackTrace();
32 | }
33 | return result;
34 | }
35 | return null;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/CommonConfigs.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | /**
4 | * 一些能公共配置信息的类
5 | * eg.任何使用该通用库的APK程序所要存储数据的根路径配置
6 | *
7 | * 2015年12月23日-下午2:13:52
8 | * @author lifei
9 | */
10 | public class CommonConfigs {
11 | /**
12 | * 如果使用方需要使用{@linkplain StorageUtil}
13 | * 需要先配置一下当前开始的APP的存储的根目录地址
14 | * 本程序的存储信息根目录名eg.: "/myapp/"
15 | */
16 | public static String APP_BASE_PATH = "";
17 |
18 | /**
19 | * 调试追踪日志标志
20 | */
21 | public static boolean DEBUG_TRACE_FLAG = true;
22 | public static final String DEBUG_TRACE_DIR_NAME = "CommonModule_Debug/";
23 | public static final String DEBUG_TRACE_FILE_NAME = "/debug_trace.txt";
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/CountTimer.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | /**
4 | * ******************(^_^)***********************
5 | * User: 11776610771@qq.com
6 | * Date: 2017/10/12
7 | * Time: 9:52
8 | * DESC:
9 | * 统计开始到结束的所用的时间
10 | * 注意,这个只适合单线程
11 | *
12 | * ******************(^_^)***********************
13 | */
14 |
15 | public class CountTimer {
16 | private static final String TAG = "CountTimer";
17 | private static long startTime;
18 |
19 | public static void start() {
20 | startTime = System.currentTimeMillis();
21 | }
22 |
23 | public static void end() {
24 | end(null);
25 | }
26 | public static void end(String logTag) {
27 | end(logTag, null);
28 | }
29 |
30 | public static void end(String logTag, String logExtraInfo) {
31 | end(logTag, logExtraInfo, 1);
32 | }
33 | /**
34 | * 结束计时,并且输出打印信息
35 | * @param logTag Log 的tag,如果为null 则用本类的TAG="CountTimer"
36 | * @param logExtraInfo Log的内容 : 如果为null,则直接是"-->end() experience time: ",否则,为 "xxxx() -->end() experience time: "
37 | * @param logLevel Log输出级别,1:i; 2:w;3:e.
38 | */
39 | public static void end(String logTag, String logExtraInfo, int logLevel) {
40 | long endTiem = System.currentTimeMillis();
41 | long wasteTiem = endTiem - startTime;
42 | String finalLogTag = logTag == null ? TAG : logTag;
43 | String logInfoContent = " --> waste time: "+ wasteTiem;
44 | if (logExtraInfo != null) {
45 | logInfoContent = logExtraInfo + logInfoContent;
46 | }
47 | switch (logLevel) {
48 | case 1:
49 | CommonLog.i(finalLogTag, logInfoContent);
50 | break;
51 | case 2:
52 | CommonLog.w(finalLogTag, logInfoContent);
53 | break;
54 | case 3:
55 | CommonLog.e(finalLogTag, logInfoContent);
56 | break;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/CountdownTimerImpl.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | import android.os.CountDownTimer;
4 |
5 | /**
6 | * *****************(^_^)***********************
7 | * User: fee(QQ/WeiXin:1176610771)
8 | * Date: 2020/2/12
9 | * Time: 15:24
10 | * DESC:
11 | * 倒数实现者
12 | *
13 | * ******************(^_^)***********************
14 | */
15 | public class CountdownTimerImpl extends CountDownTimer {
16 | /**
17 | * @param millisInFuture The number of millis in the future from the call
18 | * to {@link #start()} until the countdown is done and {@link #onFinish()}
19 | * is called.
20 | * @param countDownInterval The interval along the way to receive
21 | * {@link #onTick(long)} callbacks.
22 | */
23 | public CountdownTimerImpl(long millisInFuture, long countDownInterval) {
24 | super(millisInFuture, countDownInterval);
25 | }
26 |
27 | private ICountdown countdown;
28 |
29 | public void setCountdown(ICountdown countdown) {
30 | this.countdown = countdown;
31 | }
32 | /**
33 | * Callback fired on regular interval.
34 | *
35 | * @param millisUntilFinished The amount of time until finished.
36 | */
37 | @Override
38 | public void onTick(long millisUntilFinished) {
39 | if (countdown != null) {
40 | countdown.onTick(millisUntilFinished);
41 | }
42 | }
43 |
44 | /**
45 | * Callback fired when the time is up.
46 | */
47 | @Override
48 | public void onFinish() {
49 | if (countdown != null) {
50 | countdown.onFinish();
51 | }
52 | }
53 |
54 | public interface ICountdown{
55 | void onFinish();
56 |
57 | /**
58 | * 一次倒数回调
59 | * @param leftMillisUntilFinished 倒数后剩下的毫秒数
60 | */
61 | void onTick(long leftMillisUntilFinished);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/FileUtil.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | import androidx.annotation.WorkerThread;
4 |
5 | import java.io.File;
6 | import java.io.FileWriter;
7 | import java.io.IOException;
8 |
9 | /**
10 | * *****************(^_^)***********************
11 | * User: fee(QQ/WeiXin:1176610771)
12 | * Date: 2021/4/24
13 | * Time: 22:42
14 | * DESC:
15 | * 操作文件的工具类
16 | *
17 | * ******************(^_^)***********************
18 | */
19 | public class FileUtil {
20 |
21 |
22 | public static boolean writeStrContentToFile(String content, String fileAbsPath,boolean toAppendFileEnd) {
23 | boolean isWritenOk = false;
24 | FileWriter fw = null;
25 | try {
26 | fw = new FileWriter(fileAbsPath, toAppendFileEnd);
27 | fw.write(content);
28 | isWritenOk = true;
29 | } catch (Exception exception) {
30 | exception.printStackTrace();
31 | }finally {
32 | if (fw != null) {
33 | try {
34 | fw.flush();
35 | fw.close();
36 | } catch (IOException e) {
37 | e.printStackTrace();
38 | }
39 | }
40 | }
41 | return isWritenOk;
42 | }
43 |
44 | @WorkerThread
45 | public static boolean deleteFileOrDir(String filePath) {
46 | if (CheckUtil.isEmpty(filePath)) {
47 | return false;
48 | }
49 | try {
50 | boolean isOptSuc = false;
51 | File theFile = new File(filePath);
52 | if (theFile.exists()) {
53 | if (theFile.isFile()) {
54 | isOptSuc = theFile.delete();
55 | }else if(theFile.isDirectory()) {
56 | //文件夹需要递归删除
57 | StorageUtil.deleteFile(theFile);
58 | }
59 | }
60 | return isOptSuc;
61 | } catch (Exception e) {
62 | e.printStackTrace();
63 | }
64 | return false;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/GenericsParamUtil.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | import java.lang.reflect.GenericArrayType;
4 | import java.lang.reflect.ParameterizedType;
5 | import java.lang.reflect.Type;
6 | import java.lang.reflect.TypeVariable;
7 |
8 | /**
9 | * ******************(^_^)***********************
10 | * User: 11776610771@qq.com
11 | * Date: 2017/4/5
12 | * Time: 18:11
13 | * DESC: 泛型参数工具类,主要用来获取泛型参数的具体所指代的参数类型,eg.: X ,当被赋值X,用来获取T为User对象并返回
14 | * User.class
15 | ********************(^_^)***********************
16 | */
17 |
18 | public class GenericsParamUtil {
19 | public static Class getGenericsParamCalss(Type type, int i) {
20 | if (type instanceof ParameterizedType) { // 处理泛型类型
21 | return getGenericClass((ParameterizedType) type, i);
22 | } else if (type instanceof TypeVariable) {
23 | return getGenericsParamCalss(((TypeVariable) type).getBounds()[0], 0); // 处理泛型擦拭对象
24 | } else {// class本身也是type,强制转型
25 | return (Class) type;
26 | }
27 | }
28 |
29 | public static Class getGenericClass(ParameterizedType parameterizedType, int i) {
30 | Object genericClass = parameterizedType.getActualTypeArguments()[i];
31 | if (genericClass instanceof ParameterizedType) { // 处理多级泛型
32 | return (Class) ((ParameterizedType) genericClass).getRawType();
33 | } else if (genericClass instanceof GenericArrayType) { // 处理数组泛型
34 | return (Class) ((GenericArrayType) genericClass).getGenericComponentType();
35 | } else if (genericClass instanceof TypeVariable) { // 处理泛型擦拭对象
36 | return (Class) getGenericsParamCalss(((TypeVariable) genericClass).getBounds()[0], 0);
37 | } else {
38 | return (Class) genericClass;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/ITimeCounterListener.kt:
--------------------------------------------------------------------------------
1 | package common.base.utils
2 |
3 | import androidx.annotation.WorkerThread
4 |
5 |
6 | interface ITimeCounterListener {
7 | /**
8 | * 计时回调
9 | * @param theCounter 当前的计时者
10 | * @param curTime 计时后的当前时间
11 | * @param isComplete true:完成(一般是倒计时场景);
12 | */
13 | @WorkerThread
14 | fun onTimeCount(theCounter: TimeCounter, curTime: Long, isComplete: Boolean)
15 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/StepTracker.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | /**
4 | * ******************(^_^)***********************
5 | * User: fee(QQ/WeiXin:1176610771)
6 | * Date: 2019/4/11
7 | * Time: 16:51
8 | * DESC:
9 | * 运行步骤的步次tracker
10 | *
11 | * ******************(^_^)***********************
12 | */
13 | public class StepTracker {
14 | private static int curStep;
15 | private static final String TAG = "StepTracker";
16 |
17 | private static void trackStep(String stepTag, String logMsg,int logLevel) {
18 | curStep++;
19 | if (CheckUtil.isEmpty(stepTag)) {
20 | stepTag = TAG;
21 | }
22 | if (logMsg == null) {
23 | logMsg = "";
24 | }
25 | logMsg += " curStep = " + curStep;
26 | switch (logLevel) {
27 | case 1:
28 | CommonLog.i(stepTag, logMsg);
29 | break;
30 | case 2:
31 | CommonLog.w(stepTag,logMsg);
32 | break;
33 | case 3:
34 | CommonLog.e(stepTag,logMsg);
35 | break;
36 | case 4:
37 | CommonLog.d(stepTag, logMsg);
38 | break;
39 | default:
40 | CommonLog.i(stepTag, logMsg);
41 | break;
42 | }
43 | }
44 | public static void trackStepLogW(String stepTag, String logMsg) {
45 | trackStep(stepTag,logMsg,2);
46 | }
47 | public static void trackStepLogD(String stepTag, String logMsg) {
48 | trackStep(stepTag,logMsg,4);
49 | }
50 | public static void trackStepLogI(String stepTag, String logMsg) {
51 | trackStep(stepTag,logMsg,1);
52 | }
53 | public static void trackStepLogE(String stepTag, String logMsg) {
54 | trackStep(stepTag,logMsg,3);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/TopSmoothScroller.java:
--------------------------------------------------------------------------------
1 | package common.base.utils;
2 |
3 | import android.content.Context;
4 | import androidx.recyclerview.widget.LinearSmoothScroller;
5 |
6 | /**
7 | * ******************(^_^)***********************
8 | * User: fee(QQ/WeiXin:1176610771)
9 | * Date: 2019/10/10
10 | * Time: 15:15
11 | * DESC:
12 | * 供RecyclerView作平滑滚动到指定position的滚动者
13 | * 有一个平滑滚动效果,并且可以滚动到对应position位置并置顶
14 | *
15 | * ******************(^_^)***********************
16 | */
17 | public class TopSmoothScroller extends LinearSmoothScroller {
18 |
19 | public TopSmoothScroller(Context context) {
20 | super(context);
21 | }
22 |
23 | @Override
24 | protected int getHorizontalSnapPreference() {
25 | return SNAP_TO_START;//具体见源码注释
26 | }
27 | @Override
28 | protected int getVerticalSnapPreference() {
29 | return SNAP_TO_START;//具体见源码注释
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/common/base/utils/XCoroutineScope.kt:
--------------------------------------------------------------------------------
1 | package common.base.utils
2 |
3 | import android.os.Looper
4 | import kotlinx.coroutines.CoroutineScope
5 | import kotlinx.coroutines.Dispatchers
6 | import kotlinx.coroutines.asCoroutineDispatcher
7 | import kotlinx.coroutines.launch
8 | import java.util.concurrent.ExecutorService
9 |
10 |
11 | object XCoroutineScope {
12 |
13 | /**
14 | * 主线程中的 CoroutineScope
15 | */
16 | val mainCoroutineScope by lazy {
17 | CoroutineScope(Dispatchers.Main)
18 | }
19 |
20 | /**
21 | * 需要外部指定线程执行器
22 | */
23 | var mExecutor: ExecutorService? = null
24 |
25 | val ioCoroutineScope by lazy {
26 | val asCoroutineDispatcher = mExecutor?.asCoroutineDispatcher() ?: return@lazy null
27 | CoroutineScope(asCoroutineDispatcher)
28 | }
29 |
30 | fun excute(task: Runnable) {
31 | mExecutor?.execute(task)
32 | }
33 |
34 | fun excuteOnMain(task: Runnable) {
35 | if (Looper.getMainLooper() == Looper.myLooper()){//已经在主线程上了
36 | task.run()
37 | return
38 | }
39 | mainCoroutineScope.launch {
40 | task.run()
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/main/java/common/base/views/CommonRefreshRecyclerView.java:
--------------------------------------------------------------------------------
1 | package common.base.views;
2 |
3 | import android.content.Context;
4 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
5 | import androidx.recyclerview.widget.RecyclerView;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 | import android.widget.FrameLayout;
9 | import android.widget.LinearLayout;
10 |
11 | import common.base.R;
12 | import common.base.utils.ViewUtil;
13 |
14 | /**
15 | * User: fee(1176610771@qq.com)
16 | * Date: 2016-06-27
17 | * Time: 12:02
18 | * DESC: 通用的UI界面 Android官方的下拉刷新,以及RecyclerView
19 | */
20 | public class CommonRefreshRecyclerView extends FrameLayout{
21 | public SwipeRefreshLayout swipeRefreshLayout;
22 | public RecyclerView recyclerView;
23 | private LinearLayout llContainerView;
24 | public CommonRefreshRecyclerView(Context context) {
25 | this(context,null);
26 | }
27 |
28 | public CommonRefreshRecyclerView(Context context, AttributeSet attrs) {
29 | super(context, attrs);
30 | inflate(context, R.layout.common_recycler_pull_refresh_layout, this);
31 | llContainerView = ViewUtil.findViewInContainer(this, R.id.ll_contaner_view);
32 | swipeRefreshLayout = ViewUtil.findViewInContainer(this, R.id.swipe_refreshlayout);
33 | recyclerView = ViewUtil.findViewInContainer(this,R.id.recycleview);
34 | }
35 | public RecyclerView getRecyclerView() {
36 | return recyclerView;
37 | }
38 |
39 | public SwipeRefreshLayout getSwipeRefreshLayout() {
40 | return swipeRefreshLayout;
41 | }
42 |
43 | public void addCustomHeaderView(View customHeaderView) {
44 | if (customHeaderView != null && customHeaderView.getParent() == null) {
45 | llContainerView.addView(customHeaderView,0);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/common/base/views/CustomTextView.java:
--------------------------------------------------------------------------------
1 | package common.base.views;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import androidx.annotation.Px;
6 | import androidx.appcompat.widget.AppCompatTextView;
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 |
10 | /**
11 | * ******************(^_^)***********************
12 | * User: fee(QQ/WeiXin:1176610771)
13 | * Date: 2020/1/10
14 | * Time: 11:35
15 | * DESC:
16 | *
17 | * ******************(^_^)***********************
18 | */
19 | public class CustomTextView extends AppCompatTextView {
20 |
21 | public CustomTextView(Context context) {
22 | super(context);
23 | }
24 |
25 | public CustomTextView(Context context, @Nullable AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public CustomTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
30 | super(context, attrs, defStyleAttr);
31 | }
32 |
33 | public void setTextSizeWithPxValue(@Px int textSizePxValue) {
34 | setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePxValue);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/common/base/views/CustomToast.java:
--------------------------------------------------------------------------------
1 | package common.base.views;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.content.Context;
6 | import android.widget.Toast;
7 |
8 | /**
9 | * *****************(^_^)***********************
10 | * User: fee(QQ/WeiXin:1176610771)
11 | * Date: 2020/5/30
12 | * Time: 21:54
13 | * DESC:
14 | *
15 | *
16 | * ******************(^_^)***********************
17 | */
18 | class CustomToast extends Toast {
19 |
20 | /**
21 | * Construct an empty Toast object. You must call {@link #setView} before you
22 | * can call {@link #show}.
23 | *
24 | * @param context The context to use. Usually your {@link Application}
25 | * or {@link Activity} object.
26 | */
27 | public CustomToast(Context context) {
28 | super(context);
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/common/base/views/FrameAnimationController.java:
--------------------------------------------------------------------------------
1 |
2 | package common.base.views;
3 |
4 | import android.os.Handler;
5 | import android.os.Message;
6 |
7 | public class FrameAnimationController {
8 | private static final int MSG_ANIMATE = 1000;
9 |
10 | public static final int ANIMATION_FRAME_DURATION = 1000 / 60;
11 |
12 | private static final Handler mHandler = new AnimationHandler();
13 |
14 | private FrameAnimationController() {
15 | throw new UnsupportedOperationException();
16 | }
17 |
18 | public static void requestAnimationFrame(Runnable runnable) {
19 | Message message = new Message();
20 | message.what = MSG_ANIMATE;
21 | message.obj = runnable;
22 | mHandler.sendMessageDelayed(message, ANIMATION_FRAME_DURATION);
23 | }
24 |
25 | public static void requestFrameDelay(Runnable runnable, long delay) {
26 | Message message = new Message();
27 | message.what = MSG_ANIMATE;
28 | message.obj = runnable;
29 | mHandler.sendMessageDelayed(message, delay);
30 | }
31 |
32 | private static class AnimationHandler extends Handler {
33 | public void handleMessage(Message m) {
34 | switch (m.what) {
35 | case MSG_ANIMATE:
36 | if (m.obj != null) {
37 | ((Runnable) m.obj).run();
38 | }
39 | break;
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/common/base/views/RadiusCornerBackgroundColorSpan.java:
--------------------------------------------------------------------------------
1 | package common.base.views;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 | import androidx.annotation.ColorInt;
7 | import android.text.style.ReplacementSpan;
8 |
9 | /**
10 | * *****************(^_^)***********************
11 | * User: fee(QQ/WeiXin:1176610771)
12 | * Date: 2020/2/14
13 | * Time: 14:43
14 | * DESC:
15 | * 可设置为圆角矩形的背景颜色 SPAN
16 | *
17 | * ******************(^_^)***********************
18 | */
19 | public class RadiusCornerBackgroundColorSpan extends ReplacementSpan {
20 | private int mSize;
21 | private int mColor;
22 | private int mRadius;
23 |
24 | /**
25 | * @param color 背景颜色
26 | * @param radius 圆角半径
27 | */
28 | public RadiusCornerBackgroundColorSpan(@ColorInt int color, int radius) {
29 | mColor = color;
30 | mRadius = radius;
31 | }
32 |
33 | @Override
34 | public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
35 | mSize = (int) (paint.measureText(text, start, end) + 2 * mRadius);
36 | //mSize就是span的宽度,span有多宽,开发者可以在这里随便定义规则
37 | //我的规则:这里text传入的是SpannableString,start,end对应setSpan方法相关参数
38 | //可以根据传入起始截至位置获得截取文字的宽度,最后加上左右两个圆角的半径得到span宽度
39 | return mSize;
40 | }
41 |
42 | @Override
43 | public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
44 | int color = paint.getColor();//保存文字颜色
45 | paint.setColor(mColor);//设置背景颜色
46 | paint.setAntiAlias(true);// 设置画笔的锯齿效果
47 | RectF oval = new RectF(x, y + paint.ascent(), x + mSize, y + paint.descent());
48 | //设置文字背景矩形,x为span其实左上角相对整个TextView的x值,y为span左上角相对整个View的y值。paint.ascent()获得文字上边缘,paint.descent()获得文字下边缘
49 | canvas.drawRoundRect(oval, mRadius, mRadius, paint);//绘制圆角矩形,第二个参数是x半径,第三个参数是y半径
50 | paint.setColor(color);//恢复画笔的文字颜色
51 | canvas.drawText(text, start, end, x + mRadius, y, paint);//绘制文字
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_part_left_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_part_right_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_rotate_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_whole_left_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_whole_left_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_whole_right_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/anim/common_whole_right_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
21 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/src/main/res/anim/expandable_hide.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
13 |
--------------------------------------------------------------------------------
/src/main/res/anim/expandable_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
13 |
--------------------------------------------------------------------------------
/src/main/res/anim/modal_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
10 |
11 |
19 |
20 |
29 |
30 |
39 |
--------------------------------------------------------------------------------
/src/main/res/anim/popwindow_y_translate_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/src/main/res/anim/popwindow_y_translate_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/src/main/res/anim/switcher_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/anim/switcher_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/arrow_down.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/arrow_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/arrow_up.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/circle_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/circle_loading.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/common_alert_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/common_alert_icon.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/common_right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/common_right_arrow.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/hint_info_pink_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/hint_info_pink_icon.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/message_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/message_icon.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/okey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/okey.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/pagefailed_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/pagefailed_bg.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/rotate_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/rotate_icon.png
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/toast_background.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-hdpi/toast_background.9.png
--------------------------------------------------------------------------------
/src/main/res/drawable-xhdpi/switch_btn_bottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-xhdpi/switch_btn_bottom.png
--------------------------------------------------------------------------------
/src/main/res/drawable-xhdpi/switch_btn_frame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-xhdpi/switch_btn_frame.png
--------------------------------------------------------------------------------
/src/main/res/drawable-xhdpi/switch_btn_mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-xhdpi/switch_btn_mask.png
--------------------------------------------------------------------------------
/src/main/res/drawable-xhdpi/switch_btn_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-xhdpi/switch_btn_pressed.png
--------------------------------------------------------------------------------
/src/main/res/drawable-xhdpi/swithc_btn_unpressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable-xhdpi/swithc_btn_unpressed.png
--------------------------------------------------------------------------------
/src/main/res/drawable/background_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/main/res/drawable/indeterminate_progressbar_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | -
20 |
26 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/res/drawable/indicator_corner_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/res/drawable/progressbar_style_light_green_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
7 |
8 |
9 | -
11 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/main/res/drawable/rounded_black_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/src/main/res/drawable/rounded_corner_white_stroke.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
--------------------------------------------------------------------------------
/src/main/res/drawable/rounded_different_corner_white_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/drawable/rounded_white_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/drawable/sample_footer_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feer921/BaseProject/2b26b274b924b4a7862f30335c1b416c67b5c150/src/main/res/drawable/sample_footer_loading.png
--------------------------------------------------------------------------------
/src/main/res/drawable/sample_footer_loading_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/res/drawable/selector_4_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | -
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/main/res/drawable/selector_for_text_colors_black_def.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/res/drawable/shape_4_dialog_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/res/drawable/shape_ok_toast_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/res/drawable/shape_rounded_dark_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/res/drawable/shape_stroke_1_radius_10_bg_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/src/main/res/drawable/simple_toast_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/src/main/res/drawable/top_rounded_corner_blue_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/res/layout/base_common_header_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
16 |
21 |
22 |
30 |
31 |
37 |
47 |
48 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_empty_recycler_pull_refresh_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
27 |
28 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_progress_dialog_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
16 |
23 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_progress_dialog_layout2.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
20 |
27 |
39 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_pull_refresh_recyclerview_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
17 |
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_recycler_pull_refresh_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_refresh_webview_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
21 |
26 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/res/layout/common_tabstrip_viewpager_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
26 |
--------------------------------------------------------------------------------
/src/main/res/layout/def_header_4_vrefresh_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
19 |
25 |
26 |
36 |
37 |
--------------------------------------------------------------------------------
/src/main/res/layout/def_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/src/main/res/layout/empty_error_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
28 |
29 |
34 |
35 |
36 |
49 |
50 |
--------------------------------------------------------------------------------
/src/main/res/layout/empty_loading_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/res/layout/gray_divider_line.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/src/main/res/layout/item_just_textview.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/layout/item_text_imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
22 |
--------------------------------------------------------------------------------
/src/main/res/layout/ok_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
32 |
33 |
47 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/main/res/layout/simple_dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
16 |
--------------------------------------------------------------------------------
/src/main/res/layout/simple_guide_banner_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
25 |
36 |
53 |
54 |
--------------------------------------------------------------------------------
/src/main/res/layout/view_expandable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/src/main/res/values-en/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Loading,please wait...
3 | Load more failed
4 | No more data
5 |
6 |
7 | Load data failed.
8 | No anything data.
9 | The network may be invalid.
10 | Click to retry.
11 | Setting NetWork
12 |
13 |
--------------------------------------------------------------------------------
/src/main/res/values/attrs_focus_show_text_view.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 |
--------------------------------------------------------------------------------
/src/main/res/values/attrs_imageviewplus.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/res/values/attrs_roundcornerframelayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/main/res/values/attrs_xrounded_corners_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
5 | BaseProject
6 | 确认
7 | 确定
8 | "确 定"
9 | "取 消"
10 | "取消"
11 | "提示"
12 | "正在加载,请稍候…"
13 | 下拉刷新
14 | 松开刷新数据
15 | 正在加载...
16 | 上次更新时间:
17 | 查看更多
18 | 松开载入更多
19 | 加载失败,请点我重试
20 | 没有更多数据
21 |
22 | 抱歉,数据加载失败.
23 | 暂时没有任何数据
24 | 网络好像出问题了
25 | 点击重试
26 | 设置网络
27 | 松手刷新
28 | 下拉刷新
29 | 即将刷新
30 | 刷新中
31 | 刷新完成
32 | 取消刷新
33 |
34 |
--------------------------------------------------------------------------------
/src/test/java/common/base/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package common.base;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------