Search in sources :

Example 1 with DownloadEvents

use of net.osmand.plus.download.DownloadIndexesThread.DownloadEvents in project Osmand by osmandapp.

the class DownloadActivity method newDownloadIndexes.

@Override
@UiThread
public void newDownloadIndexes() {
    visibleBanner.updateBannerInProgress();
    for (WeakReference<Fragment> ref : fragSet) {
        Fragment f = ref.get();
        if (f instanceof DownloadEvents && f.isAdded()) {
            ((DownloadEvents) f).newDownloadIndexes();
        }
    }
    downloadHasFinished();
}
Also used : DownloadEvents(net.osmand.plus.download.DownloadIndexesThread.DownloadEvents) DialogFragment(android.support.v4.app.DialogFragment) FreeVersionDialogFragment(net.osmand.plus.download.ui.FreeVersionDialogFragment) ActiveDownloadsDialogFragment(net.osmand.plus.download.ui.ActiveDownloadsDialogFragment) Fragment(android.support.v4.app.Fragment) BottomSheetDialogFragment(net.osmand.plus.base.BottomSheetDialogFragment) UpdatesIndexFragment(net.osmand.plus.download.ui.UpdatesIndexFragment) DownloadResourceGroupFragment(net.osmand.plus.download.ui.DownloadResourceGroupFragment) LocalIndexesFragment(net.osmand.plus.download.ui.LocalIndexesFragment) UiThread(android.support.annotation.UiThread)

Example 2 with DownloadEvents

use of net.osmand.plus.download.DownloadIndexesThread.DownloadEvents in project Osmand by osmandapp.

the class DownloadActivity method downloadInProgress.

@Override
@UiThread
public void downloadInProgress() {
    if (accessibilityAssistant.isUiUpdateDiscouraged())
        return;
    accessibilityAssistant.lockEvents();
    visibleBanner.updateBannerInProgress();
    showDownloadWorldMapIfNeeded();
    for (WeakReference<Fragment> ref : fragSet) {
        Fragment f = ref.get();
        if (f instanceof DownloadEvents && f.isAdded()) {
            ((DownloadEvents) f).downloadInProgress();
        }
    }
    accessibilityAssistant.unlockEvents();
}
Also used : DownloadEvents(net.osmand.plus.download.DownloadIndexesThread.DownloadEvents) DialogFragment(android.support.v4.app.DialogFragment) FreeVersionDialogFragment(net.osmand.plus.download.ui.FreeVersionDialogFragment) ActiveDownloadsDialogFragment(net.osmand.plus.download.ui.ActiveDownloadsDialogFragment) Fragment(android.support.v4.app.Fragment) BottomSheetDialogFragment(net.osmand.plus.base.BottomSheetDialogFragment) UpdatesIndexFragment(net.osmand.plus.download.ui.UpdatesIndexFragment) DownloadResourceGroupFragment(net.osmand.plus.download.ui.DownloadResourceGroupFragment) LocalIndexesFragment(net.osmand.plus.download.ui.LocalIndexesFragment) UiThread(android.support.annotation.UiThread)

Example 3 with DownloadEvents

use of net.osmand.plus.download.DownloadIndexesThread.DownloadEvents in project Osmand by osmandapp.

the class DownloadActivity method downloadHasFinished.

@Override
@UiThread
public void downloadHasFinished() {
    visibleBanner.updateBannerInProgress();
    if (downloadItem != null && downloadItem != getMyApplication().getRegions().getWorldRegion() && !WorldRegion.WORLD_BASEMAP.equals(downloadItem.getRegionDownloadNameLC())) {
        if (!Algorithms.isEmpty(downloadTargetFileName)) {
            File f = new File(downloadTargetFileName);
            if (f.exists() && f.lastModified() > System.currentTimeMillis() - 10000) {
                getMyApplication().getDownloadThread().initSettingsFirstMap(downloadItem);
                showGoToMap(downloadItem);
            }
        }
        downloadItem = null;
        downloadTargetFileName = null;
    }
    if (!Algorithms.isEmpty(downloadTargetFileName)) {
        File f = new File(downloadTargetFileName);
        if (f.exists()) {
            String fileName = f.getName();
            if (fileName.endsWith(IndexConstants.FONT_INDEX_EXT)) {
                AlertDialog.Builder bld = new AlertDialog.Builder(this);
                bld.setMessage(R.string.restart_is_required);
                bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        android.os.Process.killProcess(android.os.Process.myPid());
                    }
                });
                bld.setNegativeButton(R.string.shared_string_cancel, null);
                bld.show();
            } else if (fileName.startsWith(FileNameTranslationHelper.SEA_DEPTH)) {
                getMyApplication().getSettings().getCustomRenderBooleanProperty("depthContours").set(true);
            }
        }
        downloadItem = null;
        downloadTargetFileName = null;
    }
    for (WeakReference<Fragment> ref : fragSet) {
        Fragment f = ref.get();
        if (f instanceof DownloadEvents && f.isAdded()) {
            ((DownloadEvents) f).downloadHasFinished();
        }
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) DownloadEvents(net.osmand.plus.download.DownloadIndexesThread.DownloadEvents) File(java.io.File) DialogFragment(android.support.v4.app.DialogFragment) FreeVersionDialogFragment(net.osmand.plus.download.ui.FreeVersionDialogFragment) ActiveDownloadsDialogFragment(net.osmand.plus.download.ui.ActiveDownloadsDialogFragment) Fragment(android.support.v4.app.Fragment) BottomSheetDialogFragment(net.osmand.plus.base.BottomSheetDialogFragment) UpdatesIndexFragment(net.osmand.plus.download.ui.UpdatesIndexFragment) DownloadResourceGroupFragment(net.osmand.plus.download.ui.DownloadResourceGroupFragment) LocalIndexesFragment(net.osmand.plus.download.ui.LocalIndexesFragment) UiThread(android.support.annotation.UiThread)

Aggregations

UiThread (android.support.annotation.UiThread)3 DialogFragment (android.support.v4.app.DialogFragment)3 Fragment (android.support.v4.app.Fragment)3 BottomSheetDialogFragment (net.osmand.plus.base.BottomSheetDialogFragment)3 DownloadEvents (net.osmand.plus.download.DownloadIndexesThread.DownloadEvents)3 ActiveDownloadsDialogFragment (net.osmand.plus.download.ui.ActiveDownloadsDialogFragment)3 DownloadResourceGroupFragment (net.osmand.plus.download.ui.DownloadResourceGroupFragment)3 FreeVersionDialogFragment (net.osmand.plus.download.ui.FreeVersionDialogFragment)3 LocalIndexesFragment (net.osmand.plus.download.ui.LocalIndexesFragment)3 UpdatesIndexFragment (net.osmand.plus.download.ui.UpdatesIndexFragment)3 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 File (java.io.File)1