replace some ugly code with not-too-ugly code..
replaced this kind of code string + " " + number + "out of" + " " + number with this String.format("%1$d out of %2$d", number, number); Change-Id: If1cc296da48dd6823e9081a55b6eab2e3fcee552
This commit is contained in:
@@ -3270,10 +3270,10 @@ found in the list of installed applications.</string>
|
|||||||
<string name="delete">Delete</string>
|
<string name="delete">Delete</string>
|
||||||
<!-- Misc files [CHAR LIMIT=25] -->
|
<!-- Misc files [CHAR LIMIT=25] -->
|
||||||
<string name="misc_files">Misc Files</string>
|
<string name="misc_files">Misc Files</string>
|
||||||
<!-- number of misc files selected [CHAR LIMIT=20] -->
|
<!-- number of misc files selected [CHAR LIMIT=40] -->
|
||||||
<string name="misc_files_selected_count">selected</string>
|
<string name="misc_files_selected_count">selected %1$d out of %2$d</string>
|
||||||
<!-- the string 'out of' displayed when saying "selected N out of M" [CHAR LIMIT=20] -->
|
<!-- number of bytes represented by the selected misc files [CHAR LIMIT=40] -->
|
||||||
<string name="misc_files_selected_count_out_of">out of</string>
|
<string name="misc_files_selected_count_bytes">%1$s out of %2$s</string>
|
||||||
<!-- action to select all [CHAR LIMIT=30] -->
|
<!-- action to select all [CHAR LIMIT=30] -->
|
||||||
<string name="select_all">Select All</string>
|
<string name="select_all">Select All</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -48,8 +48,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class MiscFilesHandler extends ListActivity {
|
public class MiscFilesHandler extends ListActivity {
|
||||||
private static final String TAG = "MemorySettings";
|
private static final String TAG = "MemorySettings";
|
||||||
private String mNumSelectedStr;
|
private String mNumSelectedFormat;
|
||||||
private String mNumSelectedOutOfStr;
|
private String mNumBytesSelectedFormat;
|
||||||
private MemoryMearurementAdapter mAdapter;
|
private MemoryMearurementAdapter mAdapter;
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
@@ -58,8 +58,8 @@ public class MiscFilesHandler extends ListActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setFinishOnTouchOutside(true);
|
setFinishOnTouchOutside(true);
|
||||||
setTitle(R.string.misc_files);
|
setTitle(R.string.misc_files);
|
||||||
mNumSelectedStr = getString(R.string.misc_files_selected_count);
|
mNumSelectedFormat = getString(R.string.misc_files_selected_count);
|
||||||
mNumSelectedOutOfStr = getString(R.string.misc_files_selected_count_out_of);
|
mNumBytesSelectedFormat = getString(R.string.misc_files_selected_count_bytes);
|
||||||
mAdapter = new MemoryMearurementAdapter(this);
|
mAdapter = new MemoryMearurementAdapter(this);
|
||||||
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
setContentView(R.layout.settings_storage_miscfiles_list);
|
setContentView(R.layout.settings_storage_miscfiles_list);
|
||||||
@@ -162,8 +162,7 @@ public class MiscFilesHandler extends ListActivity {
|
|||||||
boolean checked) {
|
boolean checked) {
|
||||||
ListView lv = getListView();
|
ListView lv = getListView();
|
||||||
int numChecked = lv.getCheckedItemCount();
|
int numChecked = lv.getCheckedItemCount();
|
||||||
mode.setTitle(mNumSelectedStr + " : " + numChecked +
|
mode.setTitle(String.format(mNumSelectedFormat, numChecked, mAdapter.getCount()));
|
||||||
" " + mNumSelectedOutOfStr + " " + mAdapter.getCount());
|
|
||||||
|
|
||||||
// total the sizes of all items selected so far
|
// total the sizes of all items selected so far
|
||||||
SparseBooleanArray checkedItems = lv.getCheckedItemPositions();
|
SparseBooleanArray checkedItems = lv.getCheckedItemPositions();
|
||||||
@@ -176,9 +175,9 @@ public class MiscFilesHandler extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mode.setSubtitle(Formatter.formatFileSize(mContext, selectedDataSize) +
|
mode.setSubtitle(String.format(mNumBytesSelectedFormat,
|
||||||
" " + mNumSelectedOutOfStr + " " +
|
Formatter.formatFileSize(mContext, selectedDataSize),
|
||||||
Formatter.formatFileSize(mContext, mAdapter.getDataSize()));
|
Formatter.formatFileSize(mContext, mAdapter.getDataSize())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user