Skip to content

Commit 1a99f3e

Browse files
committed
1、修改FastMultiStatusView 里设置各种属性支持支持传入资源ID并支持设置Image占位的颜色值(5.0及以上版本)并支持文本与图片颜色同步及单独设置
2、修改FastLoadMoreView里设置各种属性支持支持传入资源ID并支持文本与图片颜色同步及单独设置 3、修改FastMultiStatusView设置占位图片宽高设置错误BUG(设置成TextView对象) 4、新增FastMultiStatusView设置ProgressBar 宽高方法setLoadingSize
1 parent 6475774 commit 1a99f3e

File tree

14 files changed

+362
-71
lines changed

14 files changed

+362
-71
lines changed

apk/sample.apk

1.49 KB
Binary file not shown.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ android {
1515
minSdkVersion ext.minSdkVersion
1616
targetSdkVersion ext.targetSdkVersion
1717
versionCode 219
18-
versionName "2.1.9-gamma"
18+
versionName "2.1.9-delta"
1919
multiDexEnabled true
2020
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2121
buildConfigField "String", "BASE_URL", "\"https://api.douban.com/\""

app/src/main/java/com/aries/library/fast/demo/App.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ public LoadMoreView createDefaultLoadMoreView(BaseQuickAdapter adapter) {
127127
//方式一:设置FastLoadMoreView--可参考FastLoadMoreView.Builder相应set方法
128128
//默认配置请参考FastLoadMoreView.Builder(mContext)里初始化
129129
return new FastLoadMoreView.Builder(mContext)
130-
.setLoadTextColor(Color.MAGENTA)
130+
// .setLoadTextColor(Color.MAGENTA)
131131
// //设置Loading 颜色-5.0以上有效
132132
// .setLoadingProgressColor(Color.MAGENTA)
133133
// //设置Loading drawable--会使Loading颜色失效
134-
// .setLoadingProgressDrawable(mContext.getResources().getDrawable(R.drawable.dialog_loading_wei_bo))
134+
// .setLoadingProgressDrawable(R.drawable.dialog_loading_wei_bo)
135135
// //设置全局TextView颜色
136136
// .setLoadTextColor(Color.MAGENTA)
137137
// //设置全局TextView文字字号
@@ -160,22 +160,25 @@ public IMultiStatusView createMultiStatusView() {
160160
//根据具体情况可设置更多属性具体请参考FastMultiStatusView.Builder里set方法
161161
//默认设置请参考Builder(Context context)里初始化
162162
return new FastMultiStatusView.Builder(mContext)
163-
// .setTextColor(getResources().getColor(R.color.colorMultiText))
163+
// .setTextColor(Color.MAGENTA)
164+
// .setTextColorResource(R.color.colorMultiText)
165+
// .setTextSizeResource(R.dimen.dp_multi_text_size)
164166
// .setTextSize(getResources().getDimensionPixelSize(R.dimen.dp_multi_text_size))
167+
// .setLoadingProgressColorResource(R.color.colorMultiProgress)
165168
// .setLoadingProgressColor(getResources().getColor(R.color.colorMultiProgress))
166169
// .setLoadingTextColor(getResources().getColor(R.color.colorMultiProgress))
167-
// .setLoadingText(getText(R.string.fast_multi_loading))
168-
// .setEmptyText(getText(R.string.fast_multi_empty))
169-
// .setErrorText(getText(R.string.fast_multi_error))
170-
// .setNoNetText(getText(R.string.fast_multi_network))
171-
// .setTextMargin(getResources().getDimensionPixelSize(R.dimen.dp_multi_margin))
172-
// .setImageWidthHeight(getResources().getDimensionPixelSize(R.dimen.dp_multi_image_size))
173-
// .setEmptyImageDrawable(FastUtil.getTintDrawable(
174-
// getResources().getDrawable(R.drawable.fast_img_multi_empty), getResources().getColor(R.color.colorMultiText)))
175-
// .setErrorImageDrawable(FastUtil.getTintDrawable(
176-
// getResources().getDrawable(R.drawable.fast_img_multi_error), getResources().getColor(R.color.colorMultiText)))
177-
// .setNoNetImageDrawable(FastUtil.getTintDrawable(
178-
// getResources().getDrawable(R.drawable.fast_img_multi_network), getResources().getColor(R.color.colorMultiText)))
170+
// .setLoadingText(R.string.fast_multi_loading)
171+
// .setEmptyText(R.string.fast_multi_empty)
172+
// .setErrorText(R.string.fast_multi_error)
173+
// .setNoNetText(R.string.fast_multi_network)
174+
// .setTextMarginResource(R.dimen.dp_multi_margin)
175+
// .setImageWidthHeightResource(R.dimen.dp_multi_image_size)
176+
// .setEmptyImageColorResource(R.color.colorTitleText)
177+
// .setEmptyImageDrawable(R.drawable.fast_img_multi_empty)
178+
// .setErrorImageColorResource(R.color.colorTitleText)
179+
// .setErrorImageDrawable(R.drawable.fast_img_multi_error)
180+
// .setNoNetImageColorResource(R.color.colorTitleText)
181+
// .setNoNetImageDrawable(R.drawable.fast_img_multi_network)
179182
.build();
180183
}
181184
})

app/src/main/java/com/aries/library/fast/demo/adapter/SubjectMovieAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected void convert(BaseViewHolder helper, SubjectsEntity item) {
3232
.setText(R.id.tv_yearMovie, "年份:" + item.year)
3333
.setText(R.id.tv_directorMovie, "导演:" + item.getDirectors())
3434
.setText(R.id.tv_castMovie, "主演:" + item.getCasts());
35-
GlideManager.loadImg(item.images.large, helper.getView(R.id.iv_coverMovie));
35+
GlideManager.loadRoundImg(item.images.large, helper.getView(R.id.iv_coverMovie),2);
3636
LabelView labelView = helper.getView(R.id.lv_topMovie);
3737
labelView.setText("Top" + (helper.getLayoutPosition() + 1));
3838
labelView.setVisibility(isShowTop ? View.VISIBLE : View.GONE);

app/src/main/java/com/aries/library/fast/demo/module/activity/ActivityFragment.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ private void setTab() {
119119
TabLayoutManager.getInstance().setSegmentTabData(this, mSegmentTab, vpContent,
120120
getResources().getStringArray(R.array.arrays_tab_activity), listFragment);
121121
}
122+
//SlidingTabLayout--需这样切换一下不然选中变粗没有效果不知是SlidingTabLayout BUG还是我设置问题
123+
mSlidingTab.setCurrentTab(1);
124+
mSlidingTab.setCurrentTab(0);
122125
}
123126

124127
private List<String> getTitles(int array) {

app/src/main/java/com/aries/library/fast/demo/module/activity/MovieBaseFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void loadData(int page) {
127127
DEFAULT_PAGE_SIZE = 15;//接口最大支持单页100
128128
ApiRepository.getInstance().getBaseMovie(mType, page * DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE)
129129
.compose(bindUntilEvent(FragmentEvent.DESTROY))
130-
.subscribe(new FastObserver<BaseMovieEntity>(this.getContext(), new Object[]{mEasyStatusView,this}) {
130+
.subscribe(new FastObserver<BaseMovieEntity>(this.getContext(), new Object[]{mEasyStatusView, this}) {
131131
@Override
132132
public void _onNext(BaseMovieEntity entity) {
133133
mRefreshLayout.finishRefresh();

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<dimen name="dp_margin_item">10dp</dimen>
77
<dimen name="dp_elevation">4dp</dimen>
8-
<dimen name="dp_radius">3dp</dimen>
8+
<dimen name="dp_radius">2dp</dimen>
99

1010
<!--以下属性为lib设置默认属性,在app设置同名属性可覆盖lib效果-->
1111

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
minSdkVersion 15
1010
targetSdkVersion 25
1111
versionCode 219
12-
versionName "2.1.9-gamma"
12+
versionName "2.1.9-delta"
1313
}
1414
buildTypes {
1515
release {

library/src/main/java/com/aries/library/fast/module/activity/FastWebActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected int getProgressColor() {
6363
* @return
6464
*/
6565
protected int getProgressHeight() {
66-
return SizeUtil.dp2px(1);
66+
return SizeUtil.dp2px(0.6f);
6767
}
6868

6969
@Override

library/src/main/java/com/aries/library/fast/util/FastUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public static int getRandom(int length) {
5858
* @return
5959
*/
6060
public static Drawable getTintDrawable(Drawable drawable, @ColorInt int color) {
61-
DrawableCompat.setTint(drawable, color);
61+
if (drawable != null) {
62+
DrawableCompat.setTint(drawable, color);
63+
}
6264
return drawable;
6365
}
6466

library/src/main/java/com/aries/library/fast/widget/FastLoadMoreView.java

Lines changed: 108 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import android.graphics.drawable.Drawable;
88
import android.os.Build;
99
import android.support.annotation.ColorInt;
10+
import android.support.annotation.ColorRes;
11+
import android.support.annotation.DimenRes;
1012
import android.support.annotation.DrawableRes;
1113
import android.support.annotation.Nullable;
1214
import android.support.annotation.StringRes;
@@ -151,16 +153,13 @@ public static final class Builder {
151153

152154
public Builder(@Nullable Context context) {
153155
mContext = context;
154-
mLoadingTextColor = getColor(R.color.colorLoadMoreText);
155-
mLoadFailTextColor = getColor(R.color.colorLoadMoreText);
156-
mLoadEndTextColor = getColor(R.color.colorLoadMoreText);
157-
mLoadingProgressColor = getColor(R.color.colorLoadMoreProgress);
158-
mLoadingTextSize = getDimensionPixelSize(R.dimen.dp_load_more_text_size);
159-
mLoadFailTextSize = getDimensionPixelSize(R.dimen.dp_load_more_text_size);
160-
mLoadEndTextSize = getDimensionPixelSize(R.dimen.dp_load_more_text_size);
161-
mLoadingText = getText(R.string.fast_load_more_loading);
162-
mLoadFailText = getText(R.string.fast_load_more_load_failed);
163-
mLoadEndText = getText(R.string.fast_load_more_load_end);
156+
setLoadTextColorResource(R.color.colorLoadMoreText);
157+
setLoadTextSizeResource(R.dimen.dp_load_more_text_size);
158+
setLoadingProgressColorResource(R.color.colorLoadMoreProgress);
159+
160+
setLoadingText(R.string.fast_load_more_loading);
161+
setLoadFailText(R.string.fast_load_more_load_failed);
162+
setLoadEndText(R.string.fast_load_more_load_end);
164163
}
165164

166165
public Builder(FastLoadMoreView fastLoadMoreView) {
@@ -179,6 +178,16 @@ public Builder(FastLoadMoreView fastLoadMoreView) {
179178

180179
}
181180

181+
/**
182+
* 设置所有TextView颜色资源
183+
*
184+
* @param mLoadTextColorRes
185+
* @return
186+
*/
187+
public Builder setLoadTextColorResource(@ColorRes int mLoadTextColorRes) {
188+
return setLoadTextColor(getColor(mLoadTextColorRes));
189+
}
190+
182191
/**
183192
* 设置所有TextView 文本颜色
184193
*
@@ -192,6 +201,16 @@ public Builder setLoadTextColor(@ColorInt int mLoadTextColor) {
192201
return this;
193202
}
194203

204+
/**
205+
* 设置所有TextView 文本尺寸资源
206+
*
207+
* @param mLoadTextSizeRes
208+
* @return
209+
*/
210+
public Builder setLoadTextSizeResource(@DimenRes int mLoadTextSizeRes) {
211+
return setLoadTextSize(getDimensionPixelSize(mLoadTextSizeRes));
212+
}
213+
195214
/**
196215
* 设置所有TextView 文本尺寸
197216
*
@@ -205,6 +224,16 @@ public Builder setLoadTextSize(int mLoadTextSize) {
205224
return this;
206225
}
207226

227+
/**
228+
* 设置加载中文本资源
229+
*
230+
* @param mLoadingText
231+
* @return
232+
*/
233+
public Builder setLoadingText(@StringRes int mLoadingText) {
234+
return setLoadingText(getText(mLoadingText));
235+
}
236+
208237
/**
209238
* 设置加载中文本
210239
*
@@ -217,14 +246,29 @@ public Builder setLoadingText(CharSequence mLoadingText) {
217246
}
218247

219248
/**
220-
* 设置加载中文本颜色
249+
* 设置加载中文本颜色资源
250+
*
251+
* @param mLoadingTextColorRes
252+
* @return
253+
*/
254+
public Builder setLoadingTextColorResource(@ColorRes int mLoadingTextColorRes) {
255+
return setLoadingTextColor(getColor(mLoadingTextColorRes));
256+
}
257+
258+
/**
259+
* 设置加载中文本颜色--同步设置 ProgressBar颜色
260+
* {@link #setLoadingProgressColor(int)} 注意调用顺序
221261
*
222262
* @param mLoadingTextColor
223263
* @return
224264
*/
225265
public Builder setLoadingTextColor(@ColorInt int mLoadingTextColor) {
226266
this.mLoadingTextColor = mLoadingTextColor;
227-
return this;
267+
return setLoadingProgressColor(mLoadingTextColor);
268+
}
269+
270+
public Builder setLoadingTextSizeResource(@DimenRes int mLoadingTextSizeRes) {
271+
return setLoadingTextSize(getDimensionPixelSize(mLoadingTextSizeRes));
228272
}
229273

230274
/**
@@ -238,6 +282,16 @@ public Builder setLoadingTextSize(int mLoadingTextSize) {
238282
return this;
239283
}
240284

285+
/**
286+
* 设置加载ProgressBar颜色资源
287+
*
288+
* @param mLoadingProgressColorRes
289+
* @return
290+
*/
291+
public Builder setLoadingProgressColorResource(@ColorRes int mLoadingProgressColorRes) {
292+
return setLoadingProgressColor(getColor(mLoadingProgressColorRes));
293+
}
294+
241295
/**
242296
* 设置加载ProgressBar颜色--5.0及以上支持
243297
*
@@ -249,6 +303,10 @@ public Builder setLoadingProgressColor(@ColorInt int mLoadingProgressColor) {
249303
return this;
250304
}
251305

306+
public Builder setLoadingProgressDrawable(@DrawableRes int mLoadingProgressDrawable) {
307+
return setLoadingProgressDrawable(getResources().getDrawable(mLoadingProgressDrawable));
308+
}
309+
252310
/**
253311
* 设置loading Drawable
254312
*
@@ -260,6 +318,10 @@ public Builder setLoadingProgressDrawable(Drawable mLoadingProgressDrawable) {
260318
return this;
261319
}
262320

321+
public Builder setLoadFailText(@StringRes int mLoadFailText) {
322+
return setLoadFailText(getText(mLoadFailText));
323+
}
324+
263325
/**
264326
* 设置加载失败文本
265327
*
@@ -271,6 +333,16 @@ public Builder setLoadFailText(CharSequence mLoadFailText) {
271333
return this;
272334
}
273335

336+
/**
337+
* 设置加载失败文本颜色资源
338+
*
339+
* @param mLoadFailTextColorRes
340+
* @return
341+
*/
342+
public Builder setLoadFailTextColorResource(@ColorRes int mLoadFailTextColorRes) {
343+
return setLoadFailTextColor(getColor(mLoadFailTextColorRes));
344+
}
345+
274346
/**
275347
* 设置加载失败文本颜色
276348
*
@@ -282,6 +354,10 @@ public Builder setLoadFailTextColor(@ColorInt int mLoadFailTextColor) {
282354
return this;
283355
}
284356

357+
public Builder setLoadFailTextSizeResource(@DimenRes int mLoadFailTextSizeRes) {
358+
return setLoadFailTextSize(getDimensionPixelSize(mLoadFailTextSizeRes));
359+
}
360+
285361
/**
286362
* 设置加载失败文本尺寸
287363
*
@@ -293,6 +369,10 @@ public Builder setLoadFailTextSize(int mLoadFailTextSize) {
293369
return this;
294370
}
295371

372+
public Builder setLoadEndText(@StringRes int mLoadEndText) {
373+
return setLoadEndText(getText(mLoadEndText));
374+
}
375+
296376
/**
297377
* 设置加载结束文本
298378
*
@@ -304,6 +384,16 @@ public Builder setLoadEndText(CharSequence mLoadEndText) {
304384
return this;
305385
}
306386

387+
/**
388+
* 设置加载结束文本颜色资源
389+
*
390+
* @param mLoadEndTextColorRes
391+
* @return
392+
*/
393+
public Builder setLoadEndTextColorResource(@ColorRes int mLoadEndTextColorRes) {
394+
return setLoadEndTextColor(getColor(mLoadEndTextColorRes));
395+
}
396+
307397
/**
308398
* 设置加载结束文本颜色
309399
*
@@ -315,6 +405,10 @@ public Builder setLoadEndTextColor(@ColorInt int mLoadEndTextColor) {
315405
return this;
316406
}
317407

408+
public Builder setLoadEndTextSizeResource(@DimenRes int mLoadEndTextSizeRes) {
409+
return setLoadEndTextSize(getDimensionPixelSize(mLoadEndTextSizeRes));
410+
}
411+
318412
/**
319413
* 设置加载结束文件尺寸
320414
*
@@ -330,11 +424,11 @@ private Resources getResources() {
330424
return mContext.getResources();
331425
}
332426

333-
private int getColor(@ColorInt int color) {
427+
private int getColor(@ColorRes int color) {
334428
return getResources().getColor(color);
335429
}
336430

337-
public int getDimensionPixelSize(@DrawableRes int dimen) {
431+
public int getDimensionPixelSize(@DimenRes int dimen) {
338432
return getResources().getDimensionPixelSize(dimen);
339433
}
340434

0 commit comments

Comments
 (0)