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.piusvelte.sonet.core.SonetNotifications.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   ww  w.j  a  v  a2s .  co  m*/
            protected Void doInBackground(Void... arg0) {
                // clear all notifications
                ContentValues values = new ContentValues();
                values.put(Notifications.CLEARED, 1);
                SonetNotifications.this.getContentResolver().update(
                        Notifications.getContentUri(SonetNotifications.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();
                }
                SonetNotifications.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.burntout.burntout.SendReportActivity.java

public void loginBurnt(String email, String plateState, String plateNumber, String lightsOut, String extraMsg,
        String vTypeString) {/*from w  w  w . ja v  a 2  s.co m*/

    pm = new ProgressDialog(this);
    pm.show();

    reportVehicle = new Post();
    reportVehicle.setCommunicator(this);

    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6);

    nameValuePairs.add(new BasicNameValuePair("email", email));
    nameValuePairs.add(new BasicNameValuePair("vehicle_type", vTypeString));
    nameValuePairs.add(new BasicNameValuePair("plate_state", plateState));
    nameValuePairs.add(new BasicNameValuePair("license_plate", plateNumber));
    nameValuePairs.add(new BasicNameValuePair("lights_out", lightsOut));
    nameValuePairs.add(new BasicNameValuePair("special_message", extraMsg));

    reportVehicle.executePosts(nameValuePairs,
            "http://combustioninnovation.com/production/Goodyear/php/sendmessage.php");

}

From source file:com.code.android.vibevault.SearchScreen.java

/** Dialog creation method.
*
* Includes Thread bookkeeping to prevent not leaking Views on orientation changes.
*//*from   ww w. j  a va  2  s  .  c  o m*/
@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case VibeVault.SEARCHING_DIALOG_ID:

        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage("Finding Shows");
        return dialog;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.hypers.frame.http.core.AsyncHttpResponseHandler.java

/**
 * Creates a new AsyncHttpResponseHandler
 *///from w  w  w .j av  a  2  s .c  o  m
public AsyncHttpResponseHandler(Context context, boolean isShowProgress) {
    this.context = context;
    this.isShowProgress = isShowProgress;

    if (this.isShowProgress) {
        this.progressDialog = new ProgressDialog(context);
    }

    // Set up a handler to post events back to the correct thread if possible
    if (Looper.myLooper() != null) {
        handler = new ResponderHandler(this);
    }
}

From source file:de.wikilab.android.friendica01.Max.java

/**
* Calls the api method <code>verify_credentials</code> with the login data
 * saved in the <code>SharedPreferences</code>. Calls ctx.OnLogin on success,
 * showLoginForm(ctx, "error") on error//from   w  w w  .  j  a v a  2  s. c  o  m
* @param ctx     MUST IMPLEMENT LoginListener !!!
*/
public static void tryLogin(final Activity ctx) {

    final ProgressDialog pd = new ProgressDialog(ctx);
    pd.setMessage(ctx.getResources().getString(R.string.logging_in));
    pd.show();

    String server = Max.getServer(ctx);
    Log.i(TAG, "tryLogin on server " + server);

    final TwAjax t = new TwAjax(ctx, true, true);
    t.getUrlContent(server + "/api/account/verify_credentials", new Runnable() {
        @Override
        public void run() {
            pd.dismiss();
            try {
                if (t.isSuccess()) {
                    Log.i(TAG, "... tryLogin - http status: " + t.getHttpCode());
                    if (t.getHttpCode() == 200) {
                        JSONObject r = (JSONObject) t.getJsonResult();
                        String name = r.getString("name");
                        ((TextView) ctx.findViewById(R.id.selected_clipboard)).setText(name);
                        ((LoginListener) ctx).OnLogin();

                        final TwAjax profileImgDl = new TwAjax();
                        final String targetFs = IMG_CACHE_DIR + "/my_profile_pic_" + r.getString("id") + ".jpg";
                        if (new File(targetFs).isFile()) {
                            ((ImageView) ctx.findViewById(R.id.profile_image))
                                    .setImageURI(Uri.parse("file://" + targetFs));
                        } else {
                            profileImgDl.urlDownloadToFile(r.getString("profile_image_url"), targetFs,
                                    new Runnable() {
                                        @Override
                                        public void run() {
                                            ((ImageView) ctx.findViewById(R.id.profile_image))
                                                    .setImageURI(Uri.parse("file://" + targetFs));
                                        }
                                    });
                        }

                    } else {
                        showLoginForm(ctx, "Error: " + t.getResult());
                    }
                } else {
                    Log.w(TAG, "... tryLogin - request failed");
                    showLoginForm(ctx, "ERR: " + t.getError().toString());
                }

            } catch (Exception ex) {
                Log.w(TAG, "... tryLogin - exception:");
                ex.printStackTrace();
                showLoginForm(ctx, "ERR2: " + t.getResult() + ex.toString());

            }
        }
    });
}

From source file:com.photocitygame.android.ImageActivity.java

protected void uploadPhoto(User user) {
    if (user == null) {
        Log.e("PhotoCity", "No user!");
        Toast.makeText(this, "Error uploading image", Toast.LENGTH_SHORT).show();
        return;/* ww  w  .  ja v a 2  s  .  c  o m*/
    }
    ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Uploading");
    File f = Environment.getExternalStorageDirectory();
    File dir = new File(f, "photocity");
    try {
        FileInputStream in = new FileInputStream(new File(dir, "image.jpg"));
        ImageUploader uploader = new ImageUploader(this, in, user.getUserId(), flag, model);
        uploader.setProgressDialog(dialog);
        new Thread(uploader).start();
    } catch (FileNotFoundException ex) {
        Log.e("PhotoCity", "Error Uploading Image", ex);
        Toast.makeText(this, "Error uploading image", Toast.LENGTH_SHORT).show();
    }
}

From source file:net.dahanne.android.google.client.GoogleProfileActivity.java

public void showProgressDialog(CharSequence message) {
    if (this.progressDialog == null) {
        this.progressDialog = new ProgressDialog(this);
        this.progressDialog.setIndeterminate(true);
    }/* w  ww .  j  a  va 2 s . c o m*/

    this.progressDialog.setMessage(message);
    this.progressDialog.show();
}

From source file:com.junyou.jyxxx.vivo.cpp.AppActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /*//from   www.java  2 s  .  co  m
      "000023"     {}               //360?
      "000002"     {}               //
      "000005"     {}               //
      "000007"     {}               //91
      "000009"     {}               //
      "000116"     {}               //?
      "000225"     {}               //pp(UC?)
      "000800"     {}               //?
      "150001"     {}               //?
      "150002"     {}               //
      "150003"     {}               //?
      "150004"     {}               //?
      "150005"     {}               //?
      "100061"     {}               //?
      "000066"     {}               //?
      "000054"     {}               //???
      "000020"     {}               //OPPO?  ???(OPPO)
      "000084"     {}               //??
      "000008"     {}               //???
      "000368"     {}               //voio??,(vivo)
      "000016"     {}               //?
              
      */
    MobClickCppHelper.init(AppActivity.this, Constants.APP_KEY_UMENG, "000368"); //todo id
    //      Log.i(TAG, "phoneInfo: " + ComFunction.getDeviceInfo(this));
    instance = this;
    mVivoUnionManager = new VivoUnionManager(AppActivity.this);
    mVivoUnionManager.initVivoSinglePayment(AppActivity.this, mOnVivoPayResultListener);
    mVivoUnionManager.singlePaymentInit(AppActivity.this);
    //vivo ???
    mVivoUnionManager.singlePaymentInit(AppActivity.this);

    //------------------MM
    mProgressDialog = new ProgressDialog(AppActivity.this);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setMessage("?...");

    IAPHandler iapHandler = new IAPHandler(this);
    mListener = new IAPListener(this, iapHandler);
    mPaycode = Constants.MM_LEASE_PAYCODE;
    mProductNum = 1;
    mPurchase = Purchase.getInstance();

    try {
        if (null != mPurchase) {
            mPurchase.setAppInfo(Constants.MM_APPID, Constants.MM_APPKEY);
            mPurchase.setTimeout(10000, 10000); // (?)???10s
        }
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    try {
        if (null != mPurchase) {
            mPurchase.init(AppActivity.this, mListener);
        }
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    showProgressDialog();
    //------------------MM

    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            //            if (ComFunction.isWechatAvilible(AppActivity.this))
            //            Toast.makeText(AppActivity.this, getResources().getString(R.string.no_wechat), Toast.LENGTH_SHORT).show();
            if (ComFunction.networkInfo(AppActivity.this)) {
                if (msg.what == 0) {
                    try {
                        //vivo Pay
                        //                        NameValuePair[] nameValuePairs = doPaymentInit(1);
                        //                        new InitialPayTask().execute(nameValuePairs);
                        //MM Pay
                        MMOrder(AppActivity.this, mListener);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } else {
                Toast.makeText(AppActivity.this, getResources().getString(R.string.no_net), Toast.LENGTH_SHORT)
                        .show();
            }
        }
    };

    mHandler2 = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 0) {
                Toast.makeText(AppActivity.this, getResources().getString(R.string.no_wechat),
                        Toast.LENGTH_SHORT).show();
            } else if (msg.what == 1) {
                Toast.makeText(AppActivity.this, getResources().getString(R.string.no_net), Toast.LENGTH_SHORT)
                        .show();
            } else if (msg.what == 2) {
                Toast.makeText(AppActivity.this, getResources().getString(R.string.show_tonextLevelTip),
                        Toast.LENGTH_SHORT).show();
            }
        }
    };
}

From source file:com.slim.turboeditor.activity.MainActivity.java

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

    setContentView(R.layout.activity_home);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from ww w.jav  a2  s  . com*/
    toolbar.setTitle(R.string.text_editor);

    ButterKnife.bind(this);

    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setMessage(getString(R.string.please_wait));

    setupTextEditor();
    hideTextEditor();
    parseIntent(getIntent());

    SettingsProvider.get(this).registerOnSharedPreferenceChangeListener(mPreferenceListener);
}

From source file:com.arctech.stikyhive.ChattingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    recipientStkid = getIntent().getExtras().getString("recipientStkid");
    chatRecipient = getIntent().getExtras().getString("chatRecipient");
    chatRecipientUrl = getIntent().getExtras().getString("chatRecipientUrl");
    senderToken = getIntent().getExtras().getString("senderToken");
    recipientToken = getIntent().getExtras().getString("recipientToken");
    noti = getIntent().getExtras().getBoolean("noti");
    message = getIntent().getExtras().getString("message");
    rows = getIntent().getExtras().getInt("rows");

    pref = PreferenceManager.getDefaultSharedPreferences(this);
    ws = new JsonWebService();
    dbHelper = new DBHelper(this);
    dialog = new ProgressDialog(this);
    listChatContact = new ArrayList<>();
    listChatContact = dbHelper.getChatContact();
    Log.i(" Chat Contact ", " " + listChatContact.size());
    //to change font
    faceSemi_bold = Typeface.createFromAsset(getAssets(), fontOSSemi_bold);
    Typeface faceLight = Typeface.createFromAsset(getAssets(), fontOSLight);
    faceRegular = Typeface.createFromAsset(getAssets(), fontOSRegular);

    imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited()) {
        imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    }//ww  w .  j  ava  2 s . co m

    start = new Date();
    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
    timeSend = oFormat.format(start);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat);

    txtUserName = (TextView) findViewById(R.id.txtChatName);
    edTxtMsg = (EditText) findViewById(R.id.edTxtMsg);
    imgViewProfile = (ImageView) findViewById(R.id.imgViewChat);
    imgViewAddCon = (ImageView) findViewById(R.id.imgAddContact);
    lv = (ListView) findViewById(R.id.listView1);
    layoutLabel = (LinearLayout) findViewById(R.id.layoutLabel);
    txtLabel1 = (TextView) findViewById(R.id.txtLabel1);
    txtLabel2 = (TextView) findViewById(R.id.txtLabel2);
    txtLabel3 = (TextView) findViewById(R.id.txtLabel3);
    txtLabel2.setText(" " + chatRecipient + " ");
    txtLabel1.setTypeface(faceLight);
    txtLabel2.setTypeface(faceRegular);
    txtLabel3.setTypeface(faceLight);
    // lv.smoothScrollToPosition(adapter.getCount() - 1);

    for (ChatContact contact : listChatContact) {
        if (contact.getContactId().equals(recipientStkid)) {
            imgViewAddCon.setVisibility(View.INVISIBLE);
            layoutLabel.setVisibility(View.GONE);
            break;
        }
    }
    Log.i(TAG, " come back again");
    adapter = new ChatArrayAdapter(getApplicationContext(), R.layout.messaging_listview, faceSemi_bold,
            faceRegular);
    lv.setAdapter(adapter);
    // adapter.add(new StikyChat(chatRecipientUrl, "Hello", false, "12.10.2015", "12.1.2014"));

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    // BEGIN_INCLUDE (change_colors)
    // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
    swipeRefreshLayout.setColorScheme(R.color.swipe_color_1, R.color.swipe_color_2, R.color.swipe_color_3,
            R.color.swipe_color_4);
    limitMsg = 7;
    // END_INCLUDE (change_colors)
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.i(" Refresh Layout ", "onRefresh called from SwipeRefreshLayout");
            if (limitMsg < rows) {
                Log.i("Limit Message ", " " + limitMsg);
                limitMsg *= 2;
                fetchRecords();
            } else if (limitMsg > rows && (limitMsg - rows < 7)) {
                fetchRecords();
            } else {
                Log.i("No data ", "to refresh");
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(getApplicationContext(), "No data to refresh!", Toast.LENGTH_SHORT).show();
            }

            // initiateRefresh();
        }
    });

    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout headerLayout = (LinearLayout) findViewById(R.id.header);
    View header = inflator.inflate(R.layout.header, null);

    TextView textView = (TextView) header.findViewById(R.id.textView1);
    textView.setText("StikyChat");
    textView.setTypeface(faceSemi_bold);
    textView.setVisibility(View.VISIBLE);
    headerLayout.addView(header);
    LinearLayout layoutRight = (LinearLayout) header.findViewById(R.id.layoutRight);
    layoutRight.setVisibility(View.GONE);

    txtUserName.setText(chatRecipient);
    Log.i(TAG, "Activity Name " + txtUserName.getText().toString());
    txtUserName.setTypeface(faceSemi_bold);

    String url = "";
    if (chatRecipientUrl.contains("http")) {
        url = chatRecipientUrl;
    } else {
        url = this.getResources().getString(R.string.url) + "/" + chatRecipientUrl;
    }
    addAndroidUniversalImageLoader(imgViewProfile, url);
    //        if (noti && (!message.equals(""))) {
    //            adapter.add(new StikyChat(chatRecipientUrl, message, true, timeSend, ""));
    //            lv.smoothScrollToPosition(adapter.getCount() - 1);
    //        }

    //to show history chats between two users(sender & recipient)
    dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat2 = new SimpleDateFormat("dd MMM HH:mm");
    listHistory = dbHelper.getStikyChat();
    if (listHistory.size() > 0) {
        Collections.reverse(listHistory);
        for (StikyChatTb chatTb : listHistory) {
            String getDate = chatTb.getSendDate();
            String fromStikyBee = chatTb.getSender();
            try {
                String createDate = dateFormat2.format(dateFormat.parse(getDate));
                if (fromStikyBee.equals(pref.getString("stkid", ""))) {
                    adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, ""));
                } else {
                    adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, ""));
                }
                lv.smoothScrollToPosition(adapter.getCount() - 1);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            messageGCM = sharedPreferences.getString("message", "");
            recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", "");
            recipientNameGCM = sharedPreferences.getString("chatRecipientName", "");
            recipientStkidGCM = sharedPreferences.getString("recipientStkid", "");
            recipientTokenGCM = sharedPreferences.getString("recipientToken", "");
            senderTokenGCM = sharedPreferences.getString("senderToken", "");

            Log.i(TAG, "..." + recipientStkidGCM.trim() + " STKID " + recipientStkid.trim() + ":");
            if (firstConnect) {
                if (recipientStkidGCM.trim() == recipientStkid.trim()
                        || recipientStkidGCM.equals(recipientStkid)) {
                    MyGcmListenerService.flagSendNoti = false;
                    Log.i(TAG, " " + message);
                    // (1) get today's date
                    start = new Date();
                    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
                    timeSend = oFormat.format(start);

                    Log.i(TAG, "First connect " + firstConnect);
                    StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, "");
                    Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend);
                    Log.i(TAG, "User " + txtUserName.getText().toString());
                    //txtUserName.setText(message);
                    Log.i(TAG, "User 2 " + txtUserName.getText().toString());
                    adapter.add(stikyChat);
                    adapter.notifyDataSetChanged();
                    //new regTask2().execute("Obj ");
                    lv.smoothScrollToPosition(adapter.getCount() - 1);
                } else {
                    Log.i(TAG, "..." + recipientStkidGCM.trim());
                    Log.i(TAG, "&&&" + recipientStkid.trim());
                    Log.i(TAG, "else casee");
                    //notificaton send
                    flagNotifi = true;
                    new regTask2().execute("Notification");
                }
                firstConnect = false;
            }
        }
    };
}