Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

In this page you can find the example usage for android.app Dialog Dialog.

Prototype

public Dialog(@NonNull Context context) 

Source Link

Document

Creates a dialog window that uses the default dialog theme.

Usage

From source file:com.jalotsav.aalayamnavjivan.ActvtyBookView.java

private void getBookFromFirebaseStorage() {

    mDialogPrgrs = new Dialog(this);
    mDialogPrgrs.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialogPrgrs.setContentView(R.layout.lo_dialog_progress);
    Window window = mDialogPrgrs.getWindow();
    window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    mDialogPrgrs.show();//from  ww w.j  a  v  a 2 s.co m

    TextView tvDialogMessage = mDialogPrgrs.findViewById(R.id.tv_dialog_progress_message);
    final TextView tvDialogPrcntg = mDialogPrgrs.findViewById(R.id.tv_dialog_progress_prcntg);
    tvDialogMessage.setText(mWaitGettingBook);
    tvDialogPrcntg.setText(String.format(Locale.getDefault(), "%1$d%%", 0));

    File bookFilePathLocal = new File(AppConstants.PATH_BOOKS_NAVJIVAN);
    bookFilePathLocal.mkdirs();
    File bookFilePathLocalName = new File(bookFilePathLocal, mRequestedBookName);
    if (bookFilePathLocalName.exists())
        bookFilePathLocalName.delete();

    StorageReference booksNavjivanRef = mStorageRef
            .child(AppConstants.PATH_FIRESTORAGE_BOOK_NAVJIVAN + mRequestedBookName);
    booksNavjivanRef.getFile(bookFilePathLocalName)
            .addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {

                    mDialogPrgrs.dismiss();
                    getBookFromLocalStorage();
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {

                    mDialogPrgrs.dismiss();
                    Snackbar.make(mCrdntrlyot, mServerPrblmMsg, Snackbar.LENGTH_LONG).show();
                }
            }).addOnProgressListener(new OnProgressListener<FileDownloadTask.TaskSnapshot>() {
                @Override
                public void onProgress(FileDownloadTask.TaskSnapshot taskSnapshot) {

                    double progress = (100.0 * taskSnapshot.getBytesTransferred())
                            / taskSnapshot.getTotalByteCount();
                    tvDialogPrcntg.setText(String.format(Locale.getDefault(), "%1$d%%", (int) progress));
                }
            });
}

From source file:com.sentaroh.android.SMBSync.LogFileManagementFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "onCreateDialog");

    mDialog = new Dialog(getActivity());
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setCanceledOnTouchOutside(false);

    if (!terminateRequired)
        initViewWidget();//w ww .  j av  a 2s  . c o m

    return mDialog;
}

From source file:com.whitespider.impact.ble.sensortag.ViewPagerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(mResourceFragmentPager);

    // Set up the action bar
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ImageView view = (ImageView) findViewById(android.R.id.home);
    //view.setPadding(10, 0, 20, 10);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(mResourceIdPager);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from   w  ww .j a v  a2  s  . c  o m*/
        public void onPageSelected(int n) {
            // Log.d(TAG, "onPageSelected: " + n);
            actionBar.setSelectedNavigationItem(n);
        }
    });
    // Create the adapter that will return a fragment for each section
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager.setAdapter(mSectionsPagerAdapter);

    this.getActionBar().setDisplayShowTitleEnabled(false);
    this.getActionBar().setDisplayShowHomeEnabled(false);

    this.busyDialog = new Dialog(this);
    this.busyDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    ;
    this.busyDialog.setContentView(R.layout.frame_progress);
    this.progressBarTextView = (TextView) this.busyDialog.findViewById(R.id.progressTextView);
}

From source file:com.osama.cryptofm.filemanager.listview.FileSelectionManagement.java

void openFile(final String filename) {
    if (SharedData.IS_IN_COPY_MODE) {
        return;/*from  w  ww  .j a v a2s.  co m*/
    }
    if (FileUtils.getExtension(filename).equals("pgp")) {
        Log.d(TAG, "openFile: File name is: " + filename);
        if (SharedData.KEY_PASSWORD == null) {
            final Dialog dialog = new Dialog(mContext);
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.password_dialog_layout);
            dialog.show();
            dialog.findViewById(R.id.cancel_decrypt_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                }
            });
            final EditText editText = (EditText) dialog.findViewById(R.id.key_password);
            dialog.findViewById(R.id.decrypt_file_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (editText.getText().length() < 1) {
                        editText.setError("please give me your encryption password");
                        return;
                    } else {
                        SharedData.KEY_PASSWORD = editText.getText().toString();
                        dialog.dismiss();
                        new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWWORD,
                                SharedData.USERNAME, FileUtils.CURRENT_PATH + filename, SharedData.KEY_PASSWORD)
                                        .execute();
                    }

                }
            });
        } else {
            new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWWORD, SharedData.USERNAME,
                    FileUtils.CURRENT_PATH + filename, SharedData.KEY_PASSWORD).execute();
        }

    } else {
        //open file
        if (SharedData.EXTERNAL_SDCARD_ROOT_PATH != null
                && FileUtils.CURRENT_PATH.contains(SharedData.EXTERNAL_SDCARD_ROOT_PATH)) {
            //open the document file
            DocumentFile file = FileDocumentUtils.getDocumentFile(FileUtils.getFile(filename));
            Intent intent = new Intent();
            intent.setDataAndType(file.getUri(), file.getType());
            intent.setAction(Intent.ACTION_VIEW);
            Intent x = Intent.createChooser(intent, "Open with");
            mContext.startActivity(x);
            return;
        }
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(FileUtils.getExtension(filename));

        Intent intent = new Intent();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            Uri uri = FileProvider.getUriForFile(mContext,
                    mContext.getApplicationContext().getPackageName() + ".provider",
                    FileUtils.getFile(filename));
            intent.setDataAndType(uri, mimeType);
        } else {
            intent.setDataAndType(Uri.fromFile(FileUtils.getFile(filename)), mimeType);
        }
        intent.setAction(Intent.ACTION_VIEW);
        Intent x = Intent.createChooser(intent, "Open with: ");
        mContext.startActivity(x);
    }
}

From source file:com.angelhack.person2person.AbstractGetNameTask.java

@Override
protected void onPostExecute(Void result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);

    try {/*from   w  ww. j a v  a2  s  . c  o  m*/
        System.out.println("On Home Page***" + AbstractGetNameTask.GOOGLE_USER_DATA);
        JSONObject profileData = new JSONObject(AbstractGetNameTask.GOOGLE_USER_DATA);

        if (profileData.has("picture")) {
            SocialMedia_New.userImageUrl = profileData.getString("picture");

        }
        if (profileData.has("name")) {
            SocialMedia_New.textName = profileData.getString("name");
            //      SocialMedia_New.textViewName.setText(SocialMedia_New.textName);
        }

        dialog.dismiss();

        final Dialog alert_dialog = new Dialog(mActivity);
        alert_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        alert_dialog.setContentView(R.layout.dialog_custom);

        TextView content = (TextView) alert_dialog.findViewById(R.id.content_tv_id);
        TextView ok = (TextView) alert_dialog.findViewById(R.id.ok_tv_id);
        profile = (ImageView) alert_dialog.findViewById(R.id.image_id);

        new GetImageFromUrl().execute(SocialMedia_New.userImageUrl);

        content.setText(" Welcome  " + SocialMedia_New.textName);
        ok.setText("Stay Connect with Us..!");

        ok.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent intent = new Intent(mActivity, Home_Activity.class);
                mActivity.startActivity(intent);

                mActivity.overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);

                mActivity.finish();

            }
        });

        alert_dialog.show();

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

}

From source file:com.medisa.myspacecal.MainActivity.java

@Override
public void onSideNavigationItemClick(int itemId) {
    switch (itemId) {
    case R.id.side_navigation_menu_calendario:
        range = 0;/*w  ww .  ja  va 2s  .  c o  m*/
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);
        break;
    case R.id.side_navigation_menu_date_range:
        // custom dialog
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.custom_range_date);
        dialog.setTitle("Data range");

        // set the custom dialog components - text, image and button
        final DatePicker dpStart = (DatePicker) dialog.findViewById(R.id.dpStart);
        final DatePicker dpEnd = (DatePicker) dialog.findViewById(R.id.dpEnd);
        Button btnSalva = (Button) dialog.findViewById(R.id.btnSalva);
        final CheckBox cbIntegralBox = (CheckBox) dialog.findViewById(R.id.cbIntegral);
        // if button is clicked, close the custom dialog
        btnSalva.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dateStart = Funzioni.addZero(dpStart.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpStart.getMonth() + 1, 2) + "-" + dpStart.getYear();
                dateEnd = Funzioni.addZero(dpEnd.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpEnd.getMonth() + 1, 2) + "-" + dpEnd.getYear();
                Log.e(dateStart, dateEnd);
                if (cbIntegralBox.isChecked()) {
                    //#########################JSON
                    AsyncHttpClient client = new AsyncHttpClient();
                    client.get("http://199.180.196.10/json/integral?startdate=" + dateStart + "&enddate="
                            + dateEnd, new AsyncHttpResponseHandler() {
                                @Override
                                public void onSuccess(String response) {
                                    Log.e("SCARICATO", response + "");
                                    JSONArray jObject;
                                    satellitiIntegral = new ArrayList<SatelliteIntegral>();
                                    try {
                                        jObject = new JSONArray(response);
                                        for (int i = 0; i < jObject.length(); i++) {
                                            JSONArray menuObject = jObject.getJSONArray(i);
                                            String dataStart = menuObject.getString(0);
                                            String dataEnd = menuObject.getString(1);
                                            String raj2000 = menuObject.getString(2);
                                            String decj2000 = menuObject.getString(3);
                                            String target = menuObject.getString(4);
                                            Log.e("", dataStart + " " + dataEnd + " " + raj2000 + " " + decj2000
                                                    + " " + target);
                                            satellitiIntegral.add(new SatelliteIntegral(dataStart, dataEnd,
                                                    raj2000, decj2000, target));
                                        }
                                        adapter = new GridCellAdapter(getApplicationContext(),
                                                R.id.day_gridcell, month, year);
                                        adapter.notifyDataSetChanged();
                                        calendarView.setAdapter(adapter);

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

                dialog.dismiss();
                //###############################################
                //                   Intent mioIntent= new Intent(ctx, MainActivity.class);
                //                   startActivity(mioIntent);
            }

        });
        dialog.show();
        break;
    //            case R.id.side_navigation_menu_item3:
    //                invokeActivity(getString(R.string.title3), R.drawable.ic_android3);
    //                break;
    //
    //            case R.id.side_navigation_menu_item4:
    //                invokeActivity(getString(R.string.title4), R.drawable.ic_android4);
    //                break;
    //
    //            case R.id.side_navigation_menu_item5:
    //                invokeActivity(getString(R.string.title5), R.drawable.ic_android5);
    //                break;

    default:
        return;
    }
}

From source file:com.privacity.PerfilActivity.java

public void cancelarPerfil(View view) {
    JSONObject jsonObject = com.cancelarPerfil(codigo);
    Dialog dialogo = new Dialog(this);
    //Tratamiento de errores
    if (jsonObject.has("Error") || jsonObject.has("detail")) {
        dialogo.setTitle(getResources().getString(R.string.errorDeConexion));
        try {/*from   ww  w .  j a  v a2s  .  c o m*/
            String error = jsonObject.getString("Error");
            dialogo.setTitle(error);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } //IF
    else { //Si ha tenido exito
        dialogo.setTitle((getResources().getString(R.string.perfilCancelado)));
        botonCancelar.setVisibility(View.INVISIBLE);
        botonAceptar.setVisibility(View.VISIBLE);
    }
    dialogo.show();
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display introduction to the user for first time launch
 * /*from   www .j  ava2 s.  co m*/
 * @param context
 */
public static void displayIntroduction(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.introduction);

    Typeface lightTypeface = ((LauncherApplication) context.getApplicationContext()).getLightTypeface(context);

    TextView titleTextView = (TextView) dialog.findViewById(R.id.intro_title);
    titleTextView.setTypeface(lightTypeface);
    TextView textView1 = (TextView) dialog.findViewById(R.id.intro_text1);
    textView1.setTypeface(lightTypeface);
    TextView textView2 = (TextView) dialog.findViewById(R.id.intro_text2);
    textView2.setTypeface(lightTypeface);

    ((Button) dialog.findViewById(R.id.intro_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_INTRODUCTION);
}

From source file:com.slownet5.pgprootexplorer.filemanager.listview.FileSelectionManagement.java

void openFile(final String filename) {
    if (SharedData.IS_IN_COPY_MODE) {
        return;//w ww.ja  v a  2  s  .c  om
    }
    if (FileUtils.isEncryptedFile(filename)) {
        Log.d(TAG, "openFile: File name is: " + filename);
        if (SharedData.KEY_PASSWORD == null) {
            final Dialog dialog = new Dialog(mContext);
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.password_dialog_layout);
            dialog.show();
            dialog.findViewById(R.id.cancel_decrypt_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                }
            });
            final EditText editText = (EditText) dialog.findViewById(R.id.key_password);
            dialog.findViewById(R.id.decrypt_file_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (editText.getText().length() < 1) {
                        editText.setError("please give me your encryption password");
                        return;
                    } else {
                        SharedData.KEY_PASSWORD = editText.getText().toString();
                        dialog.dismiss();
                        new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWORD, SharedData.USERNAME,
                                filename, SharedData.KEY_PASSWORD).execute();
                    }

                }
            });
        } else {
            new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWORD, SharedData.USERNAME, filename,
                    SharedData.KEY_PASSWORD).execute();
        }

    } else {
        UiUtils.openFile(filename, mContext, mFileListAdapter);
    }
}

From source file:com.sentaroh.android.TaskAutomation.Log.LogFileManagementFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "onCreateDialog");

    mDialog = new Dialog(getActivity());
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (!mTerminateRequired) {
        initViewWidget();/*w  ww.j  a  va 2 s . c o m*/
    }

    return mDialog;
}