添加下载项全部开始下载或停止
No files matched your search
|
Before Width: | Height: | Size: 510 B After Width: | Height: | Size: 446 B |
|
After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 567 B After Width: | Height: | Size: 512 B |
|
Before Width: | Height: | Size: 595 B After Width: | Height: | Size: 578 B |
|
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 304 B |
|
After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 341 B |
|
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 509 B |
|
After Width: | Height: | Size: 296 B |
|
Before Width: | Height: | Size: 748 B After Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 792 B After Width: | Height: | Size: 767 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 929 B |
|
After Width: | Height: | Size: 565 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 928 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 969 B |
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 Hippo Seven
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_start"
|
||||
android:title="@string/start"
|
||||
android:icon="@drawable/ic_action_start"
|
||||
android:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_stop"
|
||||
android:title="@string/stop"
|
||||
android:icon="@drawable/ic_action_stop"
|
||||
android:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
@@ -156,6 +156,43 @@ public class DownloadService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
public void startAll() {
|
||||
for (DownloadInfo di : mData.getAllDownloads()) {
|
||||
if (di.state == DownloadInfo.STATE_NONE ||
|
||||
(di.state == DownloadInfo.STATE_FINISH && di.legacy != 0))
|
||||
di.state = DownloadInfo.STATE_WAIT;
|
||||
}
|
||||
notifyDownloadInfoChanged();
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
public void stopAll() {
|
||||
for (DownloadInfo di : mData.getAllDownloads()) {
|
||||
if (di.state == DownloadInfo.STATE_WAIT ||
|
||||
di.state == DownloadInfo.STATE_DOWNLOAD) {
|
||||
if (mCurDownloadInfo == di) {
|
||||
// Cancel download notification
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
|
||||
// Target downloadinfo is downloading
|
||||
mCurDownloadInfo.state = DownloadInfo.STATE_NONE;
|
||||
mData.addDownload(mCurDownloadInfo);
|
||||
mCurDownloadInfo = null;
|
||||
|
||||
mCurExDownloader.setListenerDownload(null);
|
||||
mCurExDownloader.setDownloadMode(false);
|
||||
mEdManager.freeExDownloader(mCurExDownloader);
|
||||
mCurExDownloader = null;
|
||||
} else {
|
||||
di.state = DownloadInfo.STATE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notifyDownloadInfoChanged();
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
public void delete(DownloadInfo di) {
|
||||
stop(di);
|
||||
mData.deleteDownload(di.galleryInfo.gid);
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -130,13 +131,33 @@ public class DownloadActivity extends AbsActivity implements AbsListView.OnItemC
|
||||
mWindowsAnimate.free();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.download, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
Intent it;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
|
||||
case R.id.action_start:
|
||||
it = new Intent(DownloadActivity.this, DownloadService.class);
|
||||
startService(it);
|
||||
mServiceConn.getService().startAll();
|
||||
return true;
|
||||
|
||||
case R.id.action_stop:
|
||||
it = new Intent(DownloadActivity.this, DownloadService.class);
|
||||
startService(it);
|
||||
mServiceConn.getService().stopAll();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||