Java Code Examples for android.text.format.Formatter#formatShortFileSize()
The following examples show how to use
android.text.format.Formatter#formatShortFileSize() .
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: Downloads.java From Beedio with GNU General Public License v2.0 | 6 votes |
@Override public void run() { long downloadSpeedValue = DownloadManager.getDownloadSpeed(); String downloadSpeedText = "Speed:" + Formatter.formatShortFileSize(getActivity(), downloadSpeedValue) + "/s"; downloadSpeed.setText(downloadSpeedText); if (downloadSpeedValue > 0) { long remainingMills = DownloadManager.getRemaining(); String remainingText = "Remaining:" + Utils.getHrsMinsSecs(remainingMills); remaining.setText(remainingText); } else { remaining.setText(R.string.remaining_undefine); } if (getFragmentManager() != null && getFragmentManager().findFragmentByTag ("downloadsInProgress") != null) { downloadsInProgress.updateDownloadItem(); } mainHandler.postDelayed(this, 1000); }
Example 2
Source File: VideoList.java From Beedio with GNU General Public License v2.0 | 6 votes |
void bind(Video video) { if (video.size != null) { String sizeFormatted = Formatter.formatShortFileSize(activity, Long.parseLong(video.size)); size.setText(sizeFormatted); } else size.setText(" "); String extStr = "." + video.type; ext.setText(extStr); check.setChecked(video.checked); name.setText(video.name); if (video.expanded) { expand.setVisibility(View.VISIBLE); AppCompatTextView detailsText = expand.findViewById(R.id.videoFoundDetailsText); detailsText.setVisibility(View.VISIBLE); detailsText.setText(video.details); } else { expand.setVisibility(View.GONE); } expand.findViewById(R.id.videoFoundRename).setOnClickListener(this); expand.findViewById(R.id.videoFoundDownload).setOnClickListener(this); expand.findViewById(R.id.videoFoundDelete).setOnClickListener(this); expand.findViewById(R.id.videoFoundDetailsBtn).setOnClickListener(this); }
Example 3
Source File: MainActivity.java From BalloonPerformer with Apache License 2.0 | 6 votes |
/** * 释放内存 <功能简述> */ public static void releaseMemory(final Context context) { ReleasePhoneMemoryTask releasePhoneMemoryTask = new ReleasePhoneMemoryTask( context) { @Override protected void onPostExecute(Long result) { String s; if (result <= 0) { s = "当前已是最佳状态!"; } else { s = "已经为您清理" + "<font color='#4898eb'>" + Formatter.formatShortFileSize(context, result) + "</font>" + "内存!"; } ReleaseToast.showToast(context, Html.fromHtml(s)); } }; releasePhoneMemoryTask.execute(); }
Example 4
Source File: Episode.java From uPods-android with Apache License 2.0 | 5 votes |
@Override public String getSubTitle() { String size; try { size = Formatter.formatShortFileSize(UpodsApplication.getContext(), Long.valueOf(length)); } catch (NumberFormatException e) { size = length; } return duration + " / " + size; }
Example 5
Source File: FileUtils.java From explorer with Apache License 2.0 | 4 votes |
public static String getStorageUsage(Context context) { File internal = getInternalStorage(); File external = getExternalStorage(); long f = internal.getFreeSpace(); long t = internal.getTotalSpace(); if (external != null) { f += external.getFreeSpace(); t += external.getTotalSpace(); } String use = Formatter.formatShortFileSize(context, t - f); String tot = Formatter.formatShortFileSize(context, t); return String.format("%s used of %s", use, tot); }
Example 6
Source File: UpdateAgent.java From update with Apache License 2.0 | 4 votes |
@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(); }
Example 7
Source File: FileUtils.java From explorer with Apache License 2.0 | 3 votes |
public static String getSize(Context context, File file) { if (file.isDirectory()) { File[] children = getChildren(file); if (children == null) return null; return String.format("%s items", children.length); } else { return Formatter.formatShortFileSize(context, file.length()); } }