Commit f2818dac authored by Muhammad Suryono's avatar Muhammad Suryono

update lagi

parent a0cdffa2
......@@ -32,10 +32,13 @@ import com.google.android.material.button.MaterialButton;
import com.google.android.material.textview.MaterialTextView;
import com.yono.messeripos.adapter.CartAdapter;
import com.yono.messeripos.api.client.Client;
import com.yono.messeripos.api.service.OrdersService;
import com.yono.messeripos.api.service.PaymentService;
import com.yono.messeripos.api.service.ProductService;
import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.models.ProductModels;
import com.yono.messeripos.response.DataResponse;
import com.yono.messeripos.response.OrdersResponse;
import com.yono.messeripos.utils.Utils;
......@@ -67,6 +70,7 @@ public class CartActivity extends AppCompatActivity {
MaterialButton btnSaveCart;
Button btnCheckout;
CardView cardView;
PaymentsModels paymentsModelsIntent;
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
......@@ -87,27 +91,10 @@ public class CartActivity extends AppCompatActivity {
cartEmptyImage.setVisibility(View.GONE);
cartEmptyText.setVisibility(View.GONE);
modelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
// actionSaveCart();
btnSaveCart.setOnClickListener(view -> actionSaveCart());
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
sharedPreferences = getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
// Log.i("Id Order on acart", "onCreate: "+orderId);
// if (orderId.isEmpty()){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString(ORDER_ID, "MES-ORDER"+orderId);
//
// if (editor.commit()){
// Toast.makeText(CartActivity.this, orderId, Toast.LENGTH_LONG).show();
// }
// }
// Toolbars
MaterialToolbar toolbars = findViewById(R.id.cAppBar);
setSupportActionBar(toolbars);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
......@@ -115,6 +102,12 @@ public class CartActivity extends AppCompatActivity {
getSupportActionBar().setTitle("Cart");
toolbars.setNavigationOnClickListener(view -> onBackPressed());
modelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
paymentsModelsIntent = getIntent().getParcelableExtra(HistoryActivity.DATA_TRANSACTION_PENDING);
// actionSaveCart();
btnSaveCart.setOnClickListener(view -> actionSaveCart());
cartAdapter = new CartAdapter();
LinearLayoutManager llm = new LinearLayoutManager(this);
......@@ -126,21 +119,60 @@ public class CartActivity extends AppCompatActivity {
modelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
// show to cart
modelsCart.getCartById(orderId).observe(this, new Observer<List<ProductCartModels>>() {
@Override
public void onChanged(List<ProductCartModels> productCartModels) {
if (!productCartModels.isEmpty()) {
dataCart = productCartModels;
cartAdapter.setCartAdapter(CartActivity.this, productCartModels);
recyclerView.setAdapter(cartAdapter);
}else {
cartEmptyText.setVisibility(View.VISIBLE);
cartEmptyImage.setVisibility(View.VISIBLE);
cardView.setVisibility(View.GONE);
recyclerView.setVisibility(View.GONE);
Log.i("GET CART", "onCreate: "+paymentsModelsIntent);
if (paymentsModelsIntent == null){
modelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
modelsCart.getCartById(orderId).observe(this, new Observer<List<ProductCartModels>>() {
@Override
public void onChanged(List<ProductCartModels> productCartModels) {
if (!productCartModels.isEmpty()) {
dataCart = productCartModels;
cartAdapter.setCartAdapter(CartActivity.this, productCartModels);
recyclerView.setAdapter(cartAdapter);
}else {
cartEmptyText.setVisibility(View.VISIBLE);
cartEmptyImage.setVisibility(View.VISIBLE);
cardView.setVisibility(View.GONE);
recyclerView.setVisibility(View.GONE);
}
}
}
});
});
}else{
Log.i("ADA_DATA", "onCreate: "+utils.convertGson(paymentsModelsIntent));
Client client = new Client();
OrdersService ordersService = client.Client(OrdersService.class);
// modelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
// modelsCart.getCartById(paymentsModelsIntent.getOrderId()).observe(this, new Observer<List<ProductCartModels>>() {
// @Override
// public void onChanged(List<ProductCartModels> productCartModels) {
// Log.i("ADA_DATA1", "onCreate: "+utils.convertGson(paymentsModelsIntent.getOrderId()));
// Log.i("ADA_DATA2", "onCreate: "+utils.convertGson(productCartModels));
// if (!productCartModels.isEmpty()) {
// dataCart = productCartModels;
// cartAdapter.setCartAdapter(CartActivity.this, productCartModels);
// recyclerView.setAdapter(cartAdapter);
// }else {
// cartEmptyText.setVisibility(View.VISIBLE);
// cartEmptyImage.setVisibility(View.VISIBLE);
// cardView.setVisibility(View.GONE);
// recyclerView.setVisibility(View.GONE);
// }
// }
// });
ordersService.getOrdersProductById(paymentsModelsIntent.getOrderId()).enqueue(new Callback<DataResponse<OrdersResponse<List<ProductModels>>>>() {
@Override
public void onResponse(Call<DataResponse<OrdersResponse<List<ProductModels>>>> call, Response<DataResponse<OrdersResponse<List<ProductModels>>>> response) {
Log.i("TAG", "onResponse: "+utils.convertGson(response.body().getData()));
}
@Override
public void onFailure(Call<DataResponse<OrdersResponse<List<ProductModels>>>> call, Throwable t) {
Log.e("error", "onFailure: "+t.getMessage(),t );
}
});
}
cartAdapter.setListener(new CartAdapter.CartListener() {
......
......@@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
......@@ -14,6 +15,7 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.google.android.material.appbar.MaterialToolbar;
import com.yono.messeripos.adapter.TransactionAdapter;
......@@ -35,6 +37,8 @@ public class HistoryActivity extends AppCompatActivity {
Utils utils = new Utils();
ProgressBar loading;
public static final String DATA_TRANSACTION_PENDING = "DATA_TRANSACTION_PENDING";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -81,10 +85,22 @@ public class HistoryActivity extends AppCompatActivity {
transactionAdapter.setListener(new TransactionAdapter.TransactionListener() {
@Override
public void onShowDetail(PaymentsModels paymentsModels) {
//set detail on click card
Intent intent = new Intent(HistoryActivity.this,PaymentActivity.class);
startActivity(intent);
if (paymentsModels.getPaymentType().equals("bank_transfer") && paymentsModels.getTransactionStatus().equals("settlement")){
new AlertDialog.Builder(HistoryActivity.this)
.setTitle("Transaction")
.setMessage("Transaction success!").show();
}else if (paymentsModels.getPaymentType().equals("bank_transfer") && paymentsModels.getTransactionStatus().equals("pending")){
new AlertDialog.Builder(HistoryActivity.this)
.setTitle("Transaction")
.setMessage("Waiting payment!").show();
}else if (paymentsModels.getPaymentType().equals("cash")){
new AlertDialog.Builder(HistoryActivity.this)
.setTitle("Transaction")
.setMessage("Transaction success!").show();
}else if (paymentsModels.getPaymentType().equals("pending")){
startActivity(new Intent(HistoryActivity.this,
CartActivity.class).putExtra(DATA_TRANSACTION_PENDING, paymentsModels));
}
}
});
......
......@@ -2,6 +2,7 @@ package com.yono.messeripos.api.service;
import com.yono.messeripos.api.ApiHelper;
import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.models.ProductModels;
import com.yono.messeripos.response.DataResponse;
import com.yono.messeripos.response.OrdersResponse;
......@@ -9,10 +10,14 @@ import java.util.List;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface OrdersService {
@POST(ApiHelper.VERSI_API_1+"order")
Call<DataResponse> postOrders(@Body OrdersResponse cartPost);
@GET(ApiHelper.VERSI_API_1+"order-products/{id}")
Call<DataResponse<OrdersResponse<List<ProductModels>>>> getOrdersProductById(@Path("id") String id);
}
......@@ -6,9 +6,14 @@ import com.yono.messeripos.response.DataResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface PaymentService {
@POST(ApiHelper.VERSI_API_1+"payment")
Call<DataResponse<PaymentsModels>> postFromCart(@Body PaymentsModels paymentsModels);
@GET(ApiHelper.VERSI_API_1+"payment/{id}")
Call<DataResponse<PaymentsModels>> getTransactionById(@Body PaymentsModels paymentsModels, @Path("id") int id);
}
......@@ -32,7 +32,7 @@ public abstract class LocalDatabase extends RoomDatabase {
synchronized (LocalDatabase.class){
if (INSTANCE == null){
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
LocalDatabase.class, "db_messer").build();
LocalDatabase.class, "db_new").build();
}
}
}
......
package com.yono.messeripos.models;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import android.widget.ImageView;
......@@ -8,7 +10,7 @@ import androidx.databinding.BindingAdapter;
import com.google.gson.annotations.SerializedName;
import com.yono.messeripos.R;
public class PaymentsModels {
public class PaymentsModels implements Parcelable {
@SerializedName("order_code")
private String orderId;
......@@ -44,6 +46,29 @@ public class PaymentsModels {
this.grossAmount = grossAmount;
}
protected PaymentsModels(Parcel in) {
orderId = in.readString();
paymentType = in.readString();
bank = in.readString();
grossAmount = in.readLong();
transactionStatus = in.readString();
createdAt = in.readString();
updatedAt = in.readString();
nomorPembayaran = in.readString();
}
public static final Creator<PaymentsModels> CREATOR = new Creator<PaymentsModels>() {
@Override
public PaymentsModels createFromParcel(Parcel in) {
return new PaymentsModels(in);
}
@Override
public PaymentsModels[] newArray(int size) {
return new PaymentsModels[size];
}
};
public String getOrderId() {
return orderId;
}
......@@ -109,4 +134,20 @@ public class PaymentsModels {
this.nomorPembayaran = nomorPembayaran;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(orderId);
parcel.writeString(paymentType);
parcel.writeString(bank);
parcel.writeLong(grossAmount);
parcel.writeString(transactionStatus);
parcel.writeString(createdAt);
parcel.writeString(updatedAt);
parcel.writeString(nomorPembayaran);
}
}
......@@ -142,4 +142,5 @@ public class ProductCartModels implements Parcelable {
public void setGrand_total_orders(int grand_total_orders) {
this.grand_total_orders = grand_total_orders;
}
}
......@@ -4,7 +4,10 @@
<item>
<shape>
<corners android:bottomLeftRadius="50mm"/>
<gradient android:startColor="#1B76D6" android:endColor="#3028A1"/>
<gradient
android:angle="90"
android:startColor="@color/colorPrimary"
android:endColor="@color/colorPrimaryDark"/>
<size android:height="100sp"/>
</shape>
</item>
......
......@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient android:startColor="#1B76D6" android:endColor="#3028A1" android:angle="90"/>
<gradient android:startColor="@color/colorPrimary" android:endColor="@color/colorPrimaryDark" android:angle="90"/>
</shape>
</item>
</selector>
\ No newline at end of file
......@@ -3,14 +3,14 @@
android:color="#74333333">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#25333333"/>
<solid android:color="@color/colorPrimary"/>
<corners android:radius="50dp"/>
</shape>
</item>
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<solid android:color="#0D333333"/>
<solid android:color="@color/colorPrimary"/>
<corners android:radius="50dp" />
</shape>
</item>
......
......@@ -58,7 +58,7 @@
android:id="@+id/btSave"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:backgroundTint="#FB8C00"
android:backgroundTint="#fcbf1e"
android:gravity="center"
android:text="save"
android:textAllCaps="true"
......
......@@ -25,7 +25,7 @@
android:id="@+id/tvLoginToAcc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_medium"
android:text="Login to your account"
android:textSize="16sp"
android:textFontWeight="600"
......@@ -76,7 +76,7 @@
android:textColor="@color/colorWhite"
android:inputType="text"
android:imeOptions="actionNext"
android:fontFamily="@font/poppins_medium" />
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
......@@ -100,7 +100,7 @@
android:textColor="@color/colorWhite"
android:inputType="textPassword"
android:imeOptions="actionGo"
android:fontFamily="@font/poppins_medium" />
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
......@@ -108,11 +108,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="#2041B8"
android:fontFamily="@font/poppins_medium"
android:backgroundTint="@color/colorWhite"
android:imeOptions="actionGo"
android:paddingVertical="15dp"
android:text="login"
android:textColor="@color/colorPrimary"
android:textFontWeight="600"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -123,7 +125,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/poppins_medium"
android:text="forgot your password ?"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -50,12 +50,22 @@
</com.google.android.material.appbar.AppBarLayout>
<TextView
android:id="@+id/tvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topBar"
android:textColor="@android:color/black"
android:textSize="18sp"
android:textAllCaps="true"
android:layout_margin="5dp"
android:text="Category"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/item_category"
android:layout_below="@id/topBar"/>
android:layout_below="@id/tvCategory"/>
<ImageView
android:id="@+id/imgEmpty"
......@@ -76,6 +86,18 @@
android:layout_centerInParent="true"/>
<!-- Scrollable content -->
<TextView
android:id="@+id/tvProduct"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rvCategory"
android:textColor="@android:color/black"
android:textSize="18sp"
android:textAllCaps="true"
android:layout_margin="5dp"
android:text="Product"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvProduct"
android:layout_width="match_parent"
......@@ -85,7 +107,7 @@
app:spanCount="2"
android:layout_marginHorizontal="5dp"
tools:listitem="@layout/item_list"
android:layout_below="@id/rvCategory"/>
android:layout_below="@id/tvProduct"/>
</RelativeLayout>
......
......@@ -119,18 +119,31 @@
<com.jaredrummler.materialspinner.MaterialSpinner
android:id="@+id/listCategory"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/stroke_spinner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tfStock"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintEnd_toStartOf="@id/btnAddCategory"
app:ms_dropdown_height="wrap_content"
app:ms_dropdown_max_height="350dp"
app:layout_constraintStart_toStartOf="parent"
app:ms_background_selector="0xFFFFFF"
tools:layout_editor_absoluteX="0dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnAddCategory"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:foregroundGravity="bottom"
android:text="@string/add"
android:padding="14dp"
android:backgroundTint="@color/colorAccentDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/listCategory"
app:layout_constraintBottom_toBottomOf="@id/listCategory"
tools:layout_editor_absoluteX="16dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnAdd"
......
......@@ -19,12 +19,12 @@
android:id="@+id/cvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#2041B8"
android:backgroundTint="@color/colorPrimary"
android:clickable="true"
android:focusable="true"
android:checkable="true"
app:cardCornerRadius="50dp"
android:clipToPadding="true"
android:background="@drawable/ic_rounded_circle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#2041B8</color>
<color name="colorPrimaryDark">#3498DB</color>
<color name="colorAccent">#2793DC</color>
<color name="colorPrimary">#4d089a</color>
<color name="colorPrimaryDark">#323edd</color>
<color name="colorAccent">#dc2ade</color>
<color name="colorAccentDark">#e8f044</color>
<color name="colorWhite">#fff</color>
<color name="mtrl_textinput_default_box_stroke_color">#fff</color>
<color name="color_stroke">#22333333</color>
......
......@@ -22,7 +22,7 @@
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:fontFamily">@font/poppins_medium</item>
<item name="android:fontFamily">@font/roboto</item>
<item name="actionBarStyle">@style/ThemeActionBar</item>
</style>
......
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