Skip to content

Commit

Permalink
#update 规范
Browse files Browse the repository at this point in the history
  • Loading branch information
wumeng1 authored and wumeng1 committed Aug 18, 2021
1 parent 282a0cc commit 613ffc1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class RefreshHelper implements OnRefreshListener, OnRefreshLoadMoreListen
/*** 当前页*/
protected int mCurPage = FIRST_PAGE;

public RefreshHelper(@NonNull RecyclerView mInnerContainer, OnRefreshListener onRefreshListener) {
this(null, mInnerContainer, onRefreshListener);
public RefreshHelper(@NonNull RecyclerView recyclerView, OnRefreshListener onRefreshListener) {
this(null, recyclerView, onRefreshListener);
}

public RefreshHelper(SmartRefreshLayout refreshLayout, @NonNull RecyclerView innerContainer, OnRefreshListener onRefreshListener) {
this(refreshLayout, (ViewGroup) innerContainer, onRefreshListener);
public RefreshHelper(SmartRefreshLayout refreshLayout, @NonNull RecyclerView recyclerView, OnRefreshListener onRefreshListener) {
this(refreshLayout, (ViewGroup) recyclerView, onRefreshListener);
}

public RefreshHelper(SmartRefreshLayout refreshLayout, @NonNull ViewGroup innerContainer, OnRefreshListener onRefreshListener) {
Expand Down
49 changes: 28 additions & 21 deletions lib_bugly/src/main/java/com/mirkowu/lib_bugly/UpgradeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ public class UpgradeDialog extends BaseDialog implements DownloadListener, Upgra
RelativeLayout llProgress;
LinearLayout llButton;

protected OnButtonClickListener listener;
private UpgradeInfo upgradeInfo;
private boolean isForceUpgrade;
protected OnButtonClickListener mClickListener;
protected UpgradeInfo mUpgradeInfo;
protected boolean mIsForceUpgrade;

public static void show(FragmentManager manager, UpgradeInfo upgradeInfo) {
if (upgradeInfo == null) return;
if (upgradeInfo == null) {
LogUtil.e("UpgradeDialog upgradeInfo == null");
return;
}
UpgradeDialog dialog = new UpgradeDialog();
dialog.upgradeInfo = upgradeInfo;
dialog.setUpgradeInfo(upgradeInfo);
dialog.showAllowingStateLoss(manager);
}

Expand Down Expand Up @@ -70,14 +73,14 @@ protected void convertView(ViewHolder viewHolder, BaseDialog baseDialog) {

tvPositive.setOnClickListener(this);

if (upgradeInfo == null) {
if (mUpgradeInfo == null) {
dismissAllowingStateLoss();
return;
}

tvTitle.setText(upgradeInfo.title);
tvContent.setText(upgradeInfo.newFeature);
isForceUpgrade = upgradeInfo.upgradeType == 2;
tvTitle.setText(mUpgradeInfo.title);
tvContent.setText(mUpgradeInfo.newFeature);
mIsForceUpgrade = mUpgradeInfo.upgradeType == 2;

initButtonText();

Expand All @@ -87,14 +90,14 @@ protected void convertView(ViewHolder viewHolder, BaseDialog baseDialog) {
}

private void initButtonText() {
if (isForceUpgrade = upgradeInfo.upgradeType == 2) { //强制
if (mIsForceUpgrade = mUpgradeInfo.upgradeType == 2) { //强制
tvNegative.setVisibility(View.GONE);
} else {
tvNegative.setVisibility(View.VISIBLE);
tvNegative.setOnClickListener(this);
}

tvNegative.setVisibility(isForceUpgrade ? GONE : VISIBLE);
tvNegative.setVisibility(mIsForceUpgrade ? GONE : VISIBLE);
tvNegative.setText(com.mirkowu.lib_upgrade.R.string.up_next_time);
tvPositive.setVisibility(VISIBLE);
tvPositive.setText(com.mirkowu.lib_upgrade.R.string.up_upgrade);
Expand Down Expand Up @@ -124,23 +127,23 @@ public void onResume() {
public void onClick(View v) {
int i = v.getId();
if (i == R.id.tvPositive) {
if (listener != null) {
listener.onButtonClick(this, true);
if (mClickListener != null) {
mClickListener.onButtonClick(this, true);
}
if (PermissionsUtil.hasPermissions(getContext(), PermissionsUtil.GROUP_STORAGE)) {
startDownloadTask();
} else {
LogUtil.e("没有存储权限");
if (listener != null) {
listener.onNeedPermission(this);
if (mClickListener != null) {
mClickListener.onNeedPermission(this);
} else {
LogUtil.e("下载到默认路径");
startDownloadTask();
}
}
} else if (i == R.id.tvNegative) {
if (listener != null) {
listener.onButtonClick(this, true);
if (mClickListener != null) {
mClickListener.onButtonClick(this, true);
}
BuglyManager.cancelDownload();
dismissAllowingStateLoss();
Expand All @@ -153,7 +156,7 @@ private void startDownloadTask() {
tvPositive.setVisibility(GONE);
tvNegative.setVisibility(VISIBLE);

if (isForceUpgrade) {
if (mIsForceUpgrade) {
tvNegative.setText(com.mirkowu.lib_upgrade.R.string.up_downloading);
tvNegative.setEnabled(false);
} else {
Expand All @@ -178,7 +181,7 @@ public void onReceive(DownloadTask downloadTask) {
tvPositive.setVisibility(GONE);
tvNegative.setVisibility(VISIBLE);

if (isForceUpgrade) {
if (mIsForceUpgrade) {
tvNegative.setText(com.mirkowu.lib_upgrade.R.string.up_downloading);
tvNegative.setEnabled(false);
} else {
Expand All @@ -191,7 +194,7 @@ public void onReceive(DownloadTask downloadTask) {
@Override
public void onCompleted(DownloadTask downloadTask) {
if (!isAdded() || isDetached()) return;
if (isForceUpgrade) {
if (mIsForceUpgrade) {
llButton.setVisibility(View.VISIBLE);
tvNegative.setVisibility(View.GONE);
tvPositive.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -239,9 +242,13 @@ public void onUpgrading(boolean b) {
public void onDownloadCompleted(boolean b) {
}

public UpgradeDialog setUpgradeInfo(UpgradeInfo upgradeInfo) {
this.mUpgradeInfo = upgradeInfo;
return this;
}

public UpgradeDialog setOnButtonClickListener(UpgradeDialog.OnButtonClickListener listener) {
this.listener = listener;
this.mClickListener = listener;
return this;
}

Expand Down

0 comments on commit 613ffc1

Please sign in to comment.