Commit 6b18875d authored by Ahmad Abi Mulya's avatar Ahmad Abi Mulya

change size of progress bar in sk activity

parents 67c8bcb8 64f13bdc
...@@ -100,7 +100,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -100,7 +100,7 @@ public class MainActivity extends AppCompatActivity {
}); });
// binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false)); // binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
// binding.rvProducts.setAdapter(adapter); binding.rvProducts.setAdapter(adapter);
viewModel = new ViewModelProvider(this).get(ProductViewModel.class); viewModel = new ViewModelProvider(this).get(ProductViewModel.class);
viewModel.getProducts().observe(this, adapter::setProducts); viewModel.getProducts().observe(this, adapter::setProducts);
......
...@@ -6,17 +6,13 @@ import androidx.cardview.widget.CardView; ...@@ -6,17 +6,13 @@ import androidx.cardview.widget.CardView;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import com.example.yourcashiertest.R; import com.example.yourcashiertest.R;
import com.example.yourcashiertest.databinding.ActivityPaymentBinding; import com.example.yourcashiertest.databinding.ActivityPaymentBinding;
import com.example.yourcashiertest.utils.Convert; import com.example.yourcashiertest.utils.Convert;
...@@ -30,8 +26,10 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -30,8 +26,10 @@ public class PaymentActivity extends AppCompatActivity {
public int refund; public int refund;
public int amount; public int amount;
CartViewModel cartViewModel; CartViewModel cartViewModel;
public boolean change = false; public String payment = "";
public static final String PAY_WITH = "pay_with";
@SuppressLint("ResourceAsColor")
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -43,56 +41,46 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -43,56 +41,46 @@ public class PaymentActivity extends AppCompatActivity {
amount = getIntent().getIntExtra(CartActivity.PRICE, 0); amount = getIntent().getIntExtra(CartActivity.PRICE, 0);
binding.setAmount(Convert.changeToCurrency(amount)); binding.setAmount(Convert.changeToCurrency(amount));
// binding.cbCash.setOnTouchListener((view, event) -> { binding.cbCash.setOnClickListener(v -> {
// changeCvColor(event, binding.cvCash); if (binding.getCheckCash()){
// return true; binding.setCheckCash(false);
// }); binding.cvCash.setCardBackgroundColor(0);
// payment = "";
// binding.cbCard.setOnTouchListener((view, event) -> { }else {
// changeCvColor(event, binding.cvCard); binding.setCheckCash(true);
// return true; binding.cvCash.setCardBackgroundColor(R.color.blue);
// }); payment = "Cash";
}
});
binding.cbCard.setOnClickListener(v -> {
if (binding.getCheckCard()){
binding.setCheckCard(false);
binding.cvCard.setCardBackgroundColor(0);
payment = "";
}else {
binding.setCheckCard(true);
binding.cvCard.setCardBackgroundColor(R.color.blue);
payment = "Card";
}
});
} }
public void btnPay(View view) { public void btnPay(View view) {
if (TextUtils.isEmpty(binding.etAmountPaid.getText().toString())){ if (TextUtils.isEmpty(binding.etAmountPaid.getText().toString())){
ViewUtil.showMessage(view, "Please input Amount Paid by Customer!"); ViewUtil.showMessage(view, "Please input Amount Paid by Customer!");
}else { }else if (payment.equals("")){
ViewUtil.showMessage(view, "Please choose type payment");
} else {
int amountPaid = Integer.parseInt(binding.etAmountPaid.getText().toString()); int amountPaid = Integer.parseInt(binding.etAmountPaid.getText().toString());
refund = amountPaid - amount; refund = amountPaid - amount;
startActivity(new Intent(PaymentActivity.this, StatusPayment.class).putExtra(REFUND, refund)); startActivity(new Intent(PaymentActivity.this, StatusPayment.class).putExtra(REFUND, refund).putExtra(PAY_WITH, payment));
cartViewModel.clear(); cartViewModel.clear();
finish(); finish();
} }
} }
// public void changeCvColor(MotionEvent event, CardView cv){
// if (change) {
// change = false;
// switch (event.getAction()) {
// case MotionEvent.ACTION_DOWN:
// cv.setCardBackgroundColor(getResources().getColor(R.color.choose_payment));
// break;
// case MotionEvent.ACTION_UP:
// cv.setCardBackgroundColor(getResources().getColor(R.color.white));
// }
// } else {
// change = true;
// switch (event.getAction()) {
// case MotionEvent.ACTION_DOWN:
// cv.setCardBackgroundColor(getResources().getColor(R.color.white));
// break;
// case MotionEvent.ACTION_UP:
// cv.setCardBackgroundColor(getResources().getColor(R.color.choose_payment));
// }
// }
// }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
......
...@@ -24,6 +24,9 @@ public class StatusPayment extends AppCompatActivity { ...@@ -24,6 +24,9 @@ public class StatusPayment extends AppCompatActivity {
int refund = getIntent().getIntExtra(PaymentActivity.REFUND, 0); int refund = getIntent().getIntExtra(PaymentActivity.REFUND, 0);
Log.d("Tag", String.valueOf(refund)); Log.d("Tag", String.valueOf(refund));
binding.setRefund(Convert.changeToCurrency(refund)); binding.setRefund(Convert.changeToCurrency(refund));
String status_pay = getIntent().getStringExtra(PaymentActivity.PAY_WITH);
binding.tvPaymentSuccess.setText("Payment by " + status_pay +" was successful");
} }
public void btnFinish(View view) { public void btnFinish(View view) {
......
...@@ -4,6 +4,14 @@ ...@@ -4,6 +4,14 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<data> <data>
<variable
name="checkCash"
type="boolean" />
<variable
name="checkCard"
type="boolean" />
<variable <variable
name="amount" name="amount"
type="String" /> type="String" />
...@@ -77,11 +85,10 @@ ...@@ -77,11 +85,10 @@
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:buttonTint="@color/black" android:buttonTint="@color/black"
android:text="Cash" android:text="Cash"
android:checked="@{checkCash}"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/>
>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
...@@ -117,6 +124,7 @@ ...@@ -117,6 +124,7 @@
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:buttonTint="@color/black" android:buttonTint="@color/black"
android:text="Card" android:text="Card"
android:checked="@{checkCard}"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/>
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<ProgressBar <ProgressBar
android:id="@+id/pbLoading" android:id="@+id/pbLoading"
android:layout_width="128dp" android:layout_width="50dp"
android:layout_height="128dp" android:layout_height="50dp"
android:layout_centerInParent="true" /> android:layout_centerInParent="true" />
</RelativeLayout> </RelativeLayout>
\ 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