Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f35a631f authored by Fujia Mi's avatar Fujia Mi Committed by Gerrit Code Review
Browse files

CMFileManager: Show loading dialog while loading files

The loading file task costs much time if the folder contains a
lot of files. This causes the illusion of a freeze if the user
presses the back key during this time.

Show a progress dialog while loading and do not allow the
user to press the back key.

CRs-Fixed: 949902
Change-Id: I527d70a55425d20bc50621533fba775bf5d0ead5
parent e339f3e7
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -29,22 +29,6 @@
    android:src="@drawable/ic_material_light_fs_warning"
    android:visibility="invisible" />

  <ProgressBar
    android:id="@+id/breadcrumb_loading"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignBottom="@id/ab_filesystem_info"
    android:layout_alignStart="@id/ab_filesystem_info"
    android:layout_alignEnd="@id/ab_filesystem_info"
    android:layout_alignTop="@id/ab_filesystem_info"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_margin="@dimen/default_margin"
    android:indeterminate="true"
    android:indeterminateBehavior="repeat"
    android:indeterminateOnly="true"
    android:visibility="invisible" />

  <HorizontalScrollView
    android:id="@+id/breadcrumb_scrollview"
    android:layout_width="match_parent"
+9 −7
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.cyanogenmod.filemanager.ui.widgets;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
@@ -61,10 +62,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
     * @hide
     */
    ProgressBar mDiskUsageInfo;
    /**
     * @hide
     */
    View mLoading;

    protected FilesystemAsyncTask mFilesystemAsyncTask;

    protected int mFreeDiskSpaceWarningLevel = 95;
@@ -73,6 +71,8 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic

    protected String mCurrentPath;

    private ProgressDialog mLoadingDialog;

    /**
     * Constructor of <code>BreadcrumbView</code>.
     *
@@ -126,7 +126,9 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
        this.mBreadcrumbBar = (ViewGroup)findViewById(R.id.breadcrumb);
        this.mFilesystemInfo = (ImageView)findViewById(R.id.ab_filesystem_info);
        this.mDiskUsageInfo = (ProgressBar)findViewById(R.id.breadcrumb_diskusage);
        this.mLoading = findViewById(R.id.breadcrumb_loading);
        this.mLoadingDialog = new ProgressDialog(getContext());
        this.mLoadingDialog.setMessage(getContext().getText(R.string.loading_message));
        this.mLoadingDialog.setCancelable(false);

        // Change the image of filesystem (this is not called after a changeBreadcrumbPath call,
        // so if need to be theme previously to protect from errors)
@@ -170,7 +172,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
            public void run() {
                BreadcrumbView.this.mFilesystemInfo.setVisibility(View.INVISIBLE);
                BreadcrumbView.this.mDiskUsageInfo.setVisibility(View.INVISIBLE);
                BreadcrumbView.this.mLoading.setVisibility(View.VISIBLE);
                BreadcrumbView.this.mLoadingDialog.show();
            }
        });
    }
@@ -184,7 +186,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
        this.post(new Runnable() {
            @Override
            public void run() {
                BreadcrumbView.this.mLoading.setVisibility(View.INVISIBLE);
                BreadcrumbView.this.mLoadingDialog.dismiss();
                BreadcrumbView.this.mFilesystemInfo.setVisibility(View.VISIBLE);
                BreadcrumbView.this.mDiskUsageInfo.setVisibility(View.VISIBLE);
            }