sourceOb) {
35 | return sourceOb.takeUntil(observable);
36 | }
37 | };
38 | }
39 |
40 | @Override
41 | public void onCreate(@Nullable Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | lifeSubject.onNext(FragmentEvent.CREATE);
44 | }
45 |
46 |
47 | @Override
48 | public void onStart() {
49 | super.onStart();
50 | lifeSubject.onNext(FragmentEvent.START);
51 | }
52 |
53 | @Override
54 | public void onResume() {
55 | super.onResume();
56 | lifeSubject.onNext(FragmentEvent.RESUME);
57 | }
58 |
59 | @Override
60 | public void onPause() {
61 | super.onPause();
62 | lifeSubject.onNext(FragmentEvent.PAUSE);
63 | }
64 |
65 | @Override
66 | public void onStop() {
67 | super.onStop();
68 | lifeSubject.onNext(FragmentEvent.STOP);
69 | }
70 |
71 | @Override
72 | public void onDestroy() {
73 | super.onDestroy();
74 | lifeSubject.onNext(FragmentEvent.DESTROY);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/recyclerview/ClassTitleDecoration2.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import java.util.List;
7 |
8 |
9 | /**
10 | * Created by _SOLID
11 | * Date:2016/10/10
12 | * Time:16:19
13 | * Desc:处理带有header的分类标题(待完善)
14 | */
15 |
16 | public class ClassTitleDecoration2 extends ClassTitleDecoration {
17 | public ClassTitleDecoration2(Context context, List extends ClassTitleItem> items) {
18 | super(context, items);
19 | }
20 |
21 | @Override
22 | protected boolean isDataUnValid(int position, RecyclerView recyclerView) {
23 | boolean result = super.isDataUnValid(position, recyclerView);
24 | int headCount = 0;
25 | if (headCount == 0) {
26 | return result;
27 | } else {
28 | return result || position < headCount;
29 | }
30 | }
31 |
32 | @Override
33 | protected int getAdjustPosition(int position, RecyclerView recyclerView) {
34 | // if (recyclerView.getAdapter() instanceof HeaderAndFooterWrapper) {
35 | // position -= ((HeaderAndFooterWrapper) recyclerView.getAdapter()).getHeadersCount();
36 | // }
37 | return super.getAdjustPosition(position, recyclerView);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/recyclerview/ClassTitleItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.recyclerview;
2 |
3 |
4 | /**
5 | * Created by _SOLID
6 | * Date:2016/10/9
7 | * Time:13:07
8 | * Desc:需要实现分类列表的数据实体必需实现此接口
9 | */
10 |
11 | public interface ClassTitleItem {
12 |
13 | String getClassTitle();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/recyclerview/LinearDecoration.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 | import android.graphics.drawable.Drawable;
9 | import android.support.v4.content.ContextCompat;
10 | import android.support.v7.widget.LinearLayoutManager;
11 | import android.support.v7.widget.RecyclerView;
12 | import android.util.TypedValue;
13 | import android.view.View;
14 |
15 | import me.solidev.library.R;
16 |
17 | /**
18 | * Created by _SOLID
19 | * Date: 2016/9/25
20 | * Time: 17:51
21 | * Desc:线性布局的分割线
22 | */
23 | public class LinearDecoration extends RecyclerView.ItemDecoration {
24 |
25 | private Paint mPaint;
26 | private Drawable mDivider;
27 | private int mDividerHeight;
28 | private int mDividerColor;
29 | private int mOrientation;//列表的方向
30 | private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
31 |
32 |
33 | /**
34 | * @param context context
35 | * @param orientation 列表方向
36 | */
37 | public LinearDecoration(Context context, int orientation) {
38 | this(context, orientation, 1);
39 | }
40 | //
41 | // /**
42 | // * 自定义分割线
43 | // *
44 | // * @param context
45 | // * @param orientation 列表方向
46 | // * @param drawableId 分割线图片
47 | // */
48 | // public LinearDecoration(Context context, int orientation, @DrawableRes int drawableId) {
49 | // this(context, orientation);
50 | // mDivider = ContextCompat.getDrawable(context, drawableId);
51 | // mDividerHeight = mDivider.getIntrinsicHeight();
52 | // }
53 |
54 | /**
55 | * 自定义分割线
56 | *
57 | * @param context context
58 | * @param orientation 列表方向
59 | * @param dividerHeight 分割线高度(dp)
60 | */
61 | public LinearDecoration(Context context, int orientation, int dividerHeight) {
62 | if (orientation != LinearLayoutManager.VERTICAL && orientation != LinearLayoutManager.HORIZONTAL) {
63 | throw new IllegalArgumentException("请输入正确的参数!");
64 | }
65 | mOrientation = orientation;
66 | final TypedArray a = context.obtainStyledAttributes(ATTRS);
67 | mDivider = a.getDrawable(0);
68 | a.recycle();
69 | mDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerHeight, context.getResources().getDisplayMetrics());
70 | mDividerColor = ContextCompat.getColor(context, R.color.tv_grey);
71 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
72 | mPaint.setColor(mDividerColor);
73 | mPaint.setStyle(Paint.Style.FILL);
74 | }
75 |
76 | public void setDividerColor(int color) {
77 | mDividerColor = color;
78 | }
79 |
80 |
81 | @Override
82 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
83 | super.getItemOffsets(outRect, view, parent, state);
84 | outRect.set(0, 0, 0, mDividerHeight);
85 | }
86 |
87 | @Override
88 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
89 | super.onDraw(c, parent, state);
90 |
91 | if (mOrientation == LinearLayoutManager.VERTICAL) {
92 | drawHorizontal(c, parent);
93 | } else if (mOrientation == LinearLayoutManager.HORIZONTAL) {
94 | drawVertical(c, parent);
95 | }
96 | }
97 |
98 | //绘制横向 item 分割线
99 | private void drawHorizontal(Canvas canvas, RecyclerView parent) {
100 |
101 | int childSize = parent.getChildCount();
102 | int left = parent.getPaddingLeft();
103 | int right = parent.getMeasuredWidth() - parent.getPaddingRight();
104 | for (int i = 0; i < childSize; i++) {
105 | View child = parent.getChildAt(i);
106 | RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
107 | int top = child.getBottom() + layoutParams.bottomMargin;
108 | int bottom = top + mDividerHeight;
109 | if (mDivider != null) {
110 | mDivider.setBounds(left, top, right, bottom);
111 | mDivider.draw(canvas);
112 | }
113 | if (mPaint != null) {
114 | canvas.drawRect(left, top, right, bottom, mPaint);
115 | }
116 | }
117 | }
118 |
119 | //绘制纵向 item 分割线
120 | private void drawVertical(Canvas canvas, RecyclerView parent) {
121 | final int top = parent.getPaddingTop();
122 | final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
123 | final int childSize = parent.getChildCount();
124 | for (int i = 0; i < childSize; i++) {
125 | final View child = parent.getChildAt(i);
126 | RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
127 | final int left = child.getRight() + layoutParams.rightMargin;
128 | final int right = left + mDividerHeight;
129 | if (mDivider != null) {
130 | mDivider.setBounds(left, top, right, bottom);
131 | mDivider.draw(canvas);
132 | }
133 | if (mPaint != null) {
134 | canvas.drawRect(left, top, right, bottom, mPaint);
135 | }
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/recyclerview/LoadMoreScrollListener.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.recyclerview;
2 |
3 | import android.support.v7.widget.LinearLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.support.v7.widget.StaggeredGridLayoutManager;
6 |
7 | /**
8 | * Created by _SOLID
9 | * Date:2016/10/9
10 | * Time:16:12
11 | * Desc:用于RecyclerView加载更多的监听,实现滑动到底部自动加载更多
12 | */
13 |
14 | public abstract class LoadMoreScrollListener extends RecyclerView.OnScrollListener {
15 |
16 |
17 | private int previousTotal;
18 | private boolean isLoading = true;
19 | private LinearLayoutManager lm;
20 | private StaggeredGridLayoutManager sm;
21 | private int[] lastPositions;
22 | private int totalItemCount;
23 | private int lastVisibleItemPosition;
24 |
25 | @Override
26 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
27 | super.onScrollStateChanged(recyclerView, newState);
28 | if (recyclerView.getLayoutManager() instanceof LinearLayoutManager)
29 | lm = (LinearLayoutManager) recyclerView.getLayoutManager();
30 | else if (recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
31 | sm = (StaggeredGridLayoutManager) recyclerView.getLayoutManager();
32 | lastPositions = sm.findLastVisibleItemPositions(null);
33 | }
34 |
35 | int visibleItemCount = recyclerView.getChildCount();
36 | if (lm != null) {
37 | totalItemCount = lm.getItemCount();
38 | lastVisibleItemPosition = lm.findLastVisibleItemPosition();
39 | } else if (sm != null) {
40 | totalItemCount = sm.getItemCount();
41 | lastVisibleItemPosition = lastPositions[0];
42 | }
43 |
44 | if (isLoading) {
45 | if (totalItemCount > previousTotal) {//加载更多结束
46 | isLoading = false;
47 | previousTotal = totalItemCount;
48 | } else if (totalItemCount < previousTotal) {//用户刷新结束
49 | previousTotal = totalItemCount;
50 | isLoading = false;
51 | } else {//有可能是在第一页刷新也可能是加载完毕
52 |
53 | }
54 |
55 |
56 | }
57 | if (!isLoading && visibleItemCount > 0 && totalItemCount - 1 == lastVisibleItemPosition && recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
58 | loadMore();
59 | }
60 |
61 | }
62 |
63 |
64 | public abstract void loadMore();
65 | }
66 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/recyclerview/OnRecyclerItemClickListener.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.GestureDetector;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 |
9 | /**
10 | * @author drakeet
11 | */
12 | public abstract class OnRecyclerItemClickListener extends GestureDetector.SimpleOnGestureListener
13 | implements RecyclerView.OnItemTouchListener {
14 |
15 | private View childView;
16 | private RecyclerView recyclerView;
17 | private GestureDetector gestureDetector;
18 |
19 |
20 | abstract void onItemClick(View view, int position);
21 |
22 |
23 | void onItemLongClick(View view, int position) {
24 |
25 | }
26 |
27 |
28 | public OnRecyclerItemClickListener(Context context) {
29 | gestureDetector = new GestureDetector(context.getApplicationContext(), this);
30 | }
31 |
32 |
33 | @Override public boolean onSingleTapUp(MotionEvent ev) {
34 | if (childView != null) {
35 | onItemClick(childView, recyclerView.getChildAdapterPosition(childView));
36 | }
37 | return true;
38 | }
39 |
40 |
41 | @Override public void onLongPress(MotionEvent ev) {
42 | if (childView != null) {
43 | onItemLongClick(childView, recyclerView.getChildAdapterPosition(childView));
44 | }
45 | }
46 |
47 |
48 | @Override
49 | public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
50 | gestureDetector.onTouchEvent(motionEvent);
51 | childView = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
52 | this.recyclerView = recyclerView;
53 | return false;
54 | }
55 |
56 |
57 | @Override public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
58 |
59 | }
60 |
61 |
62 | @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/StatusViewLayout.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.FrameLayout;
10 | import android.widget.TextView;
11 |
12 | import me.solidev.library.R;
13 | import me.solidev.library.ui.widget.loading.LVCircularJump;
14 | import me.solidev.library.ui.widget.loading.LVCircularZoom;
15 |
16 | /**
17 | * Created by _SOLID
18 | * Date:2016/8/9
19 | * Time:17:43
20 | *
21 | * 用来显示加载状态的View
22 | */
23 | public class StatusViewLayout extends FrameLayout {
24 |
25 | private int mEmptyViewResId;
26 | private int mErrorViewResId;
27 | private int mLoadingViewResId;
28 |
29 | private View mEmptyView;
30 | private View mErrorView;
31 | private View mLoadingView;
32 |
33 | private TextView lib_tv_error;
34 | private TextView lib_tv_empty_msg;
35 |
36 |
37 | private FrameLayout.LayoutParams mLayoutParams;
38 | private OnClickListener mOnRetryListener;
39 |
40 |
41 | public StatusViewLayout(Context context) {
42 | this(context, null);
43 | }
44 |
45 | public StatusViewLayout(Context context, AttributeSet attrs) {
46 | this(context, attrs, 0);
47 | }
48 |
49 | public StatusViewLayout(Context context, AttributeSet attrs, int defStyleAttr) {
50 | super(context, attrs, defStyleAttr);
51 |
52 | mEmptyViewResId = R.layout.lib_status_view_layout_empty;
53 | mErrorViewResId = R.layout.lib_status_view_layout_error;
54 | mLoadingViewResId = R.layout.lib_status_view_layout_loading;
55 | setUpView();
56 | //默认显示主内容
57 | showContent();
58 | }
59 |
60 | private void setUpView() {
61 | mLayoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
62 | mLayoutParams.gravity = Gravity.CENTER;
63 |
64 | mLoadingView = LayoutInflater.from(getContext()).inflate(mLoadingViewResId, null);
65 | mErrorView = LayoutInflater.from(getContext()).inflate(mErrorViewResId, null);
66 | mEmptyView = LayoutInflater.from(getContext()).inflate(mEmptyViewResId, null);
67 |
68 | lib_tv_empty_msg = (TextView) mEmptyView.findViewById(R.id.lib_tv_empty_msg);
69 | lib_tv_error = (TextView) mErrorView.findViewById(R.id.lib_tv_error);
70 |
71 | addView(mLoadingView, mLayoutParams);
72 | addView(mErrorView, mLayoutParams);
73 | addView(mEmptyView, mLayoutParams);
74 |
75 | mErrorView.setOnClickListener(new OnClickListener() {
76 | @Override
77 | public void onClick(View view) {
78 | if (mOnRetryListener != null) {
79 | showLoading();
80 | mOnRetryListener.onClick(view);
81 | }
82 | }
83 | });
84 | }
85 |
86 |
87 | public void setOnRetryListener(OnClickListener listener) {
88 | mOnRetryListener = listener;
89 | }
90 |
91 |
92 | public void showLoading() {
93 | for (int i = 0; i < getChildCount(); i++) {
94 | getChildAt(i).setVisibility(View.GONE);
95 | }
96 | mLoadingView.setVisibility(View.VISIBLE);
97 |
98 | }
99 |
100 | public void showError(String msg) {
101 | lib_tv_error.setText(msg);
102 | showError();
103 | }
104 |
105 | public void showError() {
106 | for (int i = 0; i < getChildCount(); i++) {
107 | getChildAt(i).setVisibility(View.GONE);
108 | }
109 | mErrorView.setVisibility(View.VISIBLE);
110 | }
111 |
112 | public void showEmpty(String msg) {
113 | lib_tv_empty_msg.setText(msg);
114 | showEmpty();
115 | }
116 |
117 | public void showEmpty() {
118 | for (int i = 0; i < getChildCount(); i++) {
119 | getChildAt(i).setVisibility(View.GONE);
120 | }
121 | mEmptyView.setVisibility(View.VISIBLE);
122 | }
123 |
124 |
125 | public void showContent() {
126 | for (int i = 0; i < getChildCount(); i++) {
127 | getChildAt(i).setVisibility(View.GONE);
128 | }
129 | getChildAt(getChildCount() - 1).setVisibility(View.VISIBLE);
130 | }
131 |
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/WrapContentViewPager.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | /**
9 | * Created by _SOLID
10 | * Date:2016/10/12
11 | * Time:18:00
12 | * Desc:copy from http://stackoverflow.com/questions/34484833/viewpager-wrap-content-not-working
13 | */
14 |
15 | public class WrapContentViewPager extends ViewPager {
16 |
17 | private int mCurrentPagePosition = 0;
18 |
19 | public WrapContentViewPager(Context context) {
20 | super(context);
21 | }
22 |
23 | public WrapContentViewPager(Context context, AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | @Override
28 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
29 | try {
30 | View child = getChildAt(mCurrentPagePosition);
31 | if (child != null) {
32 | child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
33 | int h = child.getMeasuredHeight();
34 | heightMeasureSpec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);
35 | }
36 | } catch (Exception e) {
37 | e.printStackTrace();
38 | }
39 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
40 | }
41 |
42 | public void reMeasureCurrentPage(int position) {
43 | mCurrentPagePosition = position;
44 | requestLayout();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/gridpager/GridPagerItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.gridpager;
2 |
3 | /**
4 | * Created by _SOLID
5 | * Date:2016/10/12
6 | * Time:13:37
7 | * Desc:
8 | */
9 |
10 | public interface GridPagerItem {
11 |
12 | String getImageUrl();
13 |
14 | String getTitle();
15 | }
16 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/indicator/ShapeHolder.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.indicator;
2 |
3 | import android.graphics.Paint;
4 | import android.graphics.drawable.ShapeDrawable;
5 | import android.graphics.drawable.shapes.Shape;
6 |
7 | /**
8 | * A data structure that holds a Shape and various properties that can be used to define
9 | * how the shape is drawn.
10 | */
11 | public class ShapeHolder {
12 | private float x = 0, y = 0;
13 | private ShapeDrawable shape;
14 | private int color;
15 | private float alpha = 1f;
16 | private Paint paint;
17 |
18 | public void setPaint(Paint value) {
19 | paint = value;
20 | }
21 |
22 | public Paint getPaint() {
23 | return paint;
24 | }
25 |
26 | public void setX(float value) {
27 | x = value;
28 | }
29 |
30 | public float getX() {
31 | return x;
32 | }
33 |
34 | public void setY(float value) {
35 | y = value;
36 | }
37 |
38 | public float getY() {
39 | return y;
40 | }
41 |
42 | public void setShape(ShapeDrawable value) {
43 | shape = value;
44 | }
45 |
46 | public ShapeDrawable getShape() {
47 | return shape;
48 | }
49 |
50 | public int getColor() {
51 | return color;
52 | }
53 |
54 | public void setColor(int value) {
55 | shape.getPaint().setColor(value);
56 | color = value;
57 |
58 | }
59 |
60 | public void setAlpha(float alpha) {
61 | this.alpha = alpha;
62 | shape.setAlpha((int) ((alpha * 255f) + .5f));
63 | }
64 |
65 | public float getWidth() {
66 | return shape.getShape().getWidth();
67 | }
68 |
69 | public void setWidth(float width) {
70 | Shape s = shape.getShape();
71 | s.resize(width, s.getHeight());
72 | }
73 |
74 | public float getHeight() {
75 | return shape.getShape().getHeight();
76 | }
77 |
78 | public void setHeight(float height) {
79 | Shape s = shape.getShape();
80 | s.resize(s.getWidth(), height);
81 | }
82 |
83 | public void resizeShape(final float width, final float height) {
84 | shape.getShape().resize(width, height);
85 | }
86 |
87 | public ShapeHolder(ShapeDrawable s) {
88 | shape = s;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/loading/LVCircularJump.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.loading;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.ValueAnimator;
6 | import android.content.Context;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 | import android.view.animation.LinearInterpolator;
13 |
14 | /**
15 | * Created by lumingmin on 16/6/20.
16 | */
17 |
18 | public class LVCircularJump extends View {
19 |
20 | private Paint mPaint;
21 |
22 | private float mWidth = 0f;
23 | private float mHeight = 0f;
24 | private float mMaxRadius = 10;
25 | private int circularCount = 4;
26 | private float mAnimatedValue = 0f;
27 | private int mJumpValue = 0;
28 |
29 |
30 | public LVCircularJump(Context context) {
31 | this(context, null);
32 | }
33 |
34 | public LVCircularJump(Context context, AttributeSet attrs) {
35 | this(context, attrs, 0);
36 | }
37 |
38 | public LVCircularJump(Context context, AttributeSet attrs, int defStyleAttr) {
39 | super(context, attrs, defStyleAttr);
40 | initPaint();
41 | }
42 |
43 | @Override
44 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
45 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
46 | mWidth = getMeasuredWidth();
47 | mHeight = getMeasuredHeight();
48 |
49 | }
50 |
51 | @Override
52 | protected void onDraw(Canvas canvas) {
53 | super.onDraw(canvas);
54 |
55 |
56 | float circularX = mWidth / circularCount;
57 |
58 | for (int i = 0; i < circularCount; i++) {
59 |
60 | if (i == mJumpValue % circularCount) {
61 |
62 | canvas.drawCircle(i * circularX + circularX / 2f,
63 | mHeight / 2 - mHeight / 2 * mAnimatedValue,
64 | mMaxRadius, mPaint);
65 |
66 | } else {
67 | canvas.drawCircle(i * circularX + circularX / 2f,
68 | mHeight / 2,
69 | mMaxRadius, mPaint);
70 | }
71 |
72 | }
73 |
74 |
75 | }
76 |
77 |
78 | private void initPaint() {
79 | mPaint = new Paint();
80 | mPaint.setAntiAlias(true);
81 | mPaint.setStyle(Paint.Style.FILL);
82 | mPaint.setColor(Color.GRAY);
83 |
84 |
85 | }
86 |
87 | public void startAnim() {
88 | stopAnim();
89 | startViewAnim(0f, 1f, 500);
90 | }
91 |
92 | public void stopAnim() {
93 | if (valueAnimator != null) {
94 | clearAnimation();
95 | mAnimatedValue = 0f;
96 | mJumpValue = 0;
97 | valueAnimator.setRepeatCount(0);
98 | valueAnimator.cancel();
99 | valueAnimator.end();
100 | }
101 | }
102 |
103 | ValueAnimator valueAnimator;
104 |
105 | private ValueAnimator startViewAnim(float startF, final float endF, long time) {
106 | valueAnimator = ValueAnimator.ofFloat(startF, endF);
107 | valueAnimator.setDuration(time);
108 | valueAnimator.setInterpolator(new LinearInterpolator());
109 | valueAnimator.setRepeatCount(ValueAnimator.INFINITE);//无限循环
110 | valueAnimator.setRepeatMode(ValueAnimator.RESTART);
111 | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
112 | @Override
113 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
114 |
115 | mAnimatedValue = (float) valueAnimator.getAnimatedValue();
116 |
117 |
118 | if (mAnimatedValue > 0.5) {
119 | mAnimatedValue = 1 - mAnimatedValue;
120 | }
121 |
122 | invalidate();
123 | }
124 | });
125 | valueAnimator.addListener(new AnimatorListenerAdapter() {
126 | @Override
127 | public void onAnimationEnd(Animator animation) {
128 | super.onAnimationEnd(animation);
129 |
130 | }
131 |
132 | @Override
133 | public void onAnimationStart(Animator animation) {
134 | super.onAnimationStart(animation);
135 | }
136 |
137 | @Override
138 | public void onAnimationRepeat(Animator animation) {
139 | super.onAnimationRepeat(animation);
140 | mJumpValue++;
141 | }
142 | });
143 | if (!valueAnimator.isRunning()) {
144 | valueAnimator.start();
145 |
146 | }
147 |
148 | return valueAnimator;
149 | }
150 |
151 | }
152 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/loading/LVCircularZoom.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.loading;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.ValueAnimator;
6 | import android.content.Context;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.util.AttributeSet;
11 | import android.util.TypedValue;
12 | import android.view.View;
13 | import android.view.animation.LinearInterpolator;
14 |
15 | import static android.R.attr.type;
16 |
17 | /**
18 | * Created by lumingmin on 16/6/20.
19 | */
20 |
21 | public class LVCircularZoom extends View {
22 |
23 | private Paint mPaint;
24 |
25 | private float mWidth = 0f;
26 | private float mHigh = 0f;
27 | private float mMaxRadius;
28 | private int circularCount = 3;
29 | private float mAnimatedValue = 1.0f;
30 | private int mJumpValue = 0;
31 |
32 |
33 | public LVCircularZoom(Context context) {
34 | this(context, null);
35 | }
36 |
37 | public LVCircularZoom(Context context, AttributeSet attrs) {
38 | this(context, attrs, 0);
39 | }
40 |
41 | public LVCircularZoom(Context context, AttributeSet attrs, int defStyleAttr) {
42 | super(context, attrs, defStyleAttr);
43 | mMaxRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, context.getResources().getDisplayMetrics());
44 | initPaint();
45 | }
46 |
47 | @Override
48 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
49 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
50 | mWidth = getMeasuredWidth();
51 | mHigh = getMeasuredHeight();
52 |
53 | }
54 |
55 | @Override
56 | protected void onDraw(Canvas canvas) {
57 | super.onDraw(canvas);
58 |
59 |
60 | float circularX = mWidth / circularCount;
61 |
62 | for (int i = 0; i < circularCount; i++) {
63 |
64 | if (i == mJumpValue % circularCount) {
65 | canvas.drawCircle(i * circularX + circularX / 2f,
66 | mHigh / 2,
67 | mMaxRadius * mAnimatedValue, mPaint);
68 |
69 |
70 | } else {
71 | canvas.drawCircle(i * circularX + circularX / 2f,
72 | mHigh / 2,
73 | mMaxRadius, mPaint);
74 | }
75 |
76 | }
77 |
78 |
79 | }
80 |
81 |
82 | private void initPaint() {
83 | mPaint = new Paint();
84 | mPaint.setAntiAlias(true);
85 | mPaint.setStyle(Paint.Style.FILL);
86 | mPaint.setColor(Color.GRAY);
87 |
88 |
89 | }
90 |
91 | public void startAnim() {
92 | stopAnim();
93 | startViewAnim(0f, 1f, 1000);
94 | }
95 |
96 | public void stopAnim() {
97 | if (valueAnimator != null) {
98 | clearAnimation();
99 | mAnimatedValue = 0f;
100 | mJumpValue = 0;
101 | valueAnimator.setRepeatCount(0);
102 | valueAnimator.cancel();
103 | valueAnimator.end();
104 | }
105 | }
106 |
107 | ValueAnimator valueAnimator = null;
108 |
109 | private ValueAnimator startViewAnim(float startF, final float endF, long time) {
110 | valueAnimator = ValueAnimator.ofFloat(startF, endF);
111 | valueAnimator.setDuration(time);
112 | valueAnimator.setInterpolator(new LinearInterpolator());
113 | valueAnimator.setRepeatCount(ValueAnimator.INFINITE);//无限循环
114 | valueAnimator.setRepeatMode(ValueAnimator.RESTART);
115 | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
116 | @Override
117 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
118 |
119 | mAnimatedValue = (float) valueAnimator.getAnimatedValue();
120 |
121 | if (mAnimatedValue < 0.2) {
122 | mAnimatedValue = 0.2f;
123 | }
124 |
125 |
126 | invalidate();
127 | }
128 | });
129 | valueAnimator.addListener(new AnimatorListenerAdapter() {
130 | @Override
131 | public void onAnimationEnd(Animator animation) {
132 | super.onAnimationEnd(animation);
133 |
134 | }
135 |
136 | @Override
137 | public void onAnimationStart(Animator animation) {
138 | super.onAnimationStart(animation);
139 | }
140 |
141 | @Override
142 | public void onAnimationRepeat(Animator animation) {
143 | super.onAnimationRepeat(animation);
144 | mJumpValue++;
145 | }
146 | });
147 | if (!valueAnimator.isRunning()) {
148 | valueAnimator.start();
149 |
150 | }
151 |
152 | return valueAnimator;
153 | }
154 |
155 | }
156 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/pulltorefresh/BaseIndicator.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.pulltorefresh;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | /**
8 | * Created by Vincent Woo
9 | * Date: 2016/6/6
10 | * Time: 16:54
11 | */
12 | public abstract class BaseIndicator {
13 | public abstract View createView(LayoutInflater inflater, ViewGroup parent);
14 | public abstract void onAction();
15 | public abstract void onUnAction();
16 | public abstract void onRestore();
17 | public abstract void onLoading();
18 | }
19 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/pulltorefresh/DefaultFooter.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.pulltorefresh;
2 |
3 | import android.graphics.Color;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 |
10 | import com.pnikosis.materialishprogress.ProgressWheel;
11 |
12 | import me.solidev.library.R;
13 |
14 | /**
15 | * Created by Vincent Woo
16 | * Date: 2016/6/6
17 | * Time: 17:37
18 | */
19 | public class DefaultFooter extends BaseIndicator {
20 | private TextView mStringIndicator;
21 | private ProgressWheel progress_wheell;
22 | private int default_rim_color;
23 |
24 | @Override
25 | public View createView(LayoutInflater inflater, ViewGroup parent) {
26 | ViewGroup v = (ViewGroup) inflater.inflate(R.layout.lib_ptr_footer_default, parent, true);
27 | View child = v.getChildAt(v.getChildCount() - 1);
28 | mStringIndicator = (TextView) child.findViewById(R.id.tv_footer);
29 | progress_wheell = (ProgressWheel) v.findViewById(R.id.progress_wheell);
30 | default_rim_color = progress_wheell.getRimColor();
31 | return child;
32 | }
33 |
34 | @Override
35 | public void onAction() {
36 | mStringIndicator.setText("放开加载更多");
37 | }
38 |
39 | @Override
40 | public void onUnAction() {
41 | mStringIndicator.setText("上拉加载更多");
42 | }
43 |
44 | @Override
45 | public void onRestore() {
46 | mStringIndicator.setText("上拉加载更多");
47 | progress_wheell.setRimColor(default_rim_color);
48 | progress_wheell.stopSpinning();
49 | }
50 |
51 | @Override
52 | public void onLoading() {
53 | mStringIndicator.setText("加载中...");
54 | progress_wheell.setRimColor(Color.parseColor("#00000000"));
55 | progress_wheell.spin();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/pulltorefresh/DefaultHeader.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.pulltorefresh;
2 |
3 | import android.graphics.Color;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.pnikosis.materialishprogress.ProgressWheel;
10 |
11 | import me.solidev.library.R;
12 |
13 | /**
14 | * Created by Vincent Woo
15 | * Date: 2016/6/6
16 | * Time: 17:02
17 | */
18 | public class DefaultHeader extends BaseIndicator {
19 | private TextView mStringIndicator;
20 | private ProgressWheel progress_wheel;
21 | private int default_rim_color;
22 |
23 | @Override
24 | public View createView(LayoutInflater inflater, ViewGroup parent) {
25 | ViewGroup v = (ViewGroup) inflater.inflate(R.layout.lib_ptr_header_default, parent, true);
26 | View child = v.getChildAt(v.getChildCount() - 1);
27 | mStringIndicator = (TextView) child.findViewById(R.id.tv_header);
28 | progress_wheel = (ProgressWheel) v.findViewById(R.id.progress_wheel);
29 | default_rim_color = progress_wheel.getRimColor();
30 | return child;
31 | }
32 |
33 | @Override
34 | public void onAction() {
35 | mStringIndicator.setText("放开以刷新");
36 | }
37 |
38 | @Override
39 | public void onUnAction() {
40 | mStringIndicator.setText("下拉以刷新");
41 | }
42 |
43 | @Override
44 | public void onRestore() {
45 | mStringIndicator.setText("下拉以刷新");
46 | progress_wheel.setRimColor(default_rim_color);
47 | progress_wheel.stopSpinning();
48 | }
49 |
50 | @Override
51 | public void onLoading() {
52 | mStringIndicator.setText("加载中...");
53 | progress_wheel.setRimColor(Color.parseColor("#00000000"));
54 | progress_wheel.spin();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/subscribeview/ChannelSubscribeEvent.java:
--------------------------------------------------------------------------------
1 |
2 | package me.solidev.library.ui.widget.subscribeview;
3 |
4 | /**
5 | * Created by _SOLID
6 | * Date:2016/8/10
7 | * Time:10:59
8 | * Desc:用于订阅事件的处理
9 | */
10 | public class ChannelSubscribeEvent {
11 |
12 | public static final int TYPE_ON_MY_CHANNEL_ITEM_CLICK = 0X000001;
13 | public static final int TYPE_ON_BACK_CLICK = 0X000002;
14 | public static final int TYPE_ON_DISMISS = 0X000003;
15 |
16 | int type;
17 | int position;
18 |
19 | public ChannelSubscribeEvent(int type) {
20 | this.type = type;
21 | }
22 |
23 | public ChannelSubscribeEvent(int type, int position) {
24 | this.type = type;
25 | this.position = position;
26 | }
27 |
28 | public int getType() {
29 | return type;
30 | }
31 |
32 | public int getPosition() {
33 | return position;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/subscribeview/ItemDragHelperCallback.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.subscribeview;
2 |
3 | import android.support.v7.widget.GridLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.support.v7.widget.StaggeredGridLayoutManager;
6 | import android.support.v7.widget.helper.ItemTouchHelper;
7 |
8 | /**
9 | * ItemDragHelperCallback
10 | * Created by YoKeyword on 15/12/29.
11 | */
12 | public class ItemDragHelperCallback extends ItemTouchHelper.Callback {
13 |
14 | @Override
15 | public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
16 | int dragFlags;
17 | RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
18 | if (manager instanceof GridLayoutManager || manager instanceof StaggeredGridLayoutManager) {
19 | dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
20 | } else {
21 | dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
22 | }
23 | // 如果想支持滑动(删除)操作, swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END
24 | int swipeFlags = 0;
25 | return makeMovementFlags(dragFlags, swipeFlags);
26 | }
27 |
28 | @Override
29 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
30 | // 固定栏目不能移动
31 | if(target instanceof SubscribeAdapter.MyViewHolder) {
32 | if(((SubscribeAdapter.MyViewHolder) target).isFix) {
33 | return false;
34 | }
35 | }
36 | if(viewHolder instanceof SubscribeAdapter.MyViewHolder) {
37 | if(((SubscribeAdapter.MyViewHolder) viewHolder).isFix) {
38 | return false;
39 | }
40 | }
41 |
42 | // 不同Type之间不可移动
43 | if (viewHolder.getItemViewType() != target.getItemViewType()) {
44 | return false;
45 | }
46 |
47 | if (recyclerView.getAdapter() instanceof OnItemMoveListener) {
48 | OnItemMoveListener listener = ((OnItemMoveListener) recyclerView.getAdapter());
49 | listener.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
50 | }
51 | return true;
52 | }
53 |
54 | @Override
55 | public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
56 |
57 | }
58 |
59 | @Override
60 | public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
61 | // 不在闲置状态
62 | if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
63 | if (viewHolder instanceof OnDragVHListener) {
64 | OnDragVHListener itemViewHolder = (OnDragVHListener) viewHolder;
65 | itemViewHolder.onItemSelected();
66 | }
67 | }
68 | super.onSelectedChanged(viewHolder, actionState);
69 | }
70 |
71 | @Override
72 | public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
73 | if (viewHolder instanceof OnDragVHListener) {
74 | OnDragVHListener itemViewHolder = (OnDragVHListener) viewHolder;
75 | itemViewHolder.onItemFinish();
76 | }
77 | super.clearView(recyclerView, viewHolder);
78 | }
79 |
80 | @Override
81 | public boolean isLongPressDragEnabled() {
82 | // 不支持长按拖拽功能 手动控制
83 | return false;
84 | }
85 |
86 | @Override
87 | public boolean isItemViewSwipeEnabled() {
88 | // 不支持滑动功能
89 | return false;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/subscribeview/OnDragVHListener.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.subscribeview;
2 |
3 | /**
4 | * ViewHolder 被选中 以及 拖拽释放 触发监听器
5 | * Created by YoKeyword on 15/12/29.
6 | */
7 | public interface OnDragVHListener {
8 | /**
9 | * Item被选中时触发
10 | */
11 | void onItemSelected();
12 |
13 |
14 | /**
15 | * Item在拖拽结束/滑动结束后触发
16 | */
17 | void onItemFinish();
18 | }
19 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/subscribeview/OnItemMoveListener.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.subscribeview;
2 |
3 | /**
4 | * Item移动后 触发
5 | * Created by YoKeyword on 15/12/28.
6 | */
7 | public interface OnItemMoveListener {
8 | void onItemMove(int fromPosition, int toPosition);
9 | }
10 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/ui/widget/subscribeview/SubscribeItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.ui.widget.subscribeview;
2 |
3 | /**
4 | * Created by _SOLID
5 | * Date:2016/10/17
6 | * Time:16:54
7 | * Desc:
8 | */
9 |
10 | public interface SubscribeItem {
11 |
12 | //频道所属类别
13 | String getCategory();
14 |
15 | void setCategory(String category);
16 |
17 | //频道标题
18 | void setTitle(String title);
19 |
20 | String getTitle();
21 |
22 | //是否固定
23 | void setIsFix(int isFix);
24 |
25 | int getIsFix();
26 |
27 | //是否订阅
28 | void setIsSubscribe(int isSubscribe);
29 |
30 | int getIsSubscribe();
31 |
32 | //频道排序
33 | void setSort(int sort);
34 |
35 | int getSort();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/ConstUtils.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils;
2 |
3 | /**
4 | *
5 | * author: Blankj
6 | * blog : http://blankj.com
7 | * time : 2016/8/11
8 | * desc : 常量相关工具类
9 | *
10 | */
11 | public class ConstUtils {
12 |
13 | private ConstUtils() {
14 | throw new UnsupportedOperationException("u can't instantiate me...");
15 | }
16 |
17 | /******************** 存储相关常量 ********************/
18 | /**
19 | * Byte与Byte的倍数
20 | */
21 | public static final int BYTE = 1;
22 | /**
23 | * KB与Byte的倍数
24 | */
25 | public static final int KB = 1024;
26 | /**
27 | * MB与Byte的倍数
28 | */
29 | public static final int MB = 1048576;
30 | /**
31 | * GB与Byte的倍数
32 | */
33 | public static final int GB = 1073741824;
34 |
35 | public enum MemoryUnit {
36 | BYTE,
37 | KB,
38 | MB,
39 | GB
40 | }
41 |
42 | /******************** 时间相关常量 ********************/
43 | /**
44 | * 毫秒与毫秒的倍数
45 | */
46 | public static final int MSEC = 1;
47 | /**
48 | * 秒与毫秒的倍数
49 | */
50 | public static final int SEC = 1000;
51 | /**
52 | * 分与毫秒的倍数
53 | */
54 | public static final int MIN = 60000;
55 | /**
56 | * 时与毫秒的倍数
57 | */
58 | public static final int HOUR = 3600000;
59 | /**
60 | * 天与毫秒的倍数
61 | */
62 | public static final int DAY = 86400000;
63 |
64 | public enum TimeUnit {
65 | MSEC,
66 | SEC,
67 | MIN,
68 | HOUR,
69 | DAY
70 | }
71 |
72 | /******************** 正则相关常量 ********************/
73 | /**
74 | * 正则:手机号(简单)
75 | */
76 | public static final String REGEX_MOBILE_SIMPLE = "^[1]\\d{10}$";
77 | /**
78 | * 正则:手机号(精确)
79 | * 移动:134(0-8)、135、136、137、138、139、147、150、151、152、157、158、159、178、182、183、184、187、188
80 | * 联通:130、131、132、145、155、156、175、176、185、186
81 | * 电信:133、153、173、177、180、181、189
82 | * 全球星:1349
83 | * 虚拟运营商:170
84 | */
85 | public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$";
86 | /**
87 | * 正则:电话号码
88 | */
89 | public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
90 | /**
91 | * 正则:身份证号码15位
92 | */
93 | public static final String REGEX_IDCARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
94 | /**
95 | * 正则:身份证号码18位
96 | */
97 | public static final String REGEX_IDCARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
98 | /**
99 | * 正则:邮箱
100 | */
101 | public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
102 | /**
103 | * 正则:URL
104 | */
105 | public static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
106 | /**
107 | * 正则:汉字
108 | */
109 | public static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
110 | /**
111 | * 正则:用户名,取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位
112 | */
113 | public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(? 0) {
92 | int year = (int) (time / yearSeconds);
93 | if (year > 10)
94 | showStr = "很久以前";
95 | else {
96 | showStr = year + "年前";
97 | }
98 | } else if (time / monthSeconds > 0) {
99 | showStr = time / monthSeconds + "个月前";
100 | } else if (time / daySeconds > 7) {
101 | SimpleDateFormat formatter = new SimpleDateFormat("MM-dd", Locale.getDefault());
102 | showStr = formatter.format(date);
103 | } else if (time / daySeconds > 0) {
104 | showStr = time / daySeconds + "天前";
105 | } else if (time / hourSeconds > 0) {
106 | showStr = time / hourSeconds + "小时前";
107 | } else if (time / minuteSeconds > 0) {
108 | showStr = time / minuteSeconds + "分钟前";
109 | } else if (time > 0) {
110 | showStr = time + "秒前";
111 | }
112 | return showStr;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/FileUtil.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 |
6 | import java.io.ByteArrayOutputStream;
7 | import java.io.Closeable;
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 |
12 | import me.solidev.library.constant.AppConstant;
13 |
14 | /**
15 | * Created by _SOLID
16 | * Date:2016/9/28
17 | * Time:11:28
18 | * Desc:文件处理工具类
19 | */
20 |
21 | public class FileUtil {
22 |
23 | public static File getCacheDir(Context context) {
24 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
25 | File cacheDir = context.getExternalCacheDir();
26 | if (cacheDir != null && (cacheDir.exists() || cacheDir.mkdirs())) {
27 | return cacheDir;
28 | }
29 | }
30 | return context.getCacheDir();
31 | }
32 |
33 | //region getString
34 | public static String getString(Context context, String url) {
35 | if (url.startsWith(AppConstant.URL_RAW)) {
36 | return getStringFromRaw(context, url);
37 | }
38 | return "";
39 | }
40 |
41 |
42 | /**
43 | * @param context
44 | * @param url raw://example
45 | * @return
46 | */
47 | private static String getStringFromRaw(Context context, String url) {
48 | String result = "";
49 | String name = url.substring(AppConstant.URL_RAW.length());
50 | int rawId = context.getResources().getIdentifier(name, "raw", context.getPackageName());
51 | if (rawId != 0) {
52 | InputStream inputStream = context.getResources().openRawResource(rawId);
53 | try {
54 | result = new String(getBytesFromStream(inputStream));
55 | } catch (IOException e) {
56 | e.printStackTrace();
57 | }
58 | }
59 | return result;
60 | }
61 |
62 | private static byte[] getBytesFromStream(InputStream is) throws IOException {
63 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
64 | byte[] buf = new byte[1024 * 1024];
65 | int readLen;
66 | while ((readLen = is.read(buf)) >= 0) {
67 | baos.write(buf, 0, readLen);
68 | }
69 | baos.close();
70 |
71 | return baos.toByteArray();
72 | }
73 | //endregion
74 |
75 | /**
76 | * 关闭IO
77 | *
78 | * @param closeables closeable
79 | */
80 | public static void closeIO(Closeable... closeables) {
81 | if (closeables == null) return;
82 | try {
83 | for (Closeable closeable : closeables) {
84 | if (closeable != null) {
85 | closeable.close();
86 | }
87 | }
88 | } catch (IOException e) {
89 | e.printStackTrace();
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/Logger.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | /**
8 | * Created by _SOLID
9 | * Date:2016/5/10
10 | * Time:10:15
11 | */
12 | public class Logger {
13 |
14 | /**
15 | * 是否为开发者模式(开发模式打印LOG,非开发模式不打印LOG)
16 | */
17 | private static boolean mDebug = true;
18 |
19 | private Logger() {
20 | }
21 |
22 | @NonNull
23 | private static String getTagName(Object object) {
24 | String tagName = object.getClass().getSimpleName();
25 | if (TextUtils.isEmpty(tagName)) tagName = "AnonymityClass";
26 | return tagName;
27 | }
28 |
29 | public static void i(Object object, String msg) {
30 | String tagName = getTagName(object);
31 | if (mDebug) {
32 | Log.i(tagName, msg);
33 | }
34 | }
35 |
36 |
37 | public static void i(String msg) {
38 | if (mDebug) {
39 | Log.i("LogInfo", msg);
40 | }
41 | }
42 |
43 | public static void e(Object object, String msg) {
44 | String tagName = getTagName(object);
45 | if (mDebug) {
46 | Log.e(tagName, msg);
47 | }
48 | }
49 |
50 | public static void e(String msg) {
51 | if (mDebug) {
52 | Log.e("LogError", msg);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/SpUtil.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | /**
8 | * Created by _SOLID
9 | * Date:2016/9/26
10 | * Time:15:34
11 | * Desc:SharedPreferences工具类
12 | */
13 |
14 | public class SpUtil {
15 | public static int getInt(Context context, final String key, int defaultValue) {
16 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
17 | return prefs.getInt(key, defaultValue);
18 | }
19 |
20 | public static void putInt(Context context, String key, int value) {
21 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
22 | prefs.edit().putInt(key, value).apply();
23 | }
24 |
25 | public static long getLong(Context context, final String key, long defaultValue) {
26 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
27 | return prefs.getLong(key, defaultValue);
28 | }
29 |
30 | public static void putLong(Context context, String key, long value) {
31 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
32 | prefs.edit().putLong(key, value).apply();
33 | }
34 |
35 | public static String getString(Context context, final String key, final String defaultValue) {
36 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
37 | return prefs.getString(key, defaultValue);
38 | }
39 |
40 | public static void putString(Context context, String key, String value) {
41 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
42 | prefs.edit().putString(key, value).apply();
43 | }
44 |
45 | public static boolean getBoolean(Context context, String key, final boolean defaultValue) {
46 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
47 | return prefs.getBoolean(key, defaultValue);
48 | }
49 |
50 | public static void putBoolean(Context context, String key, boolean value) {
51 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
52 | prefs.edit().putBoolean(key, value).apply();
53 | }
54 |
55 | public static void remove(Context context, String key) {
56 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
57 | prefs.edit().remove(key).apply();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/TimeUtil.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils;
2 |
3 | /**
4 | * Created by _SOLID
5 | * Date:2016/10/11
6 | * Time:10:31
7 | * Desc:
8 | */
9 |
10 | public class TimeUtil {
11 | public String getCountShowTime(int countTime) {
12 | String result = "";
13 | if (countTime < 10)
14 | result = "00:0" + countTime;
15 | else if (countTime < 60)
16 | result = "00:" + countTime;
17 | else {
18 | int minute = countTime / 60;
19 | int mod = countTime % 60;
20 | if (minute < 10) result += "0" + minute + ":";
21 | else {
22 | result += minute + ":";
23 | }
24 | if (mod < 10) result += "0" + mod;
25 | else {
26 | result += mod;
27 | }
28 |
29 | }
30 | return result;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by _SOLID
8 | * Date:2016/9/29
9 | * Time:10:37
10 | * Desc:
11 | */
12 |
13 | public class ToastUtil {
14 | private Context mContext;
15 | private static ToastUtil mInstance;
16 | private Toast mToast;
17 |
18 | public static ToastUtil getInstance() {
19 | return mInstance;
20 | }
21 |
22 | public static void initialize(Context ctx) {
23 | mInstance = new ToastUtil(ctx);
24 | }
25 |
26 | private ToastUtil(Context ctx) {
27 | mContext = ctx;
28 | }
29 |
30 | public void showShortToast(String text) {
31 | if (mToast == null) {
32 | mToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
33 | }
34 | mToast.setText(text);
35 | mToast.setDuration(Toast.LENGTH_SHORT);
36 | mToast.show();
37 | }
38 |
39 | public void showLongToast(String text) {
40 | if (mToast == null) {
41 | mToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
42 | }
43 | mToast.setText(text);
44 | mToast.setDuration(Toast.LENGTH_LONG);
45 | mToast.show();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/json/AbsConvert.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils.json;
2 |
3 | /**
4 | * Created by _SOLID
5 | * Date:2016/5/13
6 | * Time:11:39
7 | */
8 | public abstract class AbsConvert {
9 |
10 | abstract T parseData(String result);
11 | }
12 |
--------------------------------------------------------------------------------
/library/src/main/java/me/solidev/library/utils/json/JsonConvert.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library.utils.json;
2 |
3 | import android.text.TextUtils;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import org.json.JSONException;
8 | import org.json.JSONObject;
9 |
10 | import java.lang.reflect.ParameterizedType;
11 | import java.lang.reflect.Type;
12 |
13 | /**
14 | * Created by _SOLID
15 | * Date:2016/7/22
16 | * Time:17:50
17 | */
18 | public class JsonConvert extends AbsConvert {
19 |
20 | private String mDataName = null;
21 |
22 | @Override
23 | public T parseData(String result) {
24 | T t = null;
25 | try {
26 | Type trueType = ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
27 | Gson gson = new Gson();
28 | if (!TextUtils.isEmpty(mDataName)) {
29 | JSONObject jsonObject = new JSONObject(result);
30 | t = gson.fromJson(jsonObject.getString(mDataName), trueType);
31 | } else {
32 | t = gson.fromJson(result, trueType);
33 | }
34 | } catch (JSONException e) {
35 | e.printStackTrace();
36 | }
37 | return t;
38 | }
39 |
40 | /**
41 | * 在数据中要获取的name(当数据类型为集合时)
42 | *
43 | * @return data_name
44 | */
45 | public void setDataName(String dataName) {
46 | mDataName = dataName;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/subscribe_pop_hidden_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/subscribe_pop_show_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xxhdpi/lib_icon_status_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/library/src/main/res/drawable-xxhdpi/lib_icon_status_empty.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xxhdpi/lib_icon_status_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/library/src/main/res/drawable-xxhdpi/lib_icon_status_error.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xxhdpi/lib_icon_status_retry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/library/src/main/res/drawable-xxhdpi/lib_icon_status_retry.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xxhdpi/lib_icon_subscribe_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/library/src/main/res/drawable-xxhdpi/lib_icon_subscribe_edit.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/bg_banner_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/default_load_img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/library/src/main/res/drawable/default_load_img.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/default_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/library/src/main/res/drawable/default_loading.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable/default_loading_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/lib_subscribe_item_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | -
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_fragment_base_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_item_grid_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_banner_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_footer_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
21 |
22 |
32 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_grid_pager_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
23 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_subscribe_item_my.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_subscribe_item_my_channel_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
27 |
28 |
39 |
40 |
51 |
52 |
57 |
58 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_subscribe_item_other.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_subscribe_item_other_channel_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_layout_subscribe_pop_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_ptr_footer_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
23 |
24 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_ptr_header_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
23 |
24 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_status_view_layout_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
21 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_status_view_layout_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
21 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/lib_status_view_layout_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/library/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #e2e2e2
8 |
9 | #c1c1c1
10 | #353232
11 |
12 | #e75946
13 | #f4d227
14 | #4674e7
15 | #0ba62c
16 |
17 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/main/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/library/src/test/java/me/solidev/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package me.solidev.library;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'realm-android'
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.2"
6 | defaultConfig {
7 | applicationId "me.solidev.quickdevlib"
8 | minSdkVersion 14
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 | compile project(':library')
29 | compile files('libs/ormlite-android-4.49.jar')
30 | compile files('libs/ormlite-core-4.49.jar')
31 | }
32 |
--------------------------------------------------------------------------------
/sample/libs/ormlite-android-4.49.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/libs/ormlite-android-4.49.jar
--------------------------------------------------------------------------------
/sample/libs/ormlite-core-4.49.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/libs/ormlite-core-4.49.jar
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/me/solidev/quickdevlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("me.solidev.quickdevlib", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib;
2 |
3 | import android.support.design.widget.TabLayout;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.ActionBar;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import me.solidev.library.ui.activity.BaseActivity;
14 | import me.solidev.quickdevlib.fragment.GridPagerFragment;
15 | import me.solidev.quickdevlib.fragment.list.ClassTitleListFragment;
16 | import me.solidev.quickdevlib.fragment.list.GridListFragment;
17 | import me.solidev.quickdevlib.fragment.list.HeaderListFragment;
18 | import me.solidev.quickdevlib.fragment.list.SimpleListFragment;
19 | import me.solidev.quickdevlib.fragment.list.StaggeredListFragment;
20 | import me.solidev.quickdevlib.fragment.subscribe.SubscribeFragment;
21 |
22 |
23 | public class MainActivity extends BaseActivity {
24 |
25 | private ViewPager mViewPager;
26 | private TabLayout mTabLayout;
27 | private ArrayList mDemoTitles;
28 |
29 | @Override
30 | protected int setLayoutResourceID() {
31 | return R.layout.activity_main;
32 | }
33 |
34 | @Override
35 | protected void setUpView() {
36 |
37 |
38 | ActionBar mActionBar = getSupportActionBar();
39 | mActionBar.setElevation(0);
40 | mTabLayout = $(R.id.tab_layout);
41 | mViewPager = $(R.id.viewpager);
42 | mDemoTitles = new ArrayList<>();
43 | mDemoTitles.add("简单列表");
44 | mDemoTitles.add("带有Header");
45 | mDemoTitles.add("分组列表");
46 | mDemoTitles.add("网格");
47 | mDemoTitles.add("瀑布流");
48 | mDemoTitles.add("订阅");
49 | mDemoTitles.add("GridPager");
50 |
51 | for (String title : mDemoTitles) {
52 | mTabLayout.addTab(mTabLayout.newTab().setText(title));
53 | }
54 | mViewPager.setAdapter(new DemoPagerAdapter(getSupportFragmentManager(), mDemoTitles));
55 | mTabLayout.setupWithViewPager(mViewPager);
56 | mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
57 | @Override
58 | public void onTabSelected(TabLayout.Tab tab) {
59 |
60 | }
61 |
62 | @Override
63 | public void onTabUnselected(TabLayout.Tab tab) {
64 |
65 | }
66 |
67 | @Override
68 | public void onTabReselected(TabLayout.Tab tab) {
69 |
70 | }
71 | });
72 |
73 | }
74 |
75 | @Override
76 | protected void setUpData() {
77 | }
78 |
79 | class DemoPagerAdapter extends FragmentStatePagerAdapter {
80 |
81 | List mTitles;
82 | private int mChildCount = 0;
83 |
84 | public DemoPagerAdapter(FragmentManager fm, List titles) {
85 | super(fm);
86 | mTitles = titles;
87 | }
88 |
89 | @Override
90 | public Fragment getItem(int position) {
91 | Fragment fragment = new SimpleListFragment();
92 | if ("简单列表".equals(mTitles.get(position))) {
93 | fragment = new SimpleListFragment();
94 | } else if ("带有Header".equals(mTitles.get(position))) {
95 | fragment = new HeaderListFragment();
96 | } else if ("分组列表".equals(mTitles.get(position))) {
97 | fragment = new ClassTitleListFragment();
98 | } else if ("网格".equals(mTitles.get(position))) {
99 | fragment = new GridListFragment();
100 | } else if ("瀑布流".equals(mTitles.get(position))) {
101 | fragment = new StaggeredListFragment();
102 | } else if ("订阅".equals(mTitles.get(position))) {
103 | fragment = new SubscribeFragment();
104 | } else if ("GridPager".equals(mTitles.get(position))) {
105 | fragment = new GridPagerFragment();
106 | }
107 | return fragment;
108 | }
109 |
110 | @Override
111 | public void notifyDataSetChanged() {
112 | mChildCount = getCount();
113 | super.notifyDataSetChanged();
114 | }
115 |
116 | @Override
117 | public int getItemPosition(Object object) {
118 | if (mChildCount > 0) {
119 | mChildCount--;
120 | return POSITION_NONE;
121 | }
122 | return super.getItemPosition(object);
123 | }
124 |
125 | @Override
126 | public int getCount() {
127 | return mTitles.size();
128 | }
129 |
130 | @Override
131 | public CharSequence getPageTitle(int position) {
132 | return mTitles.get(position);
133 | }
134 |
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/MultiTypeInstaller.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib;
2 |
3 | import me.drakeet.multitype.GlobalMultiTypePool;
4 | import me.solidev.quickdevlib.entity.Banners;
5 | import me.solidev.quickdevlib.entity.NewsItem;
6 | import me.solidev.quickdevlib.entity.image_type.GridImageItem;
7 | import me.solidev.quickdevlib.entity.image_type.StaggeredImageItem;
8 | import me.solidev.quickdevlib.entity.news_type.DefaultNewsItem;
9 | import me.solidev.quickdevlib.entity.news_type.SubjectNewsItem;
10 | import me.solidev.quickdevlib.entity.news_type.TextNewsItem;
11 | import me.solidev.quickdevlib.provider.BannerItemViewProvider;
12 | import me.solidev.quickdevlib.provider.DefaultNewsItemViewProvider;
13 | import me.solidev.quickdevlib.provider.GridImageItemViewProvider;
14 | import me.solidev.quickdevlib.provider.StaggeredImageItemViewProvider;
15 | import me.solidev.quickdevlib.provider.SubjectNewsItemViewProvider;
16 | import me.solidev.quickdevlib.provider.TextNewsItemViewProvider;
17 |
18 | /**
19 | * Created by _SOLID
20 | * Date:2016/10/9
21 | * Time:10:53
22 | * Desc:
23 | */
24 |
25 | public class MultiTypeInstaller {
26 | public static void install() {
27 |
28 |
29 | GlobalMultiTypePool.register(NewsItem.class, new DefaultNewsItemViewProvider());
30 | GlobalMultiTypePool.register(DefaultNewsItem.class, new DefaultNewsItemViewProvider());
31 | GlobalMultiTypePool.register(TextNewsItem.class, new TextNewsItemViewProvider());
32 | GlobalMultiTypePool.register(SubjectNewsItem.class, new SubjectNewsItemViewProvider());
33 | GlobalMultiTypePool.register(Banners.class, new BannerItemViewProvider());
34 |
35 | GlobalMultiTypePool.register(GridImageItem.class, new GridImageItemViewProvider());
36 | GlobalMultiTypePool.register(StaggeredImageItem.class, new StaggeredImageItemViewProvider());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/SampleApp.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib;
2 |
3 | import me.solidev.library.BaseApp;
4 | import me.solidev.quickdevlib.fragment.subscribe.database.DatabaseHelper;
5 |
6 | /**
7 | * Created by _SOLID
8 | * Date:2016/9/26
9 | * Time:14:40
10 | */
11 |
12 | public class SampleApp extends BaseApp {
13 |
14 | public DatabaseHelper dbHelper;
15 |
16 | @Override
17 | public void onCreate() {
18 | super.onCreate();
19 | MultiTypeInstaller.install();
20 | dbHelper = new DatabaseHelper(this, "SampleApp.db");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/api/DemoService.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.api;
2 |
3 | import me.solidev.quickdevlib.entity.NewsResult;
4 | import retrofit2.http.GET;
5 | import rx.Observable;
6 |
7 | /**
8 | * Created by _SOLID
9 | * Date:2016/11/7
10 | * Time:13:55
11 | * Desc:
12 | */
13 |
14 | public interface DemoService {
15 | String BASE_URL = "https://raw.githubusercontent.com/burgessjp/QuickDevLib/master/sample/src/main/res/raw/";
16 |
17 | @GET("news_list.json")
18 | Observable getNewsData();
19 | }
20 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/AppBannerItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity;
2 |
3 | import me.solidev.library.module.banner.BannerItem;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/11/4
8 | * Time:14:36
9 | * Desc:
10 | */
11 |
12 | public class AppBannerItem implements BannerItem {
13 |
14 | private String imageUrl;
15 | private String title;
16 |
17 | @Override
18 | public String getImageUrl() {
19 | return imageUrl;
20 | }
21 |
22 | @Override
23 | public String getTitle() {
24 | return title;
25 | }
26 |
27 | public void setImageUrl(String imageUrl) {
28 | this.imageUrl = imageUrl;
29 | }
30 |
31 | public void setTitle(String title) {
32 | this.title = title;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/Banners.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2017/1/10
8 | * Time:16:24
9 | * Desc:
10 | */
11 |
12 | public class Banners {
13 | public List banners;
14 |
15 | public Banners(List banners) {
16 | this.banners = banners;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/ImageItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity;
2 |
3 | /**
4 | * Created by _SOLID
5 | * Date:2016/10/8
6 | * Time:13:27
7 | * Desc:
8 | */
9 |
10 | public class ImageItem {
11 | private String imageTitle;
12 | private String imageUrl;
13 |
14 | public String getImageTitle() {
15 | return imageTitle;
16 | }
17 |
18 | public void setImageTitle(String imageTitle) {
19 | this.imageTitle = imageTitle;
20 | }
21 |
22 | public String getImageUrl() {
23 | return imageUrl;
24 | }
25 |
26 | public void setImageUrl(String imageUrl) {
27 | this.imageUrl = imageUrl;
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/NewsItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity;
2 |
3 | import java.util.List;
4 |
5 | import me.solidev.library.ui.recyclerview.ClassTitleItem;
6 |
7 | /**
8 | * Created by _SOLID
9 | * Date:2016/9/29
10 | * Time:11:17
11 | * Desc:
12 | */
13 |
14 | public class NewsItem implements ClassTitleItem {
15 |
16 | private int channelId;
17 | private int docId;
18 | private int docType;
19 | private int clickType;
20 | private String title;
21 | private String content;
22 | private String source;
23 | private SponsorBean sponsor;
24 | private String url;
25 | private String media;
26 | private String date;
27 | private List images;
28 |
29 | private List imagesUrl;
30 |
31 | public int getChannelId() {
32 | return channelId;
33 | }
34 |
35 | public void setChannelId(int channelId) {
36 | this.channelId = channelId;
37 | }
38 |
39 | public int getDocId() {
40 | return docId;
41 | }
42 |
43 | public void setDocId(int docId) {
44 | this.docId = docId;
45 | }
46 |
47 | public int getDocType() {
48 | return docType;
49 | }
50 |
51 | public void setDocType(int docType) {
52 | this.docType = docType;
53 | }
54 |
55 | public int getClickType() {
56 | return clickType;
57 | }
58 |
59 | public void setClickType(int clickType) {
60 | this.clickType = clickType;
61 | }
62 |
63 | public String getTitle() {
64 | return title;
65 | }
66 |
67 | public void setTitle(String title) {
68 | this.title = title;
69 | }
70 |
71 | public String getContent() {
72 | return content;
73 | }
74 |
75 | public void setContent(String content) {
76 | this.content = content;
77 | }
78 |
79 | public String getSource() {
80 | return source;
81 | }
82 |
83 | public void setSource(String source) {
84 | this.source = source;
85 | }
86 |
87 | public SponsorBean getSponsor() {
88 | return sponsor;
89 | }
90 |
91 | public void setSponsor(SponsorBean sponsor) {
92 | this.sponsor = sponsor;
93 | }
94 |
95 | public String getUrl() {
96 | return url;
97 | }
98 |
99 | public void setUrl(String url) {
100 | this.url = url;
101 | }
102 |
103 | public String getMedia() {
104 | return media;
105 | }
106 |
107 | public void setMedia(String media) {
108 | this.media = media;
109 | }
110 |
111 | public String getDate() {
112 | return date;
113 | }
114 |
115 | public void setDate(String date) {
116 | this.date = date;
117 | }
118 |
119 | public List getImages() {
120 | return images;
121 | }
122 |
123 | public void setImages(List images) {
124 | this.images = images;
125 | }
126 |
127 | public List getImagesUrl() {
128 | return imagesUrl;
129 | }
130 |
131 | public void setImagesUrl(List imagesUrl) {
132 | this.imagesUrl = imagesUrl;
133 | }
134 |
135 | @Override
136 | public String getClassTitle() {
137 | return title;
138 | }
139 |
140 | public static class SponsorBean {
141 | private String nickname;
142 | private String avatar;
143 |
144 | public String getNickname() {
145 | return nickname;
146 | }
147 |
148 | public void setNickname(String nickname) {
149 | this.nickname = nickname;
150 | }
151 |
152 | public String getAvatar() {
153 | return avatar;
154 | }
155 |
156 | public void setAvatar(String avatar) {
157 | this.avatar = avatar;
158 | }
159 | }
160 |
161 | public static class ImagesUrlBean {
162 | private int imageId;
163 | private String imageTitle;
164 | private String imageUrl;
165 |
166 | public int getImageId() {
167 | return imageId;
168 | }
169 |
170 | public void setImageId(int imageId) {
171 | this.imageId = imageId;
172 | }
173 |
174 | public String getImageTitle() {
175 | return imageTitle;
176 | }
177 |
178 | public void setImageTitle(String imageTitle) {
179 | this.imageTitle = imageTitle;
180 | }
181 |
182 | public String getImageUrl() {
183 | return imageUrl;
184 | }
185 |
186 | public void setImageUrl(String imageUrl) {
187 | this.imageUrl = imageUrl;
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/NewsResult.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/11/7
8 | * Time:14:07
9 | * Desc:
10 | */
11 |
12 | public class NewsResult {
13 |
14 | private List banners;
15 |
16 | private List datas;
17 |
18 | public List getDatas() {
19 | return datas;
20 | }
21 |
22 | public void setDatas(List datas) {
23 | this.datas = datas;
24 | }
25 |
26 | public List getBanners() {
27 | return banners;
28 | }
29 |
30 | public void setBanners(List banners) {
31 | this.banners = banners;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/image_type/GridImageItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity.image_type;
2 |
3 | import me.solidev.quickdevlib.entity.ImageItem;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/10/8
8 | * Time:14:40
9 | * Desc:
10 | */
11 |
12 | public class GridImageItem extends ImageItem {
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/image_type/StaggeredImageItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity.image_type;
2 |
3 | import me.solidev.quickdevlib.entity.ImageItem;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/10/8
8 | * Time:14:40
9 | * Desc:
10 | */
11 |
12 | public class StaggeredImageItem extends ImageItem {
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/news_type/DefaultNewsItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity.news_type;
2 |
3 | import me.solidev.quickdevlib.entity.NewsItem;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/9/29
8 | * Time:13:16
9 | * Desc:
10 | */
11 |
12 | public class DefaultNewsItem extends NewsItem {
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/news_type/SubjectNewsItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity.news_type;
2 |
3 | import me.solidev.quickdevlib.entity.NewsItem;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/9/29
8 | * Time:13:17
9 | * Desc:
10 | */
11 |
12 | public class SubjectNewsItem extends NewsItem {
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/entity/news_type/TextNewsItem.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.entity.news_type;
2 |
3 | import me.solidev.quickdevlib.entity.NewsItem;
4 |
5 | /**
6 | * Created by _SOLID
7 | * Date:2016/9/29
8 | * Time:13:17
9 | * Desc:
10 | */
11 |
12 | public class TextNewsItem extends NewsItem {
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/GridPagerFragment.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment;
2 |
3 | import android.support.v4.content.ContextCompat;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import me.solidev.library.module.list.BaseFragment;
9 | import me.solidev.library.ui.widget.gridpager.GridPagerItem;
10 | import me.solidev.library.ui.widget.gridpager.GridPagerView;
11 | import me.solidev.library.utils.ToastUtil;
12 | import me.solidev.quickdevlib.R;
13 |
14 | /**
15 | * Created by _SOLID
16 | * Date:2016/10/12
17 | * Time:14:06
18 | * Desc:
19 | */
20 |
21 | public class GridPagerFragment extends BaseFragment {
22 |
23 | private GridPagerView mGridPagerView;
24 |
25 | @Override
26 | protected int setLayoutResourceID() {
27 | return R.layout.fragment_grid_pager;
28 | }
29 |
30 | @Override
31 | protected void setUpView() {
32 | mGridPagerView = $(R.id.gridPager);
33 | mGridPagerView.setIndicatorSelectedBackground(ContextCompat.getColor(getContext(), R.color.orange));
34 | mGridPagerView.setRows(2);
35 | mGridPagerView.setColumns(4);
36 | mGridPagerView.setOnItemClickListener(new GridPagerView.OnItemClickListener() {
37 | @Override
38 | public void onItemClick(GridItemExample item, int position) {
39 | ToastUtil.getInstance().showShortToast("Item Click:" + position + "|type:" + item.type);
40 | }
41 | });
42 | }
43 |
44 | @Override
45 | protected void setUpData() {
46 | mGridPagerView.setItems(getItems());
47 | }
48 |
49 |
50 | public List getItems() {
51 | List items = new ArrayList<>();
52 | for (int i = 0; i < 30; i++) {
53 | final int n = i;
54 | GridItemExample item = new GridItemExample();
55 | item.imageUrl = "http://g.nxnews.net/xx/24181/images/P020160825622352690911.png";
56 | item.title = "校园";
57 | item.type = "type" + i;
58 | items.add(item);
59 | }
60 | return items;
61 | }
62 |
63 | class GridItemExample implements GridPagerItem {
64 | public String imageUrl;
65 | public String title;
66 | public String type;
67 |
68 | @Override
69 | public String getImageUrl() {
70 | return imageUrl;
71 | }
72 |
73 | @Override
74 | public String getTitle() {
75 | return title;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/list/ClassTitleListFragment.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.list;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import me.solidev.library.rx.TransformUtils;
10 | import me.solidev.library.module.list.AbsListFragment;
11 | import me.solidev.library.ui.recyclerview.ClassTitleDecoration;
12 | import me.solidev.library.ui.recyclerview.LinearDecoration;
13 | import me.solidev.quickdevlib.entity.NewsItem;
14 | import rx.Observable;
15 | import rx.Subscriber;
16 |
17 | /**
18 | * Created by _SOLID
19 | * Date:2016/9/30
20 | * Time:14:07
21 | * Desc:分类列表实现
22 | */
23 |
24 | public class ClassTitleListFragment extends AbsListFragment{
25 |
26 |
27 | @Override
28 | protected void customConfig() {
29 | addItemDecoration(new ClassTitleDecoration(getContext(), getItems()));
30 | addItemDecoration(new LinearDecoration(getContext(), RecyclerView.VERTICAL, 1));
31 | //disEnablePullUp();
32 | }
33 |
34 | @Override
35 | public void loadData(final int pageIndex) {
36 | if (pageIndex > 3) {
37 | onDataSuccessReceived(pageIndex, null);
38 |
39 | return;
40 | }
41 | Observable
42 | .create(new Observable.OnSubscribe>() {
43 | @Override
44 | public void call(Subscriber super List> subscriber) {
45 | try {
46 | Thread.sleep(1000);//模拟网络延迟
47 | } catch (InterruptedException e) {
48 | e.printStackTrace();
49 | }
50 | subscriber.onNext(getMockData(pageIndex));
51 | }
52 | })
53 | .compose(TransformUtils.>defaultSchedulers())
54 | .subscribe(new Subscriber>() {
55 | @Override
56 | public void onCompleted() {
57 |
58 | }
59 |
60 | @Override
61 | public void onError(Throwable e) {
62 |
63 | }
64 |
65 | @Override
66 | public void onNext(List newsItems) {
67 |
68 | onDataSuccessReceived(pageIndex, getMockData(pageIndex));
69 | }
70 | });
71 |
72 |
73 | }
74 |
75 | @NonNull
76 | private List getMockData(int pageIndex) {
77 | List list = new ArrayList<>();
78 | for (int i = (pageIndex - 1) * 20; i < 20 * pageIndex; i++) {
79 | NewsItem item = new NewsItem();
80 | item.setTitle("类别" + i / 5);
81 |
82 | item.setContent("content:" + i);
83 | item.setDate("2016-09-0" + i);
84 | item.setDocType(1);
85 | ArrayList imgs = new ArrayList<>();
86 | imgs.add("http://img4.imgtn.bdimg.com/it/u=1168399963,3251010511&fm=21&gp=0.jpg");
87 |
88 | item.setImages(imgs);
89 | list.add(item);
90 | }
91 | return list;
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/list/GridListFragment.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.list;
2 |
3 | import android.graphics.Color;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.GridLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import me.solidev.library.rx.TransformUtils;
12 | import me.solidev.library.module.list.AbsListFragment;
13 | import me.solidev.library.ui.recyclerview.GridDividerItemDecoration;
14 | import me.solidev.library.ui.recyclerview.GridDividerItemDecorationBug;
15 | import me.solidev.library.utils.ConvertUtils;
16 | import me.solidev.quickdevlib.entity.image_type.GridImageItem;
17 | import rx.Observable;
18 | import rx.Subscriber;
19 |
20 | /**
21 | * Created by _SOLID
22 | * Date:2016/9/30
23 | * Time:14:07
24 | * Desc:网格列表实现
25 | */
26 |
27 | public class GridListFragment extends AbsListFragment {
28 |
29 | @Override
30 | protected void customConfig() {
31 | int height = ConvertUtils.dp2px(getContext(), 20);
32 | int color = Color.parseColor("#4285F4");
33 | addItemDecoration(new GridDividerItemDecoration(height, color));
34 | }
35 |
36 | @Override
37 | public void loadData(final int pageIndex) {
38 | if (pageIndex > 5) {
39 | onDataSuccessReceived(pageIndex, new ArrayList());
40 | return;
41 | }
42 | Observable
43 | .create(new Observable.OnSubscribe>() {
44 | @Override
45 | public void call(Subscriber super List> subscriber) {
46 | try {
47 | Thread.sleep(1000);
48 | } catch (InterruptedException e) {
49 | e.printStackTrace();
50 | }
51 | subscriber.onNext(getMockData());
52 | }
53 | })
54 | .compose(TransformUtils.>defaultSchedulers())
55 | .subscribe(new Subscriber>() {
56 | @Override
57 | public void onCompleted() {
58 |
59 | }
60 |
61 | @Override
62 | public void onError(Throwable e) {
63 |
64 | }
65 |
66 | @Override
67 | public void onNext(List gridImageItems) {
68 | onDataSuccessReceived(pageIndex, gridImageItems);
69 | }
70 | });
71 |
72 | }
73 |
74 | @NonNull
75 | private List getMockData() {
76 | List list = new ArrayList<>();
77 | for (int i = 0; i < 10; i++) {
78 | GridImageItem item = new GridImageItem();
79 | item.setImageTitle("title" + i);
80 | item.setImageUrl("http://upload-images.jianshu.io/upload_images/323199-42040f8641132827.jpg");
81 | list.add(item);
82 | }
83 | return list;
84 | }
85 |
86 | @NonNull
87 | @Override
88 | protected RecyclerView.LayoutManager getLayoutManager() {
89 | return new GridLayoutManager(getContext(), 3);
90 | }
91 |
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/list/SimpleListFragment.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.list;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import me.solidev.library.module.list.AbsListFragment;
9 | import me.solidev.quickdevlib.entity.NewsItem;
10 |
11 | /**
12 | * Created by _SOLID
13 | * Date:2016/9/30
14 | * Time:14:07
15 | * Desc:最简单的一种列表实现
16 | */
17 |
18 | public class SimpleListFragment extends AbsListFragment {
19 | @Override
20 | public void loadData(int pageIndex) {
21 |
22 | List list = getMockData();
23 | onDataSuccessReceived(pageIndex, list);
24 | }
25 |
26 | @NonNull
27 | private List getMockData() {
28 | List list = new ArrayList<>();
29 | for (int i = 0; i < 10; i++) {
30 | NewsItem item = new NewsItem();
31 | item.setTitle("title:" + i);
32 | item.setContent("content:" + i);
33 | item.setDate("2016-09-0" + i);
34 | item.setDocType(1);
35 | ArrayList imgs = new ArrayList<>();
36 | imgs.add("http://img4.imgtn.bdimg.com/it/u=1168399963,3251010511&fm=21&gp=0.jpg");
37 |
38 | item.setImages(imgs);
39 | list.add(item);
40 | }
41 | return list;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/list/StaggeredListFragment.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.list;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.support.v7.widget.StaggeredGridLayoutManager;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import me.solidev.library.module.list.AbsListFragment;
11 | import me.solidev.quickdevlib.entity.image_type.StaggeredImageItem;
12 |
13 | /**
14 | * Created by _SOLID
15 | * Date:2016/9/30
16 | * Time:14:07
17 | * Desc:瀑布列表实现
18 | */
19 |
20 | public class StaggeredListFragment extends AbsListFragment {
21 | @Override
22 | public void loadData(int pageIndex) {
23 | if (pageIndex > 3) {
24 | onDataSuccessReceived(pageIndex, new ArrayList());
25 | return;
26 | }
27 | List list = getMockData();
28 | onDataSuccessReceived(pageIndex, list);
29 | }
30 |
31 | private List getMockData() {
32 | List list = new ArrayList<>();
33 | for (int i = 0; i < 10; i++) {
34 | StaggeredImageItem item = new StaggeredImageItem();
35 | item.setImageTitle("title" + i + 1);
36 | item.setImageUrl("http://upload-images.jianshu.io/upload_images/323199-42040f8641132827.jpg");
37 | list.add(item);
38 | }
39 | return list;
40 | }
41 |
42 | @NonNull
43 | @Override
44 | protected RecyclerView.LayoutManager getLayoutManager() {
45 | return new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/subscribe/MyChannel.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.subscribe;
2 |
3 | import com.j256.ormlite.field.DatabaseField;
4 | import com.j256.ormlite.table.DatabaseTable;
5 |
6 | import me.solidev.library.ui.widget.subscribeview.SubscribeItem;
7 |
8 | /**
9 | * Created by _SOLID
10 | * Date:2016/10/18
11 | * Time:11:03
12 | * Desc:
13 | */
14 |
15 | @DatabaseTable(tableName = "MyChannel")
16 | public class MyChannel implements SubscribeItem {
17 |
18 |
19 | @DatabaseField(columnName = "id", generatedId = true)
20 | private long id;
21 | @DatabaseField(columnName = "sort")
22 | private int sort;
23 | @DatabaseField(columnName = "title")
24 | private String title;
25 | @DatabaseField(columnName = "isFix")
26 | private int isFix;
27 | @DatabaseField(columnName = "isSubscribe")
28 | private int isSubscribe;
29 | @DatabaseField(columnName = "category")
30 | private String category;
31 |
32 | public long getId() {
33 | return id;
34 | }
35 |
36 | public void setId(long id) {
37 | this.id = id;
38 | }
39 |
40 | @Override
41 | public void setTitle(String title) {
42 | this.title = title;
43 | }
44 |
45 | @Override
46 | public String getTitle() {
47 | return title;
48 | }
49 |
50 | @Override
51 | public void setIsFix(int isFix) {
52 | this.isFix = isFix;
53 | }
54 |
55 | @Override
56 | public int getIsFix() {
57 | return isFix;
58 | }
59 |
60 | @Override
61 | public void setIsSubscribe(int isSubscribe) {
62 | this.isSubscribe = isSubscribe;
63 | }
64 |
65 | @Override
66 | public int getIsSubscribe() {
67 | return isSubscribe;
68 | }
69 |
70 | @Override
71 | public void setSort(int sort) {
72 | this.sort = sort;
73 | }
74 |
75 | @Override
76 | public int getSort() {
77 | return sort;
78 | }
79 |
80 | @Override
81 | public String getCategory() {
82 | return category;
83 | }
84 |
85 | @Override
86 | public void setCategory(String category) {
87 | this.category = category;
88 | }
89 | }
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/subscribe/MySubscribePopWindow.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.subscribe;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.List;
6 |
7 | import io.realm.Realm;
8 | import io.realm.RealmConfiguration;
9 | import me.solidev.library.ui.widget.subscribeview.AbsSubscribePopWindow;
10 | import me.solidev.quickdevlib.fragment.subscribe.database.SubscribeDao;
11 |
12 | /**
13 | * Created by _SOLID
14 | * Date:2016/10/18
15 | * Time:11:00
16 | * Desc:
17 | */
18 |
19 | public class MySubscribePopWindow extends AbsSubscribePopWindow {
20 |
21 | private SubscribeDao dao = new SubscribeDao();
22 | private Realm realm;
23 |
24 | public MySubscribePopWindow(Context context) {
25 | super(context);
26 | RealmConfiguration realmConfig = new RealmConfiguration
27 | .Builder(context)
28 | .build();
29 | if (realm == null) {
30 | realm = Realm.getInstance(realmConfig);
31 | realm.beginTransaction();
32 | }
33 | }
34 |
35 | public MySubscribePopWindow(Context context, String category) {
36 | super(context, category);
37 | }
38 |
39 | @Override
40 | public List getAllItemInDB(String category) {
41 | return realm.where(MyChannel1.class).findAll();
42 | }
43 |
44 | @Override
45 | public MyChannel1 getItemInDB(String category, String title) {
46 | return realm.where(MyChannel1.class).equalTo("title", title).findFirst();
47 | }
48 |
49 | @Override
50 | public void deleteItemInDB(final MyChannel1 item) {
51 | realm.copyToRealm(item).deleteFromRealm();
52 | }
53 |
54 | @Override
55 | public void addItemInDB(final MyChannel1 item) {
56 | realm.copyToRealm(item);
57 | }
58 |
59 | @Override
60 | public void updateItemInDB(final MyChannel1 item) {
61 | realm.copyToRealmOrUpdate(item);
62 | }
63 |
64 | @Override
65 | public void onDismiss() {
66 | super.onDismiss();
67 | realm.commitTransaction();
68 | realm = null;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/subscribe/SubscribeFragment.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.subscribe;
2 |
3 | import android.view.View;
4 | import android.widget.Button;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import me.solidev.library.module.list.BaseFragment;
10 | import me.solidev.library.ui.widget.subscribeview.AbsSubscribePopWindow;
11 | import me.solidev.quickdevlib.R;
12 |
13 | /**
14 | * Created by _SOLID
15 | * Date:2016/10/17
16 | * Time:17:23
17 | * Desc:
18 | */
19 |
20 | public class SubscribeFragment extends BaseFragment {
21 |
22 | private AbsSubscribePopWindow pop;
23 |
24 | @Override
25 | protected int setLayoutResourceID() {
26 | return R.layout.fragment_subscribe;
27 | }
28 |
29 | @Override
30 | protected void setUpView() {
31 | final Button btn = $(R.id.btn_subscribe);
32 | pop = new MySubscribePopWindow(getContext());
33 | pop.setNewData(getData());
34 | btn.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | pop.showAsDropDown(btn);
38 | }
39 | });
40 | }
41 |
42 | @Override
43 | protected void setUpData() {
44 |
45 | }
46 |
47 | public List getData() {
48 | List channels = new ArrayList<>();
49 | for (int i = 0; i < 15; i++) {
50 | MyChannel1 channel = new MyChannel1();
51 | channel.setId("id" + i);
52 | channel.setTitle("频道b" + i);
53 | if (i == 0) {
54 | channel.setIsFix(1);
55 | }
56 | if (i < 8) {
57 | channel.setIsSubscribe(1);
58 | } else {
59 | channel.setIsSubscribe(0);
60 | }
61 | channels.add(channel);
62 | }
63 |
64 | return channels;
65 |
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/subscribe/database/BaseDao.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.subscribe.database;
2 |
3 | import com.j256.ormlite.dao.Dao;
4 | import com.j256.ormlite.stmt.DeleteBuilder;
5 | import com.j256.ormlite.stmt.QueryBuilder;
6 |
7 | import java.lang.reflect.ParameterizedType;
8 | import java.lang.reflect.Type;
9 | import java.sql.SQLException;
10 | import java.util.List;
11 |
12 | import me.solidev.quickdevlib.SampleApp;
13 |
14 |
15 | public class BaseDao {
16 | protected Class clazz;
17 | public Dao daoOpe;
18 |
19 | public BaseDao() {
20 | Class clazz = getClass();
21 |
22 | while (clazz != Object.class) {
23 | Type t = clazz.getGenericSuperclass();
24 | if (t instanceof ParameterizedType) {
25 | Type[] args = ((ParameterizedType) t).getActualTypeArguments();
26 | if (args[0] instanceof Class) {
27 | this.clazz = (Class) args[0];
28 | break;
29 | }
30 | }
31 | clazz = clazz.getSuperclass();
32 | }
33 |
34 | try {
35 | SampleApp app = (SampleApp) SampleApp.getInstance();
36 | if (app.dbHelper == null) {
37 | throw new RuntimeException("No DbHelper Found!");
38 | }
39 | daoOpe = app.dbHelper.getDao(this.clazz);
40 | } catch (SQLException e) {
41 | e.printStackTrace();
42 | }
43 | }
44 |
45 | public void add(T t) {
46 | try {
47 | daoOpe.create(t);
48 | } catch (SQLException e) {
49 | e.printStackTrace();
50 | }
51 | }
52 |
53 | public void delete(T t) {
54 | try {
55 | daoOpe.delete(t);
56 | } catch (SQLException e) {
57 | e.printStackTrace();
58 | }
59 | }
60 |
61 | public void update(T t) {
62 | try {
63 | daoOpe.update(t);
64 | } catch (SQLException e) {
65 | e.printStackTrace();
66 | }
67 | }
68 |
69 | public List all() {
70 | try {
71 | return daoOpe.queryForAll();
72 | } catch (SQLException e) {
73 | e.printStackTrace();
74 | return null;
75 | }
76 | }
77 |
78 | public List queryByColumn(String columnName, Object columnValue) {
79 | try {
80 | QueryBuilder builder = daoOpe.queryBuilder();
81 | builder.where().eq(columnName, columnValue);
82 | return builder.query();
83 | } catch (SQLException e) {
84 | e.printStackTrace();
85 | return null;
86 | }
87 | }
88 |
89 | public List queryByColumn(String columnName1, Object columnValue1,
90 | String columnName2, Object columnValue2) {
91 | try {
92 | QueryBuilder builder = daoOpe.queryBuilder();
93 | builder.where().eq(columnName1, columnValue1).and().eq(columnName2, columnValue2);
94 | return builder.query();
95 | } catch (SQLException e) {
96 | e.printStackTrace();
97 | return null;
98 | }
99 | }
100 |
101 | public void deleteByColumn(String columnName1, Object columnValue1,
102 | String columnName2, Object columnValue2) {
103 | try {
104 | DeleteBuilder builder = daoOpe.deleteBuilder();
105 | builder.where().eq(columnName1, columnValue1).and().eq(columnName2, columnValue2);
106 | builder.delete();
107 | } catch (SQLException e) {
108 | e.printStackTrace();
109 | }
110 | }
111 |
112 | public void clearAll() {
113 | try {
114 | daoOpe.deleteBuilder().delete();
115 | } catch (SQLException e) {
116 | e.printStackTrace();
117 | }
118 | }
119 |
120 | public long count() {
121 | try {
122 | return daoOpe.countOf();
123 | } catch (SQLException e) {
124 | e.printStackTrace();
125 | return 0;
126 | }
127 | }
128 |
129 | public void createOrUpdate(T t) {
130 | try {
131 | daoOpe.createOrUpdate(t);
132 | } catch (SQLException e) {
133 | e.printStackTrace();
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/subscribe/database/DatabaseHelper.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.subscribe.database;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
7 | import com.j256.ormlite.support.ConnectionSource;
8 | import com.j256.ormlite.table.TableUtils;
9 |
10 | import java.sql.SQLException;
11 |
12 | import me.solidev.quickdevlib.R;
13 |
14 | public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
15 | private Context mContext;
16 |
17 | public DatabaseHelper(Context context, String dbName) {
18 | super(context, dbName, null, 1);
19 | mContext = context;
20 | }
21 |
22 | @Override
23 | public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
24 | try {
25 | String[] tb = mContext.getResources().getStringArray(R.array.db_tb);
26 | for (int i = 0; i < tb.length; i++) {
27 | Class clazz = Class.forName(tb[i]);
28 | TableUtils.createTable(connectionSource, clazz);
29 | }
30 | } catch (SQLException e) {
31 | e.printStackTrace();
32 | } catch (ClassNotFoundException e) {
33 | e.printStackTrace();
34 | }
35 | }
36 |
37 | @Override
38 | public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource,
39 | int oldVersion, int newVersion) {
40 | try {
41 | String[] tb = mContext.getResources().getStringArray(R.array.db_tb);
42 | for (int i = 0; i < tb.length; i++) {
43 | Class clazz = Class.forName(tb[i]);
44 | TableUtils.dropTable(connectionSource, clazz, true);
45 | }
46 | onCreate(database, connectionSource);
47 | } catch (SQLException e) {
48 | e.printStackTrace();
49 | } catch (ClassNotFoundException e) {
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 | /**
55 | * 释放资源
56 | */
57 | @Override
58 | public void close() {
59 | super.close();
60 | mContext = null;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/fragment/subscribe/database/SubscribeDao.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.fragment.subscribe.database;
2 |
3 | import com.j256.ormlite.stmt.QueryBuilder;
4 |
5 | import java.sql.SQLException;
6 | import java.util.List;
7 |
8 | import me.solidev.quickdevlib.fragment.subscribe.MyChannel;
9 |
10 | /**
11 | * Created by _SOLID
12 | * Date:2016/10/18
13 | * Time:14:22
14 | * Desc:
15 | */
16 |
17 | public class SubscribeDao extends BaseDao {
18 |
19 |
20 | public MyChannel getItem(String category, String title) {
21 | try {
22 | QueryBuilder builder = daoOpe.queryBuilder();
23 | builder.where().eq("title", title).and().eq("category", category);
24 | return (MyChannel) builder.queryForFirst();
25 | } catch (SQLException e) {
26 | e.printStackTrace();
27 | return null;
28 | }
29 | }
30 |
31 | public List getAll(String category) {
32 | try {
33 | QueryBuilder builder = daoOpe.queryBuilder();
34 | builder.where().eq("category", category);
35 | return builder.query();
36 | } catch (SQLException e) {
37 | e.printStackTrace();
38 | return null;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/provider/BannerItemViewProvider.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.provider;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.ViewGroup;
7 |
8 | import me.drakeet.multitype.ItemViewProvider;
9 | import me.solidev.library.module.banner.BannerController;
10 | import me.solidev.quickdevlib.entity.Banners;
11 |
12 | /**
13 | * Created by _SOLID
14 | * Date:2017/1/10
15 | * Time:16:13
16 | * Desc:
17 | */
18 | public class BannerItemViewProvider
19 | extends ItemViewProvider {
20 |
21 | @NonNull
22 | @Override
23 | protected ViewHolder onCreateViewHolder(
24 | @NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
25 | BannerController banner = new BannerController(inflater.getContext());
26 | return new ViewHolder(banner);
27 | }
28 |
29 | @Override
30 | protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull Banners banners) {
31 | holder.banner.setBannerList(banners.banners);
32 | }
33 |
34 | static class ViewHolder extends RecyclerView.ViewHolder {
35 |
36 | BannerController banner;
37 |
38 | ViewHolder(BannerController banner) {
39 | super(banner.getView());
40 | this.banner = banner;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/provider/DefaultNewsItemViewProvider.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.provider;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import me.drakeet.multitype.ItemViewProvider;
13 | import me.solidev.library.ui.adapter.ViewHolder;
14 | import me.solidev.library.module.imageloader.ImageLoader;
15 | import me.solidev.library.utils.ToastUtil;
16 | import me.solidev.quickdevlib.R;
17 | import me.solidev.quickdevlib.entity.NewsItem;
18 |
19 |
20 | /**
21 | * Created by _SOLID
22 | * Date:2016/9/23
23 | * Time:13:11
24 | */
25 |
26 | public class DefaultNewsItemViewProvider extends ItemViewProvider {
27 |
28 | @NonNull
29 | @Override
30 | protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
31 | View view = inflater.inflate(R.layout.item_news_default, parent, false);
32 | return new ViewHolder(view);
33 | }
34 |
35 | @Override
36 | protected void onBindViewHolder(@NonNull final ViewHolder holder, @NonNull final NewsItem item) {
37 | holder.tv_title.setText(item.getTitle());
38 | holder.tv_content.setText(item.getContent());
39 | holder.tv_date.setText(item.getDate());
40 | ImageLoader.displayImage(holder.iv_img, item.getImages().get(0));
41 |
42 | holder.itemView.setOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | ToastUtil.getInstance().showShortToast("DefaultNewsItem:" + item.getTitle());
46 | Log.e("zzz", "height:" + holder.itemView.getHeight());
47 | }
48 | });
49 | }
50 |
51 | static class ViewHolder extends RecyclerView.ViewHolder {
52 | TextView tv_title;
53 | TextView tv_content;
54 | TextView tv_date;
55 | ImageView iv_img;
56 |
57 | public ViewHolder(View itemView) {
58 | super(itemView);
59 | tv_title = (TextView) itemView.findViewById(R.id.tv_title);
60 | tv_content = (TextView) itemView.findViewById(R.id.tv_content);
61 | tv_date = (TextView) itemView.findViewById(R.id.tv_date);
62 | iv_img = (ImageView) itemView.findViewById(R.id.iv_img);
63 | }
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/provider/GridImageItemViewProvider.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.provider;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import me.drakeet.multitype.ItemViewProvider;
13 | import me.solidev.library.module.imageloader.ImageLoader;
14 | import me.solidev.quickdevlib.R;
15 | import me.solidev.quickdevlib.entity.ImageItem;
16 |
17 | /**
18 | * Created by _SOLID
19 | * Date:2016/10/8
20 | * Time:13:29
21 | * Desc:
22 | */
23 |
24 | public class GridImageItemViewProvider extends ItemViewProvider {
25 | @NonNull
26 | @Override
27 | protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
28 | View view = inflater.inflate(R.layout.item_image, parent, false);
29 | return new ViewHolder(view);
30 | }
31 |
32 | @Override
33 | protected void onBindViewHolder(@NonNull final ViewHolder holder, @NonNull ImageItem imageItem) {
34 | holder.tv_title.setText(imageItem.getImageTitle());
35 | ImageLoader.displayImage(holder.iv_img, imageItem.getImageUrl());
36 | holder.itemView.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View v) {
39 |
40 | Log.e("zzz","width:"+holder.itemView.getWidth());
41 | Log.e("zzz","height:"+holder.itemView.getHeight());
42 | }
43 | });
44 | }
45 |
46 | static class ViewHolder extends RecyclerView.ViewHolder {
47 | TextView tv_title;
48 | ImageView iv_img;
49 |
50 | public ViewHolder(View itemView) {
51 | super(itemView);
52 | tv_title = (TextView) itemView.findViewById(R.id.tv_title);
53 | iv_img = (ImageView) itemView.findViewById(R.id.iv_img);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/provider/StaggeredImageItemViewProvider.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.provider;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import java.util.Random;
12 |
13 | import me.drakeet.multitype.ItemViewProvider;
14 | import me.solidev.library.module.imageloader.ImageLoader;
15 | import me.solidev.library.utils.ConvertUtils;
16 | import me.solidev.quickdevlib.R;
17 | import me.solidev.quickdevlib.entity.ImageItem;
18 |
19 | /**
20 | * Created by _SOLID
21 | * Date:2016/10/8
22 | * Time:13:29
23 | * Desc:
24 | */
25 |
26 | public class StaggeredImageItemViewProvider extends ItemViewProvider {
27 | @NonNull
28 | @Override
29 | protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
30 | View view = inflater.inflate(R.layout.item_image, parent, false);
31 | return new ViewHolder(view);
32 | }
33 |
34 | @Override
35 | protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull ImageItem imageItem) {
36 | holder.tv_title.setText(imageItem.getImageTitle());
37 | Random r = new Random();
38 | int height = ConvertUtils.dp2px(holder.itemView.getContext(), 100 + r.nextInt(100));
39 |
40 | ViewGroup.LayoutParams layoutParams = holder.iv_img.getLayoutParams();
41 | layoutParams.height = height;
42 | holder.iv_img.setLayoutParams(layoutParams);
43 | ImageLoader.displayImage(holder.iv_img, imageItem.getImageUrl());
44 | }
45 |
46 | static class ViewHolder extends RecyclerView.ViewHolder {
47 | TextView tv_title;
48 | ImageView iv_img;
49 |
50 | public ViewHolder(View itemView) {
51 | super(itemView);
52 | tv_title = (TextView) itemView.findViewById(R.id.tv_title);
53 | iv_img = (ImageView) itemView.findViewById(R.id.iv_img);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/provider/SubjectNewsItemViewProvider.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.provider;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import me.drakeet.multitype.ItemViewProvider;
12 | import me.solidev.library.module.imageloader.ImageLoader;
13 | import me.solidev.quickdevlib.R;
14 | import me.solidev.quickdevlib.entity.NewsItem;
15 |
16 |
17 | /**
18 | * Created by _SOLID
19 | * Date:2016/9/23
20 | * Time:13:11
21 | */
22 |
23 | public class SubjectNewsItemViewProvider extends ItemViewProvider {
24 |
25 |
26 | @NonNull
27 | @Override
28 | protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
29 | View view = inflater.inflate(R.layout.item_news_subject, parent, false);
30 | return new ViewHolder(view);
31 | }
32 |
33 | @Override
34 | protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull NewsItem item) {
35 | holder.tv_title.setText(item.getTitle());
36 | ImageLoader.displayImage(holder.iv_img, item.getImages().get(0));
37 | }
38 |
39 | static class ViewHolder extends RecyclerView.ViewHolder {
40 | TextView tv_title;
41 | ImageView iv_img;
42 |
43 | public ViewHolder(View itemView) {
44 | super(itemView);
45 | tv_title = (TextView) itemView.findViewById(R.id.tv_title);
46 | iv_img = (ImageView) itemView.findViewById(R.id.iv_img);
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/solidev/quickdevlib/provider/TextNewsItemViewProvider.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib.provider;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import me.drakeet.multitype.ItemViewProvider;
12 | import me.solidev.library.ui.adapter.ViewHolder;
13 | import me.solidev.quickdevlib.R;
14 | import me.solidev.quickdevlib.entity.NewsItem;
15 |
16 |
17 | /**
18 | * Created by _SOLID
19 | * Date:2016/9/23
20 | * Time:13:11
21 | */
22 |
23 | public class TextNewsItemViewProvider extends ItemViewProvider {
24 |
25 |
26 | @NonNull
27 | @Override
28 | protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
29 | View view = inflater.inflate(R.layout.item_news_text, parent, false);
30 | return new ViewHolder(view);
31 | }
32 |
33 | @Override
34 | protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull NewsItem item) {
35 | holder.tv_title.setText(item.getTitle());
36 | holder.tv_content.setText(item.getContent());
37 | holder.tv_date.setText(item.getDate());
38 | }
39 |
40 | static class ViewHolder extends RecyclerView.ViewHolder {
41 | TextView tv_title;
42 | TextView tv_content;
43 | TextView tv_date;
44 | ImageView iv_img;
45 |
46 | public ViewHolder(View itemView) {
47 | super(itemView);
48 | tv_title = (TextView) itemView.findViewById(R.id.tv_title);
49 | tv_content = (TextView) itemView.findViewById(R.id.tv_content);
50 | tv_date = (TextView) itemView.findViewById(R.id.tv_date);
51 | iv_img = (ImageView) itemView.findViewById(R.id.iv_img);
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/bottom_item_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/icon_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/src/main/res/drawable/icon_android.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_grid_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_subscribe.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_banner_item_view_provider.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
25 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_news_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
23 |
24 |
32 |
33 |
42 |
43 |
44 |
45 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_news_subject.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
34 |
35 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_news_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
28 |
29 |
39 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/layout_head_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/layout_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/menu_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burgessjp/QuickDevLib/689c7f9555f93ae6ec8fa3324fd9ee69464f1102/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - me.solidev.quickdevlib.fragment.subscribe.MyChannel
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ffffff
4 | #050505
5 | #B0B0B0
6 | #E5E5E5
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 16sp
7 | 14sp
8 | 12sp
9 |
10 | 10dp
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sample
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/test/java/me/solidev/quickdevlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package me.solidev.quickdevlib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':library'
2 |
--------------------------------------------------------------------------------