cleaned up code

This commit is contained in:
massimiliano 2018-12-11 00:58:45 +01:00
parent 445b4b6793
commit 984cb02edc
2 changed files with 1 additions and 13 deletions

View File

@ -1773,7 +1773,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
protected Void doInBackground(Void... arg0) {
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStrincidents0 = sh.makeServiceCall(incidenturl0);
Log.e(TAG, "Response from url: " + incidenturl0);
@ -1781,23 +1780,18 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
if (jsonStrincidents0 != null) {//Incidaetnts page
try {
JSONObject jsonObj = new JSONObject(jsonStrincidents0);
// Getting JSON Array node
JSONArray data = jsonObj.getJSONArray("data");
//Make it sotre date and show state if new date is newer than stored date
int a=0;
JSONObject o = data.getJSONObject(a);
String callid = o.getString("id");
String updated = o.getString("updated_at");
// tmp hash map for single service
HashMap<String, String> date = new HashMap<>();
// adding each child node to HashMap key => value
date.put("id", callid);
date.put("updated", updated);
getDate.add(date);
String stateDate = date.put( "updated", updated );
String dateStored= checkDate.getString( "storeDate","" );
if (!stateDate.equals( dateStored ))
{
checkDate.edit().putString( "storeDate", stateDate).apply();

View File

@ -36,10 +36,8 @@ public class StateMessagesActivity extends AppCompatActivity {
Button button;
private String TAG = StateMessagesActivity.class.getSimpleName();
private ProgressDialog pDialog;
private ListView lv;
//SharedPreferences checkDate;
// URL to get data JSON
static String incidenturl0 ="https://state.disroot.org/api/v1/incidents?sort=id&order=desc";
@ -74,11 +72,7 @@ public class StateMessagesActivity extends AppCompatActivity {
messageList = new ArrayList<>();
getDate = new ArrayList<>();
lv = findViewById(R.id.list);
//checkDate = getSharedPreferences("storeDate", Context.MODE_PRIVATE);
new GetList().execute();
}