Added upload status to event list in local database. Added (non-functioning) click listener ready to open a new activity to edit the remote database event entry.
This commit is contained in:
@@ -82,7 +82,7 @@ public class LogManager implements AuthCallbackInterface, EventCallbackInterface
|
|||||||
|
|
||||||
private boolean mUploadInProgress;
|
private boolean mUploadInProgress;
|
||||||
private long mEventDuration = 120; // event duration in seconds - uploads datapoints that cover this time range centred on the event time.
|
private long mEventDuration = 120; // event duration in seconds - uploads datapoints that cover this time range centred on the event time.
|
||||||
private long mDataRetentionPeriod = 1; // Prunes the local db so it only retains data younger than this duration (in days)
|
public long mDataRetentionPeriod = 1; // Prunes the local db so it only retains data younger than this duration (in days)
|
||||||
private long mRemoteLogPeriod = 60; // Period in seconds between uploads to the remote server.
|
private long mRemoteLogPeriod = 60; // Period in seconds between uploads to the remote server.
|
||||||
private ArrayList<JSONObject> mDatapointsToUploadList;
|
private ArrayList<JSONObject> mDatapointsToUploadList;
|
||||||
private int mCurrentEventId;
|
private int mCurrentEventId;
|
||||||
@@ -373,7 +373,7 @@ public class LogManager implements AuthCallbackInterface, EventCallbackInterface
|
|||||||
statusStr = "Unknown";
|
statusStr = "Unknown";
|
||||||
}
|
}
|
||||||
event.put("status",statusStr);
|
event.put("status",statusStr);
|
||||||
//event.put("uploaded", cursor.getString(cursor.getColumnIndex("uploaded")));
|
event.put("uploaded", cursor.getString(cursor.getColumnIndex("uploaded")));
|
||||||
//event.put("dataJSON", cursor.getString(cursor.getColumnIndex("dataJSON")));
|
//event.put("dataJSON", cursor.getString(cursor.getColumnIndex("dataJSON")));
|
||||||
eventsList.add(event);
|
eventsList.add(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.support.v7.app.AlertDialog;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@@ -48,6 +49,9 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
(Button) findViewById(R.id.view_remote_db_button);
|
(Button) findViewById(R.id.view_remote_db_button);
|
||||||
remoteDbBtn.setOnClickListener(onRemoteDbBtn);
|
remoteDbBtn.setOnClickListener(onRemoteDbBtn);
|
||||||
|
|
||||||
|
ListView lv = (ListView) findViewById(R.id.eventLogListView);
|
||||||
|
lv.setOnItemClickListener(onEventListClick);
|
||||||
|
|
||||||
|
|
||||||
mLm = new LogManager(this);
|
mLm = new LogManager(this);
|
||||||
|
|
||||||
@@ -67,7 +71,6 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void updateUi() {
|
private void updateUi() {
|
||||||
//Log.v(TAG,"updateUi()");
|
//Log.v(TAG,"updateUi()");
|
||||||
TextView tv;
|
TextView tv;
|
||||||
@@ -86,8 +89,8 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
mEventsList = mLm.getEventsList(true);
|
mEventsList = mLm.getEventsList(true);
|
||||||
ListView lv = (ListView) findViewById(R.id.eventLogListView);
|
ListView lv = (ListView) findViewById(R.id.eventLogListView);
|
||||||
ListAdapter adapter = new SimpleAdapter(LogManagerControlActivity.this, mEventsList, R.layout.log_entry_layout,
|
ListAdapter adapter = new SimpleAdapter(LogManagerControlActivity.this, mEventsList, R.layout.log_entry_layout,
|
||||||
new String[]{"dataTime","status"},
|
new String[]{"dataTime", "status", "uploaded"},
|
||||||
new int[]{R.id.event_date, R.id.event_alarmState});
|
new int[]{R.id.event_date, R.id.event_alarmState, R.id.event_uploaded});
|
||||||
lv.setAdapter(adapter);
|
lv.setAdapter(adapter);
|
||||||
//Log.v(TAG,"eventsList="+mEventsList);
|
//Log.v(TAG,"eventsList="+mEventsList);
|
||||||
|
|
||||||
@@ -121,10 +124,9 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
Log.v(TAG, "onPruneBtn");
|
Log.v(TAG, "onPruneBtn");
|
||||||
// Confirmation dialog based on: https://stackoverflow.com/a/12213536/2104584
|
// Confirmation dialog based on: https://stackoverflow.com/a/12213536/2104584
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||||
|
|
||||||
builder.setTitle("Prune Database");
|
builder.setTitle("Prune Database");
|
||||||
builder.setMessage("This will remove all data from the database that is more than xxx days old."
|
builder.setMessage(String.format("This will remove all data from the database that is more than %d days old."
|
||||||
+"\nThis can NOT be undone.\nAre you sure?");
|
+ "\nThis can NOT be undone.\nAre you sure?", mLm.mDataRetentionPeriod));
|
||||||
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
@@ -132,14 +134,12 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
@@ -167,6 +167,33 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AdapterView.OnItemClickListener onEventListClick =
|
||||||
|
new AdapterView.OnItemClickListener() {
|
||||||
|
public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
|
||||||
|
Log.v(TAG, "onItemClicKListener() - Position=" + position + ", id=" + id);// Confirmation dialog based on: https://stackoverflow.com/a/12213536/2104584
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||||
|
builder.setTitle("Edit Remote Event Details");
|
||||||
|
builder.setMessage("Edit this event details on the remote database?");
|
||||||
|
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// Do Something!
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.show();
|
||||||
|
|
||||||
|
//MyClass selItem = (MyClass) myList.getSelectedItem(); //
|
||||||
|
//String value= selItem.getTheValue(); //getter method
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the timer that will upload data to the remote server after a given period.
|
* Start the timer that will upload data to the remote server after a given period.
|
||||||
|
|||||||
@@ -21,14 +21,17 @@
|
|||||||
android:text="alarm"
|
android:text="alarm"
|
||||||
android:id="@+id/event_alarmState"
|
android:id="@+id/event_alarmState"
|
||||||
/>
|
/>
|
||||||
|
<TextView
|
||||||
<!-- <TextView
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="note"
|
android:text=" : "/>
|
||||||
android:id="@+id/event_note"
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="uploaded"
|
||||||
|
android:id="@+id/event_uploaded"
|
||||||
/>
|
/>
|
||||||
-->
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- <TextView
|
<!-- <TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user