Commit b1efe15a authored by Alfansyah Fadlian's avatar Alfansyah Fadlian

tes

parents 005a5c7f aee372a2
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<activity <activity
android:name=".BottomSheets" android:name=".BottomSheets"
tools:ignore="Instantiatable" /> tools:ignore="Instantiatable" />
<activity android:name=".QRCode" /> <activity android:name=".PaymentCreated" />
<activity <activity
android:name=".HistoryActivity" android:name=".HistoryActivity"
android:theme="@style/AppTheme.appbar" /> android:theme="@style/AppTheme.appbar" />
......
...@@ -47,19 +47,17 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -47,19 +47,17 @@ public class BottomSheets extends BottomSheetDialogFragment {
Utils utils; Utils utils;
String defaultText = "0"; String defaultText = "0";
Client client = new Client(); Client client = new Client();
<<<<<<< HEAD
public static long grossAmount,result, input;
=======
public static long grossAmount, input, result; public static long grossAmount, input, result;
>>>>>>> 11ad115d91d3c4c2c59b6e78989bffbbad0f3ed1
SharedPreferences sharedPreferences; SharedPreferences sharedPreferences;
public static BottomSheetBehavior bottomSheetBehavior; public static BottomSheetBehavior bottomSheetBehavior;
RelativeLayout layoutFormCash; RelativeLayout layoutFormCash;
int statusUpdatePayment = 0;
PaymentsModels paymentsModels; public static PaymentsModels paymentsModels;
public BottomSheets(PaymentsModels paymentsModels) { public BottomSheets(PaymentsModels paymentsModels, int statusUpdatePayment) {
this.paymentsModels = paymentsModels; this.paymentsModels = paymentsModels;
this.statusUpdatePayment = statusUpdatePayment;
} }
public interface CashListener { public interface CashListener {
...@@ -74,8 +72,7 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -74,8 +72,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable public View onCreateView(LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState) ViewGroup container, @Nullable Bundle savedInstanceState) {
{
View v = inflater.inflate(R.layout.activity_bottom_sheets, View v = inflater.inflate(R.layout.activity_bottom_sheets,
container, false); container, false);
...@@ -86,16 +83,13 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -86,16 +83,13 @@ public class BottomSheets extends BottomSheetDialogFragment {
btnCash = v.findViewById(R.id.btnCash); btnCash = v.findViewById(R.id.btnCash);
totalHarga = v.findViewById(R.id.totalHarga); totalHarga = v.findViewById(R.id.totalHarga);
utils = new Utils(); utils = new Utils();
<<<<<<< HEAD
=======
btnCash.setEnabled(false); btnCash.setEnabled(false);
>>>>>>> 11ad115d91d3c4c2c59b6e78989bffbbad0f3ed1
// bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash); // bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
sharedPreferences = getActivity().getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE); sharedPreferences = getActivity().getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
Log.i("BITTOM", "BottomSheets: "+utils.convertGson(paymentsModels)+"ID "+statusUpdatePayment);
long ga = paymentsModels.getGrossAmount(); long ga = paymentsModels.getGrossAmount();
String setCurrency = utils.convertPrice("Rp.", ga); String setCurrency = utils.convertPrice("Rp.", ga);
...@@ -115,7 +109,7 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -115,7 +109,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
// case BottomSheetBehavior.STATE_DRAGGING: // case BottomSheetBehavior.STATE_DRAGGING:
// break; // break;
// case BottomSheetBehavior.STATE_SETTLING: // case BottomSheetBehavior.STATE_SETTLING:
// break; // break;int
// } // }
// } // }
...@@ -141,15 +135,16 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -141,15 +135,16 @@ public class BottomSheets extends BottomSheetDialogFragment {
grossAmount = paymentsModels.getGrossAmount(); grossAmount = paymentsModels.getGrossAmount();
input = Long.parseLong(inputAmount.getText().toString()); input = Long.parseLong(inputAmount.getText().toString());
result = input-grossAmount; result = input - grossAmount;
if (result > 0) { if (result >= 0) {
btnCash.setEnabled(true); btnCash.setEnabled(true);
}else { } else {
btnCash.setEnabled(false); btnCash.setEnabled(false);
} }
hargaChange.setText(utils.convertPrice("Rp.", result)); hargaChange.setText(utils.convertPrice("Rp.", result));
} }
@Override @Override
...@@ -166,19 +161,20 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -166,19 +161,20 @@ public class BottomSheets extends BottomSheetDialogFragment {
private void bayar(View view) { private void bayar(View view) {
// String orderId, String paymentType, String bank, long grossAmount // String orderId, String paymentType, String bank, long grossAmount
PaymentsModels paymentsModels = new PaymentsModels( PaymentsModels paymentsModels1 = new PaymentsModels();
sharedPreferences.getString(ORDER_ID, ""), paymentsModels1.setTransactionStatus("success");
"cash", paymentsModels1.setPaymentType("cash");
"none", paymentsModels1.setGrossAmount(grossAmount);
grossAmount paymentsModels1.setBank("");
);
PaymentService paymentService = client.Client(PaymentService.class); PaymentService paymentService = client.Client(PaymentService.class);
<<<<<<< HEAD
paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels<List<VaNumberModels>>>>() { if (statusUpdatePayment == 0){
paymentsModels1.setOrderId(sharedPreferences.getString(ORDER_ID, ""));
paymentService.postFromCart(paymentsModels1).enqueue(new Callback<DataResponse<PaymentsModels<List<VaNumberModels>>>>() {
@Override @Override
public void onResponse(Call<DataResponse<PaymentsModels<List<VaNumberModels>>>> call, Response<DataResponse<PaymentsModels<List<VaNumberModels>>>> response) { public void onResponse(Call<DataResponse<PaymentsModels<List<VaNumberModels>>>> call, Response<DataResponse<PaymentsModels<List<VaNumberModels>>>> response) {
Log.i("CASH", "onResponse: "+utils.convertGson(response.body())); Log.i("CASH_0", "onResponse: "+utils.convertGson(response.body()));
if (response.body() != null){ if (response.body() != null){
SharedPreferences.Editor editor = PaymentActivity.sharedPreferences.edit(); SharedPreferences.Editor editor = PaymentActivity.sharedPreferences.edit();
editor.putBoolean(CHECKOUT, false); editor.putBoolean(CHECKOUT, false);
...@@ -192,28 +188,35 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -192,28 +188,35 @@ public class BottomSheets extends BottomSheetDialogFragment {
@Override @Override
public void onFailure(Call<DataResponse<PaymentsModels<List<VaNumberModels>>>> call, Throwable t) { public void onFailure(Call<DataResponse<PaymentsModels<List<VaNumberModels>>>> call, Throwable t) {
=======
paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels>>() { }
});
}else{
paymentsModels.setTransactionStatus("success");
paymentsModels.setPaymentType("cash");
paymentService.postFromCartPending(paymentsModels.getOrderId(), paymentsModels).enqueue(new Callback<DataResponse>() {
@Override @Override
public void onResponse(Call<DataResponse<PaymentsModels>> call, Response<DataResponse<PaymentsModels>> response) { public void onResponse(Call<DataResponse> call, Response<DataResponse> response) {
Log.i("CASH", "onResponse: " + utils.convertGson(response.body())); Log.i("CASH_1", "onResponse: "+utils.convertGson(paymentsModels));
if (response.body() != null) { if (response.body() != null){
SharedPreferences.Editor editor = PaymentActivity.sharedPreferences.edit(); SharedPreferences.Editor editor = PaymentActivity.sharedPreferences.edit();
editor.putBoolean(CHECKOUT, false); editor.putBoolean(CHECKOUT, false);
editor.putString(ORDER_ID, ""); editor.putString(ORDER_ID, "");
if (editor.commit()) { if (editor.commit()){
Intent i = new Intent(getActivity(), MainActivity.class); Intent i = new Intent(getActivity(), MainActivity.class);
view.getContext().startActivity(i); view.getContext().startActivity(i);
} }
} }
} }
@Override @Override
public void onFailure(Call<DataResponse<PaymentsModels>> call, Throwable t) { public void onFailure(Call<DataResponse> call, Throwable t) {
>>>>>>> 11ad115d91d3c4c2c59b6e78989bffbbad0f3ed1
} }
}); });
}
} }
} }
...@@ -2,9 +2,9 @@ package com.yono.messeripos; ...@@ -2,9 +2,9 @@ package com.yono.messeripos;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point; import android.graphics.Point;
import android.os.Bundle; import android.os.Bundle;
...@@ -14,12 +14,12 @@ import android.view.LayoutInflater; ...@@ -14,12 +14,12 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.EditText; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textview.MaterialTextView; import com.google.android.material.textview.MaterialTextView;
import com.google.zxing.WriterException;
import com.yono.messeripos.models.PaymentsModels; import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.VaNumberModels; import com.yono.messeripos.models.VaNumberModels;
import com.yono.messeripos.response.DataResponse; import com.yono.messeripos.response.DataResponse;
...@@ -29,20 +29,9 @@ import java.util.List; ...@@ -29,20 +29,9 @@ import java.util.List;
import androidmads.library.qrgenearator.QRGContents; import androidmads.library.qrgenearator.QRGContents;
import androidmads.library.qrgenearator.QRGEncoder; import androidmads.library.qrgenearator.QRGEncoder;
public class QRCode extends BottomSheetDialogFragment { public class PaymentCreated extends BottomSheetDialogFragment {
ImageView qrCode; Button btnHome;
MaterialTextView vaText;
QRGEncoder qrgEncoder;
String inputValue;
Bitmap bitmap;
DataResponse<PaymentsModels<List<VaNumberModels>>> paymentsModels;
public QRCode(DataResponse<PaymentsModels<List<VaNumberModels>>> paymentsModels) {
this.paymentsModels = paymentsModels;
Log.d("TAG", "QRCode: "+paymentsModels);
}
@Nullable @Nullable
@Override @Override
...@@ -53,33 +42,44 @@ public class QRCode extends BottomSheetDialogFragment { ...@@ -53,33 +42,44 @@ public class QRCode extends BottomSheetDialogFragment {
false false
); );
qrCode = v.findViewById(R.id.qr_image); btnHome = v.findViewById(R.id.btnBackHome);
vaText = v.findViewById(R.id.etVA);
WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point point = new Point();
display.getSize(point);
int width = point.x;
int height = point.y;
int smallDimens = Math.min(width, height);
smallDimens = smallDimens * 3 / 4;
qrgEncoder = new QRGEncoder(
"inputValue", null,
QRGContents.Type.TEXT,
smallDimens
);
try { btnHome.setOnClickListener(new View.OnClickListener() {
bitmap = qrgEncoder.getBitmap(); @Override
qrCode.setImageBitmap(bitmap); public void onClick(View view) {
}catch (Exception e) { startActivity(new Intent(v.getContext(), MainActivity.class));
Log.d("onCreate: ", e.toString()); getActivity().finish();
} }
});
return v; return v;
} }
} }
// qrCode = v.findViewById(R.id.qr_image);
// vaText = v.findViewById(R.id.etVA);
//
// WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
//
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// int width = point.x;
// int height = point.y;
// int smallDimens = Math.min(width, height);
// smallDimens = smallDimens * 3 / 4;
// qrgEncoder = new QRGEncoder(
// "inputValue", null,
// QRGContents.Type.TEXT,
// smallDimens
// );
//
// try {
// bitmap = qrgEncoder.getBitmap();
// qrCode.setImageBitmap(bitmap);
// }catch (Exception e) {
// Log.d("onCreate: ", e.toString());
// }
//
// return v;
// }
<vector android:height="128dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="128dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
</vector>
...@@ -13,27 +13,48 @@ ...@@ -13,27 +13,48 @@
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView <ImageView
android:id="@+id/qr_image" android:id="@+id/successIcon"
android:layout_width="300dp" android:layout_width="351dp"
android:layout_height="300dp" android:layout_height="181dp"
android:backgroundTint="#333" android:layout_marginTop="64dp"
android:src="@mipmap/ic_launcher" android:src="@drawable/payment_created"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/paymentCreated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:text="Payment Success Created"
android:textFontWeight="600"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
/> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/successIcon" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/etVA" android:id="@+id/textDetail"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Va_Text" android:text="Please make a payment"
android:textSize="20sp" app:layout_constraintEnd_toEndOf="parent"
android:textStyle="bold" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/qr_image" app:layout_constraintTop_toBottomOf="@id/paymentCreated" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnBackHome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginVertical="20dp"
android:text="back to home"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textDetail"
app:layout_constraintVertical_bias="0.997" />
/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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