Example usage for android.app ProgressDialog STYLE_HORIZONTAL

List of usage examples for android.app ProgressDialog STYLE_HORIZONTAL

Introduction

In this page you can find the example usage for android.app ProgressDialog STYLE_HORIZONTAL.

Prototype

int STYLE_HORIZONTAL

To view the source code for android.app ProgressDialog STYLE_HORIZONTAL.

Click Source Link

Document

Creates a ProgressDialog with a horizontal progress bar.

Usage

From source file:com.zoffcc.applications.zanavi.Navit.java

@TargetApi(Build.VERSION_CODES.FROYO)
protected Dialog onCreateDialog(int id) {

    System.out.println("onCreateDialog id=" + id);

    switch (id) {
    // ==============---------- real search offline (old style) here ----------==============
    // ==============---------- real search offline (old style) here ----------==============
    // ==============---------- real search offline (old style) here ----------==============
    case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
        search_results_wait_offline = new ProgressDialog(this);
        search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        search_results_wait_offline.setTitle("--");
        search_results_wait_offline.setMessage("--");
        search_results_wait_offline.setCancelable(true); // allow to stop search
        search_results_wait_offline.setProgress(0);
        search_results_wait_offline.setMax(10);

        search_results_wait_offline.setOnCancelListener(new OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                Message msg = new Message();
                Bundle b = new Bundle();
                b.putInt("Callback", 46);
                msg.setData(b);// w  ww . j a va2 s. c  o  m
                try {
                    NavitGraphics.callback_handler.sendMessage(msg);
                } catch (Exception e) {
                }
                Log.e("Navit", "onCancel: search_results_wait offline");
            }
        });

        /*
         * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
         * {
         * public void onClick(DialogInterface dialog, int which)
         * {
         * // Use either finish() or return() to either close the activity or just the dialog
         * return;
         * }
         * });
         */

        DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: search_results_wait offline");
                dialog.dismiss();
                dialog.cancel();
                searchresultsThread_offline.stop_me();
            }
        };
        search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
        System.out.println("new SearchResultsThread 001");
        searchresultsThread_offline = new SearchResultsThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
        searchresultsThread_offline.start();

        NavitAddressSearchSpinnerActive = true;
        spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
        spinner_thread_offline.start();

        return search_results_wait_offline;
    case Navit.SEARCHRESULTS_WAIT_DIALOG:
        search_results_wait = new ProgressDialog(this);
        search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        search_results_wait.setTitle("--");
        search_results_wait.setMessage("--");
        search_results_wait.setCancelable(false);
        search_results_wait.setProgress(0);
        search_results_wait.setMax(10);

        DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: search_results_wait");
                dialog.dismiss();
                dialog.cancel();
                searchresultsThread.stop_me();
            }
        };
        search_results_wait.setOnDismissListener(mOnDismissListener3);
        System.out.println("new SearchResultsThread 002");
        searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
        searchresultsThread.start();

        NavitAddressSearchSpinnerActive = true;
        spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG);
        spinner_thread.start();

        return search_results_wait;
    case Navit.MAPDOWNLOAD_PRI_DIALOG:
        mapdownloader_dialog_pri = new ProgressDialog(this);
        mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mapdownloader_dialog_pri.setTitle("--");
        mapdownloader_dialog_pri.setMessage("--");
        mapdownloader_dialog_pri.setCancelable(false);
        mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
        mapdownloader_dialog_pri.setProgress(0);
        mapdownloader_dialog_pri.setMax(200);

        WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
        dialog_lparams.screenBrightness = 0.1f;
        mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);

        DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow()
                        .getAttributes();
                mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
                mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
                mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
                dialog.dismiss();
                dialog.cancel();
                progressThread_pri.stop_thread();
            }
        };

        try {
            mapdownloader_dialog_pri.setButton(AlertDialog.BUTTON_NEGATIVE, Navit.get_text("Cancel"),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mapdownloader_dialog_pri.dismiss();
                        }
                    });
        } catch (Exception e) {
            e.printStackTrace();
        }

        mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
        mapdownloader_pri = new NavitMapDownloader(this);
        progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler,
                NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
        progressThread_pri.start();
        //
        // show license for OSM maps
        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT)
                .show(); //TRANS
        return mapdownloader_dialog_pri;
    case Navit.MAPDOWNLOAD_SEC_DIALOG:
        mapdownloader_dialog_sec = new ProgressDialog(this);
        mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mapdownloader_dialog_sec.setTitle("--");
        mapdownloader_dialog_sec.setMessage("--");

        mapdownloader_dialog_sec.setCancelable(true);
        mapdownloader_dialog_sec.setProgress(0);
        mapdownloader_dialog_sec.setMax(200);
        DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
                dialog.dismiss();
                dialog.cancel();
                progressThread_sec.stop_thread();
            }
        };
        mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
        mapdownloader_sec = new NavitMapDownloader(this);
        progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler,
                NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
        progressThread_sec.start();
        //
        // show license for OSM maps
        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT)
                .show(); //TRANS
        return mapdownloader_dialog_sec;
    }
    // should never get here!!
    return null;
}