android.text.format.Formatter.formatShortFileSize()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中android.text.format.Formatter.formatShortFileSize()方法的一些代码示例,展示了Formatter.formatShortFileSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter.formatShortFileSize()方法的具体详情如下:
包路径:android.text.format.Formatter
类名称:Formatter
方法名:formatShortFileSize

Formatter.formatShortFileSize介绍

暂无

代码示例

代码示例来源: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: 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: 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: square/leakcanary

info += "* Retaining: " + formatShortFileSize(context, result.retainedHeapSize) + ".\n";

代码示例来源: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: 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: czy1121/update

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);

代码示例来源:origin: square/leakcanary

setTitle(getString(R.string.leak_canary_class_has_leaked, className));
} else {
 String size = formatShortFileSize(this, result.retainedHeapSize);
 String className = classSimpleName(result.className);
 setTitle(getString(R.string.leak_canary_class_has_leaked_retaining, className, size));

代码示例来源:origin: square/leakcanary

String size = formatShortFileSize(this, result.retainedHeapSize);
if (result.excludedLeak) {
 contentTitle =

代码示例来源:origin: sarbajitsaha/Batch-Uninstaller

@Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
  holder.mLayoutItem.setBackgroundColor(mContext.getResources().getColor(mAppsList.get(position).color));
  holder.mImgIcon.setImageBitmap(mAppsList.get(position).icon);
  holder.mTvAppName.setText(mAppsList.get(position).appName);
  holder.mTvAppSize.setText(Formatter.formatShortFileSize(mContext, mAppsList.get(position).fileSize));
  Date date = new Date(mAppsList.get(position).firstInstallTime);
  SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");
  holder.mTvAppDate.setText(df2.format(date));
}

代码示例来源: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: towavephone/MemoryCleaner

@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: easefun/polyv-android-sdk-2.0-demo

@Override
  public void onSpeed(int speed) {
    if (canUpdateView() && downloader.isDownloading()) {
      viewHolder.get().tv_speed.setText(Formatter.formatShortFileSize(appContext, speed) + "/S");
    }
  }
}

代码示例来源:origin: towavephone/MemoryCleaner

@Override public void onCleanCompleted(Context context, long cacheSize) {
  //dismissDialogLoading();
  mRubbishClean.showSnackbar(context.getString(R.string.cleaned,
      Formatter.formatShortFileSize(mContext, cacheSize)));
  mCacheListItems.clear();
  recyclerAdapter.notifyDataSetChanged();
}

代码示例来源:origin: AmazMod/AmazMod

void sync(FileData fileData) {
    fileName.setText(fileData.getName());
    icon.setImageDrawable(fileData.isDirectory() ? folder : file);
    if (!fileData.isDirectory()) {
      size.setVisibility(View.VISIBLE);
      size.setText(Formatter.formatShortFileSize(context, fileData.getSize()));
    } else {
      size.setVisibility(View.GONE);
    }
  }
}

代码示例来源:origin: filestack/filestack-android

private String formatInfo(CloudItem item) {
  if (item.getSize() == 0 && item.getMimetype() == null) {
    return "";
  }
  String fileSize = Formatter.formatShortFileSize(recyclerView.getContext(), item.getSize());
  if (item.getMimetype() == null) {
    return String.format(Locale.getDefault(), "%s", fileSize);
  }
  return String.format(Locale.getDefault(), "%s - %s", item.getMimetype(), fileSize);
}

代码示例来源:origin: Meiqia/MeiqiaSDK-Android

private String getSubTitlePrefix() {
  String size = Formatter.formatShortFileSize(getContext(), getExtraLongValue("size"));
  return size + " · ";
}

代码示例来源:origin: andstatus/andstatus

private void showMaximumSizeOfCachedMedia() {
  Preference preference = findPreference(MyPreferences.KEY_MAXIMUM_SIZE_OF_CACHED_MEDIA_MB);
  if (preference != null) {
    preference.setSummary(Formatter.formatShortFileSize(getActivity(),
        MyPreferences.getMaximumSizeOfCachedMediaBytes()));
  }
}

代码示例来源:origin: andstatus/andstatus

private void showMaximumSizeOfAttachment() {
  Preference preference = findPreference(MyPreferences.KEY_MAXIMUM_SIZE_OF_ATTACHMENT_MB);
  if (preference != null) {
    preference.setSummary(Formatter.formatShortFileSize(getActivity(),
        MyPreferences.getMaximumSizeOfAttachmentBytes()));
  }
}

代码示例来源:origin: wasdennnoch/AndroidN-ify

public static void hookMemoryTile(Object tile, Context context) {
  // Thanks to GravityBox for this snippet!
  ActivityManager mAm = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
  MemInfoReader mMemInfoReader = new MemInfoReader();
  mAm.getMemoryInfo(memInfo);
  long secServerMem = 0;//XposedHelpers.getLongField(memInfo, "secondaryServerThreshold");
  mMemInfoReader.readMemInfo();
  long availMem = mMemInfoReader.getFreeSize() + mMemInfoReader.getCachedSize() - secServerMem;
  long totalMem = mMemInfoReader.getTotalSize();
  String summary = ResourceUtils.getInstance().getString(R.string.memory_summary, Formatter.formatShortFileSize(context, totalMem - availMem), Formatter.formatShortFileSize(context, totalMem));
  XposedHelpers.setObjectField(tile, "summary", summary);
}

相关文章