Skip to content
Snippets Groups Projects
Commit 31f8ce34 authored by Christian Dresen's avatar Christian Dresen
Browse files

Fixed Charge Dialog

parent 267f77dc
No related branches found
No related tags found
No related merge requests found
......@@ -94,7 +94,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if(this.manager.getCurrentUser() == null) {
User u = User.getByCardId(card_id);
if(u != null)
MainManager.getInstance().setCurrentUser(u);
MainManager.getInstance().setCurrentUser(u,true);
}
}
@Override
......
......@@ -45,10 +45,12 @@ public class SQLiteService {
public List<User> refreshUserData(List<RestUser> u) {
User.deleteAll();
List<User> ret_val = new ArrayList<>();
for (RestUser anU : u) {
User usr = anU.toLocalUser();
usr.save();
ret_val.add(usr);
if(u != null) {
for (RestUser anU : u) {
User usr = anU.toLocalUser();
usr.save();
ret_val.add(usr);
}
}
return ret_val;
}
......@@ -56,10 +58,12 @@ public class SQLiteService {
public List<Category> refreshCategoryData(List<RestCategory> c) {
Category.deleteAll();
List<Category> ret_val = new ArrayList<>();
for (RestCategory category : c) {
Category cat = category.toLocalCategory();
cat.save();
ret_val.add(cat);
if(c!=null) {
for (RestCategory category : c) {
Category cat = category.toLocalCategory();
cat.save();
ret_val.add(cat);
}
}
return ret_val;
}
......@@ -67,12 +71,13 @@ public class SQLiteService {
public List<Product> refreshProductData(List<RestProduct> body) {
Product.deleteAll();
List<Product> ret_val = new ArrayList<>();
for (RestProduct anU : body) {
Product prod = anU.toLocalProduct();
prod.save();
ret_val.add(prod);
if (body != null) {
for (RestProduct anU : body) {
Product prod = anU.toLocalProduct();
prod.save();
ret_val.add(prod);
}
}
return ret_val;
}
......
......@@ -277,6 +277,7 @@ public class MainManager {
}
public void chargeAmount(double amount) {
User currentUser = this.dataManager.getCurrentUser();
RestTransaction t = new RestTransaction();
t.setAmount(amount);
......@@ -297,6 +298,7 @@ public class MainManager {
public void onResponse(Response<RestUser> response, Retrofit retrofit) {
DataManager.getInstance().getCurrentUser().setCredit(response.body().getCredit());
MainManager.getInstance().uiManager.refreshCreditTextView(DataManager.getInstance().getCurrentUser().getCredit());
DataManager.getInstance().getCurrentUser().save();
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment