Commit 1e073fe5 authored by Muhammad Suryono's avatar Muhammad Suryono

Update

parent 5b656e25
...@@ -75,7 +75,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -75,7 +75,7 @@ public class LoginActivity extends AppCompatActivity {
public void onChanged(DataResponse<UsersModels> usersModelsDataResponse) { public void onChanged(DataResponse<UsersModels> usersModelsDataResponse) {
Log.d("Status", usersModelsDataResponse.getMessageData()); Log.d("Status", usersModelsDataResponse.getMessageData());
if (!usersModelsDataResponse.getMessageData().equals("Login Failed")){ if (usersModelsDataResponse.getStatusData()){
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(SplashScreen.SESSION, true); editor.putBoolean(SplashScreen.SESSION, true);
editor.commit(); editor.commit();
......
...@@ -116,7 +116,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -116,7 +116,7 @@ public class MainActivity extends AppCompatActivity {
toolbar = findViewById(R.id.topAppBar); toolbar = findViewById(R.id.topAppBar);
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class); mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
if (orderId.isEmpty()) if (sharedPreferences.getString(ORDER_ID,"").isEmpty())
{ {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(ORDER_ID,"MES-ORDER"+utils.timeStamp()); editor.putString(ORDER_ID,"MES-ORDER"+utils.timeStamp());
...@@ -307,13 +307,13 @@ public class MainActivity extends AppCompatActivity { ...@@ -307,13 +307,13 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onAddCart(ProductModels product) { public void onAddCart(ProductModels product) {
mainViewModelsCart.checkOrderProduct(product.getIdProduct(), orderId).observe(MainActivity.this, new Observer<List<ProductCartModels>>() { mainViewModelsCart.checkOrderProduct(product.getIdProduct(), sharedPreferences.getString(ORDER_ID,"")).observe(MainActivity.this, new Observer<List<ProductCartModels>>() {
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
@Override @Override
public void onChanged(List<ProductCartModels> productCartModels) { public void onChanged(List<ProductCartModels> productCartModels) {
if (productCartModels.isEmpty() && cartIsEmpty){ if (productCartModels.isEmpty() && cartIsEmpty){
mainViewModelsCart.insertCart(new ProductCartModels( mainViewModelsCart.insertCart(new ProductCartModels(
orderId, sharedPreferences.getString(ORDER_ID,""),
1, 1,
product.getIdProduct(), product.getIdProduct(),
product.getProductName(), product.getProductName(),
......
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