Commit 9bb5d40e authored by Varun Patil's avatar Varun Patil

Prevent UNIQUE constraint violation in BodyFragment

parent 8e8346b6
......@@ -115,7 +115,7 @@ public class BodyFragment extends Fragment {
if (response.isSuccessful()) {
Body body = response.body();
new insertDbBody().execute(body);
new updateDbBody().execute(body);
displayBody(body);
bodySwipeRefreshLayout.setRefreshing(false);
......@@ -320,15 +320,11 @@ public class BodyFragment extends Fragment {
private class updateDbBody extends AsyncTask<Body, Void, Integer> {
@Override
protected Integer doInBackground(Body... body) {
if (appDatabase.dbDao().getBody(body[0].getBodyID()).length > 0) {
appDatabase.dbDao().updateBody(body[0]);
return 1;
}
}
private class insertDbBody extends AsyncTask<Body, Void, Integer> {
@Override
protected Integer doInBackground(Body... body) {
} else {
appDatabase.dbDao().insertBody(body[0]);
}
return 1;
}
}
......
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