Commit 6383759a authored by Muhammad Suryono's avatar Muhammad Suryono

Merge branch 'cart' into dev

parents 84f2cdbb 07483e25
......@@ -12,6 +12,8 @@ import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
......@@ -142,10 +144,6 @@ public class CartActivity extends AppCompatActivity {
});
// grandToral.setText(utils.convertPrice("Rp. ", utils.grandTotal));
cartAdapter.setListener(new CartAdapter.CartListener() {
@Override
public void onDelete(ProductCartModels productCartModels) {
......@@ -233,7 +231,7 @@ public class CartActivity extends AppCompatActivity {
}else{
new AlertDialog.Builder(CartActivity.this)
.setCancelable(false)
.setTitle("Save nwe Order")
.setTitle("Save new Order")
.setMessage("Erorr save!").show();
}
}
......@@ -242,7 +240,7 @@ public class CartActivity extends AppCompatActivity {
public void onFailure(Call<DataResponse<PaymentsModels>> call, Throwable t) {
new AlertDialog.Builder(CartActivity.this)
.setCancelable(false)
.setTitle("Save nwe Order")
.setTitle("Save new Order")
.setMessage("Add new order failed, try again!").show();
}
});
......
......@@ -88,6 +88,8 @@ public class MainActivity extends AppCompatActivity {
binding.rvProduct.setAdapter(adapter);
showLoading(true);
btnAddCart = findViewById(R.id.materialBtnAddCart);
categoryAdapter = new CategoryAdapter();
productAdapter = new ProductAdapter();
mainViewModelsCart = new ViewModelProvider(MainActivity.this).get(MainViewModelsCart.class);
......@@ -224,11 +226,9 @@ public class MainActivity extends AppCompatActivity {
}
private void mainViewModelsGetProduct() {
progressDialog.show();
mainViewModels.getProduct().observe(this, new Observer<DataResponse<List<ProductModels<CategoryModels>>>>() {
@Override
public void onChanged(DataResponse<List<ProductModels<CategoryModels>>> listDataResponse) {
progressDialog.dismiss();
if (listDataResponse.getData().size() != 0) {
List<ProductModels<CategoryModels>> productModels = listDataResponse.getData();
productModelsArrayList.clear();
......@@ -263,10 +263,12 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onDelete(ProductModels product, int position) {
progressDialog.show();
ProductService productService = client.Client(ProductService.class);
productService.deleteProducts(product.getIdProduct()).enqueue(new Callback<DataResponse<ProductModels>>() {
@Override
public void onResponse(Call<DataResponse<ProductModels>> call, Response<DataResponse<ProductModels>> response) {
progressDialog.dismiss();
productModelsArrayList.remove(position);
binding.rvProduct.removeViewAt(position);
productAdapter.notifyItemRemoved(position);
......@@ -414,13 +416,14 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.update, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
if (id == R.id.menu_cart){
if (id == R.id.menu_update){
startActivity(new Intent(MainActivity.this, MainActivity.class));
finish();
}
......
......@@ -98,7 +98,8 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
* */
subtotal = cartModels.getPrice_orders() * cartModels.getQuantity_orders();
utils.grandTotal = utils.grandTotal + (cartModels.getPrice_orders() * cartModels.getQuantity_orders());
Log.d("TAG", "bindData: "+binding.getSubTotal());
utils.grandTotal = (cartModels.getPrice_orders() * cartModels.getQuantity_orders());
Log.i("Grand Total", "bindData: "+utils.grandTotal);
CartActivity.grandToral.setText(utils.convertPrice("Rp. ", utils.grandTotal));
......
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>
\ No newline at end of file
......@@ -54,31 +54,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvCheckout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:fontFamily="@font/roboto"
android:text="Total"
android:textColor="#000"
android:textFontWeight="600"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="@+id/btSave"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvHarga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp. 600"
android:textSize="24sp"
android:textColor="#000"
android:textFontWeight="600"
android:layout_marginEnd="15dp"
app:layout_constraintBottom_toTopOf="@id/btCheckout"
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/btSave"
android:layout_width="0dp"
......
......@@ -55,17 +55,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/item_category"
android:layout_below="@id/topBar"
android:layout_above="@id/imgEmpty"/>
android:layout_below="@id/topBar"/>
<ImageView
android:id="@+id/imgEmpty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:visibility="gone"
android:src="@drawable/no"
android:layout_below="@id/topBar"
android:foregroundGravity="center"/>
android:layout_alignParentBottom="true"
android:layout_below="@id/rvCategory"
/>
<ProgressBar
android:id="@+id/pbLoading"
......
......@@ -29,6 +29,7 @@
android:layout_margin="12dp">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cvCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints">
......
......@@ -23,7 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:layout_marginVertical="10dp">
......@@ -52,6 +52,7 @@
android:id="@+id/btnDelete"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/ic_baseline_delete_24"/>
......@@ -60,6 +61,7 @@
android:id="@+id/btnEdit"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/ic_baseline_edit_24"/>
......@@ -121,6 +123,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="Add To Cart"
app:layout_constraintTop_toBottomOf="@id/price"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
......
......@@ -2,9 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_cart"
android:id="@+id/menu_update"
app:showAsAction="always"
android:icon="@drawable/ic_baseline_shopping_cart_24"
android:actionLayout="@layout/custome_action_badge"
android:icon="@drawable/ic_baseline_done_24"
android:title="Cart" />
</menu>
\ No newline at end of file
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