Java Code Examples for com.afollestad.materialdialogs.MaterialDialog#getCustomView()

The following examples show how to use com.afollestad.materialdialogs.MaterialDialog#getCustomView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SharedPreferenceActivity.java    From MagicalCamera with Apache License 2.0 6 votes vote down vote up
private View popUpLayout(final int idLayout) {
    MaterialDialog dialog = new MaterialDialog.Builder(this)
            .title(R.string.shared_change_color)
            .customView(idLayout, true)
            .positiveText(R.string.shared_accept)
            .autoDismiss(false)
            .backgroundColor(getResources().getColor(R.color.colorWhite))
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                    materialDialog.dismiss();
                    materialDialog.cancel();
                }
            })

            .show();

    return dialog.getCustomView();
}
 
Example 2
Source File: SearchFragment.java    From redgram-for-reddit with GNU General Public License v3.0 6 votes vote down vote up
private void performPositiveEvent(MaterialDialog dialog) {
    RelativeLayout layout = (RelativeLayout) dialog.getCustomView();
    EditText editText = (EditText) layout.findViewById(R.id.filter_query);

    String query = editText.getText().toString();
    String limitTo = limitToView.getText().toString();

    if(!searchSwipeContainer.isRefreshing()) {
        params.clear();
        params.put("q", (query.trim()));
        params.put("t", fromSpinner.getSelectedItem().toString());
        params.put("sort", sortSpinner.getSelectedItem().toString());

        subreddit = limitTo.trim();

        linksContainerView.search(subreddit, params);

        if (!searchView.getText().toString().equals(query)) {
            searchView.setText(query);
        }
    }

}
 
Example 3
Source File: FragmentSecurityViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
private void dialogWaitTime(long time) {
    boolean wrapInScrollView = true;

    final MaterialDialog dialogWait = new MaterialDialog.Builder(G.fragmentActivity).title(R.string.error_check_password).customView(R.layout.dialog_remind_time, wrapInScrollView).positiveText(R.string.B_ok).autoDismiss(true).canceledOnTouchOutside(true).onPositive(new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

            dialog.dismiss();
        }
    }).show();

    View v = dialogWait.getCustomView();

    final TextView remindTime = (TextView) v.findViewById(R.id.remindTime);
    CountDownTimer countWaitTimer = new CountDownTimer(time * 1000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            int seconds = (int) ((millisUntilFinished) / 1000);
            int minutes = seconds / 60;
            seconds = seconds % 60;
            remindTime.setText("" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds));
        }

        @Override
        public void onFinish() {
            remindTime.setText("00:00");
        }
    };
    countWaitTimer.start();

}
 
Example 4
Source File: FragmentRegisterViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
private void dialogWaitTimeVerifyPassword(long time) {
    boolean wrapInScrollView = true;
    final MaterialDialog dialogWait = new MaterialDialog.Builder(G.fragmentActivity).title(R.string.error_check_password).customView(R.layout.dialog_remind_time, wrapInScrollView).positiveText(R.string.B_ok).autoDismiss(true).canceledOnTouchOutside(true).onPositive(new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

            dialog.dismiss();
        }
    }).show();

    View v = dialogWait.getCustomView();

    final TextView remindTime = (TextView) v.findViewById(R.id.remindTime);
    CountDownTimer countWaitTimer = new CountDownTimer(time * 1000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            int seconds = (int) ((millisUntilFinished) / 1000);
            int minutes = seconds / 60;
            seconds = seconds % 60;
            remindTime.setText("" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds));
        }

        @Override
        public void onFinish() {
            remindTime.setText("00:00");
        }
    };
    countWaitTimer.start();
}
 
Example 5
Source File: MainActivity.java    From OneTapVideoDownload with GNU General Public License v3.0 5 votes vote down vote up
public void showPlusOneDialog() {
    final MaterialDialog dialog = new MaterialDialog.Builder(this)
            .customView(R.layout.dialog_plus_one, false)
            .canceledOnTouchOutside(true)
            .show();
    View dialogView = dialog.getCustomView();
    if (dialogView != null) {
        mPlusOneButton = (PlusOneButton) dialogView.findViewById(R.id.plus_one_button);
        mPlusOneButton.initialize(APP_URL, 0);
    }
}
 
Example 6
Source File: PreferencesInformationAbout.java    From Android-Remote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {
    MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
            .title(R.string.pref_about_title)
            .negativeText(R.string.dialog_close)
            .customView(R.layout.dialog_about, false)
            .cancelable(true)
            .show();

    View view = dialog.getCustomView();

    // Fill the people working on this project
    TextView tvAuthors = (TextView) view.findViewById(R.id.tvAuthors);
    TextView tvSupporters = (TextView) view.findViewById(R.id.tvSupporters);
    TextView tvOthers = (TextView) view.findViewById(R.id.tvOthers);

    // Authors
    tvAuthors.setText("Andreas Muttscheller\n");

    // Supporters
    tvSupporters.setText("David Sansome (Clementine-Dev)\n" +
            "John Maguire (Clementine-Dev)\n" +
            "Arnaud Bienner (Clementine-Dev)");

    // Others
    tvOthers.setText(Html.fromHtml(
            "Thanks to all the <a href=\"https://github.com/clementine-player/Android-Remote/graphs/contributors\">contributors</a> and <a href=\"https://www.transifex.com/projects/p/clementine-remote/\">translators</a>!"));
    tvOthers.setMovementMethod(LinkMovementMethod.getInstance());

    return true;
}
 
Example 7
Source File: SongDetailDialog.java    From Music-Player with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity context = getActivity();
    final Song song = getArguments().getParcelable("song");

    MaterialDialog dialog = new MaterialDialog.Builder(context)
            .customView(R.layout.dialog_file_details, true)
            .title(context.getResources().getString(R.string.label_details))
            .positiveText(android.R.string.ok)
            .build();

    View dialogView = dialog.getCustomView();
    final TextView fileName = dialogView.findViewById(R.id.file_name);
    final TextView filePath = dialogView.findViewById(R.id.file_path);
    final TextView fileSize = dialogView.findViewById(R.id.file_size);
    final TextView fileFormat = dialogView.findViewById(R.id.file_format);
    final TextView songLength = dialogView.findViewById(R.id.song_length);
    final TextView bitRate = dialogView.findViewById(R.id.bitrate);
    final TextView samplingRate = dialogView.findViewById(R.id.sampling_rate);

    fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
    filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
    fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
    fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
    songLength.setText(makeTextWithTitle(context, R.string.label_song_length, "-"));
    bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
    samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));

    if (song != null) {
        final File songFile = new File(song.data);
        if (songFile.exists()) {
            fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
            filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
            fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
            try {
                AudioFile audioFile = AudioFileIO.read(songFile);
                AudioHeader audioHeader = audioFile.getAudioHeader();

                fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
                songLength.setText(makeTextWithTitle(context, R.string.label_song_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
                bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
                samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
            } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
                Log.e(TAG, "error while reading the song file", e);
                // fallback
                songLength.setText(makeTextWithTitle(context, R.string.label_song_length, MusicUtil.getReadableDurationString(song.duration)));
            }
        } else {
            // fallback
            fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
            songLength.setText(makeTextWithTitle(context, R.string.label_song_length, MusicUtil.getReadableDurationString(song.duration)));
        }
    }

    return dialog;
}
 
Example 8
Source File: SongDetailDialog.java    From Orin with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity context = getActivity();
    final Song song = getArguments().getParcelable("song");

    MaterialDialog dialog = new MaterialDialog.Builder(context)
            .customView(R.layout.dialog_file_details, true)
            .title(context.getResources().getString(R.string.label_details))
            .positiveText(android.R.string.ok)
            .build();

    View dialogView = dialog.getCustomView();
    final TextView fileName = (TextView) dialogView.findViewById(R.id.file_name);
    final TextView filePath = (TextView) dialogView.findViewById(R.id.file_path);
    final TextView fileSize = (TextView) dialogView.findViewById(R.id.file_size);
    final TextView fileFormat = (TextView) dialogView.findViewById(R.id.file_format);
    final TextView trackLength = (TextView) dialogView.findViewById(R.id.track_length);
    final TextView bitRate = (TextView) dialogView.findViewById(R.id.bitrate);
    final TextView samplingRate = (TextView) dialogView.findViewById(R.id.sampling_rate);

    fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
    filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
    fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
    fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
    trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
    bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
    samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));

    try {
        if (song != null) {
            final File songFile = new File(song.data);
            if (songFile.exists()) {
                AudioFile audioFile = AudioFileIO.read(songFile);
                AudioHeader audioHeader = audioFile.getAudioHeader();

                fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
                filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
                fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
                fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
                trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
                bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
                samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
            }
        }
    } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
        Log.e(TAG, "error while reading the song file", e);
    }
    return dialog;
}
 
Example 9
Source File: SongDetailDialog.java    From RetroMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity context = getActivity();
    final Song song = getArguments().getParcelable("song");

    MaterialDialog dialog = new MaterialDialog.Builder(context)
            .customView(R.layout.dialog_file_details, true)
            .title(context.getResources().getString(R.string.label_details))
            .positiveText(android.R.string.ok)
            .build();

    View dialogView = dialog.getCustomView();
    final TextView fileName = dialogView.findViewById(R.id.file_name);
    final TextView filePath = dialogView.findViewById(R.id.file_path);
    final TextView fileSize = dialogView.findViewById(R.id.file_size);
    final TextView fileFormat = dialogView.findViewById(R.id.file_format);
    final TextView trackLength = dialogView.findViewById(R.id.track_length);
    final TextView bitRate = dialogView.findViewById(R.id.bitrate);
    final TextView samplingRate = dialogView.findViewById(R.id.sampling_rate);

    fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
    filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
    fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
    fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
    trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
    bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
    samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));

    try {
        if (song != null) {
            final File songFile = new File(song.data);
            if (songFile.exists()) {
                AudioFile audioFile = AudioFileIO.read(songFile);
                AudioHeader audioHeader = audioFile.getAudioHeader();

                fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
                filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
                fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
                fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
                trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
                bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
                samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
            }
        }
    } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
        Log.e(TAG, "error while reading the song file", e);
    }
    return dialog;
}
 
Example 10
Source File: SongDetailDialog.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity context = getActivity();
    final Song song = getArguments().getParcelable("song");

    MaterialDialog dialog = new MaterialDialog.Builder(context)
            .customView(R.layout.dialog_file_details, true)
            .title(context.getResources().getString(R.string.label_details))
            .positiveText(android.R.string.ok)
            .build();

    View dialogView = dialog.getCustomView();
    final TextView fileName = dialogView.findViewById(R.id.file_name);
    final TextView filePath = dialogView.findViewById(R.id.file_path);
    final TextView fileSize = dialogView.findViewById(R.id.file_size);
    final TextView fileFormat = dialogView.findViewById(R.id.file_format);
    final TextView trackLength = dialogView.findViewById(R.id.track_length);
    final TextView bitRate = dialogView.findViewById(R.id.bitrate);
    final TextView samplingRate = dialogView.findViewById(R.id.sampling_rate);
    final TextView replayGain = dialogView.findViewById(R.id.replay_gain);

    fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
    filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
    fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
    fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
    trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
    bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
    samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));
    replayGain.setText(makeTextWithTitle(context, R.string.label_replay_gain, "-"));

    if (song != null) {
        final File songFile = new File(song.data);
        if (songFile.exists()) {
            fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
            filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
            fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
            try {
                AudioFile audioFile = AudioFileIO.read(songFile);
                AudioHeader audioHeader = audioFile.getAudioHeader();

                fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
                trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
                bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
                samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));

                float rgTrack = song.getReplayGainTrack();
                float rgAlbum = song.getReplayGainAlbum();
                String replayGainValues = "";
                if (rgTrack != 0.0) {
                    replayGainValues += String.format("%s: %.2f dB ", context.getString(R.string.song), rgTrack);
                }
                if (rgAlbum != 0.0) {
                    replayGainValues += String.format("%s: %.2f dB ", context.getString(R.string.album), rgAlbum);
                }
                if (replayGainValues.equals("")) {
                    replayGainValues = context.getString(R.string.none);
                }
                replayGain.setText(makeTextWithTitle(context, R.string.label_replay_gain, replayGainValues));
            } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
                Log.e(TAG, "error while reading the song file", e);
                // fallback
                trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
            }
        } else {
            // fallback
            fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
            trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
        }
    }

    return dialog;
}
 
Example 11
Source File: SongDetailDialog.java    From Phonograph with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity context = getActivity();
    final Song song = getArguments().getParcelable("song");

    MaterialDialog dialog = new MaterialDialog.Builder(context)
            .customView(R.layout.dialog_file_details, true)
            .title(context.getResources().getString(R.string.label_details))
            .positiveText(android.R.string.ok)
            .build();

    View dialogView = dialog.getCustomView();
    final TextView fileName = dialogView.findViewById(R.id.file_name);
    final TextView filePath = dialogView.findViewById(R.id.file_path);
    final TextView fileSize = dialogView.findViewById(R.id.file_size);
    final TextView fileFormat = dialogView.findViewById(R.id.file_format);
    final TextView trackLength = dialogView.findViewById(R.id.track_length);
    final TextView bitRate = dialogView.findViewById(R.id.bitrate);
    final TextView samplingRate = dialogView.findViewById(R.id.sampling_rate);

    fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
    filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
    fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
    fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
    trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
    bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
    samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));

    if (song != null) {
        final File songFile = new File(song.data);
        if (songFile.exists()) {
            fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
            filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
            fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
            try {
                AudioFile audioFile = AudioFileIO.read(songFile);
                AudioHeader audioHeader = audioFile.getAudioHeader();

                fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
                trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
                bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
                samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
            } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
                Log.e(TAG, "error while reading the song file", e);
                // fallback
                trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
            }
        } else {
            // fallback
            fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
            trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
        }
    }

    return dialog;
}