Java Code Examples for com.google.android.play.core.install.model.InstallStatus#DOWNLOADING

The following examples show how to use com.google.android.play.core.install.model.InstallStatus#DOWNLOADING . 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: UpdateManager.java    From InAppUpdater with MIT License 6 votes vote down vote up
@Override
public void onStateUpdate(InstallState installState) {
    if (installState.installStatus() == InstallStatus.DOWNLOADING) {
        long bytesDownloaded = installState.bytesDownloaded();
        long totalBytesToDownload = installState.totalBytesToDownload();
        if (flexibleUpdateDownloadListener != null) {
            flexibleUpdateDownloadListener.onDownloadProgress(bytesDownloaded, totalBytesToDownload);
        }
    }
    if (installState.installStatus() == InstallStatus.DOWNLOADED) {
        // After the update is downloaded, show a notification
        // and request user confirmation to restart the app.
        Log.d(TAG, "An update has been downloaded");
        popupSnackbarForCompleteUpdate();
    }
}
 
Example 2
Source File: CommcareFlexibleAppUpdateManager.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
/**
 * Gets {@link AppUpdateState} using {@link #mUpdateAvailability} and {@link #mInstallStatus}
 */
private AppUpdateState getAppUpdateState() {
    AppUpdateState state = AppUpdateState.UNAVAILABLE;
    switch (mInstallStatus) {
        case InstallStatus.PENDING:
        case InstallStatus.DOWNLOADING:
            state = AppUpdateState.DOWNLOADING;
            break;
        case InstallStatus.DOWNLOADED:
            state = AppUpdateState.DOWNLOADED;
            break;
        case InstallStatus.FAILED:
            state = AppUpdateState.FAILED;
            break;
    }
    if (state == AppUpdateState.UNAVAILABLE && mUpdateAvailability == UpdateAvailability.UPDATE_AVAILABLE) {
        state = AppUpdateState.AVAILABLE;
    }
    return state;
}
 
Example 3
Source File: CommcareFlexibleAppUpdateManager.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Integer getProgress() {
    if (mInstallStatus != InstallStatus.DOWNLOADING) {
        return null;
    }
    return percentageDownloaded;
}
 
Example 4
Source File: CommcareFlexibleAppUpdateManager.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateUpdate(InstallState state) {
    Logger.log(TAG, "Install state updated with install status: " + state.installStatus()
            + ", and error code: " + state.installErrorCode());
    mInstallErrorCode = state.installErrorCode();
    if (state.installStatus() == InstallStatus.DOWNLOADING) {
        // TODO: Should be keep on publishing status for showing download percentage.
        // From https://stackoverflow.com/a/10415638/6671572
        percentageDownloaded = (int) (state.bytesDownloaded() * 100.0 / state.totalBytesToDownload() + 0.5) ;
    }
    if (mInstallStatus != state.installStatus()) {
        mInstallStatus = state.installStatus();
        publishStatus();
    }
}
 
Example 5
Source File: InAppUpdateStatus.java    From android-inapp-update with Apache License 2.0 4 votes vote down vote up
public boolean isDownloading() {
    if (installState != null)
        return installState.installStatus() == InstallStatus.DOWNLOADING;

    return false;
}