Commit 784b04f1 authored by Varun Patil's avatar Varun Patil

Refactor static constant strings into Constants

parent 3ed11a83
...@@ -32,6 +32,12 @@ public class Constants { ...@@ -32,6 +32,12 @@ public class Constants {
public static final String FCM_BUNDLE_TYPE = "type"; public static final String FCM_BUNDLE_TYPE = "type";
public static final String FCM_BUNDLE_ID = "id"; public static final String FCM_BUNDLE_ID = "id";
public static final String DATA_TYPE_EVENT = "event";
public static final String DATA_TYPE_BODY = "body";
public static final String DATA_TYPE_USER = "userprofile";
public static final String DATA_TYPE_NEWS = "newsentry";
public static final String DATA_TYPE_PT = "blogentry";
/* Map */ /* Map */
public static final double MAP_Xn = 19.134417, MAP_Yn = 72.901229, MAP_Zn = 1757, MAP_Zyn = 501; public static final double MAP_Xn = 19.134417, MAP_Yn = 72.901229, MAP_Zn = 1757, MAP_Zyn = 501;
public static final double[] MAP_WEIGHTS_X = {-11.392001766454612, -36.31634553309953, 73.91269388324432, -24.14021153064087, 3.4508817531539115, -0.1462262375477863, 5.532505074667804, -1.542391995870977, 36.14211738142935}; public static final double[] MAP_WEIGHTS_X = {-11.392001766454612, -36.31634553309953, 73.91269388324432, -24.14021153064087, 3.4508817531539115, -0.1462262375477863, 5.532505074667804, -1.542391995870977, 36.14211738142935};
......
...@@ -73,6 +73,9 @@ import retrofit2.Call; ...@@ -73,6 +73,9 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static app.insti.Constants.DATA_TYPE_BODY;
import static app.insti.Constants.DATA_TYPE_EVENT;
import static app.insti.Constants.DATA_TYPE_USER;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static app.insti.Constants.RESULT_LOAD_IMAGE; import static app.insti.Constants.RESULT_LOAD_IMAGE;
...@@ -272,13 +275,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -272,13 +275,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private void chooseIntent(String type, String id) { private void chooseIntent(String type, String id) {
if (type == null || id == null) { return; } if (type == null || id == null) { return; }
switch (type) { switch (type) {
case "body": case DATA_TYPE_BODY:
openBodyFragment(id); openBodyFragment(id);
break; break;
case "user": case DATA_TYPE_USER:
openUserFragment(id); openUserFragment(id);
break; break;
case "event": case DATA_TYPE_EVENT:
openEventFragment(id); openEventFragment(id);
break; break;
} }
...@@ -319,23 +322,23 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -319,23 +322,23 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if (appLinkData.charAt(appLinkData.length() - 1) == '/') if (appLinkData.charAt(appLinkData.length() - 1) == '/')
appLinkData = appLinkData.substring(0, appLinkData.length() - 1); appLinkData = appLinkData.substring(0, appLinkData.length() - 1);
switch (getType(appLinkData)) { switch (getType(appLinkData)) {
case "body": case DATA_TYPE_BODY:
return appLinkData.substring(appLinkData.indexOf("org") + 4); return appLinkData.substring(appLinkData.indexOf("org") + 4);
case "user": case DATA_TYPE_USER:
return appLinkData.substring(appLinkData.indexOf("user") + 5); return appLinkData.substring(appLinkData.indexOf("user") + 5);
case "event": case DATA_TYPE_EVENT:
return appLinkData.substring(appLinkData.indexOf("event") + 6); return appLinkData.substring(appLinkData.indexOf("event") + 6);
} }
return null; return null;
} }
private String getType(String appLinkData) { private String getType(String appLinkData) {
if (appLinkData.startsWith("http://insti.app/org/") || appLinkData.startsWith("https://insti.app/org/")) { if (appLinkData.contains("://insti.app/org/")) {
return "body"; return DATA_TYPE_BODY;
} else if (appLinkData.startsWith("http://insti.app/user/") || appLinkData.startsWith("https://insti.app/user/")) { } else if (appLinkData.contains("://insti.app/user/")) {
return "user"; return DATA_TYPE_USER;
} else if (appLinkData.startsWith("http://insti.app/event/") || appLinkData.startsWith("https://insti.app/event/")) { } else if (appLinkData.contains("://insti.app/event/")) {
return "event"; return DATA_TYPE_EVENT;
} }
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment