From 981917fa527ef2a7d5526c001e0171a4fcfb07ed Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Sun, 5 Jul 2020 12:27:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9dialogfragment=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AppFrame/build.gradle | 4 ++++ .../arialyy/aria/core/download/DownloadReceiver.java | 4 ++-- FtpComponent/build.gradle | 4 ++++ HttpComponent/build.gradle | 4 ++++ M3U8Component/build.gradle | 4 ++++ PublicComponent/build.gradle | 5 +++++ SFtpComponent/build.gradle | 4 ++++ app/build.gradle | 2 +- .../simple/core/download/ComponentActivity.java | 4 ++++ .../arialyy/simple/core/download/DownloadDialog.java | 10 ---------- .../simple/core/download/DownloadDialogFragment.java | 11 +++++------ .../java/com/arialyy/simple/modlue/CommonModule.java | 3 ++- app/src/main/res/values/strings.xml | 1 + 13 files changed, 40 insertions(+), 20 deletions(-) diff --git a/AppFrame/build.gradle b/AppFrame/build.gradle index f95f1802..940396e9 100644 --- a/AppFrame/build.gradle +++ b/AppFrame/build.gradle @@ -23,6 +23,10 @@ android { dataBinding { enabled = true } + lintOptions { + abortOnError false + } + } dependencies { diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index 6987c90c..d69007e4 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -166,7 +166,7 @@ public class DownloadReceiver extends AbsReceiver { public void register() { Object obj = OBJ_MAP.get(getKey()); if (obj == null) { - ALog.e(TAG, String.format("【%s】观察者为空", getTargetName())); + ALog.e(TAG, String.format("register【%s】观察者为空", getTargetName())); return; } Set set = ProxyHelper.getInstance().checkProxyType(obj.getClass()); @@ -212,7 +212,7 @@ public class DownloadReceiver extends AbsReceiver { @Override protected void unRegisterListener() { Object obj = OBJ_MAP.get(getKey()); if (obj == null) { - ALog.e(TAG, String.format("【%s】观察者为空", getTargetName())); + ALog.e(TAG, String.format("unRegister【%s】观察者为空", getTargetName())); return; } Set set = ProxyHelper.getInstance().mProxyCache.get(obj.getClass().getName()); diff --git a/FtpComponent/build.gradle b/FtpComponent/build.gradle index a480ed42..7767daed 100644 --- a/FtpComponent/build.gradle +++ b/FtpComponent/build.gradle @@ -20,6 +20,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + lintOptions { + abortOnError false + } + } dependencies { diff --git a/HttpComponent/build.gradle b/HttpComponent/build.gradle index f16fd533..e0fbecc6 100644 --- a/HttpComponent/build.gradle +++ b/HttpComponent/build.gradle @@ -19,6 +19,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + lintOptions { + abortOnError false + } + } dependencies { diff --git a/M3U8Component/build.gradle b/M3U8Component/build.gradle index 6c08e9ef..744b384c 100644 --- a/M3U8Component/build.gradle +++ b/M3U8Component/build.gradle @@ -20,6 +20,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + lintOptions { + abortOnError false + } + } dependencies { diff --git a/PublicComponent/build.gradle b/PublicComponent/build.gradle index 8df6b54e..1d3c39d0 100644 --- a/PublicComponent/build.gradle +++ b/PublicComponent/build.gradle @@ -20,6 +20,11 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + + lintOptions { + abortOnError false + } + } dependencies { diff --git a/SFtpComponent/build.gradle b/SFtpComponent/build.gradle index 535880e7..54755e11 100644 --- a/SFtpComponent/build.gradle +++ b/SFtpComponent/build.gradle @@ -20,6 +20,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + lintOptions { + abortOnError false + } + } dependencies { diff --git a/app/build.gradle b/app/build.gradle index 65bb45bf..9748e9bb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,7 +66,7 @@ dependencies { implementation 'com.google.android.material:material:1.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}" api 'com.github.PhilJay:MPAndroidChart:v3.0.3' - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4' implementation 'com.github.bumptech.glide:glide:3.7.0' implementation 'com.pddstudio:highlightjs-android:1.5.0' implementation 'org.greenrobot:eventbus:3.1.1' diff --git a/app/src/main/java/com/arialyy/simple/core/download/ComponentActivity.java b/app/src/main/java/com/arialyy/simple/core/download/ComponentActivity.java index a4f3c792..eb93a5f0 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/ComponentActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/ComponentActivity.java @@ -71,6 +71,10 @@ public class ComponentActivity extends BaseActivity { DownloadDialog dialog = new DownloadDialog(ComponentActivity.this); dialog.show(); break; + case 2: + new DownloadDialogFragment(ComponentActivity.this).show(getSupportFragmentManager(), + "df"); + break; } } }); diff --git a/app/src/main/java/com/arialyy/simple/core/download/DownloadDialog.java b/app/src/main/java/com/arialyy/simple/core/download/DownloadDialog.java index 40899abf..de3c5d70 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/DownloadDialog.java +++ b/app/src/main/java/com/arialyy/simple/core/download/DownloadDialog.java @@ -66,10 +66,7 @@ public class DownloadDialog extends AbsDialog implements View.OnClickListener { int p = (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()); mPb.setProgress(p); int state = entity.getState(); - setBtState(state != DownloadEntity.STATE_RUNNING); mTaskId = entity.getId(); - } else { - setBtState(true); } mStart.setOnClickListener(this); mCancel.setOnClickListener(this); @@ -106,16 +103,13 @@ public class DownloadDialog extends AbsDialog implements View.OnClickListener { @Download.onTaskPre public void onTaskPre(DownloadTask task) { mSize.setText(CommonUtil.formatFileSize(task.getFileSize())); - setBtState(false); } @Download.onTaskStop public void onTaskStop(DownloadTask task) { - setBtState(true); mSpeed.setText(task.getConvertSpeed()); } @Download.onTaskCancel public void onTaskCancel(DownloadTask task) { - setBtState(true); mPb.setProgress(0); mSpeed.setText(task.getConvertSpeed()); } @@ -131,8 +125,4 @@ public class DownloadDialog extends AbsDialog implements View.OnClickListener { } - private void setBtState(boolean startEnable) { - mStart.setEnabled(startEnable); - mCancel.setEnabled(!startEnable); - } } diff --git a/app/src/main/java/com/arialyy/simple/core/download/DownloadDialogFragment.java b/app/src/main/java/com/arialyy/simple/core/download/DownloadDialogFragment.java index 4a1e5895..2929a91f 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/DownloadDialogFragment.java +++ b/app/src/main/java/com/arialyy/simple/core/download/DownloadDialogFragment.java @@ -33,8 +33,8 @@ import com.arialyy.simple.util.AppUtil; @Override protected void init(Bundle savedInstanceState) { super.init(savedInstanceState); - Aria.download(getContext()).register(); - mEntity = Aria.download(getContext()).getFirstDownloadEntity(DOWNLOAD_URL); + Aria.download(this).register(); + mEntity = Aria.download(this).getFirstDownloadEntity(DOWNLOAD_URL); if (mEntity != null) { if (mEntity.getState() == IEntity.STATE_RUNNING) { getBinding().setStateStr(getString(R.string.stop)); @@ -46,7 +46,6 @@ import com.arialyy.simple.util.AppUtil; getBinding().setProgress((int) (mEntity.getCurrentProgress() * 100 / mEntity.getFileSize())); } mRootView.findViewById(R.id.start).setOnClickListener(this); - mRootView.findViewById(R.id.stop).setOnClickListener(this); mRootView.findViewById(R.id.cancel).setOnClickListener(this); } @@ -56,7 +55,7 @@ import com.arialyy.simple.util.AppUtil; @Override public void onDestroy() { super.onDestroy(); - Aria.download(getContext()).unRegister(); + Aria.download(this).unRegister(); } @Download.onPre(DOWNLOAD_URL) protected void onPre(DownloadTask task) { @@ -103,7 +102,7 @@ import com.arialyy.simple.util.AppUtil; switch (view.getId()) { case R.id.start: if (!AppUtil.chekEntityValid(mEntity)) { - Aria.download(getContext()) + Aria.download(this) .load(DOWNLOAD_URL) .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/放置江湖.apk") .create(); @@ -121,7 +120,7 @@ import com.arialyy.simple.util.AppUtil; case R.id.cancel: if (AppUtil.chekEntityValid(mEntity)) { - Aria.download(getContext()).load(mEntity.getId()).cancel(); + Aria.download(this).load(mEntity.getId()).cancel(); } break; } diff --git a/app/src/main/java/com/arialyy/simple/modlue/CommonModule.java b/app/src/main/java/com/arialyy/simple/modlue/CommonModule.java index dd046717..2312a69a 100644 --- a/app/src/main/java/com/arialyy/simple/modlue/CommonModule.java +++ b/app/src/main/java/com/arialyy/simple/modlue/CommonModule.java @@ -48,7 +48,8 @@ public class CommonModule extends BaseViewModule { String[] titles = context.getResources().getStringArray(R.array.component_items); int[] icons = new int[] { R.drawable.ic_fragment, - R.drawable.ic_dialog + R.drawable.ic_dialog, + R.drawable.ic_fragment }; int i = 0; for (String title : titles) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fdccad28..bcc543e3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -75,6 +75,7 @@ fragment中使用 dialog中使用 + dialogFragment中使用