Skip to content

Commit

Permalink
#update Toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
wumeng1 authored and wumeng1 committed Jul 19, 2021
1 parent ab497a9 commit dee0803
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static GlideCacheUtil getInstance() {
/**
* 清除图片内存缓存
*/
public void clearImageMemoryCache(Context context) {
public void clearMemoryCache(Context context) {
try {
if (Looper.myLooper() == Looper.getMainLooper()) { //只能在主线程执行
Glide.get(context).clearMemory();
Expand All @@ -41,7 +41,7 @@ public void clearImageMemoryCache(Context context) {
/**
* 清除图片所有缓存
*/
public void clearImageAllCache(Context context) {
public void clearAllCache(Context context) {
// clearImageDiskCache(context);
// clearImageMemoryCache(context);
String imageExternalCatchDir = context.getExternalCacheDir() + ExternalCacheDiskCacheFactory.DEFAULT_DISK_CACHE_DIR;
Expand Down
47 changes: 46 additions & 1 deletion lib_widget/src/main/java/com/mirkowu/lib_widget/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public Toolbar setTitle(String title) {
return this;
}


public Toolbar setTitle(@StringRes int titleResId) {
tvTitle.setText(titleResId);
return this;
Expand All @@ -118,10 +117,23 @@ public Toolbar setTitleColor(@ColorInt int colorId) {
return this;
}

/**
* 设置标题字体
*
* @param sizeSp 单位sp
* @return
*/
public Toolbar setTitleTextSize(int sizeSp) {
return setTitleTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSp);
}

/**
* 设置标题字体
*
* @param unit 单位
* @param size 大小
* @return
*/
public Toolbar setTitleTextSize(int unit, float size) {
tvTitle.setTextSize(unit, size);
return this;
Expand All @@ -144,6 +156,12 @@ public Toolbar setTitleEllipsize(TextUtils.TruncateAt where) {
return this;
}

/**
* 设置是否显示返回键
*
* @param isShow
* @return
*/
public Toolbar setShowBackIcon(boolean isShow) {
if (isShow) {
setBackIcon(mBackIconDrawable);
Expand Down Expand Up @@ -176,6 +194,12 @@ public void onClick(View v) {
return this;
}

/**
* 设置是否显示关闭按钮,一般多用于WebView
*
* @param isShow
* @return
*/
public Toolbar setShowCloseIcon(boolean isShow) {
if (isShow) {
setCloseIcon(mCloseIconDrawable);
Expand Down Expand Up @@ -208,6 +232,13 @@ public void onClick(View v) {
return this;
}

/**
* 设置右功能键 图片资源
*
* @param resId
* @param clickListener
* @return
*/
public Toolbar setRightIcon(@DrawableRes int resId, OnClickListener clickListener) {
ivRight.setVisibility(VISIBLE);
ivRight.setImageResource(resId);
Expand All @@ -231,6 +262,13 @@ public Toolbar setRightTextSize(@ColorInt int sizeSp) {
return this;
}

/**
* 设置右功能键 文字内容
*
* @param rightText
* @param clickListener
* @return
*/
public Toolbar setRightText(String rightText, OnClickListener clickListener) {
tvRight.setVisibility(VISIBLE);
tvRight.setText(rightText);
Expand All @@ -251,6 +289,13 @@ public Toolbar setShowLine(boolean showLine) {
return this;
}

/**
* 设置是否显示底部分割线
*
* @param showLine
* @param colorId
* @return
*/
public Toolbar setShowLine(boolean showLine, @ColorInt int colorId) {
mShowLine = showLine;
vLine.setVisibility(showLine ? VISIBLE : GONE);
Expand Down

0 comments on commit dee0803

Please sign in to comment.