Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

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

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:xj.property.fragment.ContactlistFragment.java

/**
 * ?/*  w ww  .  ja  va  2 s  .  c  o m*/
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                XjApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), ": " + e.getMessage(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.hyphenate.easeui.ui.EaseContactListFragment.java

/**
 * move user to blacklist// ww w .java2s  .c o m
 */
protected void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //move to blacklist
                EMClient.getInstance().contactManager().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (HyphenateException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:cn.kangeqiu.kq.activity.ContactlistFragment.java

/**
 * ?//from   w  w w .j av a2s  . com
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                BaseApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.xiaoyu.DoctorHelp.chat.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//from  w ww  .  ja  va 2 s. c  om
 *
 * @param
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                HCApplicaton.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.example.Bama.chat.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//from w  ww. java2s.  c  o m
 *
 * @param
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                HCApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });

            }

        }
    }).start();

}

From source file:la.zmkm.agent.activity.ContactlistFragment.java

/**
 * ?//from www  .  j  a  v a2 s.co m
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onClick(View v) {
    EditText cueInput = (EditText) findViewById(R.id.cue);
    EditText responseInput = (EditText) findViewById(R.id.response);
    Spinner posInput = (Spinner) findViewById(R.id.pos);
    EditText characterResponseInput = (EditText) findViewById(R.id.response_character);
    EditText characterCueInput = (EditText) findViewById(R.id.cue_character);
    final String cue = cueInput.getText().toString();
    final String response = responseInput.getText().toString();
    final String pos = posInput.getSelectedItem().toString();
    final String character_cue = characterCueInput.getText().toString();
    final String character_response = characterResponseInput.getText().toString();
    String pos_code = Utils.POS_MAP.get(pos);
    if (TextUtils.isEmpty(pos_code)) {
        pos_code = "NONE";
    }/*from  w  ww.  j a v  a  2 s  .  com*/
    final String final_pos_code = pos_code;

    if (Main.isNotLoggedIn(this)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, LoginActivity.class.getName());
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
        // navigation
        // back to this?
        LoginActivity.return_to = CreateItemActivity.class.getName();
        LoginActivity.params = new HashMap<String, String>();
        LoginActivity.params.put("list_id", list_id);
        LoginActivity.params.put("cue", cue);
        LoginActivity.params.put("response", response);
        LoginActivity.params.put("cue_language", cue_language);
        LoginActivity.params.put("response_language", response_language);
        LoginActivity.params.put("pos", pos);
        LoginActivity.params.put("character_cue", character_cue);
        LoginActivity.params.put("character_response", character_response);
        startActivity(intent);
    } else {
        // TODO cue and response languages need to be inferred from list we are
        // adding to ... Might want to fix those, i.e. not allow variation
        // on
        // search ...
        // TODO wondering whether there is some way to edit existing items
        // ...

        final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
        myOtherProgressDialog.setTitle("Please Wait ...");
        myOtherProgressDialog.setMessage("Creating Item ...");
        myOtherProgressDialog.setIndeterminate(true);
        myOtherProgressDialog.setCancelable(true);

        final Thread create_item = new Thread() {
            public void run() {
                // TODO make this interruptable .../*if
                // (!this.isInterrupted())*/
                CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue,
                        final_pos_code, response, response_language, character_response, list_id);

                myOtherProgressDialog.dismiss();

            }
        };
        myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                create_item.interrupt();
            }
        });
        OnCancelListener ocl = new OnCancelListener() {
            public void onCancel(DialogInterface arg0) {
                create_item.interrupt();
            }
        };
        myOtherProgressDialog.setOnCancelListener(ocl);
        myOtherProgressDialog.show();
        create_item.start();
    }
}

From source file:org.akvo.caddisfly.sensor.ec.CalibrateSensorActivity.java

@Override
public void onFragmentInteraction(String value) {
    String requestCommand = "SET ID " + value + LINE_FEED;

    usbService.write(requestCommand.getBytes(StandardCharsets.UTF_8));

    final ProgressDialog savingProgressDialog = ProgressDialog.show(mContext, getString(R.string.pleaseWait),
            getString(R.string.saving), true, false);

    new Handler().postDelayed(new Runnable() {
        @Override/*ww  w .ja  v a  2 s .  c  o m*/
        public void run() {
            String getIdRequest = "GET ID" + LINE_FEED;
            usbService.write(getIdRequest.getBytes(StandardCharsets.UTF_8));

            displayInformation(calibrationIndex);

            if (viewAnimator.getDisplayedChild() == 0) {
                viewAnimator.showNext();
                fabEdit.setVisibility(View.VISIBLE);
                savingProgressDialog.dismiss();
            }
        }
    }, SAVING_DELAY_MILLIS);

}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 * Set up the FAB and ensure internect connectivity exists before
 * getting map ready.//from   w  ww .  j  av a  2 s  . c om
 * @param savedInstanceState Bundle
 */
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    /*
     * If you have a basic license key, uncomment line 102.
     * See directions in the README about how to Configure a Basic License
     */

    //   ArcGISRuntimeEnvironment.setLicense(BuildConfig.LICENSE_KEY);

    // Initially hide the FAB
    mFab = (FloatingActionButton) findViewById(R.id.fab);
    if (mFab != null) {
        mFab.setVisibility(View.INVISIBLE);
        mFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                } else if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                }

            }
        });
    }

    // Check for internet connectivity
    if (!checkForInternetConnectivity()) {
        final ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage(getString(R.string.internet_connectivity));
        progressDialog.setTitle(getString(R.string.wireless_problem));
        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "CANCEL",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        progressDialog.dismiss();
                        finish();
                    }
                });
        progressDialog.show();

    } else {
        // Get data access setup
        mDataManager = DataManager.getDataManagerInstance(getApplicationContext());

        // Set up fragments
        setUpMagFragment();

        setUpBottomSheetFragment();
    }
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void buttonListener(final View view) {
    if (vibrate) {
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }/*w w w .j a  va2 s.c  om*/
    // new Functions().noPreferences(Main.this,
    // getString(R.string.gen_title_error),
    // getString(R.string.gen_setpreferences));
    if (!new Functions().checkPreferences(Main.this)) {
        new Functions().noPreferences(Main.this, getString(R.string.gen_title_error),
                getString(R.string.gen_setserverpreferences));
        return;
    }
    // noPreferences(Main.this,
    // getString(R.string.gen_title_error),
    // getString(R.string.gen_setpreferences));
    switch (view.getId()) {
    case R.id.bt_scanqr:
        // Intent intent = new
        // Intent("com.google.zxing.client.android.SCAN");
        // intent.setPackage("com.google.zxing.client.android");
        // intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        // setResult(RESULT_OK, intent);
        // startActivityForResult(intent, 0);
        Intent qrDroid = new Intent("la.droid.qr.scan");
        qrDroid.putExtra("la.droid.qr.complete", true);
        try {
            startActivityForResult(qrDroid, GET_QR);
        } catch (ActivityNotFoundException activity) {
            Functions.qrDroidRequired(Main.this);
        }

        break;

    case R.id.bt_getopsiclients:
        Log.d("Barcode", "getopsiclient");
        // if (Networking.isConnected(Main.this)) {
        getOpsiClientsTask();
        // } else {
        // Toast.makeText(Main.this, R.string.to_wifinotconnected,
        // Toast.LENGTH_LONG).show();
        // }
        break;
    case R.id.bt_defineclientselection:
        if (Networking.isConnected(Main.this)) {
            final ProgressDialog dialog = ProgressDialog.show(Main.this,
                    getString(R.string.gen_title_pleasewait), getString(R.string.pd_getclients), true);
            final Handler handler = new Handler() {
                public void handleMessage(Message msg) {
                    dialog.dismiss();
                    if (GlobalVar.getInstance().getError().equals("null")) {
                        if (doit.equals("serverdown")) {
                            Toast.makeText(Main.this,
                                    String.format(getString(R.string.to_servernotrechable), serverip),
                                    Toast.LENGTH_LONG).show();
                        }
                    } else {
                        new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                                GlobalVar.getInstance().getError(), false);
                    }
                }
            };

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

                    if (Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) {
                        doit = "true";
                        Intent i = new Intent(Main.this, ShowOpsiClientFilter.class);
                        startActivity(i);
                    } else {
                        doit = "serverdown";
                    }
                    handler.sendEmptyMessage(0);

                }
            };
            checkUpdate.start();
        } else {
            Toast.makeText(Main.this, R.string.to_wifinotconnected, Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.bt_createopsiclient:
        // new Functions().notImplementet(Main.this);
        Intent i = new Intent(Main.this, ShowOpsiCreateClient.class);
        startActivity(i);
        break;
    case R.id.bt_showdepotconfig:
        // new Functions().notImplementet(Main.this);
        Log.d("Barcode", "depotconfig");
        if (Networking.isConnected(Main.this)) {
            getOPSIDepots();
        } else {
            Toast.makeText(Main.this, R.string.to_wifinotconnected, Toast.LENGTH_LONG).show();
        }
        break;
    // case R.id.bt_test:
    // ArrayList<String> test = new ArrayList<String>();
    // test.add("test1");
    // test.add("test2");
    // test.add("test3");
    // test.add("test4");
    // ShowOpsiClientOptionsButtonDialog buttondialog = new
    // ShowOpsiClientOptionsButtonDialog(Main.this,test);
    // buttondialog.setTitle("testtitle");
    // buttondialog.show();
    // break;
    }

}