4444import java .util .ArrayList ;
4545import java .util .Locale ;
4646
47- //import com.download.library.DownloadException;
48- //import com.download.library.DownloadImpl;
49- //import com.download.library.DownloadListenerAdapter;
50- //import com.download.library.DownloadTask;
51- //import com.download.library.Downloader;
52- //import com.download.library.Extra;
53- //import com.download.library.Runtime;
5447
5548/**
5649 * @author ringle-android
@@ -82,7 +75,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
8275 /*new Thread(new Runnable() {
8376 @Override
8477 public void run() {
85- File file = DownloadImpl.getInstance(NativeDownloadActivity.this ).with(getApplicationContext()).url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk").setDownloadingListener(new DownloadListenerAdapter() {
78+ File file = DownloadImpl.getInstance().with(getApplicationContext()).url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk").setDownloadingListener(new DownloadListenerAdapter() {
8679 @Override
8780 public void onProgress(String url, long downloaded, long length, long usedTime) {
8881 super.onProgress(url, downloaded, length, usedTime);
@@ -99,7 +92,7 @@ public boolean onResult(Throwable throwable, Uri path, String url, Extra extra)
9992 Log.i(TAG, " download success:" + ((File) file).length());
10093 }
10194 }).start();*/
102- /*DownloadImpl.getInstance(NativeDownloadActivity.this )
95+ /*DownloadImpl.getInstance()
10396 .with(getApplicationContext())
10497 .setEnableIndicator(true)
10598 .url("http://shouji.360tpcdn.com/170918/f7aa8587561e4031553316ada312ab38/com.tencent.qqlive_13049.apk")
@@ -123,7 +116,7 @@ public boolean onResult(Throwable throwable, Uri path, String url, Extra extra)
123116 } catch (IOException e) {
124117 e.printStackTrace();
125118 }
126- DownloadImpl.getInstance(NativeDownloadActivity.this )
119+ DownloadImpl.getInstance()
127120 .with(getApplicationContext())
128121 .target(file)
129122 .url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk")
@@ -142,7 +135,7 @@ public boolean onResult(Throwable throwable, Uri path, String url, Extra extra)
142135 });*/
143136
144137
145- // DownloadImpl.getInstance(NativeDownloadActivity.this )
138+ // DownloadImpl.getInstance()
146139// .with(getApplicationContext())
147140// .target(getExternalFilesDir(android.os.Environment.DIRECTORY_PICTURES))
148141// .url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk")
@@ -159,7 +152,7 @@ public boolean onResult(Throwable throwable, Uri path, String url, Extra extra)
159152// return super.onResult(throwable, path, url, extra);
160153// }
161154// });
162- /* DownloadImpl.getInstance(NativeDownloadActivity.this )
155+ /* DownloadImpl.getInstance()
163156 .with(getApplicationContext())
164157 .target(new File(Runtime.getInstance().getDir(this, true).getAbsolutePath() + "/" + "com.ss.android.article.news_636.apk"), this.getPackageName() + ".DownloadFileProvider")//自定义路径需指定目录和authority(FileContentProvide),需要相对应匹配才能启动通知,和自动打开文件
165158 .setUniquePath(false)//是否唯一路径
@@ -343,7 +336,7 @@ public boolean onResult(Throwable throwable, Uri uri, String url, Extra extra) {
343336 nativeDownloadViewHolder .mStatusButton .setText ("出错" );
344337 nativeDownloadViewHolder .mStatusButton .setEnabled (false );
345338 }
346- Toast .makeText (NativeDownloadActivity .this , downloadException .getMsg (), 1 ).show ();
339+ Toast .makeText (NativeDownloadActivity .this , downloadException .getMsg (), Toast . LENGTH_SHORT ).show ();
347340 }
348341 return super .onResult (throwable , uri , url , extra );
349342 }
0 commit comments