Long click download button to download with default label
This commit is contained in:
1 parent
b6a6863f6c
commit
04ae2c1b4b
4 files changed
+21
-13
No files matched your search
@@ -216,10 +216,10 @@ public final class CommonOperations {
|
||||
client.execute(request);
|
||||
}
|
||||
|
||||
public static void startDownload(final Activity activity, final GalleryInfo galleryInfo) {
|
||||
public static void startDownload(final Activity activity, final GalleryInfo galleryInfo, boolean forceDefault) {
|
||||
final DownloadManager dm = EhApplication.getDownloadManager(activity);
|
||||
|
||||
boolean justStart = dm.containDownloadInfo(galleryInfo.gid);
|
||||
boolean justStart = forceDefault || dm.containDownloadInfo(galleryInfo.gid);
|
||||
String label = null;
|
||||
// Get default download label
|
||||
if (!justStart && Settings.getHasDefaultDownloadLabel()) {
|
||||
|
||||
@@ -104,7 +104,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener {
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
|
||||
View.OnLongClickListener{
|
||||
|
||||
@IntDef({STATE_INIT, STATE_NORMAL, STATE_REFRESH, STATE_REFRESH_HEADER, STATE_FAILED})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@@ -421,6 +422,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mCategory.setOnClickListener(this);
|
||||
mOtherActions.setOnClickListener(this);
|
||||
mDownload.setOnClickListener(this);
|
||||
mDownload.setOnLongClickListener(this);
|
||||
mRead.setOnClickListener(this);
|
||||
|
||||
mBelowHeader = mainView.findViewById(R.id.below_header);
|
||||
@@ -987,15 +989,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
lub.setCategory(category);
|
||||
GalleryListScene.startScene(this, lub);
|
||||
} else if (mDownload == v) {
|
||||
// Add download
|
||||
GalleryInfo galleryInfo = null;
|
||||
if (mGalleryInfo != null) {
|
||||
galleryInfo = mGalleryInfo;
|
||||
} else if (mGalleryDetail != null) {
|
||||
galleryInfo = mGalleryDetail;
|
||||
}
|
||||
GalleryInfo galleryInfo = getGalleryInfo();
|
||||
if (galleryInfo != null) {
|
||||
CommonOperations.startDownload(getActivity(), galleryInfo);
|
||||
CommonOperations.startDownload(getActivity(), galleryInfo, false);
|
||||
}
|
||||
} else if (mRead == v) {
|
||||
GalleryInfo galleryInfo = null;
|
||||
@@ -1106,6 +1102,18 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (mDownload == v) {
|
||||
GalleryInfo galleryInfo = getGalleryInfo();
|
||||
if (galleryInfo != null) {
|
||||
CommonOperations.startDownload(getActivity(), galleryInfo, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (ApiHelper.SUPPORT_TRANSITION && mViewTransition != null && mThumb != null &&
|
||||
|
||||
@@ -588,7 +588,7 @@ public final class GalleryListScene extends BaseScene
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0: // Download
|
||||
CommonOperations.startDownload(getActivity(), gi);
|
||||
CommonOperations.startDownload(getActivity(), gi, false);
|
||||
break;
|
||||
case 1: // Favorites
|
||||
CommonOperations.addToFavorites(getActivity(), gi,
|
||||
|
||||
@@ -174,7 +174,7 @@ public class HistoryScene extends ToolbarScene
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0: // Download
|
||||
CommonOperations.startDownload(getActivity(), gi);
|
||||
CommonOperations.startDownload(getActivity(), gi, false);
|
||||
break;
|
||||
case 1: // Favorites
|
||||
CommonOperations.addToFavorites(getActivity(), gi,
|
||||
|
||||
Reference in new issue
Block a user