Code dedup.
This commit is contained in:
parent
3700ad9813
commit
8a7776fd74
2 changed files with 20 additions and 58 deletions
|
@ -63,11 +63,7 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -99,11 +95,7 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
|
@ -125,11 +117,7 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -153,11 +141,7 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -181,16 +165,20 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void broadcastCareportalEvent(Context context, JSONObject data, Bundle bundle) {
|
||||||
|
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
DbLogger.dbAdd(intent, data.toString());
|
||||||
|
}
|
||||||
|
|
||||||
private static String getNextAvailableSecond(long time) {
|
private static String getNextAvailableSecond(long time) {
|
||||||
long second = time - time % 1000;
|
long second = time - time % 1000;
|
||||||
if (second == lastUsedSecond) second += 1000;
|
if (second == lastUsedSecond) second += 1000;
|
||||||
|
@ -257,11 +245,7 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "devicestatus");
|
bundle.putString("collection", "devicestatus");
|
||||||
bundle.putString("data", deviceStatus.mongoRecord().toString());
|
bundle.putString("data", deviceStatus.mongoRecord().toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, deviceStatus.mongoRecord(), bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, deviceStatus.mongoRecord().toString());
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -335,11 +319,7 @@ public class NSUpload {
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
bundle.putString("_id", profileSwitch._id);
|
bundle.putString("_id", profileSwitch._id);
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
|
@ -365,11 +345,7 @@ public class NSUpload {
|
||||||
bundle.putString("action", "dbAdd");
|
bundle.putString("action", "dbAdd");
|
||||||
bundle.putString("collection", "treatments");
|
bundle.putString("collection", "treatments");
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -425,11 +401,7 @@ public class NSUpload {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void uploadBg(BgReading reading) {
|
public static void uploadBg(BgReading reading) {
|
||||||
|
@ -449,11 +421,7 @@ public class NSUpload {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void uploadAppStart() {
|
public static void uploadAppStart() {
|
||||||
|
@ -471,11 +439,7 @@ public class NSUpload {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
bundle.putString("data", data.toString());
|
bundle.putString("data", data.toString());
|
||||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
broadcastCareportalEvent(context, data, bundle);
|
||||||
intent.putExtras(bundle);
|
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
DbLogger.dbAdd(intent, data.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -11,7 +9,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
|
|
Loading…
Reference in a new issue