Example usage for android.app ProgressDialog ProgressDialog

List of usage examples for android.app ProgressDialog ProgressDialog

Introduction

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

Prototype

public ProgressDialog(Context context) 

Source Link

Document

Creates a Progress dialog.

Usage

From source file:com.odoo.addons.sale.models.SaleOrder.java

public void confirmSale(final ODataRow quotation, final OnOperationSuccessListener listener) {
    new AsyncTask<Void, Void, Void>() {
        private ProgressDialog dialog;

        @Override// w  w w  .  ja va2 s .  com
        protected void onPreExecute() {
            super.onPreExecute();
            dialog = new ProgressDialog(mContext);
            dialog.setTitle(R.string.title_please_wait);
            dialog.setMessage(OResource.string(mContext, R.string.title_working));
            dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        protected Void doInBackground(Void... params) {
            try {
                OArguments args = new OArguments();
                args.add(new JSONArray().put(quotation.getInt("id")));
                args.add(new JSONObject());
                getServerDataHelper().callMethod("action_button_confirm", args);
                OValues values = new OValues();
                values.put("state", "manual");
                values.put("state_title", getStateTitle(values));
                values.put("_is_dirty", "false");
                update(quotation.getInt(OColumn.ROW_ID), values);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            dialog.dismiss();
            if (listener != null) {
                listener.OnSuccess();
            }
        }

        @Override
        protected void onCancelled() {
            super.onCancelled();
            dialog.dismiss();
            if (listener != null) {
                listener.OnCancelled();
            }
        }
    }.execute();
}

From source file:gov.sfmta.sfpark.AnnotationsOverlay.java

public void loadOverlaysProgress(boolean showprice) {

    myShowPrice = showprice;//from  w w  w. j  a  v  a  2s .  c  o  m
    mOverlays.clear();

    Log.v(TAG, "Drawing annotations");

    pd = new ProgressDialog(mContext);
    pd.setCancelable(false);
    pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    pd.setMessage("Calculating availability");
    pd.setProgress(0);
    pd.setMax(MainScreenActivity.annotations.size());
    pd.show();

    ld = new LoadOverlaysTask();
    ld.execute("String");
}

From source file:fi.mikuz.boarder.gui.DropboxMenu.java

public void initializeTransfer(final ArrayList<String> boards, final boolean cleanUnusedFiles) {

    mWaitDialog = new ProgressDialog(this);
    mWaitDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mWaitDialog.setMessage("Please wait");
    mWaitDialog.show();//from ww  w.ja  v a2 s  .c  o  m

    t = new Thread() {
        public void run() {
            Looper.prepare();

            DropboxAPI.Account account = null;
            try {
                account = mApi.accountInfo();
            } catch (DropboxException e) {
                Log.e(TAG, "Account info missing", e);
            }

            if (account != null) {

                if (mOperation == UPLOAD_OPERATION) {
                    upload(boards, cleanUnusedFiles);
                } else if (mOperation == DOWNLOAD_OPERATION) {
                    download(boards, cleanUnusedFiles);
                }
            } else {
                mWaitDialog.dismiss();
            }
        }
    };
    t.start();
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {//  w  w w  .j a  v  a2s.c  o m
        Tabs1.db.showfulldblog(Tabs1.db.TABLE_MCR_METERINGLIST);
    } catch (Throwable e) {

    }
    ctx = this;

    try {
        if (Tabs1.foldername.contains("_")) {
            tempfoldername = Tabs1.foldername.substring(0, Tabs1.foldername.indexOf("_"));
        } else {
            tempfoldername = Tabs1.foldername;
        }

        Log.d("foldername", tempfoldername);

        dbtablename = "floorplan";
        if (Tabs1.db.checktableindb(dbtablename)) {
            //
        } else {
            try {
                Tabs1.db.createfloorplandb(dbtablename);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }

        try {
            MULTILEVEL = ReadBoolean(this, "multilevel", false);
        } catch (Throwable e) {
            System.out.println("couldn't read multilevel value from preferences on start");
            MULTILEVEL = false;
        }

        try {
            NGBICONS = ReadBoolean(this, "ngbicons", false);
        } catch (Throwable e) {
            System.out.println("couldn't read autorenumber temp sensors value from preferences on start");
            NGBICONS = true;
        }

        try {
            DRAWSAMREFERENCE = ReadBoolean(this, "drawsamreferencetable", true);
        } catch (Throwable e) {

        }
        try {
            RAPIDPLACEMENT = ReadBoolean(this, "rapidplacement", false);
        } catch (Throwable e) {

        }

        // Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        // Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        Intent intent = getIntent();

        FloorPlanActivity.floorplannumber = intent.getExtras().getInt("floorplannumber");
        try {
            FloorPlanActivity.floorplancount = Tabs1.FloorPlanCount;
        } catch (Throwable e) {
            FloorPlanActivity.floorplancount = new File(Tabs1.inputfloorplandirectory).list().length;
        }
        MODE = MODE_DONOTHING;

        progressDialog = new ProgressDialog(this);
        progressDialog.setIndeterminate(true);
        if (tempfoldername.equals("Paul")) {
            progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.paul_animation));

        } else if (tempfoldername.equals("Will")) {
            progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.will_animation));

        } else if (tempfoldername.equals("Bill")) {
            progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.bill_animation));
        } else {
            progressDialog.setIndeterminateDrawable(
                    getResources().getDrawable(R.anim.progress_dialog_icon_drawable_animation));

        }

        progressDialog.setIcon(R.drawable.ic_launcher);
        progressDialog.setTitle("Loading");
        progressDialog.setMessage("Please Wait");
        progressDialog.setCancelable(false);

        rl = new RelativeLayout(this);
        RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
        rl.setLayoutParams(rllp);

        toolbar = new View(this);
        LayoutInflater inflater = (LayoutInflater) getBaseContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        toolbar = inflater.inflate(R.layout.toolbar, null);

        toptoolbar = (View) toolbar.findViewById(R.id.toptoolbar);
        righttoolbar = (View) toolbar.findViewById(R.id.righttoolbar);
        righttoolbarbuttonparent = (View) toolbar.findViewById(R.id.righttoolbarbuttonparent);

        righttoolbarscrollview = (ScrollView) toolbar.findViewById(R.id.righttoolbarscrollview);

        floorplanprevious = (ImageView) toolbar.findViewById(R.id.floorplanprevious);
        floorplannext = (ImageView) toolbar.findViewById(R.id.floorplannext);
        fullscreen = (ImageView) toolbar.findViewById(R.id.fullscreen);
        unfullscreen = (ImageView) toolbar.findViewById(R.id.unfullscreen);
        showlayers = (ImageView) toolbar.findViewById(R.id.layers);
        resizeicons = (ImageView) toolbar.findViewById(R.id.resizeicons);
        metersperpixelbutton = (ImageView) toolbar.findViewById(R.id.metersperpixelbutton);

        resizeiconsseekbar = (SeekBar) toolbar.findViewById(R.id.resizeiconsseekbar);
        resizeiconsseekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                // TODO Auto-generated method stub
                view.invalidate();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }
        });

        resizeiconscancel = (Button) toolbar.findViewById(R.id.resizeiconscancel);
        resizeiconsfinished = (Button) toolbar.findViewById(R.id.resizeiconsfinished);

        preferences = (ImageView) toolbar.findViewById(R.id.preferences);

        floorplantitle = (TextView) toolbar.findViewById(R.id.floorplantitle);
        BMS = (ImageView) toolbar.findViewById(R.id.bms);
        ELC = (ImageView) toolbar.findViewById(R.id.elc);
        Gateway = (ImageView) toolbar.findViewById(R.id.gateway);
        SAM = (ImageView) toolbar.findViewById(R.id.sam);
        tempsensor = (ImageView) toolbar.findViewById(R.id.tempsensor);
        ethernetport = (ImageView) toolbar.findViewById(R.id.ethernetport);
        distributionboard = (ImageView) toolbar.findViewById(R.id.distributionboard);
        samarray = (ImageView) toolbar.findViewById(R.id.samarray);
        datahub = (ImageView) toolbar.findViewById(R.id.datahub);

        AddText = (ImageView) toolbar.findViewById(R.id.addtexttofloorplan);

        legend = (ImageView) toolbar.findViewById(R.id.legend);

        hiddenaddpicturebutton = new Button(this);
        hiddenaddpicturebutton.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {

                int tabforpicture = view.gettabofitemselected(view.itemselectednumber);
                String foldername = view.getGenericDisplayText(view.itemselectednumber);

                //   System.out.println("this is the name of the new file to be saved."+imageF.getAbsolutePath());
                //takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                //      Uri.fromFile(imageF));

                Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
                u.log("starting activity camera");

                PICTURESTARTTIME = System.currentTimeMillis();
                TABFORGETPICTURE = tabforpicture;
                FOLDERNAMEFORGETPICTURE = foldername;

                startActivityForResult(takePictureIntent, FLOORPLANGETPICFROMCAMERA);

            }
        });
        hiddeneditpicturebutton = new Button(this);
        hiddeneditpicturebutton.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {

                Intent intent = u.openpicture(editpicturelocation);
                System.out.println("this is the name of the file to be edited." + editpicturelocation);
                startActivityForResult(intent, EDITPICTUREACTIVITY);

            }
        });
        floorplantitle.setTextColor(view.presentableblue);
        floorplantitle.setText(Tabs1.floorplanname);

        floorplanprevious.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_FLOORPLANPREVIOUS;
                view.invalidate();
            }
        });
        floorplannext.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_FLOORPLANNEXT;
                view.invalidate();
            }
        });
        fullscreen.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {

                ACTION = ACTION_FULLSCREEN;
                toptoolbar.setVisibility(View.INVISIBLE);
                righttoolbar.setVisibility(View.INVISIBLE);
                unfullscreen.setVisibility(View.VISIBLE);

            }
        });

        unfullscreen.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_UNFULLSCREEN;
                toptoolbar.setVisibility(View.VISIBLE);
                righttoolbar.setVisibility(View.VISIBLE);
                unfullscreen.setVisibility(View.INVISIBLE);

            }
        });
        showlayers.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                Log.d("show layers selected", "true");
                if (!(ACTION == ACTION_SHOWLAYERS)) {
                    ACTION = ACTION_SHOWLAYERS;
                } else {
                    ACTION = ACTION_DONOTHING;
                }
                view.invalidate();

            }
        });
        metersperpixelbutton.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                //show dialog asking if you want scale from google maps, or from 2 points on map
                getscaledialog();
                //startActivity(u.intent("Getscalefromgooglemaps"));

            }
        });

        resizeicons.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                view.resizeboolean = true;
                ACTION = ACTION_RESIZEICONS;
                toptoolbar.setVisibility(View.INVISIBLE);
                righttoolbar.setVisibility(View.INVISIBLE);

                resizeiconsseekbar.setVisibility(View.VISIBLE);
                resizeiconscancel.setVisibility(View.VISIBLE);
                resizeiconsfinished.setVisibility(View.VISIBLE);

            }
        });
        resizeiconscancel.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View arg0) {
                //restore size
                //resizeiconsseekbar.setProgress((int)((float)resizeiconsseekbar.getMax()/(float)4));
                view.invalidate();
                ACTION = ACTION_DONOTHING;
                toptoolbar.setVisibility(View.VISIBLE);
                righttoolbar.setVisibility(View.VISIBLE);

                resizeiconsseekbar.setVisibility(View.INVISIBLE);
                resizeiconscancel.setVisibility(View.INVISIBLE);
                resizeiconsfinished.setVisibility(View.INVISIBLE);

            }
        });
        resizeiconsfinished.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View arg0) {
                if (ACTION == ACTION_RESIZEICON) {
                    writeonedbitem(view.itemselectednumber);
                } else {
                    rewritewholedb();
                }

                ACTION = ACTION_DONOTHING;
                toptoolbar.setVisibility(View.VISIBLE);
                righttoolbar.setVisibility(View.VISIBLE);

                resizeiconsseekbar.setVisibility(View.INVISIBLE);
                resizeiconscancel.setVisibility(View.INVISIBLE);
                resizeiconsfinished.setVisibility(View.INVISIBLE);

            }
        });

        preferences.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_PREFERENCES;
                //preferences();
                startActivityForResult(u.intent("FloorPlanPrefs"), PREFS);
            }
        });

        BMS.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_BMS;
                Log.d("mode", u.s(MODE));

            }
        });
        ELC.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_ELC;
                Log.d("mode", u.s(MODE));

            }
        });
        Gateway.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_GATEWAY;
                Log.d("mode", u.s(MODE));

            }
        });
        SAM.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                //MODE = MODE_SAM;
                //Log.d("mode", u.s(MODE));
                int itemnum = -1;
                for (int k = 0; k < view.i; k++) {
                    if (view.ITEMtype[k] == view.TYPE_ELC) {
                        itemnum = k;
                    }
                }
                if (!(itemnum == -1)) {
                    view.addsamsdialog("ELC# " + u.s(view.ELCdisplaynumber[itemnum]) + ": SAMs Menu", itemnum);
                }

            }
        });
        tempsensor.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_TEMPSENSOR;
                Log.d("mode", u.s(MODE));

            }
        });
        ethernetport.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_ETHERNETPORT;
                Log.d("mode", u.s(MODE));

            }
        });
        distributionboard.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_DISTRIBUTIONBOARD;
                Log.d("mode", u.s(MODE));

            }
        });
        samarray.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_SAMARRAY;
                Log.d("mode", u.s(MODE));

            }
        });
        datahub.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_DATAHUB;
                Log.d("mode", u.s(MODE));

            }
        });

        AddText.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_ADDTEXT;
                getaddtextdialog("ADD TEXT", view.i, FloorPlanActivity.this).show();
                Log.d("mode", u.s(MODE));

            }
        });

        legend.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_LEGEND;
                Log.d("mode", u.s(MODE));

            }
        });

        view = new FloorPlanView(this);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        rl.addView(view);
        rl.addView(toolbar);

        setContentView(rl);
        //readexcel();

        AUTORENUMBERTEMPS = !Tabs1.db.tableexists(dbtablename);

        WriteBoolean(this, "autorenumbertemps", AUTORENUMBERTEMPS);
        System.out.println("auto number=" + AUTORENUMBERTEMPS);

        readdb();
        grabsamcounts();
        grabelccount();
        System.out.println("item" + " " + "type" + "  " + "tempcount");
        for (int h = 0; h < view.i; h++) {
            System.out.println(h + " " + view.ITEMtype[h] + "  " + view.ITEMtempsensorcount[h]);
        }
    } catch (Throwable e) {
        e.printStackTrace();
        finish();
    }
}

From source file:gov.sfmta.sfpark.MainScreenActivity.java

void refreshData() {
    pd = new ProgressDialog(mapView.getContext());
    LoadDataTask ld = new LoadDataTask();
    ld.execute("String");
}

From source file:de.evilbrain.sendtosftp.Main.java

protected void processDialog(String Title, String Message) {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setTitle(Title);//from  w  ww  .jav  a 2  s  .c  o m
    mProgressDialog.setMessage(Message);
    mProgressDialog.setIndeterminate(false);
    mProgressDialog.show();
}

From source file:com.sxt.superqq.activity.LoginActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        if (requestCode == REQUEST_CODE_SETNICK) {
            SuperQQApplication.currentUserNick = data.getStringExtra("edittext");

            progressShow = true;// w ww . j ava 2s. c  om
            final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
            pd.setCanceledOnTouchOutside(false);
            pd.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    progressShow = false;
                }
            });
            pd.setMessage(getString(R.string.Is_landing));
            pd.show();

            final long start = System.currentTimeMillis();
            // sdk??
            EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() {

                @Override
                public void onSuccess() {

                    if (!progressShow) {
                        return;
                    }
                    // ?????
                    SuperQQApplication.getInstance().setUserName(currentUsername);
                    SuperQQApplication.getInstance().setPassword(currentPassword);

                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.setMessage(getString(R.string.list_is_for));
                        }
                    });
                    try {
                        // ** ?logout???
                        // ** manually load all local groups and
                        // conversations in case we are auto login
                        EMGroupManager.getInstance().loadAllGroups();
                        EMChatManager.getInstance().loadAllConversations();
                        //??
                        processContactsAndGroups();
                    } catch (Exception e) {
                        e.printStackTrace();
                        //?????
                        runOnUiThread(new Runnable() {
                            public void run() {
                                pd.dismiss();
                                SuperQQApplication.getInstance().logout(null);
                                Toast.makeText(getApplicationContext(), R.string.login_failure_failed, 1)
                                        .show();
                            }
                        });
                        return;
                    }
                    //?nickname ios?nick
                    boolean updatenick = EMChatManager.getInstance()
                            .updateCurrentUserNick(SuperQQApplication.currentUserNick.trim());
                    if (!updatenick) {
                        Log.e("LoginActivity", "update current user nick fail");
                    }
                    if (!LoginActivity.this.isFinishing())
                        pd.dismiss();
                    // ?
                    startActivity(new Intent(LoginActivity.this, MainActivity.class));
                    finish();
                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(final int code, final String message) {
                    if (!progressShow) {
                        return;
                    }
                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.dismiss();
                            Toast.makeText(getApplicationContext(), getString(R.string.Login_failed) + message,
                                    Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });

        }
    }
}

From source file:com.shafiq.myfeedle.core.MyfeedleNotifications.java

@Override
public boolean onContextItemSelected(final MenuItem item) {
    if (item.getItemId() == CLEAR) {
        final ProgressDialog loadingDialog = new ProgressDialog(this);
        final AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {

            @Override//from  w  w  w  .  j a v  a 2s  .  c o  m
            protected Void doInBackground(Void... arg0) {
                // clear all notifications
                ContentValues values = new ContentValues();
                values.put(Notifications.CLEARED, 1);
                MyfeedleNotifications.this.getContentResolver().update(
                        Notifications.getContentUri(MyfeedleNotifications.this), values,
                        Notifications._ID + "=?",
                        new String[] { Long.toString(((AdapterContextMenuInfo) item.getMenuInfo()).id) });
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                if (loadingDialog.isShowing()) {
                    loadingDialog.dismiss();
                }
                MyfeedleNotifications.this.finish();
            }
        };
        loadingDialog.setMessage(getString(R.string.loading));
        loadingDialog.setCancelable(true);
        loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (!asyncTask.isCancelled())
                    asyncTask.cancel(true);
            }
        });
        loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        loadingDialog.show();
        asyncTask.execute();
    }
    return super.onContextItemSelected(item);
    // clear
}

From source file:com.gizwits.powersocket.activity.control.MainControlActivity.java

/**
 * Inits the views./*from w  w w.j a  va  2  s.co m*/
 */
private void initViews() {
    mView = (SlidingMenu) findViewById(R.id.main_layout);

    tvConsumption = (TextView) findViewById(R.id.tvConsumption);
    tvTiming = (TextView) findViewById(R.id.tvTiming);
    tvDelay = (TextView) findViewById(R.id.tvDelay);
    ivMenu = (ImageView) findViewById(R.id.ivMenu);
    btnPower = (Button) findViewById(R.id.btnPower);
    btnAppoinment = (Button) findViewById(R.id.btnAppoinment);
    llTiming = (LinearLayout) findViewById(R.id.llTiming);
    llDelay = (LinearLayout) findViewById(R.id.llDelay);

    mAdapter = new MenuDeviceAdapter(this, bindlist);
    lvDevice = (ListView) findViewById(R.id.lvDevice);
    lvDevice.setAdapter(mAdapter);

    progressDialogRefreshing = new ProgressDialog(MainControlActivity.this);
    progressDialogRefreshing.setMessage("?,??");
    progressDialogRefreshing.setCancelable(false);

    mDisconnectDialog = DialogManager.getDisconnectDialog(this, new OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogManager.dismissDialog(MainControlActivity.this, mDisconnectDialog);
            IntentUtils.getInstance().startActivity(MainControlActivity.this, DeviceListActivity.class);
            finish();
        }
    });
}

From source file:com.fabernovel.alertevoirie.MyIncidentsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_PROGRESS:
        mPd = new ProgressDialog(this);
        mPd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mPd.setIndeterminate(true);/*  w w  w  .java 2  s .com*/
        mPd.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                removeDialog(DIALOG_PROGRESS);
            }
        });
        mPd.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                AVService.getInstance(MyIncidentsActivity.this).cancelTask();
                finish();
            }
        });
        mPd.setMessage(getString(R.string.ui_message_loading));
        return mPd;

    default:
        return super.onCreateDialog(id);
    }
}