Skip to content

Commit

Permalink
Fixed crashing bug in Settings. Tested on Nougat.
Browse files Browse the repository at this point in the history
  • Loading branch information
aiman-al-masoud committed Jul 18, 2021
1 parent 1e25459 commit 9d5836e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
public class Paths {

public static String APP_DIR_PATH = MainActivity.CONTEXT.getFilesDir().getPath();
public static String APP_DIR_PATH = MainActivity.CONTEXT.getFilesDir().getPath();


}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static boolean getBoolean(SETTINGS_TAGS TAG_NAME){

try {
return settingsFile.getBoolean(TAG_NAME.toString());
} catch (WrongTagTypeException e) {
} catch (WrongTagTypeException | NullPointerException e) {
e.printStackTrace();
}

Expand All @@ -76,7 +76,7 @@ public static int getInt(SETTINGS_TAGS TAG_NAME){

try {
return settingsFile.getInt(TAG_NAME.toString());
} catch (WrongTagTypeException e) {
} catch (WrongTagTypeException | NullPointerException e) {
e.printStackTrace();
}

Expand All @@ -97,7 +97,14 @@ public static String getString(SETTINGS_TAGS TAG_NAME){
//set up all instance attributes
makeInstance();

return settingsFile.getString(TAG_NAME.toString());
try{
return settingsFile.getString(TAG_NAME.toString());
}catch (NullPointerException e){
}

//return the default value of the tag
return (String) TAG_NAME.DEFAULT_VAL;

}


Expand All @@ -114,7 +121,7 @@ public static double getFloat(SETTINGS_TAGS TAG_NAME){

try {
return settingsFile.getFloat(TAG_NAME.toString());
} catch (WrongTagTypeException e) {
} catch (WrongTagTypeException | NullPointerException e) {
e.printStackTrace();
}

Expand Down

0 comments on commit 9d5836e

Please sign in to comment.