Commit 89dcbb63 authored by Muhammad Suryono's avatar Muhammad Suryono

Update ya

parent d280a465
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:theme="@style/AppTheme.appbar" /> android:theme="@style/AppTheme.appbar" />
<activity android:name=".FormProductActivity" /> <activity android:name=".FormProductActivity"
android:windowSoftInputMode="adjustResize"/>
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
......
...@@ -7,6 +7,7 @@ import android.content.Intent; ...@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
...@@ -229,7 +230,9 @@ public class CartActivity extends AppCompatActivity { ...@@ -229,7 +230,9 @@ public class CartActivity extends AppCompatActivity {
} }
private void actionSaveCart() { private void actionSaveCart() {
ProgressDialog progressDialog = new ProgressDialog(CartActivity.this);
progressDialog.setMessage("Creating your orders....");
progressDialog.show();
Client client = new Client(); Client client = new Client();
modelsCart.getCartById(sharedPreferences.getString(ORDER_ID, "")).observe(this, new Observer<List<ProductCartModels>>() { modelsCart.getCartById(sharedPreferences.getString(ORDER_ID, "")).observe(this, new Observer<List<ProductCartModels>>() {
@Override @Override
...@@ -249,7 +252,18 @@ public class CartActivity extends AppCompatActivity { ...@@ -249,7 +252,18 @@ public class CartActivity extends AppCompatActivity {
paymentPending.setTransaction_time(utils.dateNow()); paymentPending.setTransaction_time(utils.dateNow());
Log.i("Convert Input", "onChanged: "+utils.convertGson(paymentPending)); Log.i("Convert Input", "onChanged: "+utils.convertGson(paymentPending));
modelsCart.savePaymentPending(paymentPending); modelsCart.savePaymentPending(paymentPending);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(ORDER_ID, "");
if (editor.commit()){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
startActivity(new Intent(CartActivity.this, MainActivity.class));
finish();
}
}, 700);
}
} }
}); });
} }
......
...@@ -10,6 +10,7 @@ import androidx.viewpager.widget.ViewPager; ...@@ -10,6 +10,7 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import com.yono.messeripos.adapter.TabAdapterTransaction; import com.yono.messeripos.adapter.TabAdapterTransaction;
import com.yono.messeripos.transactiontab.TransactionPending;
import com.yono.messeripos.transactiontab.TransactionSuccess; import com.yono.messeripos.transactiontab.TransactionSuccess;
import java.util.Objects; import java.util.Objects;
...@@ -34,7 +35,7 @@ public class TransactionActivity extends AppCompatActivity { ...@@ -34,7 +35,7 @@ public class TransactionActivity extends AppCompatActivity {
adapter = new TabAdapterTransaction(getSupportFragmentManager()); adapter = new TabAdapterTransaction(getSupportFragmentManager());
adapter.addFragment(new TransactionSuccess(), "Transaction Success"); adapter.addFragment(new TransactionSuccess(), "Transaction Success");
adapter.addFragment(new TransactionSuccess(), "Transaction Pending"); adapter.addFragment(new TransactionPending(), "Transaction Pending");
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
......
package com.yono.messeripos.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.yono.messeripos.R;
import com.yono.messeripos.databinding.ItemPendingBinding;
import com.yono.messeripos.models.PaymentPending;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.utils.Utils;
import java.util.ArrayList;
public class PendingAdapter extends RecyclerView.Adapter<PendingAdapter.MyViewHolder> {
private ArrayList<PaymentPending> paymentPendings = new ArrayList<>();
Context context;
Utils utils = new Utils();
public void setPendingAdapter(Context context, ArrayList<PaymentPending> paymentPending){
this.paymentPendings = paymentPending;
this.context = context;
}
@NonNull
@Override
public PendingAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemPendingBinding itemPendingBinding = DataBindingUtil.inflate(
LayoutInflater.from(parent.getContext()),
R.layout.item_pending,
parent,
false
);
return new MyViewHolder(itemPendingBinding);
}
@Override
public void onBindViewHolder(@NonNull PendingAdapter.MyViewHolder holder, int position) {
holder.binData(paymentPendings.get(position));
}
@Override
public int getItemCount() {
return paymentPendings.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
ItemPendingBinding binding;
public MyViewHolder(@NonNull ItemPendingBinding itemView) {
super(itemView.getRoot());
binding = itemView;
}
public void binData(PaymentPending paymentPending) {
binding.setTransaction(paymentPending);
binding.setDate(paymentPending.getTransaction_time());
binding.setGrossAmount(utils.convertPrice("Rp. ", paymentPending.getGross_amount()));
}
}
}
...@@ -68,6 +68,10 @@ public class MainViewModelsCart extends AndroidViewModel { ...@@ -68,6 +68,10 @@ public class MainViewModelsCart extends AndroidViewModel {
paymentPendingRepositories.insert(paymentPending); paymentPendingRepositories.insert(paymentPending);
} }
public LiveData<List<PaymentPending>> getAllPaymentPending(){
return paymentPendingRepositories.getPaymentPending();
}
public void insertPayments(){ public void insertPayments(){
} }
......
...@@ -21,6 +21,10 @@ public class PaymentPendingRepositories { ...@@ -21,6 +21,10 @@ public class PaymentPendingRepositories {
paymentPending = daos.getAll(); paymentPending = daos.getAll();
} }
public LiveData<List<PaymentPending>> getPaymentPending(){
return paymentPending;
}
public void insert(PaymentPending paymentPending){ public void insert(PaymentPending paymentPending){
LocalDatabase.databaseWriterExecutor.execute(() -> daos.insertPaymentPending(paymentPending)); LocalDatabase.databaseWriterExecutor.execute(() -> daos.insertPaymentPending(paymentPending));
} }
......
package com.yono.messeripos.transactiontab;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yono.messeripos.R;
import com.yono.messeripos.adapter.PendingAdapter;
import com.yono.messeripos.adapter.TransactionAdapter;
import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.PaymentPending;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.utils.Utils;
import java.util.ArrayList;
import java.util.List;
public class TransactionPending extends Fragment {
PendingAdapter pendingAdapter;
PaymentPending paymentPending;
MainViewModelsCart mainViewModelsCart;
RecyclerView recyclerView;
Utils utils = new Utils();
ProgressBar loading;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View v = inflater.inflate(
R.layout.activity_pending,
container,
false
);
mainViewModelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
recyclerView = v.findViewById(R.id.rvPending);
loading = v.findViewById(R.id.loadingPending);
pendingAdapter = new PendingAdapter();
LifecycleOwner lifecycleOwner = this;
loading.setVisibility(View.VISIBLE);
mainViewModelsCart.getAllPaymentPending().observe(lifecycleOwner, new Observer<List<PaymentPending>>() {
@Override
public void onChanged(List<PaymentPending> paymentPendings) {
Log.i("Get data", "onChanged: "+utils.convertGson(paymentPendings));
loading.setVisibility(View.GONE);
ArrayList<PaymentPending> pendingArrayList = new ArrayList<>();
pendingArrayList.addAll(paymentPendings);
pendingAdapter.setPendingAdapter(v.getContext(),pendingArrayList);
recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext(), RecyclerView.VERTICAL, false));
recyclerView.setAdapter(pendingAdapter);
}
});
return v;
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HistoryActivity">
<!-- <include-->
<!-- android:id="@+id/cAppBar"-->
<!-- layout="@layout/app_bar" />-->
<ProgressBar
android:id="@+id/loadingPending"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:elevation="1dp"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvPending"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/cAppBar"
tools:listitem="@layout/item_pending" />
</ScrollView>
</RelativeLayout>
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<data> <data>
<variable <variable
name="transaction" name="transaction"
type="com.yono.messeripos.models.PaymentsModels" /> type="com.yono.messeripos.models.PaymentPending" />
<variable <variable
name="date" name="date"
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
android:textStyle="bold" android:textStyle="bold"
android:textAllCaps="true" android:textAllCaps="true"
tools:text="@string/hint_pay" tools:text="@string/hint_pay"
android:text="@{transaction.paymentType}" android:text="Pending"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@font/roboto" android:fontFamily="@font/roboto"
android:textSize="16sp" android:textSize="16sp"
android:text="@{transaction.nomorPembayaranGet}" android:text="@{transaction.id_orders}"
tools:text="#6821739123" tools:text="#6821739123"
app:layout_constraintStart_toStartOf="@id/tvDate" app:layout_constraintStart_toStartOf="@id/tvDate"
app:layout_constraintTop_toBottomOf="@+id/tvDate" /> app:layout_constraintTop_toBottomOf="@+id/tvDate" />
......
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