A magic number is "a unique value with unexplained meaning or multiple occurrences which could (preferably) be replaced with a named constant" - Wikipedia.
There are many instances where a number is used as a case in a switch or if statement to specify which action should be done (e.g. if(action == 5) { //create note), and it is a practice that has been found to often introduce bugs and reduce code readability.
The preferred solution in Android is to replace it with an IntDef.
Here are some examples that need changing (some are links to function definitions, so all calls to that function need to change; likewise for variables):
A magic number is "a unique value with unexplained meaning or multiple occurrences which could (preferably) be replaced with a named constant" - Wikipedia.
There are many instances where a number is used as a case in a switch or if statement to specify which action should be done (e.g.
if(action == 5) { //create note), and it is a practice that has been found to often introduce bugs and reduce code readability.The preferred solution in Android is to replace it with an IntDef.
Here are some examples that need changing (some are links to function definitions, so all calls to that function need to change; likewise for variables):
GeniForAndroid/app/src/main/java/app/familygem/ConfirmationActivity.java
Line 77 in f394c44
GeniForAndroid/app/src/main/java/app/familygem/ConfirmationActivity.java
Line 54 in f394c44
GeniForAndroid/app/src/main/java/app/familygem/list/NotesFragment.java
Line 101 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/list/RepositoriesFragment.java
Line 163 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/list/RepositoriesFragment.java
Line 62 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/list/RepositoriesFragment.java
Line 171 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/list/RepositoriesFragment.java
Line 195 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/visitor/MediaList.java
Line 38 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/visitor/MediaList.java
Line 48 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/visitor/MediaList.java
Line 91 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/CompareActivity.java
Line 64 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/CompareActivity.java
Line 174 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/CompareActivity.java
Line 277 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/Comparison.java
Line 55 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/Comparison.java
Line 70 in 8be0097
GeniForAndroid/app/src/main/java/app/familygem/Diagram.java
Line 103 in 8be0097