-
-
Save owlishDeveloper/2629e06fff73700954d2fd0c53d6a886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDownload { | |
WebExtension.DownloadItem mExtensionDownload; | |
// Cancels the download | |
GeckoResult<Void> cancel() { | |
// Actually cancel the download | |
// Notifies extension | |
DownloadItemUpdate update = mExtensionDownload.updateCanceled(true).commit(); | |
DownloadItemUpdate.Builder b = new DownloadItem.Builder(mExtensionDownload, update); | |
mExtensionDownload = b.build(); | |
return GeckoResult.fromValue(Void); | |
} | |
void setDownloadItem(DownloadItem item) { | |
mExtensionDownload = item; | |
} | |
} | |
class AppDownloadController { | |
// stuff ... | |
@Override | |
GeckoResult<Void> onCancel(DownloadItem item, WebExtension extension) { | |
AppDownload download = mDownloads.byDownloadItem(item); | |
// Update the download item in case it's out of date | |
download.setDownloadItem(item); | |
return download.cancel(); | |
} | |
} | |
// UI Code | |
onClick() { | |
mDownload.cancel(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment