Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
xLaMbChOpSx committed Mar 15, 2014
1 parent 34b4d33 commit 3f06f50
Show file tree
Hide file tree
Showing 11 changed files with 432 additions and 467 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class BuildProp {

private final boolean ENABLE_DEBUG = false;
private ArrayList<String> mBuildPropContent = new ArrayList<String>();
private final ArrayList<String> mBuildPropContent = new ArrayList<String>();

public BuildProp() {
}
Expand Down Expand Up @@ -66,8 +66,8 @@ public void initializeBuildprop()
if (ENABLE_DEBUG) {
Log.i("ViPER4Android",
"Dumping the content of build.prop, size = " + mBuildPropContent.size());
for (int i = 0; i < mBuildPropContent.size(); i++) {
Log.i("ViPER4Android", "[build.prop] " + mBuildPropContent.get(i));
for (String aMBuildPropContent : mBuildPropContent) {
Log.i("ViPER4Android", "[build.prop] " + aMBuildPropContent);
}
}
}
Expand All @@ -76,8 +76,8 @@ public void initializeBuildprop()
* Check whether build.prop contains a property
*/
public boolean propExists(String key) {
for (int i = 0; i < mBuildPropContent.size(); i++) {
String currLine = mBuildPropContent.get(i).trim();
for (String aMBuildPropContent : mBuildPropContent) {
String currLine = aMBuildPropContent.trim();
if ((currLine == null) || currLine.equals(""))
continue;
if (currLine.startsWith("#"))
Expand All @@ -100,8 +100,8 @@ public boolean propExists(String key) {
* Get a property value
*/
public String getProp(String key) {
for (int i = 0; i < mBuildPropContent.size(); i++) {
String currLine = mBuildPropContent.get(i).trim();
for (String aMBuildPropContent : mBuildPropContent) {
String currLine = aMBuildPropContent.trim();
if ((currLine == null) || currLine.equals(""))
continue;
if (currLine.startsWith("#"))
Expand Down Expand Up @@ -182,8 +182,7 @@ public void commitBuildprop(String tmpDirPath) {
fosOutput = new FileOutputStream(tempBuildpropFile);
oswOutput = new OutputStreamWriter(fosOutput, "ASCII");
bufferOutput = new BufferedWriter(oswOutput);
for (int i = 0; i < mBuildPropContent.size(); i++) {
String currLine = mBuildPropContent.get(i);
for (String currLine : mBuildPropContent) {
if ((currLine == null) || currLine.equals("")) {
bufferOutput.write("\n");
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String config = getArguments().getString("config");
String config = "";
if (getArguments() != null) {
config = getArguments().getString("config");
}
PreferenceManager prefManager = getPreferenceManager();

SharedPreferences prefSettings = getActivity().getSharedPreferences(
Expand All @@ -94,18 +97,20 @@ public void onCreate(Bundle savedInstanceState) {
mControlLevel = 0;
}

prefManager.setSharedPreferencesName(
ViPER4Android.SHARED_PREFERENCES_BASENAME + "." + config);
prefManager.setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
try {
int xmlId = R.xml.class.getField(config + "_preferences_l" + mControlLevel)
.getInt(null);
addPreferencesFromResource(xmlId);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (prefManager != null) {
prefManager.setSharedPreferencesName(
ViPER4Android.SHARED_PREFERENCES_BASENAME + "." + config);
prefManager.setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
try {
int xmlId = R.xml.class.getField(config + "_preferences_l" + mControlLevel)
.getInt(null);
addPreferencesFromResource(xmlId);
} catch (Exception e) {
throw new RuntimeException(e);
}

prefManager.getSharedPreferences().registerOnSharedPreferenceChangeListener(listener);
prefManager.getSharedPreferences().registerOnSharedPreferenceChangeListener(listener);
}
}

@Override
Expand Down
Loading

0 comments on commit 3f06f50

Please sign in to comment.