Back to project page android_device.
The source code is released under:
[Apache License](http://www.apache.org/licenses/): Version 2.0, January 2004 =============== ## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION ## ### 1. Definitions. ### "License" sha...
If you think the Android project android_device listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * ================================================================================================= * Copyright (C) 2013 - 2014 Martin Albedinsky [Wolf-ITechnologies] * ================================================================================================= * Licensed under the Apache License, Version 2.0 or later (further "License" only). * ------------------------------------------------------------------------------------------------- * You may use this file only in compliance with the License. More details and copy of this License * you may obtain at/*from ww w. j a v a 2 s .c o m*/ * * http://www.apache.org/licenses/LICENSE-2.0 * * You can redistribute, modify or publish any part of the code written within this file but as it * is described in the License, the software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES or CONDITIONS OF ANY KIND. * * See the License for the specific language governing permissions and limitations under the License. * ================================================================================================= */ package com.wit.android.device.examples.fragment; import android.content.res.Resources; import android.os.Bundle; import android.view.View; import android.widget.ListView; import com.wit.android.device.Storage; import com.wit.android.device.examples.R; import com.wit.android.device.examples.adapter.SimpleInfoAdapter; import com.wit.android.device.examples.model.SimpleInfo; import com.wit.android.examples.libs.fragment.annotation.ExActionBarOptions; import com.wit.android.examples.libs.fragment.annotation.ExContentView; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; /** * <p> * Description. * </p> * * @author Martin Albedinsky */ @ExContentView(R.layout.fragment_listview) @ExActionBarOptions(title = R.string.Navigation_Label_StorageInfo) public class StorageInfoFragment extends BaseDeviceFragment { /** * Log TAG. */ // private static final String TAG = ScreenInfoFragment.class.getSimpleName(); /** * */ private final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##"); { DECIMAL_FORMAT.setGroupingUsed(true); DECIMAL_FORMAT.setGroupingSize(3); } /** */ @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final Resources res = getResources(); final Storage storage = getAndroidDevice().getStorage(); // Obtain all information data about storage. final List<SimpleInfo> items = new ArrayList<>(); /** * External storage state. */ items.add(SimpleInfo.create( R.string.Storage_Info_Label_External_Mounted, Boolean.toString(storage.isExternalMounted()), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_External_ReadOnly, Boolean.toString(storage.isExternalReadOnly()), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_External_Available, Boolean.toString(storage.isExternalAvailable()), res )); /** * Storage paths + free space. */ items.add(SimpleInfo.create( R.string.Storage_Info_Label_Path_Root, res.getString( R.string.Storage_Info_Label_Path_format, storage.getStoragePath(Storage.ROOT), DECIMAL_FORMAT.format( Storage.Unit.MB.formatBytes(storage.getFreeSpace(Storage.ROOT)) ) ), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_Path_Data, res.getString( R.string.Storage_Info_Label_Path_format, storage.getStoragePath(Storage.DATA), DECIMAL_FORMAT.format( Storage.Unit.MB.formatBytes(storage.getFreeSpace(Storage.DATA)) ) ), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_Path_Cache, res.getString( R.string.Storage_Info_Label_Path_format, storage.getStoragePath(Storage.CACHE), DECIMAL_FORMAT.format( Storage.Unit.MB.formatBytes(storage.getFreeSpace(Storage.CACHE)) ) ), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_Path_Internal, res.getString( R.string.Storage_Info_Label_Path_format, storage.getStoragePath(Storage.INTERNAL), DECIMAL_FORMAT.format( Storage.Unit.MB.formatBytes(storage.getFreeSpace(Storage.INTERNAL)) ) ), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_Path_External, res.getString( R.string.Storage_Info_Label_Path_format, storage.getStoragePath(Storage.EXTERNAL), DECIMAL_FORMAT.format( Storage.Unit.MB.formatBytes(storage.getFreeSpace(Storage.EXTERNAL)) ) ), res )); items.add(SimpleInfo.create( R.string.Storage_Info_Label_Path_External_Package, res.getString( R.string.Storage_Info_Label_Path_format, storage.getStoragePath(Storage.EXTERNAL_PACKAGE), DECIMAL_FORMAT.format( Storage.Unit.MB.formatBytes(storage.getFreeSpace(Storage.EXTERNAL_PACKAGE)) ) ), res )); // Set up adapter. final SimpleInfoAdapter adapter = new SimpleInfoAdapter(getActivity()); adapter.changeItems(items); // Set up list view. ((ListView) view.findViewById(android.R.id.list)).setAdapter(adapter); } }