当前位置: 首页>>代码示例>>Java>>正文


Java MaterialDialog.getCustomView方法代码示例

本文整理汇总了Java中com.afollestad.materialdialogs.MaterialDialog.getCustomView方法的典型用法代码示例。如果您正苦于以下问题:Java MaterialDialog.getCustomView方法的具体用法?Java MaterialDialog.getCustomView怎么用?Java MaterialDialog.getCustomView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.afollestad.materialdialogs.MaterialDialog的用法示例。


在下文中一共展示了MaterialDialog.getCustomView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateDialog

import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
@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;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:51,代码来源:SongDetailDialog.java

示例2: onCreateDialog

import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
@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;
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:51,代码来源:SongDetailDialog.java


注:本文中的com.afollestad.materialdialogs.MaterialDialog.getCustomView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。