Search in sources :

Example 1 with ProgressDialog

use of carbon.dialog.ProgressDialog in project Carbon by ZieIony.

the class ProgressDialogActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initToolbar();
    EditText titleText = findViewById(R.id.titleText);
    EditText messageText = findViewById(R.id.messageText);
    EditText buttonText = findViewById(R.id.buttonText);
    findViewById(R.id.showProgressDialog).setOnClickListener(view -> {
        ProgressDialog dialog = new ProgressDialog(this);
        if (titleText.length() > 0)
            dialog.setTitle(titleText.getText());
        if (buttonText.length() > 0)
            dialog.addButton(buttonText.getText().toString(), null);
        Handler handler = new Handler(Looper.getMainLooper());
        Runnable dismissRunnable = dialog::dismiss;
        dialog.setOnDismissListener(dialogInterface -> handler.removeCallbacks(dismissRunnable));
        dialog.setText(messageText.getText());
        dialog.show();
        handler.postDelayed(dialog::dismiss, 2000);
    });
}
Also used : EditText(carbon.widget.EditText) Handler(android.os.Handler) ProgressDialog(carbon.dialog.ProgressDialog)

Aggregations

Handler (android.os.Handler)1 ProgressDialog (carbon.dialog.ProgressDialog)1 EditText (carbon.widget.EditText)1