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.wenwen.chatuidemo.activity.ContactSickFragment.java

/**
 * ??????//w w  w. j  a  v  a 2 s .c  o m
 */
private void getContactList() {
    try {
        RequestParams params = new RequestParams();
        params.put("uid", DemoApplication.getInstance().getUserUid());
        params.put("flag", "1");
        params.put("pageindex", "1");
        params.put("pagesize", "20");
        pd = new ProgressDialog(getActivity());
        pd.setMessage("?...");
        HttpClientRequest.post(Urls.FRIENDSGET, params, 3000, new AsyncHttpResponseHandler() {
            @Override
            public void onStart() {
                // TODO Auto-generated method stub
                super.onStart();
                pd.show();
            }

            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
                // TODO Auto-generated method stub
                String res = new String(arg2);
                DebugLog.i(TAG, "==" + res);
                JsonParser parser = new JsonParser();
                JsonArray Jarray = parser.parse(res).getAsJsonArray();
                MyUser1 myuser1 = null;
                ScikUser user = null;
                for (JsonElement obj : Jarray) {
                    myuser1 = gson.fromJson(obj, MyUser1.class);
                    if (!myuser1.getAccount_name().equals("") && myuser1.getAccount_name() != null) {
                        contactList.add(myuser1);
                    }
                }
                // ?
                Collections.sort(contactList, new Comparator<MyUser1>() {
                    @Override
                    public int compare(MyUser1 lhs, MyUser1 rhs) {
                        return lhs.getAccount_username().compareTo(rhs.getAccount_username());
                    }
                });
                adapter = new SickContactAdapter(getActivity(), contactList);
                listView.setAdapter(adapter);
            }

            @Override
            public void onFinish() {
                // TODO Auto-generated method stub
                super.onFinish();
                pd.dismiss();
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
                // TODO Auto-generated method stub
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.burntout.burntout.AddCarActivity.java

public void loginBurnt(String vType, String makeModel, String vState, String vPlateNumber) {

    pm = new ProgressDialog(this);
    pm.show();/*  w w w. j  a  v a 2  s. co  m*/

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

    StringCheck stringCheck = new StringCheck();
    makeModel = stringCheck.cleanseSpecialChars(makeModel);
    vPlateNumber = stringCheck.cleanseSpecialChars(vPlateNumber);

    if (checkInputs(makeModel, vPlateNumber)) {

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

        nameValuePairs.add(new BasicNameValuePair("email", email));
        nameValuePairs.add(new BasicNameValuePair("vehicle_type", vType));
        nameValuePairs.add(new BasicNameValuePair("car_model", makeModel));
        nameValuePairs.add(new BasicNameValuePair("plate_state", vState));
        nameValuePairs.add(new BasicNameValuePair("plate_number", vPlateNumber));

        addVehicle.executePosts(nameValuePairs,
                "http://combustioninnovation.com/production/Goodyear/php/addvehicle.php");
    } else {
        pm.dismiss();
        pm = null;
    }

}

From source file:edu.usf.cutr.opentripplanner.android.tasks.ServerSelector.java

/**
 * Constructs a new ServerSelector//from  ww w .jav  a  2 s .  c  o m
 * @param context
 * @param dataSource
 * @param callback
 * @param mustRefreshList true if we should download a new list of servers from the Google Doc, false if we should use cached list of servers
 * @param isAutoDetectEnabled true if we should automatically compare the user's current location to the bounding boxes of OTP servers, false if we should prompt the user to pick the OTP server manually
 * @param showDialog true if a progress dialog is requested
 */
public ServerSelector(WeakReference<Activity> activity, Context context, ServersDataSource dataSource,
        ServerSelectorCompleteListener callback, boolean mustRefreshList, boolean showDialog) {
    this.activity = activity;
    this.context = context;
    this.dataSource = dataSource;
    this.callback = callback;
    this.mustRefreshList = mustRefreshList;
    this.showDialog = false;//showDialog;
    if ((activity.get() != null) && showDialog) {
        progressDialog = new ProgressDialog(activity.get());
    }
}

From source file:io.v.android.apps.syncslides.SignInActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mAccountName = mPrefs.getString(SignInActivity.PREF_USER_ACCOUNT_NAME, "");
    mProgressDialog = new ProgressDialog(this);
    if (mAccountName.isEmpty()) {
        mProgressDialog.setMessage("Signing in...");
        mProgressDialog.show();//from  w  w w.j  a  va2  s  .c  o  m
        pickAccount();
    } else {
        finishActivity();
    }
}

From source file:com.esri.arcgisruntime.sample.editfeatureattachments.EditAttachmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.attachments);

    Bundle bundle = getIntent().getExtras();
    String s = bundle.getString(getApplication().getString(R.string.attribute));
    noOfAttachments = bundle.getInt(getApplication().getString(R.string.noOfAttachments));

    // Build a alert dialog with specified style
    builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle);

    // inflate the floating action button
    addAttachmentFab = (FloatingActionButton) findViewById(R.id.addAttachmentFAB);

    // select an image to upload as an attachment
    addAttachmentFab.setOnClickListener(new View.OnClickListener() {
        @Override/*from  ww w  .ja  v  a  2 s .  c  om*/
        public void onClick(View v) {

            if (!permissionsGranted) {
                getPermissions(requestCodeGallery);
            } else {
                selectAttachment();
            }

        }
    });

    mServiceFeatureTable = new ServiceFeatureTable(getResources().getString(R.string.sample_service_url));

    progressDialog = new ProgressDialog(this);

    // display progress dialog if selected feature has attachments
    if (noOfAttachments != 0) {
        progressDialog.setTitle(getApplication().getString(R.string.fetching_attachments));
        progressDialog.setMessage(getApplication().getString(R.string.wait));

        progressDialog.show();
    } else {
        Toast.makeText(EditAttachmentActivity.this,
                getApplication().getString(R.string.empty_attachment_message), Toast.LENGTH_LONG).show();
    }

    // inflate the list view
    list = (ListView) findViewById(R.id.listView);
    // create custom adapter
    adapter = new CustomList(EditAttachmentActivity.this, attachmentList);
    // set custom adapter on the list
    list.setAdapter(adapter);
    fetchAttachmentsFromServer(s);

    // listener on attachment items to download the attachment
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {

            listPosition = position;
            listView = view;
            if (!permissionsGranted) {
                getPermissions(requestCodeFolder);
            } else {
                fetchAttachmentAsync(position, view);
            }
        }
    });

    //set onlong click listener to delete the attachment
    list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int pos, long id) {

            builder.setMessage(getApplication().getString(R.string.delete_query));
            builder.setCancelable(true);

            builder.setPositiveButton(getResources().getString(R.string.yes),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            deleteAttachment(pos);
                            dialog.dismiss();
                        }
                    });
            builder.setNegativeButton(getResources().getString(R.string.no),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
            return true;
        }
    });
}

From source file:it.iziozi.iziozi.gui.IORemoteImageSearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smimages_search);

    mGridView = (GridView) findViewById(R.id.ImageSearchGridView);
    mEmptyTextView = (TextView) findViewById(R.id.ImageSearchNotFoundText);
    mEmptyTextView.setText(getString(R.string.no_picto_found));
    mEmptyTextView.setVisibility(View.INVISIBLE);

    /*//from   ww  w  .j av  a  2  s.  c  o m
            mGridView.setNumColumns(5);
    */
    mGridView.setAdapter(new RemoteImagesGridAdapter(this, R.layout.image_grid_cell));

    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (isExternalStorageReadable()) {
                final IOPictogram pictogram = mPictograms.get(position);

                File baseFolder = new File(Environment.getExternalStorageDirectory() + "/"
                        + IOApplication.APPLICATION_FOLDER + "/pictograms");
                Character pictoChar = pictogram.getFilePath().charAt(0);
                File pictoFolder = new File(baseFolder + "/" + pictoChar + "/");
                final File pictoFile = new File(baseFolder + "/" + pictoChar + "/" + pictogram.getFilePath());

                final Intent backIntent = new Intent(getApplicationContext(), IOCreateButtonActivity.class);
                backIntent.putExtra(IOCreateButtonActivity.IMAGE_URL, pictogram.getUrl());
                backIntent.putExtra(IOCreateButtonActivity.IMAGE_TITLE, pictogram.getDescription());

                if (!pictoFile.exists() && isExternalStorageWritable()) {

                    pictoFolder.mkdirs();

                    //download it

                    mBarProgressDialog = new ProgressDialog(IORemoteImageSearchActivity.this);
                    mBarProgressDialog.setTitle(getString(R.string.image_download_title));
                    mBarProgressDialog.setMessage(getString(R.string.download_text));
                    mBarProgressDialog.setProgressStyle(mBarProgressDialog.STYLE_HORIZONTAL);
                    mBarProgressDialog.setProgress(0);
                    mBarProgressDialog.setMax(100);
                    mBarProgressDialog.show();

                    AsyncHttpClient client = new AsyncHttpClient();
                    client.get(pictogram.getUrl(), new FileAsyncHttpResponseHandler(pictoFile) {
                        @Override
                        public void onFailure(int statusCode, Header[] headers, Throwable throwable,
                                File file) {
                            mBarProgressDialog.cancel();
                            Toast.makeText(getApplicationContext(), getString(R.string.download_error),
                                    Toast.LENGTH_LONG).show();
                        }

                        @Override
                        public void onProgress(int bytesWritten, int totalSize) {
                            super.onProgress(bytesWritten, totalSize);

                            int progress = bytesWritten / totalSize;
                            progress *= 100;

                            mBarProgressDialog.setProgress(progress);
                        }

                        @Override
                        public void onSuccess(int statusCode, Header[] headers, File downloadedFile) {

                            if (pictoFile.exists()) {
                                backIntent.putExtra(IOCreateButtonActivity.IMAGE_FILE, pictoFile.toString());
                                finish();
                                startActivity(backIntent);
                            } else {
                                Toast.makeText(getApplicationContext(), getString(R.string.image_save_error),
                                        Toast.LENGTH_SHORT).show();
                                mBarProgressDialog.cancel();
                            }
                        }
                    });
                } else {
                    //file already exists
                    backIntent.putExtra(IOCreateButtonActivity.IMAGE_FILE, pictoFile.toString());
                    finish();
                    startActivity(backIntent);
                }
            }
        }
    });

    ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    if (activeNetwork == null) {
        new AlertDialog.Builder(this).setCancelable(true).setTitle(getString(R.string.warning))
                .setMessage(getString(R.string.data_connection_needed))
                .setNegativeButton(getString(R.string.continue_string), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).create().show();
    } else
        handleIntent(getIntent());

}

From source file:arc.noaa.weather.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Initialize the associated SharedPreferences file with default values
    PreferenceManager.setDefaultValues(this, R.xml.prefs, false);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    setTheme(theme = getTheme(prefs.getString("theme", "fresh")));
    boolean darkTheme = theme == R.style.AppTheme_NoActionBar_Dark
            || theme == R.style.AppTheme_NoActionBar_Classic_Dark;

    // Initiate activity
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);
    appView = findViewById(R.id.viewApp);

    progressDialog = new ProgressDialog(MainActivity.this);

    // Load toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from w w  w  .ja va 2s .  c om
    if (darkTheme) {
        toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay_Dark);
    }

    // Initialize textboxes
    todayTemperature = (TextView) findViewById(R.id.todayTemperature);
    todayDescription = (TextView) findViewById(R.id.todayDescription);
    todayWind = (TextView) findViewById(R.id.todayWind);
    todayPressure = (TextView) findViewById(R.id.todayPressure);
    todayHumidity = (TextView) findViewById(R.id.todayHumidity);
    todaySunrise = (TextView) findViewById(R.id.todaySunrise);
    todaySunset = (TextView) findViewById(R.id.todaySunset);
    lastUpdate = (TextView) findViewById(R.id.lastUpdate);
    todayIcon = (TextView) findViewById(R.id.todayIcon);
    weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf");
    todayIcon.setTypeface(weatherFont);

    // Initialize viewPager
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    tabLayout = (TabLayout) findViewById(R.id.tabs);

    destroyed = false;

    initMappings();

    // Preload data from cache
    preloadWeather();
    updateLastUpdateTime();

    // Set autoupdater
    AlarmReceiver.setRecurringAlarm(this);
}

From source file:vee.vee.string.downloader.StringDownloader.java

/**
 * @see android.os.AsyncTask#doInBackground(java.lang.Object[])
 *//*from  w w w. j  av  a  2s.  c o  m*/
@Override
protected String doInBackground(String... params) {
    if (activity
            .checkCallingOrSelfPermission(Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED) {
        mSetterGetter.setDownloadStatus(false);
        publishProgress(1000);
        Log.wtf(tag, StringDownloaderSnippets.noInternetPermission);
        return null;
    }

    if (debug) {
        Log.w(tag, "doInBackground");
        Log.w(tag, "Number of URL(s) :<>: " + params.length);
    }
    String url;

    for (int i = 0; i < params.length; i++) {

        if (debug) {
            Log.v(tag, "Executing");
        }

        url = params[i];

        publishProgress(1);
        if (!dialog.isShowing()) {

            try {
                dialog = new ProgressDialog(activity);
                dialog.setCancelable(false);
                dialog.setCanceledOnTouchOutside(false);
                dialog.show();
            } catch (final Exception e) {
                if (debug) {
                    Log.wtf(tag, "Dialog Exception" + e.getMessage());
                }
                continue;
            }

        }

        result = null;
        try {

            url = new URL(url).toURI().toString();

            if (debug) {
                Log.w(tag, "Executing URL :<>: " + (i + 1));
                Log.v(tag, url);
            }

            httpGet = new HttpGet(url);

            response = httpClient.execute(httpGet, mCookieJar.getLocalContext());

            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && response.getEntity() != null) {

                publishProgress(2);

                final HttpEntity httpEntity = response.getEntity();

                result = EntityUtils.toString(httpEntity);

                // Do NOT UPDATE UI IN THREAD, Move this to PostExe
                // strgDwnLsnr.stringDownloadedSuccessfully(result);

                if (debug) {
                    Log.i(tag, "URL > " + (i + 1) + " > Downloaded Successfully");
                }
                mSetterGetter.setDownloadStatus(true);

                if (mCookieJar.getCookieStore() != null) {
                    mCookieJar.setCookieStore(mCookieJar.getCookieStore());
                }
                if (mCookieJar.getLocalContext() != null) {
                    mCookieJar.setLocalContext(mCookieJar.getLocalContext());
                }

                if (result != null) {
                    strgDwnLsnr.stringDownloadedSuccessfully(result, url, i, mCookieJar.getCookieStore());
                } else {

                    /* There is highly NO chance of coming here */

                    reasonForFailure = StringDownloaderSnippets.serverScrewed;
                    strgDwnLsnr.errorInServerSide(response.getStatusLine().getStatusCode(),
                            getStatusEquivalent(response.getStatusLine().getStatusCode()), url, i,
                            mCookieJar.getCookieStore());
                }

            } else {

                strgDwnLsnr.errorInServerSide(response.getStatusLine().getStatusCode(),
                        getStatusEquivalent(response.getStatusLine().getStatusCode()), url, i,
                        mCookieJar.getCookieStore());
                result = null;
                mSetterGetter.setDownloadStatus(false);
                publishProgress(500);
                // Do NOT UPDATE UI IN THREAD, Move this to PostExe
                // strgDwnLsnr.dataDownloadFailed();
            }
        } catch (final Exception e) {

            result = null;
            mSetterGetter.setDownloadStatus(false);
            publishProgress(1000);
            reasonForFailure = e.getMessage();
            strgDwnLsnr.stringFetchingFailed(reasonForFailure, url, i, mCookieJar.getCookieStore());
            if (debug) {
                Log.wtf(tag, reasonForFailure);
            }

        }

    }

    return result;
}

From source file:com.google.zxing.client.android.history.HistoryActivity.java

@Override
protected void onListItemClick(ListView l, View v, final int positionItemList, long id) {
    progDialog = new ProgressDialog(this);

    if (adapter.getItem(positionItemList).getResult() != null) {
        Intent intent = new Intent(this, CaptureActivity.class);
        intent.putExtra(Intents.History.ITEM_NUMBER, positionItemList);
        setResult(Activity.RESULT_OK, intent);

        AlertDialog.Builder builder2 = new AlertDialog.Builder(this, 3);
        builder2.setMessage(getBaseContext().getResources().getString(R.string.alerta_enviar_dado));
        builder2.setCancelable(true);/*from  ww w . j a  v a 2  s . com*/
        builder2.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i2) {

                /*
                 * mandando somente um dado para o servidor
                 */
                boolean conectado = verificaConexao();
                if (conectado) {
                    try {
                        progDialog.setTitle(
                                getBaseContext().getResources().getString(R.string.alerta_enviando_dado));
                        progDialog.setMessage(
                                getBaseContext().getResources().getString(R.string.alerta_dado_sendo_enviado));
                        progDialog.setIcon(android.R.drawable.ic_menu_upload);
                        progDialog.show();

                        String dado = adapter.getItem(positionItemList).getDisplay();
                        enviarItemHistorico(dado);

                    } catch (Exception ex) {
                        // TODO: handle exception
                        ex.printStackTrace();
                    }
                }
                dialog.dismiss();
                reloadHistoryItems();
            }
        });
        builder2.setNegativeButton(R.string.button_cancel, null);
        builder2.show();

    }

}