當前位置: 首頁>>代碼示例>>Java>>正文


Java Formatter類代碼示例

本文整理匯總了Java中android.text.format.Formatter的典型用法代碼示例。如果您正苦於以下問題:Java Formatter類的具體用法?Java Formatter怎麽用?Java Formatter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Formatter類屬於android.text.format包,在下文中一共展示了Formatter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupOriginInfo

import android.text.format.Formatter; //導入依賴的package包/類
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);
}
 
開發者ID:Sunzxyong,項目名稱:Tiny,代碼行數:20,代碼來源:BatchBitmapCompressTestActivity.java

示例2: setupCompressInfo

import android.text.format.Formatter; //導入依賴的package包/類
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);
}
 
開發者ID:Sunzxyong,項目名稱:Tiny,代碼行數:27,代碼來源:BatchFileWithReturnBitmapCompressTestActivity.java

示例3: onCreate

import android.text.format.Formatter; //導入依賴的package包/類
@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);

}
 
開發者ID:mateuszk87,項目名稱:BadIntent,代碼行數:18,代碼來源:BadIntentPreferencesActivity.java

示例4: setupOriginInfo

import android.text.format.Formatter; //導入依賴的package包/類
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);
}
 
開發者ID:Sunzxyong,項目名稱:Tiny,代碼行數:22,代碼來源:BatchFileCompressTestActivity.java

示例5: logFileItems

import android.text.format.Formatter; //導入依賴的package包/類
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());
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:26,代碼來源:Luban.java

示例6: getTotalMemory

import android.text.format.Formatter; //導入依賴的package包/類
/**
 * 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,內存大小規格化
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:28,代碼來源:MemoryCache.java

示例7: onCheckedChanged

import android.text.format.Formatter; //導入依賴的package包/類
@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));
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:18,代碼來源:ImagePreviewActivity.java

示例8: getWifiAddress

import android.text.format.Formatter; //導入依賴的package包/類
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);
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:10,代碼來源:WifiTool.java

示例9: startServer

import android.text.format.Formatter; //導入依賴的package包/類
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);
        }
    }
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:20,代碼來源:DeskDroidService.java

示例10: getAutoFileOrFilesSize

import android.text.format.Formatter; //導入依賴的package包/類
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);
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:19,代碼來源:FileSizeUtil.java

示例11: onProgressUpdate

import android.text.format.Formatter; //導入依賴的package包/類
@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));


}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:25,代碼來源:Paste.java

示例12: refresh

import android.text.format.Formatter; //導入依賴的package包/類
/**
 * 刷新數據
 */
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));
}
 
開發者ID:bonepeople,項目名稱:SDCardCleaner,代碼行數:22,代碼來源:SDCardPercent.java

示例13: onClick

import android.text.format.Formatter; //導入依賴的package包/類
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();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:18,代碼來源:WifiInfoActivity.java

示例14: show_network_info

import android.text.format.Formatter; //導入依賴的package包/類
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();
}
 
開發者ID:c3cashdesk,項目名稱:postixdroid,代碼行數:18,代碼來源:MainActivity.java

示例15: setupCompressInfo

import android.text.format.Formatter; //導入依賴的package包/類
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);
}
 
開發者ID:tangqipeng,項目名稱:tiny,代碼行數:20,代碼來源:BatchBitmapCompressTestActivity.java


注:本文中的android.text.format.Formatter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。