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:Main.java

public static Dialog backgroundProcess(Context context, final Runnable run, final boolean showDialog,
        String loadingComment) {// w w  w  . j a  v a 2  s  .c om
    final ProgressDialog progressdialog = creativeProgressBar(context, loadingComment);
    if (showDialog)
        progressdialog.show();
    Runnable wrapper = new Runnable() {
        public void run() {
            run.run();
            if (showDialog)
                progressdialog.dismiss();
        }
    };
    Thread thread = new Thread(wrapper);
    thread.setDaemon(true);
    thread.start();
    return progressdialog;
}

From source file:ru.gkpromtech.exhibition.organizations.OrganizationFilesDownloader.java

public static void download(final Context context, final Organization organization) {
    final ProgressDialog dialog = ProgressDialog.show(context, context.getString(R.string.please_wait),
            context.getString(R.string.loading_materials_info), false);

    ServiceClient.getJson("organizations/files?id=" + organization.id, new Callback<JsonNode>() {
        @Override//  w  ww  . j a  v  a 2  s .  c  o  m
        public void onSuccess(JsonNode data) throws Exception {
            dialog.dismiss();

            String url = data.get("url").asText();
            int size = data.get("size").asInt();
            confirmAndDownload(context, organization, url, size);
        }

        @Override
        public void onError(Throwable exception) {
            dialog.dismiss();
            Toast.makeText(context, R.string.error_loading_data, Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:org.liberty.android.fantastischmemo.utils.AMGUIUtility.java

public static void doProgressTask(final Activity activity, final String progressTitle,
        final String progressMessage, final ProgressTask task) {
    final ProgressDialog mProgressDialog = ProgressDialog.show(activity, progressTitle, progressMessage, true);
    final Handler handler = new Handler();
    new Thread() {
        public void run() {
            try {
                task.doHeavyTask();/*from w  ww.  j a v a  2  s  . c o m*/
                handler.post(new Runnable() {
                    public void run() {
                        task.doUITask();
                        mProgressDialog.dismiss();
                    }
                });
            } catch (final Exception e) {
                handler.post(new Runnable() {
                    public void run() {
                        mProgressDialog.dismiss();
                        displayException(activity, activity.getString(R.string.exception_text),
                                activity.getString(R.string.exception_message), e);
                        Log.e(TAG, "Error running progress task", e);
                    }
                });
            }
        }
    }.start();
}

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/* www  . j av a  2 s  .co  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:de.unistuttgart.ipvs.pmp.apps.infoapp.InfoAppActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int displayed = this.mPager.getCurrentItem();
    IPanel panel = this.mAdapter.getPanel(displayed);
    ProgressDialog dialog;
    switch (item.getItemId()) {
    case R.id.menu_refresh:
        dialog = ProgressDialog.show(this, "", getText(R.string.dialog_refresh), true);
        panel.update();/*w  w w .  ja v  a  2  s. c o m*/
        dialog.dismiss();
        break;
    case R.id.menu_upload:
        dialog = ProgressDialog.show(this, "", getText(R.string.dialog_upload), true);
        panel.upload(dialog);
        break;
    }
    return true;
}

From source file:com.softminds.matrixcalculator.OperationFragments.TraceFragment.java

private void RunToGetTrace(int position, ProgressDialog progressDialog) {
    double result = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(position).getTrace();
    final String formatted = GetText(result);
    progressDialog.dismiss();
    String formatted2 = getString(R.string.trace_is) + " " + formatted;
    new AlertDialog.Builder(getContext()).setCancelable(true).setMessage(formatted2)
            .setTitle(R.string.trace_text)
            .setPositiveButton(R.string.copy, new DialogInterface.OnClickListener() {
                @Override/* www .  j  ava 2 s  .  c om*/
                public void onClick(DialogInterface dialog, int which) {
                    ClipboardManager manager = (ClipboardManager) getContext()
                            .getSystemService(Context.CLIPBOARD_SERVICE);
                    ClipData data = ClipData.newPlainText("TRACE_RES", formatted);
                    manager.setPrimaryClip(data);
                    if (manager.hasPrimaryClip())
                        Toast.makeText(getContext(), R.string.CopyToClip, Toast.LENGTH_SHORT).show();
                    else
                        Log.e(TAG, "Cannot Put Data to Clip");
                    dialog.dismiss();
                }
            }).setNeutralButton(R.string.Done, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).show();
}

From source file:com.dedipower.portal.android.InvoiceLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.invoicelanding);
    final ListView list = (ListView) findViewById(R.id.InvoiceList);

    final ProgressDialog dialog = ProgressDialog.show(this, "DediPortal", "Please wait: loading data....",
            true);/*from   w w w .  j  a  v  a  2s  .c om*/
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                InvoiceAdaptor adapter = new InvoiceAdaptor(InvoiceLanding.this, listOfInvoices, API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                InvoiceAPIReturn = API.PortalQueryHack("invoices", "", "");
                Success = InvoiceAPIReturn.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                Log.i("API", "Success was false");
                try {
                    ErrorMessage = InvoiceAPIReturn.getJSONObject("hackReturn").getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                int InvoiceCount = 0;
                Log.i("APIFuncs", InvoiceAPIReturn.toString());
                try {
                    Invoices = InvoiceAPIReturn.getJSONObject("hackReturn").getJSONArray("data");
                    InvoiceCount = Invoices.length();
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There don't appear to be any invoices for your account.....";
                    InvoiceCount = 0;
                    Log.e("API", "There was an eror parsing the array");
                    Log.e("API", e.getMessage());
                }

                //OK lets actually do something useful

                if (InvoiceCount == 0) {
                    Success = "false";
                    ErrorMessage = "There are no invoices for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < InvoiceCount; i++) {
                    JSONObject CurrentInvoice = null;
                    try {
                        CurrentInvoice = Invoices.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        if (CurrentInvoice.getString("type").equals("invoice"))
                            listOfInvoices.add(new Invoices(CurrentInvoice.getString("ref"),
                                    CurrentInvoice.getDouble("amount"), CurrentInvoice.getString("details"),
                                    CurrentInvoice.getLong("date")));
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}

From source file:com.crossword.activity.FeedbackActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.feed_send:
        final ProgressDialog progress = ProgressDialog.show(FeedbackActivity.this, "",
                getResources().getString(R.string.feedback_sending), true);
        new Thread((new Runnable() {
            @Override/*  www  . j av a  2  s . com*/
            public void run() {
                postMessage();
                progress.dismiss();
                runOnUiThread(new Runnable() {
                    public void run() {
                        new AlertDialog.Builder(FeedbackActivity.this).setMessage(FeedbackActivity.this.error)
                                .setCancelable(false)
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();
                                    }
                                }).create().show();
                    }
                });
            }
        })).start();
    }
}

From source file:com.dedipower.portal.android.TicketLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ticketlanding);
    final ListView list = (ListView) findViewById(R.id.TicketList);

    final ProgressDialog dialog = ProgressDialog.show(this, "DediPortal", "Please wait: loading data....",
            true);//  ww w. j ava 2s  .co  m
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                OpenTicketsAdaptor adapter = new OpenTicketsAdaptor(TicketLanding.this, listOfTickets,
                        API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                TicketAPI = API.PortalQuery("tickets", "none");
                Success = TicketAPI.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                try {
                    ErrorMessage = TicketAPI.getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                Log.i("APIFuncs", TicketAPI.toString());
                try {
                    Tickets = TicketAPI.getJSONArray("tickets");
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There are no open tickets for your account.";
                }

                //OK lets actually do something useful
                //ListView list = (ListView)findViewById(R.id.TicketList);
                //List<OpenTickets> listOfTickets = new ArrayList<OpenTickets>();
                int TicketCount = Tickets.length();

                if (TicketCount == 0) {
                    ErrorMessage = "There are no open tickets for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < TicketCount; i++) {
                    JSONObject CurrentTicket = null;
                    try {
                        CurrentTicket = Tickets.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        listOfTickets.add(new OpenTickets(CurrentTicket.getString("status"),
                                CurrentTicket.getInt("id"), CurrentTicket.getString("server"),
                                CurrentTicket.getString("email"), CurrentTicket.getString("subject"),
                                CurrentTicket.getInt("createdat"), CurrentTicket.getInt("lastupdate"), false));
                        //CurrentTicket.getBoolean("subscriber")));
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}

From source file:net.networksaremadeofstring.pulsant.portal.InvoiceLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.invoicelanding);
    final ListView list = (ListView) findViewById(R.id.InvoiceList);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Accounting");

    final ProgressDialog dialog = ProgressDialog.show(this, "Pulsant Portal", "Please wait: loading data....",
            true);//from w  ww  .  j  a v a  2s.  c om
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                InvoiceAdaptor adapter = new InvoiceAdaptor(InvoiceLanding.this, listOfInvoices, API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                InvoiceAPIReturn = API.PortalQueryHack("invoices", "", "");
                Success = InvoiceAPIReturn.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                Log.i("API", "Success was false");
                try {
                    ErrorMessage = InvoiceAPIReturn.getJSONObject("hackReturn").getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                int InvoiceCount = 0;
                Log.i("APIFuncs", InvoiceAPIReturn.toString());
                try {
                    Invoices = InvoiceAPIReturn.getJSONObject("hackReturn").getJSONArray("data");
                    InvoiceCount = Invoices.length();
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There don't appear to be any invoices for your account.....";
                    InvoiceCount = 0;
                    Log.e("API", "There was an eror parsing the array");
                    Log.e("API", e.getMessage());
                }

                //OK lets actually do something useful

                if (InvoiceCount == 0) {
                    Success = "false";
                    ErrorMessage = "There are no invoices for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < InvoiceCount; i++) {
                    JSONObject CurrentInvoice = null;
                    try {
                        CurrentInvoice = Invoices.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        if (CurrentInvoice.getString("type").equals("invoice")) {
                            listOfInvoices.add(new Invoices(CurrentInvoice.getString("ref"),
                                    CurrentInvoice.getDouble("amount"), CurrentInvoice.getString("details"),
                                    CurrentInvoice.getString("date")));
                        } else {
                            Receipts.add(new Receipts(CurrentInvoice.getString("ref"),
                                    CurrentInvoice.getDouble("amount"), CurrentInvoice.getString("details"),
                                    CurrentInvoice.getString("date")));
                        }
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}