当前位置: 首页>>代码示例>>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;未经允许,请勿转载。