本文整理了Java中android.text.format.Formatter
类的一些代码示例,展示了Formatter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter
类的具体详情如下:
包路径:android.text.format.Formatter
类名称:Formatter
暂无
代码示例来源:origin: bumptech/glide
private String toMb(int bytes) {
return Formatter.formatFileSize(context, bytes);
}
代码示例来源:origin: joyoyao/superCleanMaster
@Override
public void onCleanCompleted(Context context, long cacheSize) {
String msg = getString(R.string.cleaned, Formatter.formatShortFileSize(
CleanerService.this, cacheSize));
Log.d(TAG, msg);
Toast.makeText(CleanerService.this, msg, Toast.LENGTH_LONG).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
stopSelf();
}
}, 5000);
}
});
代码示例来源:origin: yangchong211/YCAudioPlayer
private String getDataText(List<DialogListBean> list) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(list.size());
stringBuffer.append("个/");
String size = Formatter.formatShortFileSize(this, 10003200);
stringBuffer.append(size);
stringBuffer.append(" ");
stringBuffer.append("可用空间");
stringBuffer.append(Formatter.formatFileSize(this, SDUtils.getAvailableSize()));
return stringBuffer.toString();
}
代码示例来源:origin: ac-pm/Inspeckage
String ssid = wi.getSSID();
li.add(new FingerprintItem("Wi-Fi", "SSID", ssid.substring(1, ssid.length() - 1), ssid.substring(1, ssid.length() - 1), false));
String ipAddress = Formatter.formatIpAddress(wi.getIpAddress());
li.add(new FingerprintItem("Wi-Fi", "IP", ipAddress, ipAddress, false));
代码示例来源:origin: piotrpolak/android-http-server
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return Formatter.formatIpAddress(inetAddress.hashCode());
代码示例来源:origin: smuyyh/BookReader
/**
* 获取系统当前可用内存大小
*
* @param context
* @return
*/
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static String getAvailMemory(Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
am.getMemoryInfo(mi);
return Formatter.formatFileSize(context, mi.availMem);// 将获取的内存大小规格化
}
代码示例来源:origin: joyoyao/superCleanMaster
@Override
public void onCleanCompleted(Context context, long cacheSize) {
String msg = getString(R.string.cleaned, Formatter.formatShortFileSize(
CoreService.this, cacheSize));
Log.d(TAG, msg);
Toast.makeText(CoreService.this, msg, Toast.LENGTH_LONG).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
stopSelf();
}
}, 5000);
}
});
代码示例来源:origin: couchbaselabs/mini-hacks
/** Get local IP to display in a TextView on the P2P tab */
public String getLocalIpAddress() {
WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
@Override
public void initViews(Bundle savedInstanceState) {
long phoneTotalSize = CommonUtil.getPhoneTotalSize();
long phoneAvailableSize = CommonUtil.getPhoneAvailableSize();
//转换为G的显示单位
String totalSizeStr = Formatter.formatFileSize(this, phoneTotalSize);
String availabSizeStr = Formatter.formatFileSize(this, phoneAvailableSize);
//计算占用空间的百分比
int progress = countProgress(phoneTotalSize, phoneAvailableSize);
mProgressBar.setProgress(progress);
mCacheSize.setText("主存储:" + totalSizeStr + "/" + "可用:" + availabSizeStr);
CustomEmptyView mEmptyLayout = (CustomEmptyView) findViewById(R.id.empty_layout);
assert mEmptyLayout != null;
mEmptyLayout.setEmptyImage(R.drawable.img_tips_error_no_downloads);
mEmptyLayout.setEmptyText("没有找到你的缓存哟");
}
代码示例来源:origin: joyoyao/superCleanMaster
@Override
public void onCleanCompleted(Context context, long cacheSize) {
Log.d(TAG,"CLean compleate");
dismissDialogLoading();
Toast.makeText(context, context.getString(R.string.cleaned, Formatter.formatShortFileSize(
mContext, cacheSize)), Toast.LENGTH_LONG).show();
header.setVisibility(View.GONE);
bottom_lin.setVisibility(View.GONE);
mCacheListItem.clear();
rublishMemoryAdapter.notifyDataSetChanged();
}
代码示例来源:origin: ShawnBaker/RPiCameraViewer
public static String getLocalIpAddress()
{
String address = "";
WifiManager manager = (WifiManager)App.getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (manager.isWifiEnabled())
{
WifiInfo wifiInfo = manager.getConnectionInfo();
if (wifiInfo != null)
{
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR)
{
int ip = wifiInfo.getIpAddress();
address = Formatter.formatIpAddress(ip);
}
}
}
return address;
}
代码示例来源:origin: jeasonlzy/ImagePicker
/**
* 图片添加成功后,修改当前图片的选中数量
* 当调用 addSelectedImageItem 或 deleteSelectedImageItem 都会触发当前回调
*/
@Override
public void onImageSelected(int position, ImageItem item, boolean isAdd) {
if (imagePicker.getSelectImageCount() > 0) {
mBtnOk.setText(getString(R.string.ip_select_complete, imagePicker.getSelectImageCount(), imagePicker.getSelectLimit()));
} else {
mBtnOk.setText(getString(R.string.ip_complete));
}
if (mCbOrigin.isChecked()) {
long size = 0;
for (ImageItem imageItem : selectedImages)
size += imageItem.size;
String fileSize = Formatter.formatFileSize(this, size);
mCbOrigin.setText(getString(R.string.ip_origin_size, fileSize));
}
}
代码示例来源:origin: square/leakcanary
info += "* Retaining: " + formatShortFileSize(context, result.retainedHeapSize) + ".\n";
代码示例来源:origin: brarcher/protect-baby-monitor
final String ipAddress = Formatter.formatIpAddress(address);
addressText.setText(ipAddress);
代码示例来源:origin: jeasonlzy/ImagePicker
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int id = buttonView.getId();
if (id == R.id.cb_origin) {
if (isChecked) {
long size = 0;
for (ImageItem item : selectedImages)
size += item.size;
String fileSize = Formatter.formatFileSize(this, size);
isOrigin = true;
mCbOrigin.setText(getString(R.string.ip_origin_size, fileSize));
} else {
isOrigin = false;
mCbOrigin.setText(getString(R.string.ip_origin));
}
}
}
代码示例来源:origin: square/leakcanary
title = getString(R.string.leak_canary_class_has_leaked, className);
} else {
String size = formatShortFileSize(DisplayLeakActivity.this,
leak.result.retainedHeapSize);
title = getString(R.string.leak_canary_class_has_leaked_retaining, className, size);
代码示例来源:origin: termux/termux-api
@SuppressLint("HardwareIds")
@Override
public void writeJson(JsonWriter out) throws Exception {
WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
out.beginObject();
if (info == null) {
out.name("API_ERROR").value("No current connection");
} else {
out.name("bssid").value(info.getBSSID());
out.name("frequency_mhz").value(info.getFrequency());
//noinspection deprecation - formatIpAddress is deprecated, but we only have a ipv4 address here:
out.name("ip").value(Formatter.formatIpAddress(info.getIpAddress()));
out.name("link_speed_mbps").value(info.getLinkSpeed());
out.name("mac_address").value(info.getMacAddress());
out.name("network_id").value(info.getNetworkId());
out.name("rssi").value(info.getRssi());
out.name("ssid").value(info.getSSID().replaceAll("\"", ""));
out.name("ssid_hidden").value(info.getHiddenSSID());
out.name("supplicant_state").value(info.getSupplicantState().toString());
}
out.endObject();
}
});
代码示例来源:origin: guolindev/giffun
private String toMb(int bytes) {
return Formatter.formatFileSize(context, bytes);
}
代码示例来源:origin: joyoyao/superCleanMaster
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = infater.inflate(R.layout.listview_rublish_clean,
parent, false);
holder = new ViewHolder();
holder.appIcon = (ImageView) convertView
.findViewById(R.id.app_icon);
holder.appName = (TextView) convertView
.findViewById(R.id.app_name);
holder.size = (TextView) convertView
.findViewById(R.id.app_size);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final CacheListItem item = (CacheListItem) getItem(position);
if (item != null) {
holder.appIcon.setImageDrawable(item.getApplicationIcon());
holder.appName.setText(item.getApplicationName());
holder.size.setText(Formatter.formatShortFileSize(mContext, item.getCacheSize()));
holder.packageName = item.getPackageName();
}
return convertView;
}
代码示例来源:origin: mozilla-tw/Rocket
private String toMb(int bytes) {
return Formatter.formatFileSize(context, bytes);
}
内容来源于网络,如有侵权,请联系作者删除!