@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { ContentResolver cr = getContext().getContentResolver(); if (fromTouch && seekBar == mStartVolumeSeekBar) { CMSettings.System.putFloat(cr, CMSettings.System.INCREASING_RING_START_VOLUME, (float) progress / 1000F); } else if (seekBar == mRampUpTimeSeekBar) { int seconds = (progress + 1) * 5; mRampUpTimeValue.setText( Formatter.formatShortElapsedTime(getContext(), seconds * 1000)); if (fromTouch) { CMSettings.System.putInt(cr, CMSettings.System.INCREASING_RING_RAMP_UP_TIME, seconds); } } }
private void setupOriginInfo(Bitmap bitmap1, Bitmap bitmap2, Bitmap bitmap3, Bitmap bitmap4) { mOriginImg1.setImageBitmap(bitmap1); mOriginImg2.setImageBitmap(bitmap2); mOriginImg3.setImageBitmap(bitmap3); mOriginImg4.setImageBitmap(bitmap4); mOriginTv.setText("origin bitmap memory size:\nbitmap[1,2,3,4]:" + Formatter.formatFileSize(this, bitmap1.getByteCount()) + "," + Formatter.formatFileSize(this, bitmap2.getByteCount()) + "," + Formatter.formatFileSize(this, bitmap3.getByteCount()) + "," + Formatter.formatFileSize(this, bitmap4.getByteCount()) + "\nwidth[1,2,3,4]:" + bitmap1.getWidth() + "," + bitmap2.getWidth() + "," + bitmap3.getWidth() + "," + bitmap4.getWidth() + "\nheight[1,2,3,4]:" + bitmap1.getHeight() + "," + bitmap2.getHeight() + "," + bitmap3.getHeight() + "," + bitmap4.getHeight() + "\nconfig:" + mConfig); }
private void setupCompressInfo( Bitmap bitmap1, Bitmap bitmap2, Bitmap bitmap3, Bitmap bitmap4, String outfile1, String outfile2, String outfile3, String outfile4, long sizeBytes1, long sizeBytes2, long sizeBytes3, long sizeBytes4) { mCompressImg1.setImageBitmap(bitmap1); mCompressImg2.setImageBitmap(bitmap2); mCompressImg3.setImageBitmap(bitmap3); mCompressImg4.setImageBitmap(bitmap4); mCompressTv.setText("compress file size:\nfile[1,2,3,4]:" + Formatter.formatFileSize(this, sizeBytes1) + "," + Formatter.formatFileSize(this, sizeBytes2) + "," + Formatter.formatFileSize(this, sizeBytes3) + "," + Formatter.formatFileSize(this, sizeBytes4) + "\nwidth[1,2,3,4]:" + bitmap1.getWidth() + "," + bitmap2.getWidth() + "," + bitmap3.getWidth() + "," + bitmap4.getWidth() + "\nheight[1,2,3,4]:" + bitmap1.getHeight() + "," + bitmap2.getHeight() + "," + bitmap3.getHeight() + "," + bitmap4.getHeight() + "\n\noutfile1:" + outfile1 + "\n\noutfile2:" + outfile2 + "\n\noutfile3:" + outfile3 + "\n\noutfile4:" + outfile4 + "\n\nconfig:" + mConfig); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //try to set this WiFi IP (in case there is no [valid] value set yet) WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); String wifiIP = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); SharedPreferences sPrefs = getSharedPreferences(AppAnalyzer.PREFNAME, MODE_WORLD_READABLE); String target_ip = sPrefs.getString(BadIntentConstants.TARGET_IP, " "); if (target_ip.equals(" ") || target_ip.equals("0.0.0.0")) { sPrefs.edit() .putString(BadIntentConstants.TARGET_IP, wifiIP) .apply(); } addPreferencesFromResource(R.xml.bad_intent_preferences); }
private void setupOriginInfo(Bitmap bitmap1, Bitmap bitmap2, Bitmap bitmap3, Bitmap bitmap4 , long sizeBytes1, long sizeBytes2, long sizeBytes3, long sizeBytes4) { mOriginImg1.setImageBitmap(bitmap1); mOriginImg2.setImageBitmap(bitmap2); mOriginImg3.setImageBitmap(bitmap3); mOriginImg4.setImageBitmap(bitmap4); mOriginTv.setText("origin file size:\nfile[1,2,3,4]:" + Formatter.formatFileSize(this, sizeBytes1) + "," + Formatter.formatFileSize(this, sizeBytes2) + "," + Formatter.formatFileSize(this, sizeBytes3) + "," + Formatter.formatFileSize(this, sizeBytes4) + "\nwidth[1,2,3,4]:" + bitmap1.getWidth() + "," + bitmap2.getWidth() + "," + bitmap3.getWidth() + "," + bitmap4.getWidth() + "\nheight[1,2,3,4]:" + bitmap1.getHeight() + "," + bitmap2.getHeight() + "," + bitmap3.getHeight() + "," + bitmap4.getHeight() + "\nconfig:" + mConfig); }
public static void logFileItems(Context context, ArrayList<ImageItem> files) { if (files == null) { return; } for (ImageItem s : files) { File originFile = new File(s.path); File thumbFile = new File(s.thumbPath); StringBuilder stringBuilder = new StringBuilder("\n"); if (originFile.exists()) { stringBuilder.append("原始:"); stringBuilder.append(originFile.getAbsolutePath()); stringBuilder.append(" "); stringBuilder.append(Formatter.formatFileSize(context, originFile.length())); stringBuilder.append("\n"); } if (thumbFile.exists()) { stringBuilder.append("压缩:"); stringBuilder.append(thumbFile.getAbsolutePath()); stringBuilder.append(" "); stringBuilder.append(Formatter.formatFileSize(context, thumbFile.length())); stringBuilder.append("\n"); } L.e(stringBuilder.toString()); } }
/** * Get total memory * * @param context * @return */ public static String getTotalMemory(Context context) { String str1 = "/proc/meminfo"; String str2; String[] arrayOfString; long initial_memory = 0; try { FileReader localFileReader = new FileReader(str1); BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192); str2 = localBufferedReader.readLine(); arrayOfString = str2.split("\\s+"); for (String num : arrayOfString) { Log.i(str2, num + "\t"); } initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024; localBufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } return Formatter.formatFileSize(context, initial_memory);// Byte转换为KB或者MB,内存大小规格化 }
@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.origin_size, fileSize)); } else { isOrigin = false; mCbOrigin.setText(getString(R.string.origin)); } } }
public static String getWifiAddress(Context context) { WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(WIFI_SERVICE); if(wifiMgr == null){ return null; } WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); int ip = wifiInfo.getIpAddress(); return Formatter.formatIpAddress(ip); }
protected void startServer() { WifiManager wifiMgr = (WifiManager) getApplicationContext() .getSystemService(Service.WIFI_SERVICE); if (wifiMgr.isWifiEnabled()) { // Deprecated. Does not support ipv6. *shrug* :) String ipAddress = Formatter.formatIpAddress(wifiMgr.getConnectionInfo() .getIpAddress()); URI baseUri = UriBuilder.fromUri("http://" + ipAddress) .port(49152) .build(); ResourceConfig config = new ResourceConfig(SseFeature.class) .register(JacksonFeature.class); config.registerInstances(new SecureFilter(this)); config.registerInstances(new DeskDroidResource(this)); // server = JettyHttpContainerFactory.createServer(baseUri, config); server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); } }
public static String getAutoFileOrFilesSize(String... filePaths) { long totalSize = 0; for (String filePath : filePaths) { File file = new File(filePath); long blockSize = 0; try { if (file.isDirectory()) { blockSize = getFileSizes(file); } else { blockSize = getFileSize(file); } } catch (Exception e) { e.printStackTrace(); } totalSize = totalSize + blockSize; } return Formatter.formatFileSize(App.getContext(), totalSize); }
@Override public void onProgressUpdate() { FileManagerService service = FileManagerService.fileManagerService; if(service.getPasteTotalSize()>0) mProgress.setProgress((int) (MAX_PROGRESS * service.getPasteTotalProgress() / service.getPasteTotalSize())); if( service.getPasteTotalProgress() != service.getPasteTotalSize()){ if(service.getFilesToPaste().size()>0) { setMessage(service.getFilesToPaste().get(service.getCurrentFile()).getName()); if (service.getFilesToPaste().size() > 1) { mProgressText.setText(mContext.getResources().getString(com.archos.filecorelibrary.R.string.pasting_copy_many, service.getCurrentFile()+1, service.getFilesToPaste().size(), Formatter.formatShortFileSize(mContext, service.getPasteTotalProgress()), Formatter.formatShortFileSize(mContext, service.getPasteTotalSize()))); } else { mProgressText.setText(mContext.getResources().getString(com.archos.filecorelibrary.R.string.pasting_copy_one, Formatter.formatShortFileSize(mContext, service.getPasteTotalProgress()), Formatter.formatShortFileSize(mContext, service.getPasteTotalSize()))); } } } else mProgressText.setText(mContext.getResources().getString(com.archos.filecorelibrary.R.string.pasting_done)); }
/** * 刷新数据 */ public void refresh() { long _space_free = Environment.getExternalStorageDirectory().getFreeSpace(); long _fileCount_all = Global.get_fileCount_all(); long _fileSize_all = Global.get_fileSize_all(); long _fileCount_rubbish = Global.get_fileCount_rubbish(); long _fileSize_rubbish = Global.get_fileSize_rubbish(); TransitionManager.beginDelayedTransition(_line); _set_line.setGuidelinePercent(R.id.guideLine_rubbish, (float) NumberUtil.div(_fileSize_rubbish, _space_total, 3)); _set_line.setGuidelinePercent(R.id.guideLine_file, (float) NumberUtil.div(_fileSize_all, _space_total, 3)); _set_line.setGuidelinePercent(R.id.guideLine_system, (float) (1 - NumberUtil.div(_space_free, _space_total, 3))); _set_line.applyTo(_line); _text_system.setText(getContext().getString(R.string.state_fileCount_system, Formatter.formatFileSize(getContext(), _space_total - _space_free - _fileSize_all))); _text_blank.setText(getContext().getString(R.string.state_fileCount_blank, Formatter.formatFileSize(getContext(), _space_free))); _text_file.setText(getContext().getString(R.string.state_fileCount_file, Formatter.formatFileSize(getContext(), _fileSize_all), _fileCount_all)); _text_rubbish.setText(getContext().getString(R.string.state_fileCount_rubbish, Formatter.formatFileSize(getContext(), _fileSize_rubbish), _fileCount_rubbish)); }
public void onClick(View v) { out.setText(""); out.append("\n\nConfigured Networks:"); // Get IP Address int ipAddress = wifimanager.getConnectionInfo().getIpAddress(); out.append("\nThe ip address is " + Formatter.formatIpAddress(ipAddress)); // Get configured networks List<WifiConfiguration> configuredNetworks = wifimanager.getConfiguredNetworks(); for (WifiConfiguration conf : configuredNetworks) { out.append(String.format("\n%s", conf.SSID)); } wifimanager.startScan(); }
private void show_network_info() { WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); String mac = wm.getConnectionInfo().getMacAddress(); StringBuilder sb = new StringBuilder(); sb.append("WiFi IP address: "); sb.append(ip); sb.append("\nWiFi MAC address: "); sb.append(mac); final AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.networkinfo) .setMessage(sb.toString()) .setPositiveButton(R.string.dismiss, null) .create(); dialog.show(); }
private void setupCompressInfo(Bitmap bitmap1, Bitmap bitmap2, Bitmap bitmap3, Bitmap bitmap4) { mCompressImg1.setImageBitmap(bitmap1); mCompressImg2.setImageBitmap(bitmap2); mCompressImg3.setImageBitmap(bitmap3); mCompressImg4.setImageBitmap(bitmap4); mCompressTv.setText("compress bitmap memory size:\nbitmap[1,2,3,4]:" + Formatter.formatFileSize(this, bitmap1.getByteCount()) + "," + Formatter.formatFileSize(this, bitmap2.getByteCount()) + "," + Formatter.formatFileSize(this, bitmap3.getByteCount()) + "," + Formatter.formatFileSize(this, bitmap4.getByteCount()) + "\nwidth[1,2,3,4]:" + bitmap1.getWidth() + "," + bitmap2.getWidth() + "," + bitmap3.getWidth() + "," + bitmap4.getWidth() + "\nheight[1,2,3,4]:" + bitmap1.getHeight() + "," + bitmap2.getHeight() + "," + bitmap3.getHeight() + "," + bitmap4.getHeight() + "\nconfig:" + mConfig); }
/** * 图片添加成功后,修改当前图片的选中数量 * 当调用 addSelectedImageItem 或 deleteSelectedImageItem 都会触发当前回调 */ @Override public void onImageSelected(int position, ImageItem item, boolean isAdd) { if (imagePicker.getSelectImageCount() > 0) { mBtnOk.setText(getString(R.string.select_complete, imagePicker.getSelectImageCount(), imagePicker.getSelectLimit())); mBtnOk.setEnabled(true); } else { mBtnOk.setText(getString(R.string.complete)); mBtnOk.setEnabled(false); } if (mCbOrigin.isChecked()) { long size = 0; for (ImageItem imageItem : selectedImages) size += imageItem.size; String fileSize = Formatter.formatFileSize(this, size); mCbOrigin.setText(getString(R.string.origin_size, fileSize)); } }
public void handleMessage(Message msg) { if (msg.what == MSG_SIZE_COMPUTED) { ArrayList<Object> list = (ArrayList<Object>) msg.obj; if (msg.arg1 == -1 && msg.arg2 == -1) { // Size is computed, hide the progressbar ProgressBar pb = (ProgressBar) list.get(1); pb.setVisibility(View.GONE); } else { // Size is beeing computed => display the current total TextView sizeTv = (TextView) list.get(0); TextView numberFilesTv = (TextView) list.get(2); sizeTv.setText(Formatter.formatFileSize(mC, (Long) list.get(3))); if (msg.arg1 == 0 && msg.arg2 == 0) { numberFilesTv.setText(R.string.file_info_directory_empty); } else { numberFilesTv.setText(InfoDialog.formatDirectoryInfo(mC, msg.arg1, msg.arg2)); } } } }
@Override protected void onBindView(View view) { super.onBindView(view); getPreferenceManager().registerOnActivityStopListener(this); initHandler(); final SeekBar seekBar = (SeekBar) view.findViewById(R.id.start_volume); if (seekBar == mStartVolumeSeekBar) return; mStartVolumeSeekBar = seekBar; mRampUpTimeSeekBar = (SeekBar) view.findViewById(R.id.ramp_up_time); mRampUpTimeValue = (TextView) view.findViewById(R.id.ramp_up_time_value); final ContentResolver cr = getContext().getContentResolver(); float startVolume = CMSettings.System.getFloat(cr, CMSettings.System.INCREASING_RING_START_VOLUME, 0.1f); int rampUpTime = CMSettings.System.getInt(cr, CMSettings.System.INCREASING_RING_RAMP_UP_TIME, 10); mStartVolumeSeekBar.setProgress(Math.round(startVolume * 1000F)); mStartVolumeSeekBar.setOnSeekBarChangeListener(this); mRampUpTimeSeekBar.setOnSeekBarChangeListener(this); mRampUpTimeSeekBar.setProgress((rampUpTime / 5) - 1); mRampUpTimeValue.setText( Formatter.formatShortElapsedTime(getContext(), rampUpTime * 1000)); }
/** * 获取系统当前可用内存大小 * * @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);// 将获取的内存大小规格化 }
public void refresh(Progress progress) { String currentSize = Formatter.formatFileSize(context, progress.currentSize); String totalSize = Formatter.formatFileSize(context, progress.totalSize); downloadSize.setText(currentSize + "/" + totalSize); priority.setText(String.format("优先级:%s", progress.priority)); switch (progress.status) { case Progress.NONE: netSpeed.setText("停止"); upload.setText("上传"); break; case Progress.PAUSE: netSpeed.setText("暂停中"); upload.setText("继续"); break; case Progress.ERROR: netSpeed.setText("上传出错"); upload.setText("出错"); break; case Progress.WAITING: netSpeed.setText("等待中"); upload.setText("等待"); break; case Progress.FINISH: upload.setText("完成"); netSpeed.setText("上传成功"); break; case Progress.LOADING: String speed = Formatter.formatFileSize(context, progress.speed); netSpeed.setText(String.format("%s/s", speed)); upload.setText("停止"); break; } tvProgress.setText(numberFormat.format(progress.fraction)); pbProgress.setMax(10000); pbProgress.setProgress((int) (progress.fraction * 10000)); }
public void refresh(Progress progress) { String currentSize = Formatter.formatFileSize(context, progress.currentSize); String totalSize = Formatter.formatFileSize(context, progress.totalSize); downloadSize.setText(currentSize + "/" + totalSize); priority.setText(String.format("优先级:%s", progress.priority)); switch (progress.status) { case Progress.NONE: netSpeed.setText("停止"); download.setText("下载"); break; case Progress.PAUSE: netSpeed.setText("暂停中"); download.setText("继续"); break; case Progress.ERROR: netSpeed.setText("下载出错"); download.setText("出错"); break; case Progress.WAITING: netSpeed.setText("等待中"); download.setText("等待"); break; case Progress.FINISH: netSpeed.setText("下载完成"); download.setText("完成"); break; case Progress.LOADING: String speed = Formatter.formatFileSize(context, progress.speed); netSpeed.setText(String.format("%s/s", speed)); download.setText("暂停"); break; } tvProgress.setText(numberFormat.format(progress.fraction)); pbProgress.setMax(10000); pbProgress.setProgress((int) (progress.fraction * 10000)); }
private void refreshUi(Progress progress) { String currentSize = Formatter.formatFileSize(this, progress.currentSize); String totalSize = Formatter.formatFileSize(this, progress.totalSize); downloadSize.setText(currentSize + "/" + totalSize); String speed = Formatter.formatFileSize(this, progress.speed); netSpeed.setText(String.format("%s/s", speed)); tvProgress.setText(numberFormat.format(progress.fraction)); pbProgress.setMax(10000); pbProgress.setProgress((int) (progress.fraction * 10000)); switch (progress.status) { case Progress.NONE: download.setText("下载"); break; case Progress.LOADING: download.setText("暂停"); break; case Progress.PAUSE: download.setText("继续"); break; case Progress.WAITING: download.setText("等待"); break; case Progress.ERROR: download.setText("出错"); break; case Progress.FINISH: if (ApkUtils.isAvailable(this, new File(progress.filePath))) { download.setText("卸载"); } else { download.setText("安装"); } break; } }
private String getSDTotalSize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return Formatter.formatFileSize(SimpleActivity.this, blockSize * totalBlocks); }
/** * 获得sd卡剩余容量,即可用大小 * * @return */ private String getSDAvailableSize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(SimpleActivity.this, blockSize * availableBlocks); }
/** * 获得机身内存总大小 * * @return */ private String getRomTotalSize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return Formatter.formatFileSize(SimpleActivity.this, blockSize * totalBlocks); }
/** * 获得机身可用内存 * * @return */ private String getRomAvailableSize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(SimpleActivity.this, blockSize * availableBlocks); }
private String getRomAvailableSize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(this, blockSize * availableBlocks); }
@Override public void setData(DownLoadInfo data) { this.data = data; checkTypeUI(data); mProgress.setMax((int) data.mTotalbytes); mProgress.setProgress((int) data.mDownloadedbytes); mSpeed.setText(Formatter.formatFileSize(mContext, data.mSpeed) + "/s"); mPercent.setText(data.mFilename); mSize.setText(Utils.formatFilesize(data.mDownloadedbytes) + "/" ); mFlieSize.setText(Utils.formatFilesize(data.mTotalbytes)); checkUI(data); }
private void getCaches(){ // scan pm = getPackageManager(); List<PackageInfo> packages = pm.getInstalledPackages(0); int max = packages.size(); int current = 0; sb.delete(0, sb.length()); sb.append(""); sb.append("本机一共安装了:" + max+"个应用"); tvShowCaches.setText(sb.toString()); for (PackageInfo pinfo : packages) { String packageName = pinfo.packageName; try { Method getPackageSizeInfo = PackageManager.class .getDeclaredMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class); getPackageSizeInfo.invoke(pm, packageName, new MyPackageStateObserver()); current++; } catch (Exception e) { current++; e.printStackTrace(); } } //===到这里,数据准备完成 mHadler.postDelayed(new Runnable() { @Override public void run() { btnClearAll.setVisibility(View.VISIBLE); Toast.makeText(getApplicationContext(),"已读取全部缓存",Toast.LENGTH_SHORT).show(); sbCache.append(Formatter.formatFileSize(getApplicationContext(),cacheS)+"\n"); tvShowCaches.setText(sb.toString()); tvAppCache.setText(sbCache.toString()); sbCache.delete(0,sbCache.length()); } }, 1000); //ok,所有应用程序信息显示完成 }
@Override protected View cretaeSuccessView() { View view = UIUtils.inflate(R.layout.fragment_app_introduction); ButterKnife.bind(this, view); /*应用截图数据*/ for (int i = 0; i < mIntroductionBean.getImageCompressList().size(); i++) { String url = mIntroductionBean.getImageCompressList().get(i); View screenView = View.inflate(getContext(), R.layout.appdetail_item_screen_image, null); ImageView screenImageView = (ImageView) screenView.findViewById(R.id.appdetail_screen_img_imageview); //设置图片描述(一般用户是看不到的) screenImageView.setContentDescription(screenImageView.getResources().getString(R.string.appdetail_screenshot)); //设置图片的放大模式 screenImageView.setScaleType(ImageView.ScaleType.FIT_XY); screenView.setOnClickListener(this); screenView.setTag(i); Glide.with(UIUtils.getContext()).load(url).into(screenImageView); app_detail_gallery_container.addView(screenView); } /*应用信息描述*/ appInfoTariff.setText(mIntroductionBean.getAppInfoBean().getTariffDesc()); appInfoSize.setText(Formatter.formatFileSize(getContext(), Long.parseLong(mIntroductionBean.getAppInfoBean().getSize()))); appInfoDate.setText(mIntroductionBean.getAppInfoBean().getReleaseDate()); appInfoVersion.setText(mIntroductionBean.getAppInfoBean().getVersion()); appInfoDeveloper.setText(mIntroductionBean.getAppInfoBean().getDeveloper()); for (int i = 0; i < mIntroductionBean.getAppDetailInfoBeanList().size(); i++) { FoldingTextView foldingTextView = new FoldingTextView(getContext()); foldingTextView.setTitle(mIntroductionBean.getAppDetailInfoBeanList().get(i).getTitle()); foldingTextView.setContent(mIntroductionBean.getAppDetailInfoBeanList().get(i).getBody()); appInfoDes.addView(foldingTextView); } //应用标签数据 List<String> tagList = mIntroductionBean.getTagList(); for (int i = 0; i < tagList.size(); i++) { View labView = UIUtils.inflate(R.layout.appdetail_item_label_item); TextView tv = (TextView) labView.findViewById(R.id.appdetail_label_content_textview); tv.setText(tagList.get(i)); flowLayout.addView(labView); } return view; }
@Override public void onBindViewHolder(ViewHolder holder, int position) { SDFile _temp_data = _data.get_children().get(position); //设置文件大小比例条 float _percent = (float) NumberUtil.div(_temp_data.get_sizePercent(), 100, 2); PercentRelativeLayout.LayoutParams _params = new PercentRelativeLayout.LayoutParams(0, 0); _params.getPercentLayoutInfo().widthPercent = _percent; holder._view_percent.setLayoutParams(_params); int _color = (int) _evaluator.evaluate(_percent, COLOR_START, COLOR_END); holder._view_percent.setBackgroundColor(_color); //设置清理标志 if (_temp_data.isRubbish()) holder._image_rubbish.setVisibility(ImageView.VISIBLE); else holder._image_rubbish.setVisibility(ImageView.GONE); //设置类型图标 if (_temp_data.isDirectory()) holder._image_type.setImageResource(R.drawable.icon_directory); else holder._image_type.setImageResource(R.drawable.icon_file); //设置基本信息 holder._text_name.setText(_temp_data.get_name()); String _str_size; if (_temp_data.isDirectory()) _str_size = holder._view_click.getContext().getString(R.string.state_directory_size, Formatter.formatFileSize(holder._view_click.getContext(), _temp_data.get_size()), _temp_data.get_fileCount()); else _str_size = Formatter.formatFileSize(holder._view_click.getContext(), _temp_data.get_size()); holder._text_size.setText(_str_size); holder._view_click.setTag(new String[]{ACTION_CLICK_ITEM, String.valueOf(position)}); }
@Override protected Void doInBackground(Void... params) { filePath = doc.path; if (!Utils.isDir(doc.mimeType)) { final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, doc.mimeType); int thumbSize = getResources().getDimensionPixelSize(R.dimen.grid_width); Point mThumbSize = new Point(thumbSize, thumbSize); final Uri uri = DocumentsContract.buildDocumentUri(doc.authority, doc.documentId); final Context context = getActivity(); final ContentResolver resolver = context.getContentResolver(); ContentProviderClient client = null; try { if (doc.mimeType.equals(Document.MIME_TYPE_APK) && !TextUtils.isEmpty(filePath)) { result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context, filePath, Document.MIME_TYPE_APK)).getBitmap(); } else { client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, uri.getAuthority()); result = DocumentsContract.getDocumentThumbnail(resolver, uri, mThumbSize, null); } } catch (Exception e) { if (!(e instanceof OperationCanceledException)) { Log.w(TAG_DETAIL, "Failed to load thumbnail for " + uri + ": " + e); } CrashReportingManager.logException(e); } finally { ContentProviderClientCompat.releaseQuietly(client); } sizeString = Formatter.formatFileSize(context, doc.size); } else{ if(!TextUtils.isEmpty(filePath)){ File dir = new File(filePath); sizeString = Formatter.formatFileSize(getActivity(), Utils.getDirectorySize(dir)); } } return null; }
@Override protected void onPostExecute(Long result) { if (isCancelled()) { result = null; } if (mSizeView.getTag() == this && result != null) { mSizeView.setTag(null); String size = Formatter.formatFileSize(mSizeView.getContext(), result); mSizeView.setText(size); mSizes.put(mPosition, result); } }
public void setInfo(RootInfo root) { icon.setImageDrawable(root.loadDrawerIcon(mContext)); title.setText(root.title); // Show available space if no summary String summaryText = root.summary; if (TextUtils.isEmpty(summaryText) && root.availableBytes >= 0) { summaryText = mContext.getString(R.string.root_available_bytes, Formatter.formatFileSize(mContext, root.availableBytes)); try { Long current = 100 * root.availableBytes / root.totalBytes ; progress.setVisibility(View.VISIBLE); progress.setMax(100); progress.setProgress(100 - current.intValue()); progress.setColor(color); } catch (Exception e){ progress.setVisibility(View.GONE); } } else{ progress.setVisibility(View.GONE); } summary.setText(summaryText); summary.setVisibility(TextUtils.isEmpty(summaryText) ? View.GONE : View.VISIBLE); }
/** * Get available memory * * @param context * @return */ public static String getAvailableMemory(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); }