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:ch.fixme.status.Widget_config.java

@Override
protected Dialog onCreateDialog(int id) {
    AlertDialog dialog = null;/*from ww  w.  j a va 2 s .  c  o  m*/
    switch (id) {
    case DIALOG_LOADING:
        dialog = new ProgressDialog(this);
        dialog.setCancelable(false);
        dialog.setMessage(getString(R.string.msg_loading));
        dialog.setCancelable(true);
        ((ProgressDialog) dialog).setIndeterminate(true);
        break;
    }
    return dialog;
}

From source file:com.gmail.altakey.lucene.AsyncImageLoader.java

protected void onPreExecute() {
    Context context = this.view.getContext();
    this.httpClient = AndroidHttpClient.newInstance(this.getUserAgent());
    this.oomMessage = Toast.makeText(context, R.string.toast_out_of_memory, Toast.LENGTH_SHORT);
    this.progress = new ProgressDialog(context);
    this.progress.setTitle(context.getString(R.string.dialog_loading_title));
    this.progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    this.progress.setMessage(context.getString(R.string.dialog_loading_message));
    this.progress.show();

    ImageUnloader.unload(this.view);
}

From source file:com.toppatch.mv.ui.activities.LoginActivity2.java

private void setupReferences() {
    email = (EditText) findViewById(R.id.email_address);
    passcode = (EditText) findViewById(R.id.password);
    submit = (Button) findViewById(R.id.submit);

    progress = new ProgressDialog(LoginActivity2.this);
    progress.setMessage("Checking Login... Please wait");
    progress.setCancelable(false);/* w w w .  ja va  2s  .  co  m*/
}

From source file:com.zotfeed2.CardContentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    recyclerView = (RecyclerView) inflater.inflate(R.layout.recycler_view, container, false);
    if (constants.isNetworkAvailable()) {
        dialog = new ProgressDialog(getContext());
        dialog.setIndeterminate(true);//from  w  w w  . j a  v  a  2  s .  c  om
        dialog.setMessage("Loading Anteater TV Videos");
        dialog.show();
        recyclerView.setAdapter(new ContentAdapter(null));
        if (getCommand.equals("videos") || getCommand.contains("v")) {
            loadVideos("");
        } else if (getCommand.equals("playlist") || getCommand.contains("p")) {
            loadPlaylists("");
        } else if (search) {
            recyclerView.setAdapter(new ContentAdapter(videoBeans));
            recyclerView.setHasFixedSize(true);
            recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        }

    } else {
        showDialog();
    }
    setHasOptionsMenu(true);
    return recyclerView;
}

From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java

public void onWrongConnectionState(int state, final INotifiableManager manager, final Command<?> source) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    switch (state) {
    case WifiHelper.WIFI_STATE_DISABLED:
        builder.setTitle("Wifi disabled");
        builder.setMessage("This host is Wifi only. Should I activate Wifi?");
        builder.setNeutralButton("Activate Wifi", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                final ProgressDialog pd = new ProgressDialog(mActivity);
                pd.setCancelable(true);/*from  ww  w .  j av  a  2 s .  c  om*/
                pd.setTitle("Activating Wifi");
                pd.setMessage("Please wait while Wifi is activated.");
                pd.show();
                (new Thread() {
                    public void run() {
                        final WifiHelper helper = WifiHelper.getInstance(mActivity);
                        helper.enableWifi(true);
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_ENABLED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        manager.retryAll();
                        pd.cancel();
                        mDialogShowing = false;

                    }
                }).start();
            }
        });
        showDialog(builder);
        break;
    case WifiHelper.WIFI_STATE_ENABLED:
        final Host host = HostFactory.host;
        final WifiHelper helper = WifiHelper.getInstance(mActivity);
        final String msg;
        if (host != null && host.access_point != null && !host.access_point.equals("")) {
            helper.connect(host);
            msg = "Connecting to " + host.access_point + ". Please wait";
        } else {
            msg = "Waiting for Wifi to connect to your LAN.";
        }
        final ProgressDialog pd = new ProgressDialog(mActivity);
        pd.setCancelable(true);
        pd.setTitle("Connecting");
        pd.setMessage(msg);
        mWaitForWifi = new Thread() {
            public void run() {
                mDialogShowing = true;
                pd.show();
                (new Thread() {
                    public void run() {
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        pd.cancel();
                        mDialogShowing = false;
                    }
                }).start();
                pd.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(DialogInterface dialog) {
                        if (helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            builder.setTitle("Wifi doesn't seem to connect");
                            builder.setMessage(
                                    "You can open the Wifi settings or wait " + MAX_WAIT_FOR_WIFI + " seconds");
                            builder.setNeutralButton("Wifi Settings", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
                                }
                            });
                            builder.setCancelable(true);
                            builder.setNegativeButton("Wait", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.runOnUiThread(mWaitForWifi); //had to make the Thread a field because of this line
                                }
                            });

                            mActivity.runOnUiThread(new Runnable() {
                                public void run() {
                                    final AlertDialog alert = builder.create();
                                    try {
                                        if (!mDialogShowing) {
                                            alert.show();
                                            mDialogShowing = true;
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                        }
                    }

                });
            }
        };
        mActivity.runOnUiThread(mWaitForWifi);
    }

}

From source file:com.aibasis.parent.ui.entrance.RegisterActivity.java

/**
 * /*from  w w w .ja v  a 2  s . c o m*/
 * 
 * @param view
 */
public void register(View view) {
    final String username = userNameEditText.getText().toString().trim();
    final String pwd = passwordEditText.getText().toString().trim();
    String confirm_pwd = confirmPwdEditText.getText().toString().trim();
    if (TextUtils.isEmpty(username)) {
        Toast.makeText(this, getResources().getString(R.string.User_name_cannot_be_empty), Toast.LENGTH_SHORT)
                .show();
        userNameEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(pwd)) {
        Toast.makeText(this, getResources().getString(R.string.Password_cannot_be_empty), Toast.LENGTH_SHORT)
                .show();
        passwordEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(confirm_pwd)) {
        Toast.makeText(this, getResources().getString(R.string.Confirm_password_cannot_be_empty),
                Toast.LENGTH_SHORT).show();
        confirmPwdEditText.requestFocus();
        return;
    } else if (!pwd.equals(confirm_pwd)) {
        Toast.makeText(this, getResources().getString(R.string.Two_input_password), Toast.LENGTH_SHORT).show();
        return;
    }

    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage(getResources().getString(R.string.Is_the_registered));
        pd.show();

        new Thread(new Runnable() {
            public void run() {
                //               try {
                //                  // sdk
                //                  EMChatManager.getInstance().createAccountOnServer(username, pwd);
                //                  runOnUiThread(new Runnable() {
                //                     public void run() {
                //                        if (!RegisterActivity.this.isFinishing())
                //                           pd.dismiss();
                //                        // ???
                //                        DemoApplication.getInstance().setUserName(username);
                //                        Toast.makeText(getApplicationContext(), getResources().getString(R.string.Registered_successfully), 0).show();
                //                        finish();
                //                     }
                //                  });
                //               } catch (final EaseMobException e) {
                //                  runOnUiThread(new Runnable() {
                //                     public void run() {
                //                        if (!RegisterActivity.this.isFinishing())
                //                           pd.dismiss();
                //                        int errorCode=e.getErrorCode();
                //                        if(errorCode==EMError.NONETWORK_ERROR){
                //                           Toast.makeText(getApplicationContext(), getResources().getString(R.string.network_anomalies), Toast.LENGTH_SHORT).show();
                //                        }else if(errorCode == EMError.USER_ALREADY_EXISTS){
                //                           Toast.makeText(getApplicationContext(), getResources().getString(R.string.User_already_exists), Toast.LENGTH_SHORT).show();
                //                        }else if(errorCode == EMError.UNAUTHORIZED){
                //                           Toast.makeText(getApplicationContext(), getResources().getString(R.string.registration_failed_without_permission), Toast.LENGTH_SHORT).show();
                //                        }else if(errorCode == EMError.ILLEGAL_USER_NAME){
                //                            Toast.makeText(getApplicationContext(), getResources().getString(R.string.illegal_user_name),Toast.LENGTH_SHORT).show();
                //                        }else{
                //                           Toast.makeText(getApplicationContext(), getResources().getString(R.string.Registration_failed) + e.getMessage(), Toast.LENGTH_SHORT).show();
                //                        }
                //                     }
                //                  });
                //               }
                accountAPI.register(username, pwd, new RequestListener() {
                    @Override
                    public void onComplete(String result) {
                        if (!RegisterActivity.this.isFinishing())
                            pd.dismiss();
                        try {
                            RegisterResult registerResult = RegisterResult.parse(result);
                            if (RegisterResult.SUCCESS.equals(registerResult.getResult())) {
                                DemoApplication.getInstance().setParentId(registerResult.getParentId());
                                DemoApplication.getInstance().setEaseId(registerResult.getEaseId());
                                DemoApplication.getInstance().setEasePassword(registerResult.getEasePassword());

                                SharePreferenceUtil sharePreferenceUtil = new SharePreferenceUtil(
                                        RegisterActivity.this);
                                sharePreferenceUtil.setParentId(registerResult.getParentId());
                            } else if (RegisterResult.USERNAME_EXISTS.equals(registerResult.getResult())) {
                                Toast.makeText(RegisterActivity.this,
                                        getResources().getString(R.string.User_already_exists),
                                        Toast.LENGTH_SHORT).show();
                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        finish();
                    }

                    @Override
                    public void onAPIException(APIException exception) {
                        Log.e("jijun", exception.toString());
                    }
                });

            }
        }).start();
    }
}

From source file:im.afterclass.android.activity.RegisterActivity.java

/**
 * /*from www  .  jav a2 s .c o m*/
 * @param view
 */
public void register(View view) {
    final String username = userNameEditText.getText().toString().trim();
    final String pwd = passwordEditText.getText().toString().trim();
    String confirm_pwd = confirmPwdEditText.getText().toString().trim();
    if (TextUtils.isEmpty(username)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        userNameEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        passwordEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(confirm_pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        confirmPwdEditText.requestFocus();
        return;
    } else if (!pwd.equals(confirm_pwd)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        return;
    }

    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        pd.show();
        new Thread(new Runnable() {
            public void run() {
                try {
                    //sdk
                    EMChatManager.getInstance().createAccountOnServer(username, pwd);
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            //???
                            DemoApplication.getInstance().setUserName(username);
                            Toast.makeText(getApplicationContext(), "?", 0).show();
                            newRegister();
                            finish();
                        }
                    });
                } catch (final Exception e) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            if (e != null && e.getMessage() != null) {
                                String errorMsg = e.getMessage();
                                if (errorMsg.indexOf("EMNetworkUnconnectedException") != -1) {
                                    Toast.makeText(getApplicationContext(), "?",
                                            0).show();
                                } else if (errorMsg.indexOf("conflict") != -1) {
                                    Toast.makeText(getApplicationContext(), "?", 0).show();
                                } else {
                                    Toast.makeText(getApplicationContext(), ": " + e.getMessage(),
                                            1).show();
                                }

                            } else {
                                Toast.makeText(getApplicationContext(), ": ", 1).show();

                            }
                        }
                    });
                }
            }
        }).start();

    }
}

From source file:com.df.push.DemoActivity.java

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

    setContentView(R.layout.main);/*from  www. j a  va 2s.co m*/
    mDisplay = (TextView) findViewById(R.id.display);

    context = getApplicationContext();
    progressDialog = new ProgressDialog(DemoActivity.this);
    progressDialog.setMessage("Please wait...");
    // Check device for Play Services APK. If check succeeds, proceed with GCM registration.
    if (checkPlayServices()) {
        // display loading bar and fetch topics for future use
        getTopics();
    } else {
        Log.i(TAG, "No valid Google Play Services APK found.");
    }

    readSubscriptions(); // if subscribed previously
    final SharedPreferences prefs = getGcmPreferences(context);
    if (prefs.getString(PROPERTY_REG_URL, null) == null) {
        // device token is not updated on server, disable subscribe and unsubscribe buttons
        findViewById(R.id.subscribe).setVisibility(View.GONE);
        findViewById(R.id.unsubscribe).setVisibility(View.GONE);
    } else {
        findViewById(R.id.subscribe).setVisibility(View.VISIBLE);
        findViewById(R.id.unsubscribe).setVisibility(View.VISIBLE);
    }
}

From source file:com.safecell.AccountFormActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setWindowAnimations(R.anim.null_animation);
    context = AccountFormActivity.this;
    this.initUI();
    profilesRepository = new ProfilesRepository(context);
    createAccountButton.setOnClickListener(createAccountButtonOnclickListenr);

    progressDialog = new ProgressDialog(context);
    licenseProgressDialog = new ProgressDialog(context);
    licenseThread = new LicenseThread();

    Intent intent = getIntent();/*  w w w .  j av a  2  s.c o m*/
    Bundle bundle = intent.getExtras();
    callingActivity = bundle.getString("from");

    handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            super.handleMessage(msg);
            licenseProgressDialog.dismiss();
            if (licenseThread.isAlive()) {
                licenseThread.interrupt();
                licenseThread = new LicenseThread();
            }
            if (licensekeyString == null) {
                message = getLicenseKey.getFailureMessage();
                UIUtils.OkDialog(context, message);
                return;
            }

            selectLicenseFromDialog();
        }
    };

    PackageManager pm = getPackageManager();
    try {
        //---get the package info---
        PackageInfo pi = pm.getPackageInfo("com.safecell", 0);
        //Log.v("Version Code", "Code = "+pi.versionCode);
        //Log.v("Version Name", "Name = "+pi.versionName); 
        versionName = pi.versionName;

    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    preferences = getSharedPreferences("AccountUniqueID", MODE_WORLD_WRITEABLE);
    preferences.getString("AccountUID", "");
    createAccountUniqueID(SCProfile.newUniqueDeviceKey());

}

From source file:com.dropbox.android.dropeso.dropeso.java

/** Called when the activity is first created. */
@Override/*  ww  w . j av  a 2  s.  co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mDropbox = new Dropbox(this, CONSUMER_KEY, CONSUMER_SECRET);

    mLoginEmail = (EditText) findViewById(R.id.login_email);
    mLoginPassword = (EditText) findViewById(R.id.login_password);
    mSubmit = (Button) findViewById(R.id.login_submit);
    mText = (TextView) findViewById(R.id.text);

    mUploadWeight = (Button) findViewById(R.id.upload_button);
    mWeightValue = (EditText) findViewById(R.id.weight_value);

    mProgress = new ProgressDialog(this);
    mProgress.setMessage("Please wait...");
    mProgress.setTitle("Login Info Found! Signing in...");

    File file = getApplicationContext().getFileStreamPath(loginfile);
    if (file.exists()) {
        byte[] buffer = new byte[(int) getApplicationContext().getFileStreamPath(loginfile).length()];
        FileInputStream f = null;
        try {
            f = openFileInput(loginfile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            f.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        String s = new String(buffer);
        JSONObject json = null;
        try {
            json = new JSONObject(s);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        mProgress.show();
        String email = null;
        String password = null;
        try {
            email = json.getString("email");
            password = json.getString("password");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        mDropbox.login(mLoginListener, email, password);
    }
    mSubmit.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mLoggedIn) {
                // We're going to log out
                mDropbox.deauthenticate();
                setLoggedIn(false);
                mText.setText("");
            } else {
                // Try to log in
                try {
                    getAccountInfo();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    });

    mUploadWeight.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            runOnUiThread(new Runnable() {
                public void run() {
                    showToast("Downloading file...");
                }
            });
            try {

                mDropbox.downloadDropboxFile("/Dropeso/dropeso.json",
                        getApplicationContext().getFileStreamPath("dropeso.json"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            FileInputStream f = null;
            try {
                f = openFileInput("dropeso.json");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            byte[] buffer = new byte[(int) getApplicationContext().getFileStreamPath("dropeso.json").length()];
            try {
                f.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            String s = new String(buffer);
            Boolean json_ok = false;
            JSONObject json = null;
            if (!s.isEmpty()) {
                try {
                    json = new JSONObject(s);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                ;

                if (json.has("dates") && json.has("values")) {
                    showToast("Data ok, appending...");
                    json_ok = true;
                }
            }
            if (json_ok) {

            } else {
                json = new JSONObject();
                showToast("Data corrupted. Starting fresh...");
                ArrayList<Double> values = new ArrayList<Double>();
                values.add(Double.parseDouble(mWeightValue.getText().toString()));
                ArrayList<String> dates = new ArrayList<String>();
                Date date = new Date();
                SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                dates.add(mSimpleDateFormat.format(date));
                try {
                    json.put("values", values);
                    json.put("dates", dates);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                FileOutputStream fos;
                try {
                    fos = openFileOutput("dropeso.json", Context.MODE_PRIVATE);
                    fos.write(json.toString().getBytes());
                    fos.close();
                    mDropbox.putFile("dropbox", "/Dropeso",
                            getApplicationContext().getFileStreamPath("dropeso.json"));
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

        }
    });

    /*
     * if (mDropbox.authenticate()) { // We can query the account info
     * already, since we have stored // credentials getAccountInfo(); }
     */
}