Android Open Source - FAST Loading Dialog






From Project

Back to project page FAST.

License

The source code is released under:

GNU General Public License

If you think the Android project FAST listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.ligi.fast.ui;
//  ww  w . j  av a  2s  . co m
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import org.ligi.axt.helpers.ActivityHelper;
import org.ligi.fast.R;
import org.ligi.fast.background.BaseAppGatherAsyncTask;
import org.ligi.fast.model.AppInfo;
import org.ligi.fast.util.AppInfoListStore;

/**
 * Dialog to make the waiting time for the initial index building nicer for the user
 * inform him which app we are processing and how far we are progressed with that
 */
public class LoadingDialog extends Activity {

    private ImageView iconImageView; // we will show the icon of the act app which is processed - makes the time appear shorter
    private TextView labelTextView;
    private ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_dialog);
        iconImageView = (ImageView) findViewById(R.id.imageView);
        labelTextView = (TextView) findViewById(R.id.textView);
        progressBar = (ProgressBar) findViewById(R.id.progress);
        setTitle(getString(R.string.loadingDialogTitle));

        new BaseAppGatherAsyncTask(this) {

            private int actAppIndex = 0;

            @Override
            protected void onProgressUpdate(AppInfo... values) {
                super.onProgressUpdate(values);

                actAppIndex++;
                getProgressBar().setMax(appCount);
                getProgressBar().setProgress(actAppIndex);

                setIcon(values[0].getIcon());
                setText(values[0].getLabel());

            }

            @Override
            protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                new AppInfoListStore(LoadingDialog.this).save(appInfoList);
                setResult(RESULT_OK);
                finish();
            }

        }.execute();

        setWindowWidth();
        new ActivityHelper(this).disableRotation();
    }

    @SuppressWarnings("deprecation")
    // we cannot use the new getSize function - or we would get a NoSuchMethod error on newer devices
    private void setWindowWidth() {
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = 3 * getWindowManager().getDefaultDisplay().getWidth() / 4;
        getWindow().setAttributes(params);
    }

    public void setIcon(Drawable icon) {
        iconImageView.setImageDrawable(icon);
    }

    public void setText(String text) {
        labelTextView.setText(text);
    }

    public ProgressBar getProgressBar() {
        return progressBar;
    }

    @Override
    public void onBackPressed() {
        // do nothing - user should not be able to cancel this dialog
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
            // do nothing - user should not be able to cancel this dialog
            return true;
        }
        return false;
    }
}




Java Source Code List

org.ligi.axt.helpers.ActivityHelper.java
org.ligi.axt.helpers.ContextHelper.java
org.ligi.axt.helpers.FileHelper.java
org.ligi.axt.helpers.ResolveInfoHelper.java
org.ligi.axt.helpers.ViewHelper.java
org.ligi.axt.simplifications.SimpleTextWatcher.java
org.ligi.fast.App.java
org.ligi.fast.TargetStore.java
org.ligi.fast.TargetStore.java
org.ligi.fast.TargetStore.java
org.ligi.fast.background.AppInstallOrRemoveReceiver.java
org.ligi.fast.background.BackgroundGatherAsyncTask.java
org.ligi.fast.background.BaseAppGatherAsyncTask.java
org.ligi.fast.model.AppIconCache.java
org.ligi.fast.model.AppInfoList.java
org.ligi.fast.model.AppInfoSortByLabelComparator.java
org.ligi.fast.model.AppInfoSortByMostUsedComparator.java
org.ligi.fast.model.AppInfo.java
org.ligi.fast.model.DynamicAppInfoList.java
org.ligi.fast.settings.AndroidFASTSettings.java
org.ligi.fast.settings.FASTSettings.java
org.ligi.fast.testing.AppInfoTestBase.java
org.ligi.fast.testing.MutableFastSettings.java
org.ligi.fast.testing.TheAppIconCache.java
org.ligi.fast.testing.TheAppInfoStore.java
org.ligi.fast.testing.TheAppInfo.java
org.ligi.fast.testing.TheSearchActivity.java
org.ligi.fast.ui.AppActionDialogBuilder.java
org.ligi.fast.ui.AppInfoAdapter.java
org.ligi.fast.ui.FASTSettingsActivity.java
org.ligi.fast.ui.HelpDialog.java
org.ligi.fast.ui.HelpDialog.java
org.ligi.fast.ui.IconDimensions.java
org.ligi.fast.ui.LoadingDialog.java
org.ligi.fast.ui.SearchActivity.java
org.ligi.fast.util.AppInfoListStore.java
org.ligi.fast.util.PackageListSerializer.java
org.ligi.fast.util.StringUtils.java
org.ligi.fast.util.UmlautConverter.java