This commit is contained in:
Damian 2020-01-27 15:04:13 +01:00
parent 030d19744b
commit 4176fb2139

View File

@ -1,7 +1,6 @@
package com.example.foodinder_app;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.util.Pair;
import android.widget.ImageView;
@ -13,6 +12,7 @@ import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
@ -78,6 +78,8 @@ public class Main3Activity extends AppCompatActivity {
text.setText(card.getName());
}
restart();
} catch (JSONException e) {
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
}
@ -164,4 +166,22 @@ public class Main3Activity extends AppCompatActivity {
int index = random.nextInt(list.size());
return list.get(index);
}
}
private void restart(){
String url = Swipper.api + "/exec?action=restart";
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
mQueue.add(stringRequest);
}
}