Skip to content

Commit

Permalink
Show delete downloads option if the gallery is downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
seven332 committed Jun 20, 2019
1 parent 323b36c commit 2da10a5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1061,33 +1061,12 @@ public boolean onItemLongClick(EasyRecyclerView parent, View view, int position,
return true;
}

boolean download;
switch (mDownloadManager.getDownloadState(gi.gid)) {
default:
case DownloadInfo.STATE_INVALID:
download = true;
break;
case DownloadInfo.STATE_NONE:
download = true;
break;
case DownloadInfo.STATE_WAIT:
download = false;
break;
case DownloadInfo.STATE_DOWNLOAD:
download = false;
break;
case DownloadInfo.STATE_FINISH:
download = true;
break;
case DownloadInfo.STATE_FAILED:
download = true;
break;
}
boolean downloaded = mDownloadManager.getDownloadState(gi.gid) != DownloadInfo.STATE_INVALID;
boolean favourite = gi.favoriteSlot == -2;

CharSequence[] items = new CharSequence[] {
context.getString(R.string.read),
context.getString(download ? R.string.download : R.string.stop_downloading),
context.getString(downloaded ? R.string.delete_downloads : R.string.download),
context.getString(favourite ? R.string.add_to_favourites : R.string.remove_from_favourites),
};

Expand All @@ -1102,10 +1081,10 @@ public boolean onItemLongClick(EasyRecyclerView parent, View view, int position,
startActivity(intent);
break;
case 1: // Download
if (download) {
CommonOperations.startDownload(activity, gi, false);
if (downloaded) {
mDownloadManager.deleteDownload(gi.gid);
} else {
mDownloadManager.stopDownload(gi.gid);
CommonOperations.startDownload(activity, gi, false);
}
break;
case 2: // Favorites
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<string name="remove_from_favourites">移除收藏</string>

<string name="stop_downloading">停止下载</string>
<string name="delete_downloads">删除下载</string>

<string name="quick_search">快速搜索</string>
<string name="quick_search_tip">点击“+”来添加快速搜索</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<string name="remove_from_favourites">移除收藏</string>

<string name="stop_downloading">停止下載</string>
<string name="delete_downloads">刪除下載</string>

<string name="quick_search">快速搜索</string>
<string name="quick_search_tip">點擊“+”來添加快速搜索</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<string name="remove_from_favourites">移除收藏</string>

<string name="stop_downloading">停止下載</string>
<string name="delete_downloads">刪除下載</string>

<string name="quick_search">快速搜尋</string>
<string name="quick_search_tip">點擊“+”以新增快速搜尋</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
<string name="remove_from_favourites">Remove from favourites</string>

<string name="stop_downloading">Stop downloading</string>
<string name="delete_downloads">Delete downloads</string>

<string name="quick_search">Quick search</string>
<string name="quick_search_tip">Tap \"+\" to add Quick Search</string>
Expand Down

0 comments on commit 2da10a5

Please sign in to comment.