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 ...@@ -94,7 +94,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if(this.manager.getCurrentUser() == null) { if(this.manager.getCurrentUser() == null) {
User u = User.getByCardId(card_id); User u = User.getByCardId(card_id);
if(u != null) if(u != null)
MainManager.getInstance().setCurrentUser(u); MainManager.getInstance().setCurrentUser(u,true);
} }
} }
@Override @Override
......
...@@ -45,10 +45,12 @@ public class SQLiteService { ...@@ -45,10 +45,12 @@ public class SQLiteService {
public List<User> refreshUserData(List<RestUser> u) { public List<User> refreshUserData(List<RestUser> u) {
User.deleteAll(); User.deleteAll();
List<User> ret_val = new ArrayList<>(); List<User> ret_val = new ArrayList<>();
for (RestUser anU : u) { if(u != null) {
User usr = anU.toLocalUser(); for (RestUser anU : u) {
usr.save(); User usr = anU.toLocalUser();
ret_val.add(usr); usr.save();
ret_val.add(usr);
}
} }
return ret_val; return ret_val;
} }
...@@ -56,10 +58,12 @@ public class SQLiteService { ...@@ -56,10 +58,12 @@ public class SQLiteService {
public List<Category> refreshCategoryData(List<RestCategory> c) { public List<Category> refreshCategoryData(List<RestCategory> c) {
Category.deleteAll(); Category.deleteAll();
List<Category> ret_val = new ArrayList<>(); List<Category> ret_val = new ArrayList<>();
for (RestCategory category : c) { if(c!=null) {
Category cat = category.toLocalCategory(); for (RestCategory category : c) {
cat.save(); Category cat = category.toLocalCategory();
ret_val.add(cat); cat.save();
ret_val.add(cat);
}
} }
return ret_val; return ret_val;
} }
...@@ -67,12 +71,13 @@ public class SQLiteService { ...@@ -67,12 +71,13 @@ public class SQLiteService {
public List<Product> refreshProductData(List<RestProduct> body) { public List<Product> refreshProductData(List<RestProduct> body) {
Product.deleteAll(); Product.deleteAll();
List<Product> ret_val = new ArrayList<>(); List<Product> ret_val = new ArrayList<>();
for (RestProduct anU : body) { if (body != null) {
Product prod = anU.toLocalProduct(); for (RestProduct anU : body) {
prod.save(); Product prod = anU.toLocalProduct();
ret_val.add(prod); prod.save();
ret_val.add(prod);
}
} }
return ret_val; return ret_val;
} }
......
...@@ -277,6 +277,7 @@ public class MainManager { ...@@ -277,6 +277,7 @@ public class MainManager {
} }
public void chargeAmount(double amount) { public void chargeAmount(double amount) {
User currentUser = this.dataManager.getCurrentUser(); User currentUser = this.dataManager.getCurrentUser();
RestTransaction t = new RestTransaction(); RestTransaction t = new RestTransaction();
t.setAmount(amount); t.setAmount(amount);
...@@ -297,6 +298,7 @@ public class MainManager { ...@@ -297,6 +298,7 @@ public class MainManager {
public void onResponse(Response<RestUser> response, Retrofit retrofit) { public void onResponse(Response<RestUser> response, Retrofit retrofit) {
DataManager.getInstance().getCurrentUser().setCredit(response.body().getCredit()); DataManager.getInstance().getCurrentUser().setCredit(response.body().getCredit());
MainManager.getInstance().uiManager.refreshCreditTextView(DataManager.getInstance().getCurrentUser().getCredit()); MainManager.getInstance().uiManager.refreshCreditTextView(DataManager.getInstance().getCurrentUser().getCredit());
DataManager.getInstance().getCurrentUser().save();
} }
@Override @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