Search in sources :

Example 1 with DownloadManagerUi

use of org.chromium.chrome.browser.download.ui.DownloadManagerUi in project AndroidChromium by JackyAndroid.

the class DownloadActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    boolean isOffTheRecord = DownloadUtils.shouldShowOffTheRecordDownloads(getIntent());
    ComponentName parentComponent = IntentUtils.safeGetParcelableExtra(getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
    mDownloadManagerUi = new DownloadManagerUi(this, isOffTheRecord, parentComponent);
    setContentView(mDownloadManagerUi.getView());
    mIsOffTheRecord = isOffTheRecord;
    mDownloadManagerUi.addObserver(mUiObserver);
    // Call updateForUrl() to align with how DownloadPage interacts with DownloadManagerUi.
    mDownloadManagerUi.updateForUrl(UrlConstants.DOWNLOADS_URL);
}
Also used : ComponentName(android.content.ComponentName) DownloadManagerUi(org.chromium.chrome.browser.download.ui.DownloadManagerUi)

Example 2 with DownloadManagerUi

use of org.chromium.chrome.browser.download.ui.DownloadManagerUi in project AndroidChromium by JackyAndroid.

the class DownloadPage method initialize.

@Override
protected void initialize(Activity activity, final Tab tab) {
    ThreadUtils.assertOnUiThread();
    mManager = new DownloadManagerUi(activity, tab.isIncognito(), activity.getComponentName());
    mManager.setBasicNativePage(this);
    mTitle = activity.getString(R.string.download_manager_ui_all_downloads);
    // #destroy() unregisters the ActivityStateListener to avoid checking for externally removed
    // downloads after the downloads page is closed. This requires each DownloadPage to have its
    // own ActivityStateListener. If multiple tabs are showing the downloads page, multiple
    // requests to check for externally removed downloads will be issued when the activity is
    // resumed.
    mActivityStateListener = new ActivityStateListener() {

        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.RESUMED) {
                DownloadUtils.checkForExternallyRemovedDownloads(mManager.getBackendProvider(), tab.isIncognito());
            }
        }
    };
    ApplicationStatus.registerStateListenerForActivity(mActivityStateListener, activity);
}
Also used : ActivityStateListener(org.chromium.base.ApplicationStatus.ActivityStateListener) Activity(android.app.Activity) DownloadManagerUi(org.chromium.chrome.browser.download.ui.DownloadManagerUi)

Aggregations

DownloadManagerUi (org.chromium.chrome.browser.download.ui.DownloadManagerUi)2 Activity (android.app.Activity)1 ComponentName (android.content.ComponentName)1 ActivityStateListener (org.chromium.base.ApplicationStatus.ActivityStateListener)1