Skip to content

Commit

Permalink
1、修改FastMultiStatusView 里设置各种属性支持支持传入资源ID并支持设置Image占位的颜色值(5.0及以上版本)并支…
Browse files Browse the repository at this point in the history
…持文本与图片颜色同步及单独设置

2、修改FastLoadMoreView里设置各种属性支持支持传入资源ID并支持文本与图片颜色同步及单独设置
3、修改FastMultiStatusView设置占位图片宽高设置错误BUG(设置成TextView对象)
4、新增FastMultiStatusView设置ProgressBar 宽高方法setLoadingSize
  • Loading branch information
AriesHoo committed Nov 20, 2017
1 parent 6475774 commit 1a99f3e
Show file tree
Hide file tree
Showing 14 changed files with 362 additions and 71 deletions.
Binary file modified apk/sample.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdkVersion ext.minSdkVersion
targetSdkVersion ext.targetSdkVersion
versionCode 219
versionName "2.1.9-gamma"
versionName "2.1.9-delta"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField "String", "BASE_URL", "\"https://api.douban.com/\""
Expand Down
33 changes: 18 additions & 15 deletions app/src/main/java/com/aries/library/fast/demo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ public LoadMoreView createDefaultLoadMoreView(BaseQuickAdapter adapter) {
//方式一:设置FastLoadMoreView--可参考FastLoadMoreView.Builder相应set方法
//默认配置请参考FastLoadMoreView.Builder(mContext)里初始化
return new FastLoadMoreView.Builder(mContext)
.setLoadTextColor(Color.MAGENTA)
// .setLoadTextColor(Color.MAGENTA)
// //设置Loading 颜色-5.0以上有效
// .setLoadingProgressColor(Color.MAGENTA)
// //设置Loading drawable--会使Loading颜色失效
// .setLoadingProgressDrawable(mContext.getResources().getDrawable(R.drawable.dialog_loading_wei_bo))
// .setLoadingProgressDrawable(R.drawable.dialog_loading_wei_bo)
// //设置全局TextView颜色
// .setLoadTextColor(Color.MAGENTA)
// //设置全局TextView文字字号
Expand Down Expand Up @@ -160,22 +160,25 @@ public IMultiStatusView createMultiStatusView() {
//根据具体情况可设置更多属性具体请参考FastMultiStatusView.Builder里set方法
//默认设置请参考Builder(Context context)里初始化
return new FastMultiStatusView.Builder(mContext)
// .setTextColor(getResources().getColor(R.color.colorMultiText))
// .setTextColor(Color.MAGENTA)
// .setTextColorResource(R.color.colorMultiText)
// .setTextSizeResource(R.dimen.dp_multi_text_size)
// .setTextSize(getResources().getDimensionPixelSize(R.dimen.dp_multi_text_size))
// .setLoadingProgressColorResource(R.color.colorMultiProgress)
// .setLoadingProgressColor(getResources().getColor(R.color.colorMultiProgress))
// .setLoadingTextColor(getResources().getColor(R.color.colorMultiProgress))
// .setLoadingText(getText(R.string.fast_multi_loading))
// .setEmptyText(getText(R.string.fast_multi_empty))
// .setErrorText(getText(R.string.fast_multi_error))
// .setNoNetText(getText(R.string.fast_multi_network))
// .setTextMargin(getResources().getDimensionPixelSize(R.dimen.dp_multi_margin))
// .setImageWidthHeight(getResources().getDimensionPixelSize(R.dimen.dp_multi_image_size))
// .setEmptyImageDrawable(FastUtil.getTintDrawable(
// getResources().getDrawable(R.drawable.fast_img_multi_empty), getResources().getColor(R.color.colorMultiText)))
// .setErrorImageDrawable(FastUtil.getTintDrawable(
// getResources().getDrawable(R.drawable.fast_img_multi_error), getResources().getColor(R.color.colorMultiText)))
// .setNoNetImageDrawable(FastUtil.getTintDrawable(
// getResources().getDrawable(R.drawable.fast_img_multi_network), getResources().getColor(R.color.colorMultiText)))
// .setLoadingText(R.string.fast_multi_loading)
// .setEmptyText(R.string.fast_multi_empty)
// .setErrorText(R.string.fast_multi_error)
// .setNoNetText(R.string.fast_multi_network)
// .setTextMarginResource(R.dimen.dp_multi_margin)
// .setImageWidthHeightResource(R.dimen.dp_multi_image_size)
// .setEmptyImageColorResource(R.color.colorTitleText)
// .setEmptyImageDrawable(R.drawable.fast_img_multi_empty)
// .setErrorImageColorResource(R.color.colorTitleText)
// .setErrorImageDrawable(R.drawable.fast_img_multi_error)
// .setNoNetImageColorResource(R.color.colorTitleText)
// .setNoNetImageDrawable(R.drawable.fast_img_multi_network)
.build();
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected void convert(BaseViewHolder helper, SubjectsEntity item) {
.setText(R.id.tv_yearMovie, "年份:" + item.year)
.setText(R.id.tv_directorMovie, "导演:" + item.getDirectors())
.setText(R.id.tv_castMovie, "主演:" + item.getCasts());
GlideManager.loadImg(item.images.large, helper.getView(R.id.iv_coverMovie));
GlideManager.loadRoundImg(item.images.large, helper.getView(R.id.iv_coverMovie),2);
LabelView labelView = helper.getView(R.id.lv_topMovie);
labelView.setText("Top" + (helper.getLayoutPosition() + 1));
labelView.setVisibility(isShowTop ? View.VISIBLE : View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ private void setTab() {
TabLayoutManager.getInstance().setSegmentTabData(this, mSegmentTab, vpContent,
getResources().getStringArray(R.array.arrays_tab_activity), listFragment);
}
//SlidingTabLayout--需这样切换一下不然选中变粗没有效果不知是SlidingTabLayout BUG还是我设置问题
mSlidingTab.setCurrentTab(1);
mSlidingTab.setCurrentTab(0);
}

private List<String> getTitles(int array) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void loadData(int page) {
DEFAULT_PAGE_SIZE = 15;//接口最大支持单页100
ApiRepository.getInstance().getBaseMovie(mType, page * DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE)
.compose(bindUntilEvent(FragmentEvent.DESTROY))
.subscribe(new FastObserver<BaseMovieEntity>(this.getContext(), new Object[]{mEasyStatusView,this}) {
.subscribe(new FastObserver<BaseMovieEntity>(this.getContext(), new Object[]{mEasyStatusView, this}) {
@Override
public void _onNext(BaseMovieEntity entity) {
mRefreshLayout.finishRefresh();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<dimen name="dp_margin_item">10dp</dimen>
<dimen name="dp_elevation">4dp</dimen>
<dimen name="dp_radius">3dp</dimen>
<dimen name="dp_radius">2dp</dimen>

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

Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 15
targetSdkVersion 25
versionCode 219
versionName "2.1.9-gamma"
versionName "2.1.9-delta"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected int getProgressColor() {
* @return
*/
protected int getProgressHeight() {
return SizeUtil.dp2px(1);
return SizeUtil.dp2px(0.6f);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public static int getRandom(int length) {
* @return
*/
public static Drawable getTintDrawable(Drawable drawable, @ColorInt int color) {
DrawableCompat.setTint(drawable, color);
if (drawable != null) {
DrawableCompat.setTint(drawable, color);
}
return drawable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
Expand Down Expand Up @@ -151,16 +153,13 @@ public static final class Builder {

public Builder(@Nullable Context context) {
mContext = context;
mLoadingTextColor = getColor(R.color.colorLoadMoreText);
mLoadFailTextColor = getColor(R.color.colorLoadMoreText);
mLoadEndTextColor = getColor(R.color.colorLoadMoreText);
mLoadingProgressColor = getColor(R.color.colorLoadMoreProgress);
mLoadingTextSize = getDimensionPixelSize(R.dimen.dp_load_more_text_size);
mLoadFailTextSize = getDimensionPixelSize(R.dimen.dp_load_more_text_size);
mLoadEndTextSize = getDimensionPixelSize(R.dimen.dp_load_more_text_size);
mLoadingText = getText(R.string.fast_load_more_loading);
mLoadFailText = getText(R.string.fast_load_more_load_failed);
mLoadEndText = getText(R.string.fast_load_more_load_end);
setLoadTextColorResource(R.color.colorLoadMoreText);
setLoadTextSizeResource(R.dimen.dp_load_more_text_size);
setLoadingProgressColorResource(R.color.colorLoadMoreProgress);

setLoadingText(R.string.fast_load_more_loading);
setLoadFailText(R.string.fast_load_more_load_failed);
setLoadEndText(R.string.fast_load_more_load_end);
}

public Builder(FastLoadMoreView fastLoadMoreView) {
Expand All @@ -179,6 +178,16 @@ public Builder(FastLoadMoreView fastLoadMoreView) {

}

/**
* 设置所有TextView颜色资源
*
* @param mLoadTextColorRes
* @return
*/
public Builder setLoadTextColorResource(@ColorRes int mLoadTextColorRes) {
return setLoadTextColor(getColor(mLoadTextColorRes));
}

/**
* 设置所有TextView 文本颜色
*
Expand All @@ -192,6 +201,16 @@ public Builder setLoadTextColor(@ColorInt int mLoadTextColor) {
return this;
}

/**
* 设置所有TextView 文本尺寸资源
*
* @param mLoadTextSizeRes
* @return
*/
public Builder setLoadTextSizeResource(@DimenRes int mLoadTextSizeRes) {
return setLoadTextSize(getDimensionPixelSize(mLoadTextSizeRes));
}

/**
* 设置所有TextView 文本尺寸
*
Expand All @@ -205,6 +224,16 @@ public Builder setLoadTextSize(int mLoadTextSize) {
return this;
}

/**
* 设置加载中文本资源
*
* @param mLoadingText
* @return
*/
public Builder setLoadingText(@StringRes int mLoadingText) {
return setLoadingText(getText(mLoadingText));
}

/**
* 设置加载中文本
*
Expand All @@ -217,14 +246,29 @@ public Builder setLoadingText(CharSequence mLoadingText) {
}

/**
* 设置加载中文本颜色
* 设置加载中文本颜色资源
*
* @param mLoadingTextColorRes
* @return
*/
public Builder setLoadingTextColorResource(@ColorRes int mLoadingTextColorRes) {
return setLoadingTextColor(getColor(mLoadingTextColorRes));
}

/**
* 设置加载中文本颜色--同步设置 ProgressBar颜色
* {@link #setLoadingProgressColor(int)} 注意调用顺序
*
* @param mLoadingTextColor
* @return
*/
public Builder setLoadingTextColor(@ColorInt int mLoadingTextColor) {
this.mLoadingTextColor = mLoadingTextColor;
return this;
return setLoadingProgressColor(mLoadingTextColor);
}

public Builder setLoadingTextSizeResource(@DimenRes int mLoadingTextSizeRes) {
return setLoadingTextSize(getDimensionPixelSize(mLoadingTextSizeRes));
}

/**
Expand All @@ -238,6 +282,16 @@ public Builder setLoadingTextSize(int mLoadingTextSize) {
return this;
}

/**
* 设置加载ProgressBar颜色资源
*
* @param mLoadingProgressColorRes
* @return
*/
public Builder setLoadingProgressColorResource(@ColorRes int mLoadingProgressColorRes) {
return setLoadingProgressColor(getColor(mLoadingProgressColorRes));
}

/**
* 设置加载ProgressBar颜色--5.0及以上支持
*
Expand All @@ -249,6 +303,10 @@ public Builder setLoadingProgressColor(@ColorInt int mLoadingProgressColor) {
return this;
}

public Builder setLoadingProgressDrawable(@DrawableRes int mLoadingProgressDrawable) {
return setLoadingProgressDrawable(getResources().getDrawable(mLoadingProgressDrawable));
}

/**
* 设置loading Drawable
*
Expand All @@ -260,6 +318,10 @@ public Builder setLoadingProgressDrawable(Drawable mLoadingProgressDrawable) {
return this;
}

public Builder setLoadFailText(@StringRes int mLoadFailText) {
return setLoadFailText(getText(mLoadFailText));
}

/**
* 设置加载失败文本
*
Expand All @@ -271,6 +333,16 @@ public Builder setLoadFailText(CharSequence mLoadFailText) {
return this;
}

/**
* 设置加载失败文本颜色资源
*
* @param mLoadFailTextColorRes
* @return
*/
public Builder setLoadFailTextColorResource(@ColorRes int mLoadFailTextColorRes) {
return setLoadFailTextColor(getColor(mLoadFailTextColorRes));
}

/**
* 设置加载失败文本颜色
*
Expand All @@ -282,6 +354,10 @@ public Builder setLoadFailTextColor(@ColorInt int mLoadFailTextColor) {
return this;
}

public Builder setLoadFailTextSizeResource(@DimenRes int mLoadFailTextSizeRes) {
return setLoadFailTextSize(getDimensionPixelSize(mLoadFailTextSizeRes));
}

/**
* 设置加载失败文本尺寸
*
Expand All @@ -293,6 +369,10 @@ public Builder setLoadFailTextSize(int mLoadFailTextSize) {
return this;
}

public Builder setLoadEndText(@StringRes int mLoadEndText) {
return setLoadEndText(getText(mLoadEndText));
}

/**
* 设置加载结束文本
*
Expand All @@ -304,6 +384,16 @@ public Builder setLoadEndText(CharSequence mLoadEndText) {
return this;
}

/**
* 设置加载结束文本颜色资源
*
* @param mLoadEndTextColorRes
* @return
*/
public Builder setLoadEndTextColorResource(@ColorRes int mLoadEndTextColorRes) {
return setLoadEndTextColor(getColor(mLoadEndTextColorRes));
}

/**
* 设置加载结束文本颜色
*
Expand All @@ -315,6 +405,10 @@ public Builder setLoadEndTextColor(@ColorInt int mLoadEndTextColor) {
return this;
}

public Builder setLoadEndTextSizeResource(@DimenRes int mLoadEndTextSizeRes) {
return setLoadEndTextSize(getDimensionPixelSize(mLoadEndTextSizeRes));
}

/**
* 设置加载结束文件尺寸
*
Expand All @@ -330,11 +424,11 @@ private Resources getResources() {
return mContext.getResources();
}

private int getColor(@ColorInt int color) {
private int getColor(@ColorRes int color) {
return getResources().getColor(color);
}

public int getDimensionPixelSize(@DrawableRes int dimen) {
public int getDimensionPixelSize(@DimenRes int dimen) {
return getResources().getDimensionPixelSize(dimen);
}

Expand Down
Loading

0 comments on commit 1a99f3e

Please sign in to comment.