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


Java DateUtils.formatElapsedTime方法代码示例

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


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

示例1: setPGTime

import android.text.format.DateUtils; //导入方法依赖的package包/类
private void setPGTime(int progress) {
    try {
        String timeString = "00.00";
        int linePG = 0;
        currentSong = streamingManager.getCurrentAudio();
        if (currentSong != null && progress != Long.parseLong(currentSong.getMediaDuration())) {
            timeString = DateUtils.formatElapsedTime(progress / 1000);
            Long audioDuration = Long.parseLong(currentSong.getMediaDuration());
            linePG = (int) (((progress / 1000) * 100) / audioDuration);
        }
        time_progress_bottom.setText(timeString);
        time_progress_slide.setText(timeString);
        lineProgress.setLineProgress(linePG);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:18,代码来源:MusicActivity.java

示例2: formatSeconds

import android.text.format.DateUtils; //导入方法依赖的package包/类
public static String formatSeconds(long seconds) {
    /* Takes number of seconds and returns a String with format HH:MM. */
    String timeString = DateUtils.formatElapsedTime(seconds);
    //If the time is less than an hour, then add "00:" to the beginning:
    if (seconds < 3600) timeString = "00:" + timeString;
    //Otherwise, if the time is less than 10 hours, then add "0" to the beginning:
    else if (seconds < 36000) timeString = "0" + timeString;
    //Removes seconds from time, because it's unneeded information
    return timeString.substring(0, timeString.length()-3);
}
 
开发者ID:brianjaustin,项目名称:permitlog-android,代码行数:11,代码来源:ElapsedTime.java

示例3: setMaxTime

import android.text.format.DateUtils; //导入方法依赖的package包/类
private void setMaxTime() {
    try {
        String timeString = DateUtils.formatElapsedTime(Long.parseLong(currentSong.getMediaDuration()));
        time_total_bottom.setText(timeString);
        time_total_slide.setText(timeString);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:10,代码来源:MusicActivity.java

示例4: formatTime

import android.text.format.DateUtils; //导入方法依赖的package包/类
private String formatTime(String duration) {
    try {
        long dur = Long.valueOf(duration);
        return DateUtils.formatElapsedTime(dur);
    } catch (NumberFormatException e) {
        return duration;
    }
}
 
开发者ID:mingdroid,项目名称:tumbviewer,代码行数:9,代码来源:PhotoPostVH.java

示例5: getFormatedDuration

import android.text.format.DateUtils; //导入方法依赖的package包/类
public String getFormatedDuration(){
    if(!TextUtils.isEmpty(duration)){
        long time=Long.parseLong(duration);
        return DateUtils.formatElapsedTime(time/1000);
    }
    return null;
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:8,代码来源:Track.java

示例6: onBindViewHolder

import android.text.format.DateUtils; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(@NonNull final TwoLinesViewHolder holder,
                             @NonNull final Cursor cursor, final int position) {
    final SpannableStringBuilder primary = new SpannableStringBuilder();
    final String cachedName = cursor.getString(cursor.getColumnIndexOrThrow(CallLog.Calls.CACHED_NAME));
    final String number = cursor.getString(cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER));
    SpannableStringBuilderCompat.append(primary, (cachedName != null ? cachedName : number),
            new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    primary.append(" ");

    final long duration = cursor.getLong(cursor.getColumnIndexOrThrow(CallLog.Calls.DURATION));
    if (duration > 0) {
        final CharSequence formattedDuration = DateUtils.formatElapsedTime(duration);
        primary.append(formattedDuration);
    }

    holder.setText1(primary);

    final SpannableStringBuilder summary = new SpannableStringBuilder();
    final int type = cursor.getInt(cursor.getColumnIndexOrThrow(CallLog.Calls.TYPE));
    switch (type) {
        case CallLog.Calls.INCOMING_TYPE:
            SpannableStringBuilderCompat.append(summary, "←", new ForegroundColorSpan(Color.BLUE),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;

        case CallLog.Calls.OUTGOING_TYPE:
            SpannableStringBuilderCompat.append(summary, "→", new ForegroundColorSpan(Color.GREEN),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;

        case CallLog.Calls.MISSED_TYPE:
        case CallLog.Calls.REJECTED_TYPE:
            SpannableStringBuilderCompat.append(summary, "☇", new ForegroundColorSpan(Color.RED),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;

        case CallLog.Calls.BLOCKED_TYPE:
            SpannableStringBuilderCompat.append(summary, "☓", new ForegroundColorSpan(Color.BLACK),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;
    }

    final long date = cursor.getLong(cursor.getColumnIndexOrThrow(CallLog.Calls.DATE));
    final CharSequence relativeDate = DateUtils.getRelativeTimeSpanString(date,
            System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
    summary.append(relativeDate);

    holder.setText2(summary);
}
 
开发者ID:GlobusLTD,项目名称:recyclerview-android,代码行数:55,代码来源:CallsAdapter.java

示例7: formatMillis

import android.text.format.DateUtils; //导入方法依赖的package包/类
/**
 * Formats time from milliseconds to hh:mm:ss string format.
 */
public static String formatMillis(int millis) {
    return DateUtils.formatElapsedTime(millis/1000);
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:7,代码来源:Utils.java


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