本文整理匯總了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);
}
}
示例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();
}
示例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();
}
示例4: getSubTitlePrefix
import android.text.format.Formatter; //導入方法依賴的package包/類
private String getSubTitlePrefix() {
return Formatter.formatShortFileSize(getContext(), getExtraLongValue("size")) + " · ";
}