com.google.android.vending.expansion.downloader.IDownloaderClient Java Examples
The following examples show how to use
com.google.android.vending.expansion.downloader.IDownloaderClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AliteStartManager.java From Alite with GNU General Public License v3.0 | 6 votes |
@Override public void onDownloadStateChanged(int newState) { setStatus(getString(Helpers.getDownloaderStringResourceIDFromState(newState))); if (newState == IDownloaderClient.STATE_COMPLETED) { ((TextView) findViewById(R.id.downloadProgressPercentTextView)).setText("100%"); ((ProgressBar) findViewById(R.id.downloadProgressBar)).setProgress((int) AliteConfig.EXTENSION_FILE_LENGTH); ((TextView) findViewById(R.id.downloadTextView)).setText("Download complete."); AliteFiles.performMount(this, new IMethodHook() { private static final long serialVersionUID = -5369313962579796580L; @Override public void execute(float deltaTime) { startGame(); } }, new ErrorHook()); } }
Example #2
Source File: DownloadThread.java From QtAndroidTools with MIT License | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, HttpURLConnection request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); int responseCode = sendRequest(state, request); handleExceptionalStatus(state, innerState, request, responseCode); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, request); InputStream entityStream = openResponseEntity(state, request); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example #3
Source File: DownloadThread.java From play-apk-expansion with Apache License 2.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, HttpURLConnection request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); int responseCode = sendRequest(state, request); handleExceptionalStatus(state, innerState, request, responseCode); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, request); InputStream entityStream = openResponseEntity(state, request); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example #4
Source File: DownloadThread.java From travelguide with Apache License 2.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, AndroidHttpClient client, HttpGet request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); HttpResponse response = sendRequest(state, client, request); handleExceptionalStatus(state, innerState, response); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, response); InputStream entityStream = openResponseEntity(state, response); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example #5
Source File: ExpansionActivity.java From travelguide with Apache License 2.0 | 5 votes |
@Override public void onDownloadStateChanged(int newState) { mDownloadState.setText(Helpers.getDownloaderStringResourceIDFromState(newState)); mState = newState; switch (mState) { case IDownloaderClient.STATE_COMPLETED: forwardToApp(); return; } setUpResumePauseRetry(newState); }
Example #6
Source File: DownloadThread.java From Alite with GNU General Public License v3.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, AndroidHttpClient client, HttpGet request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); HttpResponse response = sendRequest(state, client, request); handleExceptionalStatus(state, innerState, response); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, response); InputStream entityStream = openResponseEntity(state, response); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example #7
Source File: DownloadThread.java From UnityOBBDownloader with Apache License 2.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, HttpURLConnection request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); int responseCode = sendRequest(state, request); handleExceptionalStatus(state, innerState, request, responseCode); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, request); InputStream entityStream = openResponseEntity(state, request); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example #8
Source File: DownloadNotification.java From QtAndroidTools with MIT License | 4 votes |
void onDownloadStateChanged(int newState) { mClientProxy.onDownloadStateChanged(newState); if (newState != mState) { mState = newState; if (newState == IDownloaderClient.STATE_IDLE || null == mContentIntent) { return; } @StringRes int stringDownloadID; int iconResource; boolean ongoingEvent; mBuilder.setPriority(NotificationCompat.PRIORITY_LOW); // get the new title string and paused text switch (newState) { case 0: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = AndroidApkExpansionFiles.STRING_UNKNOWN; ongoingEvent = false; break; case IDownloaderClient.STATE_DOWNLOADING: iconResource = android.R.drawable.stat_sys_download; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_FETCHING_URL: case IDownloaderClient.STATE_CONNECTING: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_COMPLETED: // show notification without progress mCurrentBuilder = mBuilder; mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); case IDownloaderClient.STATE_PAUSED_BY_REQUEST: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; case IDownloaderClient.STATE_FAILED: case IDownloaderClient.STATE_FAILED_CANCELED: case IDownloaderClient.STATE_FAILED_FETCHING_URL: case IDownloaderClient.STATE_FAILED_SDCARD_FULL: case IDownloaderClient.STATE_FAILED_UNLICENSED: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; default: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; } mCurrentText = AndroidApkExpansionFiles.getString(stringDownloadID); mCurrentTitle = mLabel; mCurrentBuilder.setTicker(mLabel + ": " + mCurrentText); mCurrentBuilder.setSmallIcon(iconResource); mCurrentBuilder.setContentTitle(mCurrentTitle); mCurrentBuilder.setContentText(mCurrentText); if (ongoingEvent) { mCurrentBuilder.setOngoing(true); mCurrentBuilder.setOnlyAlertOnce(true); } else { mCurrentBuilder.setOnlyAlertOnce(false); mCurrentBuilder.setOngoing(false); mCurrentBuilder.setAutoCancel(true); } mNotificationManager.notify(NOTIFICATION_ID, mCurrentBuilder.build()); } }
Example #9
Source File: DownloadNotification.java From play-apk-expansion with Apache License 2.0 | 4 votes |
@Override public void onDownloadStateChanged(int newState) { if (null != mClientProxy) { mClientProxy.onDownloadStateChanged(newState); } if (newState != mState) { mState = newState; if (newState == IDownloaderClient.STATE_IDLE || null == mContentIntent) { return; } int stringDownloadID; int iconResource; boolean ongoingEvent; // get the new title string and paused text switch (newState) { case 0: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = R.string.state_unknown; ongoingEvent = false; break; case IDownloaderClient.STATE_DOWNLOADING: iconResource = android.R.drawable.stat_sys_download; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_FETCHING_URL: case IDownloaderClient.STATE_CONNECTING: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_COMPLETED: case IDownloaderClient.STATE_PAUSED_BY_REQUEST: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; case IDownloaderClient.STATE_FAILED: case IDownloaderClient.STATE_FAILED_CANCELED: case IDownloaderClient.STATE_FAILED_FETCHING_URL: case IDownloaderClient.STATE_FAILED_SDCARD_FULL: case IDownloaderClient.STATE_FAILED_UNLICENSED: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; default: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; } mCurrentText = mContext.getString(stringDownloadID); mCurrentTitle = mLabel; mCurrentBuilder.setTicker(mLabel + ": " + mCurrentText); mCurrentBuilder.setSmallIcon(iconResource); mCurrentBuilder.setContentTitle(mCurrentTitle); mCurrentBuilder.setContentText(mCurrentText); if (ongoingEvent) { mCurrentBuilder.setOngoing(true); } else { mCurrentBuilder.setOngoing(false); mCurrentBuilder.setAutoCancel(true); } mNotificationManager.notify(NOTIFICATION_ID, mCurrentBuilder.build()); } }
Example #10
Source File: SampleDownloaderActivity.java From play-apk-expansion with Apache License 2.0 | 4 votes |
/** * The download state should trigger changes in the UI --- it may be useful * to show the state as being indeterminate at times. This sample can be * considered a guideline. */ @Override public void onDownloadStateChanged(int newState) { setState(newState); boolean showDashboard = true; boolean showCellMessage = false; boolean paused; boolean indeterminate; switch (newState) { case IDownloaderClient.STATE_IDLE: // STATE_IDLE means the service is listening, so it's // safe to start making calls via mRemoteService. paused = false; indeterminate = true; break; case IDownloaderClient.STATE_CONNECTING: case IDownloaderClient.STATE_FETCHING_URL: showDashboard = true; paused = false; indeterminate = true; break; case IDownloaderClient.STATE_DOWNLOADING: paused = false; showDashboard = true; indeterminate = false; break; case IDownloaderClient.STATE_FAILED_CANCELED: case IDownloaderClient.STATE_FAILED: case IDownloaderClient.STATE_FAILED_FETCHING_URL: case IDownloaderClient.STATE_FAILED_UNLICENSED: paused = true; showDashboard = false; indeterminate = false; break; case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION: case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION: showDashboard = false; paused = true; indeterminate = false; showCellMessage = true; break; case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED: case IDownloaderClient.STATE_PAUSED_NEED_WIFI: showDashboard = false; paused = true; indeterminate = false; showCellMessage = true; break; case IDownloaderClient.STATE_PAUSED_BY_REQUEST: paused = true; indeterminate = false; break; case IDownloaderClient.STATE_PAUSED_ROAMING: case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE: paused = true; indeterminate = false; break; case IDownloaderClient.STATE_COMPLETED: showDashboard = false; paused = false; indeterminate = false; validateXAPKZipFiles(); return; default: paused = true; indeterminate = true; showDashboard = true; } int newDashboardVisibility = showDashboard ? View.VISIBLE : View.GONE; if (mDashboard.getVisibility() != newDashboardVisibility) { mDashboard.setVisibility(newDashboardVisibility); } int cellMessageVisibility = showCellMessage ? View.VISIBLE : View.GONE; if (mCellMessage.getVisibility() != cellMessageVisibility) { mCellMessage.setVisibility(cellMessageVisibility); } mPB.setIndeterminate(indeterminate); setButtonPausedState(paused); }
Example #11
Source File: DownloadNotification.java From travelguide with Apache License 2.0 | 4 votes |
@Override public void onDownloadStateChanged(int newState) { if (null != mClientProxy) { mClientProxy.onDownloadStateChanged(newState); } if (newState != mState) { mState = newState; if (newState == IDownloaderClient.STATE_IDLE || null == mContentIntent) { return; } int stringDownloadID; int iconResource; boolean ongoingEvent; // get the new title string and paused text switch (newState) { case 0: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = R.string.state_unknown; ongoingEvent = false; break; case IDownloaderClient.STATE_DOWNLOADING: iconResource = android.R.drawable.stat_sys_download; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_FETCHING_URL: case IDownloaderClient.STATE_CONNECTING: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_COMPLETED: case IDownloaderClient.STATE_PAUSED_BY_REQUEST: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; case IDownloaderClient.STATE_FAILED: case IDownloaderClient.STATE_FAILED_CANCELED: case IDownloaderClient.STATE_FAILED_FETCHING_URL: case IDownloaderClient.STATE_FAILED_SDCARD_FULL: case IDownloaderClient.STATE_FAILED_UNLICENSED: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; default: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; } mCurrentText = mContext.getString(stringDownloadID); mCurrentTitle = mLabel.toString(); mCurrentNotification.tickerText = mLabel + ": " + mCurrentText; mCurrentNotification.icon = iconResource; mCurrentNotification.setLatestEventInfo(mContext, mCurrentTitle, mCurrentText, mContentIntent); if (ongoingEvent) { mCurrentNotification.flags |= Notification.FLAG_ONGOING_EVENT; } else { mCurrentNotification.flags &= ~Notification.FLAG_ONGOING_EVENT; mCurrentNotification.flags |= Notification.FLAG_AUTO_CANCEL; } mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotification); } }
Example #12
Source File: DownloadNotification.java From Alite with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public void onDownloadStateChanged(int newState) { if (null != mClientProxy) { mClientProxy.onDownloadStateChanged(newState); } if (newState != mState) { mState = newState; if (newState == IDownloaderClient.STATE_IDLE || null == mContentIntent) { return; } int stringDownloadID; int iconResource; boolean ongoingEvent; // get the new title string and paused text switch (newState) { case 0: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = R.string.state_unknown; ongoingEvent = false; break; case IDownloaderClient.STATE_DOWNLOADING: iconResource = android.R.drawable.stat_sys_download; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_FETCHING_URL: case IDownloaderClient.STATE_CONNECTING: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; case IDownloaderClient.STATE_COMPLETED: case IDownloaderClient.STATE_PAUSED_BY_REQUEST: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; case IDownloaderClient.STATE_FAILED: case IDownloaderClient.STATE_FAILED_CANCELED: case IDownloaderClient.STATE_FAILED_FETCHING_URL: case IDownloaderClient.STATE_FAILED_SDCARD_FULL: case IDownloaderClient.STATE_FAILED_UNLICENSED: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = false; break; default: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState); ongoingEvent = true; break; } mCurrentText = mContext.getString(stringDownloadID); mCurrentTitle = mLabel.toString(); mCurrentNotification.tickerText = mLabel + ": " + mCurrentText; mCurrentNotification.icon = iconResource; mCurrentNotification.setLatestEventInfo(mContext, mCurrentTitle, mCurrentText, mContentIntent); if (ongoingEvent) { mCurrentNotification.flags |= Notification.FLAG_ONGOING_EVENT; } else { mCurrentNotification.flags &= ~Notification.FLAG_ONGOING_EVENT; mCurrentNotification.flags |= Notification.FLAG_AUTO_CANCEL; } mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotification); } }
Example #13
Source File: DownloadNotification.java From UnityOBBDownloader with Apache License 2.0 | 4 votes |
@Override public void onDownloadStateChanged(int newState) { if (null != mClientProxy) { mClientProxy.onDownloadStateChanged(newState); } if (newState != mState) { mState = newState; if (newState == IDownloaderClient.STATE_IDLE || null == mContentIntent) { return; } int stringDownloadID; int iconResource; boolean ongoingEvent; // get the new title string and paused text switch (newState) { case 0: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getStringResource(mContext, "state_unknown"); ongoingEvent = false; break; case IDownloaderClient.STATE_DOWNLOADING: iconResource = android.R.drawable.stat_sys_download; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(mContext, newState); ongoingEvent = true; break; case IDownloaderClient.STATE_FETCHING_URL: case IDownloaderClient.STATE_CONNECTING: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(mContext, newState); ongoingEvent = true; break; case IDownloaderClient.STATE_COMPLETED: case IDownloaderClient.STATE_PAUSED_BY_REQUEST: iconResource = android.R.drawable.stat_sys_download_done; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(mContext, newState); ongoingEvent = false; break; case IDownloaderClient.STATE_FAILED: case IDownloaderClient.STATE_FAILED_CANCELED: case IDownloaderClient.STATE_FAILED_FETCHING_URL: case IDownloaderClient.STATE_FAILED_SDCARD_FULL: case IDownloaderClient.STATE_FAILED_UNLICENSED: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(mContext, newState); ongoingEvent = false; break; default: iconResource = android.R.drawable.stat_sys_warning; stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(mContext, newState); ongoingEvent = true; break; } mCurrentText = mContext.getString(stringDownloadID); mCurrentTitle = mLabel; mCurrentBuilder.setTicker(mLabel + ": " + mCurrentText) .setSmallIcon(iconResource) .setContentTitle(mCurrentTitle) .setContentText(mCurrentText); if (ongoingEvent) { mCurrentBuilder.setOngoing(true); } else { mCurrentBuilder.setOngoing(false); mCurrentBuilder.setAutoCancel(true); } Notification notification; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notification = mCurrentBuilder.build(); } else { notification = mCurrentBuilder.getNotification(); } mNotificationManager.notify(NOTIFICATION_ID, notification); } }