當前位置: 首頁>>代碼示例>>Java>>正文


Java Formatter.formatShortFileSize方法代碼示例

本文整理匯總了Java中android.text.format.Formatter.formatShortFileSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Formatter.formatShortFileSize方法的具體用法?Java Formatter.formatShortFileSize怎麽用?Java Formatter.formatShortFileSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.format.Formatter的用法示例。


在下文中一共展示了Formatter.formatShortFileSize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateStatusbarNotification

import android.text.format.Formatter; //導入方法依賴的package包/類
private void updateStatusbarNotification(long currentSize, long totalSize, int currentFiles, int totalFiles) {

        if (mNotificationBuilder != null) {
            String formattedCurrentSize = Formatter.formatShortFileSize(this, currentSize);
            String formattedTotalSize = Formatter.formatShortFileSize(this, totalSize);
            int textId;
            String formattedString;
            if (totalFiles <= 0) {
                textId = R.string.pasting_copy_one;
                // Display the progress in bytes only
                formattedString = getResources().getString(textId, formattedCurrentSize, formattedTotalSize);
            }
            else {
                textId = R.string.pasting_copy_many;
                // Display the progress in number of files and bytes
                formattedString = getResources().getString(textId, currentFiles, totalFiles,
                        formattedCurrentSize, formattedTotalSize);
            }
            mNotificationBuilder.setProgress((int)totalSize, (int)currentSize, false);
            updateStatusbarNotification(formattedString);
        }
    }
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:23,代碼來源:FileManagerService.java

示例2: onPrompt

import android.text.format.Formatter; //導入方法依賴的package包/類
@Override
public void onPrompt(UpdateAgent agent) {
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新內容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("應用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new OnPromptClick(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新應用才能繼續使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "確定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以後再說", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略該版", listener);
        }
    }
    dialog.show();
}
 
開發者ID:zhanghangyes,項目名稱:updateUtils,代碼行數:39,代碼來源:UpdateAgent.java

示例3: prompt

import android.text.format.Formatter; //導入方法依賴的package包/類
@Override
public void prompt(IUpdateAgent agent) {
    if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) {
        return;
    }
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新內容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("應用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新應用才能繼續使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "確定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以後再說", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略該版", listener);
        }
    }
    dialog.show();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:42,代碼來源:UpdateAgent.java

示例4: getSubTitlePrefix

import android.text.format.Formatter; //導入方法依賴的package包/類
private String getSubTitlePrefix() {
    return Formatter.formatShortFileSize(getContext(), getExtraLongValue("size")) + " · ";
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:MQChatFileItem.java


注:本文中的android.text.format.Formatter.formatShortFileSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。