Commit e5e292b8 authored by iman Fauzi's avatar iman Fauzi

fix conflict

parents 1e05ef17 4443b63a
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -6,7 +6,7 @@ android { ...@@ -6,7 +6,7 @@ android {
defaultConfig { defaultConfig {
applicationId "com.yono.messeripos" applicationId "com.yono.messeripos"
minSdkVersion 22 minSdkVersion 23
targetSdkVersion 30 targetSdkVersion 30
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
......
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
android:roundIcon="@mipmap/ic_launcher_new_icon" android:roundIcon="@mipmap/ic_launcher_new_icon"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme.appbar"> android:theme="@style/AppTheme.appbar">
<activity android:name=".InvoiceActivity"></activity> <activity
android:name=".HistoryActivity"
android:theme="@style/AppTheme.appbar" />
<activity android:name=".InvoiceActivity" />
<activity <activity
android:name=".LoginActivity" android:name=".LoginActivity"
android:theme="@style/AppTheme.appbar" /> android:theme="@style/AppTheme.appbar" />
......
...@@ -26,8 +26,6 @@ import com.yono.messeripos.models.MainViewModelsCart; ...@@ -26,8 +26,6 @@ import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.ProductCartModels; import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.response.OrdersResponse; import com.yono.messeripos.response.OrdersResponse;
import com.google.android.material.snackbar.Snackbar;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -59,9 +57,9 @@ public class CartActivity extends AppCompatActivity { ...@@ -59,9 +57,9 @@ public class CartActivity extends AppCompatActivity {
toolbars.setNavigationOnClickListener(view -> onBackPressed()); toolbars.setNavigationOnClickListener(view -> onBackPressed());
recyclerView = findViewById(R.id.rvCart); recyclerView = findViewById(R.id.rvCart);
cartAdapter = new CartAdapter();
btnCheckout = findViewById(R.id.btCheckout); btnCheckout = findViewById(R.id.btCheckout);
cartAdapter = new CartAdapter();
LinearLayoutManager llm = new LinearLayoutManager(this); LinearLayoutManager llm = new LinearLayoutManager(this);
recyclerView.setLayoutManager(llm); recyclerView.setLayoutManager(llm);
...@@ -74,7 +72,7 @@ public class CartActivity extends AppCompatActivity { ...@@ -74,7 +72,7 @@ public class CartActivity extends AppCompatActivity {
@Override @Override
public void onChanged(List<ProductCartModels> productCartModels) { public void onChanged(List<ProductCartModels> productCartModels) {
if (productCartModels != null){ if (productCartModels != null) {
dataCart = productCartModels; dataCart = productCartModels;
cartAdapter.setCartAdapter(CartActivity.this, productCartModels); cartAdapter.setCartAdapter(CartActivity.this, productCartModels);
recyclerView.setAdapter(cartAdapter); recyclerView.setAdapter(cartAdapter);
...@@ -90,14 +88,14 @@ public class CartActivity extends AppCompatActivity { ...@@ -90,14 +88,14 @@ public class CartActivity extends AppCompatActivity {
@Override @Override
public void onUpdateQuantityPlus(ProductCartModels productCartModels) { public void onUpdateQuantityPlus(ProductCartModels productCartModels) {
productCartModels.setQuantity_orders(productCartModels.getQuantity_orders()+1); productCartModels.setQuantity_orders(productCartModels.getQuantity_orders() + 1);
modelsCart.updateCart(productCartModels); modelsCart.updateCart(productCartModels);
} }
@Override @Override
public void onUpdateQuantityMinus(ProductCartModels productCartModels) { public void onUpdateQuantityMinus(ProductCartModels productCartModels) {
if (productCartModels.getQuantity_orders() > 1) { if (productCartModels.getQuantity_orders() > 1) {
productCartModels.setQuantity_orders(productCartModels.getQuantity_orders()-1); productCartModels.setQuantity_orders(productCartModels.getQuantity_orders() - 1);
modelsCart.updateCart(productCartModels); modelsCart.updateCart(productCartModels);
} }
} }
...@@ -116,16 +114,17 @@ public class CartActivity extends AppCompatActivity { ...@@ -116,16 +114,17 @@ public class CartActivity extends AppCompatActivity {
OrdersResponse ordersResponse = new OrdersResponse(); OrdersResponse ordersResponse = new OrdersResponse();
List<ProductCartModels> productCartModels; List<ProductCartModels> productCartModels;
Log.d("Data cart checkout", "onClick: "+dataCart); Log.d("Data cart checkout", "onClick: " + dataCart);
for (ProductCartModels pd : dataCart){ for (ProductCartModels pd : dataCart) {
ordersResponse.setOrders_id(pd.getId_orders()); ordersResponse.setOrders_id(pd.getId_orders());
} }
ordersResponse.setProduct_cart(dataCart); ordersResponse.setProduct_cart(dataCart);
modelsCart.insertOrders(ordersResponse); modelsCart.insertOrders(ordersResponse);
progressDialog.dismiss(); progressDialog.dismiss();
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(SplashScreen.CHECKOUT, true); editor.putBoolean(MainActivity.CHECKOUT, true);
if(editor.commit()){ if(editor.commit()){
startActivity(new Intent(CartActivity.this, PaymentActivity.class)); startActivity(new Intent(CartActivity.this, PaymentActivity.class));
finish(); finish();
......
package com.yono.messeripos; package com.yono.messeripos;
import android.Manifest;
import android.content.CursorLoader; import android.content.CursorLoader;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
...@@ -61,6 +62,9 @@ public class FormProductActivity extends AppCompatActivity { ...@@ -61,6 +62,9 @@ public class FormProductActivity extends AppCompatActivity {
"Oreo" "Oreo"
}; };
private String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -68,6 +72,7 @@ public class FormProductActivity extends AppCompatActivity { ...@@ -68,6 +72,7 @@ public class FormProductActivity extends AppCompatActivity {
binding.btnAdd.setText("Add New Prooduct"); binding.btnAdd.setText("Add New Prooduct");
productModels = new ProductModels(); productModels = new ProductModels();
requestPermissions(permissions, REQUEST_PERMISSIONS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); Window w = getWindow();
......
package com.yono.messeripos;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import com.google.android.material.appbar.MaterialToolbar;
import com.yono.messeripos.adapter.TransactionAdapter;
import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.response.DataResponse;
import com.yono.messeripos.utils.Utils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class HistoryActivity extends AppCompatActivity {
TransactionAdapter transactionAdapter;
PaymentsModels paymentsModels;
MainViewModels mainViewModels;
RecyclerView recyclerView;
Utils utils = new Utils();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
MaterialToolbar toolbars = findViewById(R.id.cAppBar);
recyclerView = findViewById(R.id.rvHistory);
recyclerView.addItemDecoration(utils.dividerItemDecoration(HistoryActivity.this));
transactionAdapter = new TransactionAdapter();
mainViewModels = new ViewModelProvider(this).get(MainViewModels.class);
setSupportActionBar(toolbars);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle("All Transaction");
toolbars.setNavigationOnClickListener(view -> onBackPressed());
mainViewModels.getAllTransactions().observe(HistoryActivity.this,
new Observer<DataResponse<List<PaymentsModels>>>() {
@Override
public void onChanged(DataResponse<List<PaymentsModels>> listDataResponse) {
ArrayList<PaymentsModels> newData = new ArrayList<>();
newData.addAll(listDataResponse.getData());
transactionAdapter.setTransactionAdapter(HistoryActivity.this, newData);
/*
* SET RECYCLE VIEW MANAGER DISINI
* GUNAKAN LINEARLAYOUT MANAGER VERTICAL UNTUK SETTING LAYOUT MANAGER
*
* SET RECYCLEVIEW ADAPTER DENGAN TRANSACTION ADAPTER
*
* UNTUK BISA CLICK CARD VIEW NYA
* PANGGIL ADAPTERNYA KEMUDIAN .setList.....
* SILAHKAN PINDAH KE ACTIVITY SELANJUTNYA PADA ON.....
* */
}
});
}
}
\ No newline at end of file
...@@ -7,12 +7,15 @@ import android.content.Intent; ...@@ -7,12 +7,15 @@ 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.text.Editable;
import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -36,6 +39,7 @@ import com.yono.messeripos.databinding.ActivityMainBinding; ...@@ -36,6 +39,7 @@ import com.yono.messeripos.databinding.ActivityMainBinding;
import com.yono.messeripos.models.CategoryModels; import com.yono.messeripos.models.CategoryModels;
import com.yono.messeripos.models.MainViewModels; import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.MainViewModelsCart; import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductCartModels; import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.models.ProductModels; import com.yono.messeripos.models.ProductModels;
import com.yono.messeripos.response.DataResponse; import com.yono.messeripos.response.DataResponse;
...@@ -52,29 +56,35 @@ public class MainActivity extends AppCompatActivity { ...@@ -52,29 +56,35 @@ public class MainActivity extends AppCompatActivity {
ProductAdapter productAdapter; ProductAdapter productAdapter;
CartAdapter cartAdapter; CartAdapter cartAdapter;
TextView txtBadge; TextView txtBadge;
EditText etSearch;
Utils utils = new Utils(); Utils utils = new Utils();
public static Boolean status_update = false; public static Boolean status_update = false;
MainViewModelsCart mainViewModelsCart; MainViewModelsCart mainViewModelsCart;
public static Boolean cartIsEmpty; public static Boolean cartIsEmpty;
SharedPreferences sharedPreferences; SharedPreferences sharedPreferences;
public static final String CHECKOUT = "checkout";
public static Boolean checkout;
public static Boolean selectCategory = false;
@SuppressLint("LongLogTag") @SuppressLint("LongLogTag")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ProductAdapter adapter = new ProductAdapter();
binding = DataBindingUtil.setContentView(this, R.layout.activity_main); binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
ProductAdapter adapter = new ProductAdapter();
binding.rvProduct.setAdapter(adapter); binding.rvProduct.setAdapter(adapter);
// binding.appBarUpdate.setVisibility(View.GONE); // binding.appBarUpdate.setVisibility(View.GONE);
Log.i("Status Checkout main activity", "onCreate: "+SplashScreen.checkout);
showLoading(true); showLoading(true);
categoryAdapter = new CategoryAdapter(); categoryAdapter = new CategoryAdapter();
productAdapter = new ProductAdapter(); productAdapter = new ProductAdapter();
mainViewModelsCart = new ViewModelProvider(MainActivity.this).get(MainViewModelsCart.class); mainViewModelsCart = new ViewModelProvider(MainActivity.this).get(MainViewModelsCart.class);
sharedPreferences = getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE); sharedPreferences = getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
checkout = sharedPreferences.getBoolean(CHECKOUT,false);
toolbar = findViewById(R.id.topAppBar);
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
...@@ -82,13 +92,29 @@ public class MainActivity extends AppCompatActivity { ...@@ -82,13 +92,29 @@ public class MainActivity extends AppCompatActivity {
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} }
toolbar = findViewById(R.id.topAppBar); binding.etSearchProduct.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
productAdapter.getFilter().filter(charSequence);
}
@Override
public void afterTextChanged(Editable editable) {
}
});
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.menu_cart) { if (id == R.id.menu_cart) {
if (SplashScreen.checkout){ if (checkout){
startActivity(new Intent(getApplicationContext(), PaymentActivity.class)); startActivity(new Intent(getApplicationContext(), PaymentActivity.class));
}else{ }else{
startActivity(new Intent(getApplicationContext(), CartActivity.class)); startActivity(new Intent(getApplicationContext(), CartActivity.class));
...@@ -108,20 +134,25 @@ public class MainActivity extends AppCompatActivity { ...@@ -108,20 +134,25 @@ public class MainActivity extends AppCompatActivity {
productAdapter.notifyDataSetChanged(); productAdapter.notifyDataSetChanged();
}else if (id == R.id.create) { }else if (id == R.id.create) {
startActivity(new Intent(getApplicationContext(), FormProductActivity.class)); startActivity(new Intent(getApplicationContext(), FormProductActivity.class));
}else if (id == R.id.allTransaction){
startActivity(new Intent(getApplicationContext(), HistoryActivity.class));
} }
return true; return true;
} }
}); });
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
mainViewModels.getCategory().observe(this, new Observer<DataResponse<List<CategoryModels>>>() { mainViewModels.getCategory().observe(this, new Observer<DataResponse<List<CategoryModels>>>() {
@Override @Override
public void onChanged(DataResponse<List<CategoryModels>> listDataResponse) { public void onChanged(DataResponse<List<CategoryModels>> listDataResponse) {
if (listDataResponse != null) { if (listDataResponse != null) {
CategoryModels caModels = new CategoryModels();
caModels.setNameCategory("All");
caModels.setIdCategory(0);
List<CategoryModels> categoryModels = listDataResponse.getData(); List<CategoryModels> categoryModels = listDataResponse.getData();
ArrayList<CategoryModels> categoryModelsArrayList = new ArrayList<>(); ArrayList<CategoryModels> categoryModelsArrayList = new ArrayList<>();
categoryModels.add(0,caModels);
categoryModelsArrayList.addAll(categoryModels); categoryModelsArrayList.addAll(categoryModels);
categoryAdapter.setCategoriAdapter(MainActivity.this, categoryModelsArrayList); categoryAdapter.setCategoriAdapter(MainActivity.this, categoryModelsArrayList);
binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false)); binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
...@@ -134,8 +165,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -134,8 +165,6 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
binding.imgEmpty.setOnClickListener(new View.OnClickListener() { binding.imgEmpty.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
...@@ -245,9 +274,54 @@ public class MainActivity extends AppCompatActivity { ...@@ -245,9 +274,54 @@ public class MainActivity extends AppCompatActivity {
showLoading(true); showLoading(true);
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this); ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Loading..."); progressDialog.setMessage("Loading...");
Log.i("diluar if", "onGetProduct: "+selectCategory);
if (!selectCategory){
progressDialog.show(); progressDialog.show();
}
selectCategory = true;
Log.i("setelah if", "onGetProduct: "+selectCategory);
binding.rvProduct.setVisibility(View.GONE); binding.rvProduct.setVisibility(View.GONE);
if (categoryModels.getIdCategory() == 0){
if (mainViewModels.getProduct().getValue().getData().size() != 0){
progressDialog.dismiss();
selectCategory = false;
}else{
binding.rvProduct.setVisibility(View.GONE);
binding.imgEmpty.setVisibility(View.VISIBLE);
binding.imgEmpty.bringToFront();
selectCategory = false;
}
// mainViewModels.getProduct().observe(MainActivity.this, new Observer<DataResponse<List<ProductModels<CategoryModels>>>>() {
// @Override
// public void onChanged(DataResponse<List<ProductModels<CategoryModels>>> listDataResponse) {
// if (listDataResponse != null) {
// ArrayList<ProductModels> productModelsArrayList = new ArrayList<>();
//
// productModelsArrayList.addAll(listDataResponse.getData());
// progressDialog.dismiss();
// showLoading(false);
// if (productModelsArrayList.isEmpty()) {
// binding.rvProduct.setVisibility(View.GONE);
// binding.imgEmpty.setVisibility(View.VISIBLE);
// binding.imgEmpty.bringToFront();
// selectCategory = false;
// Log.i("daidalam get if", "onGetProduct: "+selectCategory);
// } else {
// binding.rvProduct.setVisibility(View.VISIBLE);
// binding.imgEmpty.setVisibility(View.GONE);
// productAdapter.setProduct(MainActivity.this, productModelsArrayList);
// binding.rvProduct.setLayoutManager(new GridLayoutManager(MainActivity.this, 2));
// binding.rvProduct.setAdapter(productAdapter);
// selectCategory = false;
// Log.i("daidalam get else", "onGetProduct: "+selectCategory);
//// productAdapter.notifyDataSetChanged();
// }
// }
// }
// });
selectCategory = false;
}else{
mainViewModels.getProductByCategory(categoryModels.getIdCategory()).observe(MainActivity.this, new Observer<DataResponse<List<ProductModels>>>() { mainViewModels.getProductByCategory(categoryModels.getIdCategory()).observe(MainActivity.this, new Observer<DataResponse<List<ProductModels>>>() {
@Override @Override
public void onChanged(DataResponse<List<ProductModels>> listDataResponse) { public void onChanged(DataResponse<List<ProductModels>> listDataResponse) {
...@@ -267,12 +341,13 @@ public class MainActivity extends AppCompatActivity { ...@@ -267,12 +341,13 @@ public class MainActivity extends AppCompatActivity {
productAdapter.setProduct(MainActivity.this, productModelsArrayList); productAdapter.setProduct(MainActivity.this, productModelsArrayList);
binding.rvProduct.setLayoutManager(new GridLayoutManager(MainActivity.this, 2)); binding.rvProduct.setLayoutManager(new GridLayoutManager(MainActivity.this, 2));
binding.rvProduct.setAdapter(productAdapter); binding.rvProduct.setAdapter(productAdapter);
productAdapter.notifyDataSetChanged(); // productAdapter.notifyDataSetChanged();
} }
} }
} }
}); });
} }
}
}); });
} }
......
...@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
...@@ -15,41 +16,59 @@ import android.view.View; ...@@ -15,41 +16,59 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.Toolbar; import android.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.yono.messeripos.adapter.CartAdapter;
import com.yono.messeripos.adapter.CheckoutAdapter;
import com.yono.messeripos.adapter.PaymentAdapter; import com.yono.messeripos.adapter.PaymentAdapter;
import com.yono.messeripos.models.MainViewModels; import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.MainViewModelsCart; import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductCartModels; import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.response.PaymentResponse; import com.yono.messeripos.response.PaymentResponse;
import com.yono.messeripos.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.yono.messeripos.MainActivity.checkout;
public class PaymentActivity extends AppCompatActivity { public class PaymentActivity extends AppCompatActivity {
private ArrayList<PaymentResponse> paymentResponses = new ArrayList<>(); private ArrayList<PaymentResponse> paymentResponses = new ArrayList<>();
public static String methodPay=""; public static String methodPay="";
private Button btnPay; private Button btnPay;
private MainViewModelsCart mainViewModels; private MainViewModelsCart mainViewModels;
private PaymentsModels paymentsModels;
private long total = 0;
private Utils utils = new Utils();
private RecyclerView recyclerView;
private CheckoutAdapter checkoutAdapter;
private TextView grandTotal;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment); setContentView(R.layout.activity_payment);
Log.i("Status Checkout payment", "onCreate: "+SplashScreen.checkout); Log.i("Status Checkout payment", "onCreate: "+checkout);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} }
paymentsModels = new PaymentsModels();
checkoutAdapter = new CheckoutAdapter();
recyclerView = findViewById(R.id.rvItem);
grandTotal = findViewById(R.id.grand_total);
MaterialToolbar toolbars = findViewById(R.id.appbar); MaterialToolbar toolbars = findViewById(R.id.appbar);
setSupportActionBar(toolbars); setSupportActionBar(toolbars);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
mainViewModels = new ViewModelProvider(PaymentActivity.this).get(MainViewModelsCart.class); mainViewModels = new ViewModelProvider(PaymentActivity.this).get(MainViewModelsCart.class);
mainViewModels.getCartProduct().observe(this, new Observer<List<ProductCartModels>>() { mainViewModels.getCartProduct().observe(this, new Observer<List<ProductCartModels>>() {
@Override @Override
...@@ -57,7 +76,18 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -57,7 +76,18 @@ public class PaymentActivity extends AppCompatActivity {
String js = new Gson().toJson(productCartModels); String js = new Gson().toJson(productCartModels);
Log.i("On payment", "onChanged: "+js); Log.i("On payment", "onChanged: "+js);
for (ProductCartModels pd : productCartModels){
total = total + pd.getPrice_orders()*pd.getQuantity_orders();
}
getSupportActionBar().setTitle(productCartModels.get(0).getId_orders()); getSupportActionBar().setTitle(productCartModels.get(0).getId_orders());
paymentsModels.setOrderId(productCartModels.get(0).getId_orders());
paymentsModels.setGrossAmount(total);
checkoutAdapter.setCheckoutAdapter(PaymentActivity.this, productCartModels);
recyclerView.setLayoutManager(new LinearLayoutManager(PaymentActivity.this, RecyclerView.VERTICAL, false));
recyclerView.setAdapter(checkoutAdapter);
recyclerView.addItemDecoration(dividerItemDecoration);
grandTotal.setText(utils.convertPrice("Rp. ", total));
} }
}); });
...@@ -85,7 +115,14 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -85,7 +115,14 @@ public class PaymentActivity extends AppCompatActivity {
btnPay.setOnClickListener(new View.OnClickListener() { btnPay.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Toast.makeText(getApplicationContext(), methodPay, Toast.LENGTH_LONG).show(); if (methodPay.equals("cash")){
paymentsModels.setPaymentType("cash");
Log.i("CASH", "onClick: "+utils.convertGson(paymentsModels));
}else{
paymentsModels.setPaymentType("bank_transfer");
paymentsModels.setBank(methodPay);
Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
}
} }
}); });
} }
......
...@@ -24,9 +24,7 @@ public class SplashScreen extends AppCompatActivity { ...@@ -24,9 +24,7 @@ public class SplashScreen extends AppCompatActivity {
SharedPreferences sharedPreferences; SharedPreferences sharedPreferences;
public static final String MY_SHARED_PREFERENCES = "my_shared_preferences"; public static final String MY_SHARED_PREFERENCES = "my_shared_preferences";
public static final String SESSION = "session"; public static final String SESSION = "session";
public static final String CHECKOUT = "checkout";
public static Boolean session; public static Boolean session;
public static Boolean checkout;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -50,7 +48,6 @@ public class SplashScreen extends AppCompatActivity { ...@@ -50,7 +48,6 @@ public class SplashScreen extends AppCompatActivity {
}, 700); }, 700);
sharedPreferences = getSharedPreferences(MY_SHARED_PREFERENCES, Context.MODE_PRIVATE); sharedPreferences = getSharedPreferences(MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
session = sharedPreferences.getBoolean(SESSION, false); session = sharedPreferences.getBoolean(SESSION, false);
checkout = sharedPreferences.getBoolean(CHECKOUT, false);
......
...@@ -15,6 +15,7 @@ import com.google.gson.Gson; ...@@ -15,6 +15,7 @@ import com.google.gson.Gson;
import com.yono.messeripos.CartActivity; import com.yono.messeripos.CartActivity;
import com.yono.messeripos.R; import com.yono.messeripos.R;
import com.yono.messeripos.databinding.ItemCartBinding; import com.yono.messeripos.databinding.ItemCartBinding;
import com.yono.messeripos.databinding.ItemCheckoutBinding;
import com.yono.messeripos.models.CartModels; import com.yono.messeripos.models.CartModels;
import com.yono.messeripos.models.CategoryModels; import com.yono.messeripos.models.CategoryModels;
import com.yono.messeripos.models.ProductCartModels; import com.yono.messeripos.models.ProductCartModels;
...@@ -66,6 +67,7 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder> ...@@ -66,6 +67,7 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
parent, parent,
false false
); );
return new MyViewHolder(itemCartBinding); return new MyViewHolder(itemCartBinding);
} }
...@@ -90,17 +92,17 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder> ...@@ -90,17 +92,17 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
public void bindData(ProductCartModels cartModels) { public void bindData(ProductCartModels cartModels) {
binding.setCarts(cartModels); /*
binding.setPrice(utils.convertPrice("Rp. ", cartModels.getPrice_orders())); * Data binding for itemCart in cart activity
* */
subtotal = cartModels.getPrice_orders() * cartModels.getQuantity_orders(); subtotal = cartModels.getPrice_orders() * cartModels.getQuantity_orders();
binding.setCarts(cartModels);
binding.setPrice(utils.convertPrice("Rp. ", cartModels.getPrice_orders()));
binding.setSubTotal(utils.convertPrice("Rp. ", subtotal)); binding.setSubTotal(utils.convertPrice("Rp. ", subtotal));
binding.etQty.setText(Long.toString(cartModels.getQuantity_orders())); binding.etQty.setText(Long.toString(cartModels.getQuantity_orders()));
binding.btDelete.setOnClickListener(view -> {
listener.onDelete(cartModels);
});
// set edit text qty // set edit text qty
binding.etQty.setText(Long.toString(cartModels.getQuantity_orders())); binding.etQty.setText(Long.toString(cartModels.getQuantity_orders()));
...@@ -113,6 +115,11 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder> ...@@ -113,6 +115,11 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
listener.onUpdateQuantityMinus(cartModels); listener.onUpdateQuantityMinus(cartModels);
}); });
binding.btDelete.setOnClickListener(view -> {
listener.onDelete(cartModels);
});
} }
} }
......
package com.yono.messeripos.adapter;
import android.content.Context;
import android.util.Log;
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.ItemCartBinding;
import com.yono.messeripos.databinding.ItemCheckoutBinding;
import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.utils.Utils;
import java.util.List;
public class CheckoutAdapter extends RecyclerView.Adapter<CheckoutAdapter.MyViewHolder> {
private List<ProductCartModels> cartModels;
private int price;
Context context;
Utils utils = new Utils();
public void setCheckoutAdapter(Context context, List<ProductCartModels> cartModels) {
this.cartModels = cartModels;
this.context = context;
Log.d("Checkout Adapter: ", String.valueOf(this.cartModels));
notifyDataSetChanged();
}
@NonNull
@Override
public CheckoutAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemCheckoutBinding itemCheckoutBinding = DataBindingUtil.inflate(
LayoutInflater.from(parent.getContext()),
R.layout.item_checkout,
parent,
false
);
return new MyViewHolder(itemCheckoutBinding);
}
@Override
public void onBindViewHolder(@NonNull CheckoutAdapter.MyViewHolder holder, int position) {
holder.binData(cartModels.get(position));
}
@Override
public int getItemCount() {
return cartModels.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
private long subtotal = 0;
private ItemCheckoutBinding itemCheckoutBinding;
public MyViewHolder(@NonNull ItemCheckoutBinding itemView) {
super(itemView.getRoot());
this.itemCheckoutBinding = itemView;
}
public void binData(ProductCartModels cartModels){
subtotal = cartModels.getPrice_orders() * cartModels.getQuantity_orders();
itemCheckoutBinding.setCheckout(cartModels);
itemCheckoutBinding.setSubtotal(utils.convertPrice("Rp. ", subtotal));
}
}
}
...@@ -2,42 +2,31 @@ package com.yono.messeripos.adapter; ...@@ -2,42 +2,31 @@ package com.yono.messeripos.adapter;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast; import android.widget.Filter;
import android.widget.Filterable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.yono.messeripos.MainActivity;
import com.yono.messeripos.R;
import com.yono.messeripos.databinding.ItemListBinding;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson; import com.yono.messeripos.MainActivity;
import com.yono.messeripos.R; import com.yono.messeripos.R;
import com.yono.messeripos.databinding.ItemListBinding; import com.yono.messeripos.databinding.ItemListBinding;
import com.yono.messeripos.models.CartModels;
import com.yono.messeripos.models.MainViewModelsCart; import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.models.ProductModels; import com.yono.messeripos.models.ProductModels;
import com.yono.messeripos.utils.Utils; import com.yono.messeripos.utils.Utils;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHolder> { public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHolder> implements Filterable {
private ArrayList<ProductModels> productModels = new ArrayList<>(); private ArrayList<ProductModels> productModels = new ArrayList<>();
private ArrayList<ProductModels> productModelsFiltered = new ArrayList<>();
Context context; Context context;
MainViewModelsCart mainViewModelsCart;
Utils utils = new Utils(); Utils utils = new Utils();
public interface ProductListener { public interface ProductListener {
...@@ -58,10 +47,42 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo ...@@ -58,10 +47,42 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
public void setProduct(Context context, ArrayList<ProductModels> productModels) { public void setProduct(Context context, ArrayList<ProductModels> productModels) {
this.productModels = productModels; this.productModels = productModels;
this.context = context; this.context = context;
mainViewModelsCart = ViewModelProviders.of((FragmentActivity) context).get(MainViewModelsCart.class); this.productModelsFiltered = productModels;
notifyDataSetChanged(); notifyDataSetChanged();
} }
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence charSequence) {
String charString = charSequence.toString();
if (charString.isEmpty()) {
productModelsFiltered = productModels;
} else {
ArrayList<ProductModels> filteredList = new ArrayList<>();
for (ProductModels prdk : productModels) {
if (prdk.getProductName().toLowerCase().contains(charString.toLowerCase())) {
filteredList.add(prdk);
}
}
productModelsFiltered = filteredList;
}
FilterResults filterResults = new FilterResults();
filterResults.values = productModelsFiltered;
return filterResults;
}
@Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
productModelsFiltered = (ArrayList<ProductModels>) filterResults.values;
notifyDataSetChanged();
}
};
}
@NonNull @NonNull
@Override @Override
public ProductAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ProductAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
...@@ -77,12 +98,12 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo ...@@ -77,12 +98,12 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
@Override @Override
public void onBindViewHolder(@NonNull ProductAdapter.MyViewHolder holder, int position) { public void onBindViewHolder(@NonNull ProductAdapter.MyViewHolder holder, int position) {
holder.bindData(productModels.get(position)); holder.bindData(productModelsFiltered.get(position));
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return productModels.size(); return productModelsFiltered.size();
} }
public class MyViewHolder extends RecyclerView.ViewHolder { public class MyViewHolder extends RecyclerView.ViewHolder {
......
package com.yono.messeripos.adapter;
import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.yono.messeripos.R;
import com.yono.messeripos.databinding.ItemHistoryBinding;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.utils.Utils;
import java.util.ArrayList;
public class TransactionAdapter extends RecyclerView.Adapter<TransactionAdapter.MyViewHolder> {
private ArrayList<PaymentsModels> paymentsModels = new ArrayList<>();
Context context;
Utils utils = new Utils();
public interface TransactionListener {
void onShowDetail(PaymentsModels paymentsModels);
}
private TransactionListener listener;
public void setListener(TransactionListener listener) {
this.listener = listener;
}
public void setTransactionAdapter(Context context, ArrayList<PaymentsModels> paymentsModels){
this.paymentsModels = paymentsModels;
this.context = context;
notifyDataSetChanged();
}
@NonNull
@Override
public TransactionAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemHistoryBinding itemHistoryBinding = DataBindingUtil.inflate(
LayoutInflater.from(parent.getContext()),
R.layout.item_history,
parent,
false
);
return new MyViewHolder(itemHistoryBinding);
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onBindViewHolder(@NonNull TransactionAdapter.MyViewHolder holder, int position) {
holder.binData(paymentsModels.get(position));
}
@Override
public int getItemCount() {
return paymentsModels.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
ItemHistoryBinding itemHistoryBinding;
public MyViewHolder(@NonNull ItemHistoryBinding itemView) {
super(itemView.getRoot());
this.itemHistoryBinding = itemView;
}
@RequiresApi(api = Build.VERSION_CODES.O)
public void binData(PaymentsModels paymentsModels){
itemHistoryBinding.setTransaction(paymentsModels);
itemHistoryBinding.setDate(utils.convertDate(paymentsModels.getUpdatedAt()));
itemHistoryBinding.cvHistory.setOnClickListener(view -> listener.onShowDetail(paymentsModels));
}
}
}
package com.yono.messeripos.api.service;
import com.yono.messeripos.api.ApiHelper;
import retrofit2.Call;
import retrofit2.http.POST;
public interface PaymentService {
// @POST(ApiHelper.VERSI_API_1+"payment")
// Call
}
package com.yono.messeripos.api.service;
import com.yono.messeripos.api.ApiHelper;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.response.DataResponse;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
public interface TransactionService {
@GET(ApiHelper.VERSI_API_1+"payments")
Call<DataResponse<List<PaymentsModels>>> getAllTransaction();
}
...@@ -4,14 +4,18 @@ import android.util.Log; ...@@ -4,14 +4,18 @@ import android.util.Log;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.yono.messeripos.api.client.Client; import com.yono.messeripos.api.client.Client;
import com.yono.messeripos.api.service.CategoryServise; import com.yono.messeripos.api.service.CategoryServise;
import com.yono.messeripos.api.service.ProductService; import com.yono.messeripos.api.service.ProductService;
import com.yono.messeripos.api.service.TransactionService;
import com.yono.messeripos.api.service.UsersService; import com.yono.messeripos.api.service.UsersService;
import com.yono.messeripos.response.DataResponse; import com.yono.messeripos.response.DataResponse;
import com.yono.messeripos.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -25,13 +29,19 @@ public class MainViewModels extends ViewModel { ...@@ -25,13 +29,19 @@ public class MainViewModels extends ViewModel {
MutableLiveData<DataResponse<List<ProductModels>>> productByCategory; MutableLiveData<DataResponse<List<ProductModels>>> productByCategory;
MutableLiveData<DataResponse<List<CategoryModels>>> categoryList; MutableLiveData<DataResponse<List<CategoryModels>>> categoryList;
MutableLiveData<DataResponse<UsersModels>> usersLogin; MutableLiveData<DataResponse<UsersModels>> usersLogin;
MutableLiveData<DataResponse<List<PaymentsModels>>> transactions;
private MainViewModels mainViewModels;
Client client = new Client(); Client client = new Client();
Utils utils = new Utils();
public MainViewModels(){ public MainViewModels(){
productList = new MutableLiveData<>(); productList = new MutableLiveData<>();
categoryList = new MutableLiveData<>(); categoryList = new MutableLiveData<>();
productByCategory = new MutableLiveData<>(); productByCategory = new MutableLiveData<>();
transactions = new MutableLiveData<>();
} }
public LiveData<DataResponse<List<ProductModels<CategoryModels>>>> getProduct(){ public LiveData<DataResponse<List<ProductModels<CategoryModels>>>> getProduct(){
...@@ -49,6 +59,34 @@ public class MainViewModels extends ViewModel { ...@@ -49,6 +59,34 @@ public class MainViewModels extends ViewModel {
return productByCategory; return productByCategory;
} }
public LiveData<DataResponse<List<PaymentsModels>>> getAllTransactions(){
getDataTransaction();
return transactions;
}
private void getDataTransaction() {
TransactionService transactionService = client.Client(TransactionService.class);
transactionService.getAllTransaction().enqueue(new Callback<DataResponse<List<PaymentsModels>>>() {
@Override
public void onResponse(Call<DataResponse<List<PaymentsModels>>> call,
Response<DataResponse<List<PaymentsModels>>> response) {
Log.i("Get all transaction", "onResponse: "+utils.convertGson(response.body()));
if (response.body() != null){
transactions.setValue(response.body());
}else{
transactions = null;
}
}
@Override
public void onFailure(Call<DataResponse<List<PaymentsModels>>> call, Throwable t) {
Log.e("Error get transaction", "onFailure: ",t );
transactions = null;
}
});
}
private void getDataProductByCategory(int id) { private void getDataProductByCategory(int id) {
CategoryServise categoryServise = client.Client(CategoryServise.class); CategoryServise categoryServise = client.Client(CategoryServise.class);
......
package com.yono.messeripos.models;
import com.google.gson.annotations.SerializedName;
public class PaymentsModels {
@SerializedName("order_code")
private String orderId;
@SerializedName("payment_type")
private String paymentType;
@SerializedName("bank")
private String bank;
@SerializedName("gross_amount")
private long grossAmount;
@SerializedName("transaction_status")
private String transactionStatus;
@SerializedName("created_at")
private String createdAt;
@SerializedName("updated_at")
private String updatedAt;
public PaymentsModels() {
}
public PaymentsModels(String orderId, String paymentType, String bank, long grossAmount) {
this.orderId = orderId;
this.paymentType = paymentType;
this.bank = bank;
this.grossAmount = grossAmount;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getPaymentType() {
return paymentType;
}
public void setPaymentType(String paymentType) {
this.paymentType = paymentType;
}
public String getBank() {
return bank;
}
public void setBank(String bank) {
this.bank = bank;
}
public long getGrossAmount() {
return grossAmount;
}
public void setGrossAmount(long grossAmount) {
this.grossAmount = grossAmount;
}
public String getTransactionStatus() {
return transactionStatus;
}
public void setTransactionStatus(String transactionStatus) {
this.transactionStatus = transactionStatus;
}
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public String getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}
}
package com.yono.messeripos.utils; package com.yono.messeripos.utils;
import android.content.Context;
import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.DividerItemDecoration;
import com.google.gson.Gson;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.Locale;
public class Utils { public class Utils {
public String convertPrice(String mataUang, int nilai ){ public String convertPrice(String mataUang, int nilai ){
...@@ -36,4 +48,29 @@ public class Utils { ...@@ -36,4 +48,29 @@ public class Utils {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
return timeStamp; return timeStamp;
} }
public String convertGson(Object object){
String js = new Gson().toJson(object);
return js;
}
public DividerItemDecoration dividerItemDecoration(Context context){
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
return dividerItemDecoration;
}
@RequiresApi(api = Build.VERSION_CODES.O)
public String convertDate(String date){
DateTimeFormatter dateTimeFormatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.withZone(ZoneId.of("UTC"));
LocalDateTime localDateTime = LocalDateTime
.parse(date, dateTimeFormatter);
DateTimeFormatter localFormatter = DateTimeFormatter
.ofPattern("EEEE, dd MM yyyy", new Locale("id", "ID"));
String localDate = localDateTime.format(localFormatter);
return localDate;
}
} }
...@@ -21,28 +21,6 @@ ...@@ -21,28 +21,6 @@
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/item_cart" /> tools:listitem="@layout/item_cart" />
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rvCart"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"-->
<!-- tools:listitem="@layout/item_cart"-->
<!-- android:layout_above="@+id/btCheckout"-->
<!-- />-->
<!-- <com.google.android.material.button.MaterialButton-->
<!-- android:id="@+id/btCheckout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/title_checkout"-->
<!-- android:padding="15dp"-->
<!-- android:textSize="16sp"-->
<!-- android:layout_margin="10dp"-->
<!-- android:layout_below="@id/rvCart"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_alignWithParentIfMissing="true"/>-->
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/btCheckout" android:id="@+id/btCheckout"
android:layout_width="match_parent" android:layout_width="match_parent"
......
<?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" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="600dp"
android:layout_below="@+id/cAppBar">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/cAppBar"
tools:listitem="@layout/item_history" />
</ScrollView>
<com.google.android.material.button.MaterialButton
android:id="@+id/btShow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_next"
android:padding="15dp"
android:textSize="16sp"
android:layout_alignParentBottom="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</RelativeLayout>
\ No newline at end of file
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
android:id="@+id/btCheckout" android:id="@+id/btCheckout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/title_checkout" android:text="@string/title_success"
android:padding="15dp" android:padding="15dp"
android:textSize="16sp" android:textSize="16sp"
android:layout_margin="10dp" android:layout_margin="10dp"
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
> >
<EditText <EditText
android:id="@+id/etSearchProduct"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#fff" android:textColor="#fff"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".PaymentActivity"> tools:context=".PaymentActivity">
<include <include
android:id="@+id/appbar" android:id="@+id/appbar"
layout="@layout/app_bar" layout="@layout/app_bar"
...@@ -14,99 +17,102 @@ ...@@ -14,99 +17,102 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
/> />
<ScrollView
android:layout_width="match_parent"
android:layout_height="600dp"
android:layout_marginBottom="5dp"
app:layout_constraintBottom_toTopOf="@id/btnPay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appbar"
app:layout_constraintVertical_bias="0.181">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/cvInvoice" android:id="@+id/cvInvoice"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:padding="12dp" android:layout_marginTop="10dp"
android:layout_margin="16dp" android:layout_marginBottom="10dp"
app:cardCornerRadius="20dp" android:padding="18dp"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="@+id/appbar" app:cardCornerRadius="3dp"
tools:ignore="MissingConstraints"> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/btnPay"
tools:ignore="MissingConstraints,NotSibling">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="300dp" android:layout_height="wrap_content"
> android:padding="10dp">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/tvBilling" android:id="@+id/tvBilling"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="@font/roboto" android:fontFamily="@font/roboto"
android:text="Billing "
android:textAlignment="center" android:textAlignment="center"
android:textSize="24sp" android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.099"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:text="@string/hint_billing" /> tools:layout_editor_absoluteY="-4dp" />
<ImageView <ImageView
android:id="@+id/image_splash" android:id="@+id/image_splash"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_marginTop="8dp"
android:src="@drawable/bill" android:src="@drawable/bill"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.13"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBilling" app:layout_constraintTop_toBottomOf="@id/tvBilling" />
/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvBillingProduct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="@font/roboto"
android:textAlignment="center"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@+id/image_splash"
tools:text="@string/hint_product_name" />
<com.google.android.material.textview.MaterialTextView <TextView
android:id="@+id/tvBillingPrice" android:id="@+id/grand_total"
android:layout_width="wrap_content" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="24dp"
android:fontFamily="@font/roboto" android:text=""
android:textAlignment="center" android:textColor="@android:color/black"
android:textSize="14sp" android:textSize="30sp"
app:layout_constraintTop_toBottomOf="@+id/tvBillingProduct" android:textAlignment="textEnd"
tools:text="@string/hint_price" /> app:layout_constraintBottom_toBottomOf="@id/image_splash"
app:layout_constraintEnd_toEndOf="parent"
<com.google.android.material.textview.MaterialTextView app:layout_constraintHorizontal_bias="0.99"
android:id="@+id/tvBillingQuantity" app:layout_constraintStart_toEndOf="@id/image_splash"
android:layout_width="wrap_content" app:layout_constraintTop_toTopOf="parent"
android:layout_height="wrap_content" app:layout_constraintVertical_bias="0.568"
android:layout_marginTop="16dp" tools:text="@tools:sample/full_names" />
android:fontFamily="@font/roboto"
android:textAlignment="center"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@+id/tvBillingPrice"
tools:text="@string/hint_quantity" />
<com.google.android.material.textview.MaterialTextView <TextView
android:id="@+id/tvBillingCategory" android:id="@+id/title_item"
android:layout_width="wrap_content" android:layout_width="200dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="10dp"
android:fontFamily="@font/roboto" android:textColor="@android:color/black"
android:textAlignment="center" android:text="ITEM CHECKOUT"
android:textSize="14sp" android:textSize="20sp"
app:layout_constraintTop_toBottomOf="@+id/tvBillingQuantity" app:layout_constraintStart_toStartOf="parent"
tools:text="@string/hint_category" /> app:layout_constraintTop_toBottomOf="@id/image_splash"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/tvBillingDesc" android:id="@+id/rvItem"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_margin="0dp"
android:fontFamily="@font/roboto" android:layout_marginTop="20dp"
android:textAlignment="center" app:layout_constraintTop_toBottomOf="@id/title_item"
android:textSize="14sp" tools:layout_editor_absoluteX="10dp"
app:layout_constraintTop_toBottomOf="@+id/tvBillingCategory" tools:listitem="@layout/item_checkout" />
tools:text="@string/hint_description" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
...@@ -115,8 +121,17 @@ ...@@ -115,8 +121,17 @@
android:id="@+id/rvPayment" android:id="@+id/rvPayment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:overScrollMode="never" android:layout_margin="10dp"
app:layout_constraintTop_toBottomOf="@id/cvInvoice"/> android:layout_marginTop="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cvInvoice"
tools:layout_editor_absoluteX="10dp"
tools:listitem="@layout/payment_list" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/btnPay" android:id="@+id/btnPay"
...@@ -127,6 +142,7 @@ ...@@ -127,6 +142,7 @@
android:textSize="16sp" android:textSize="16sp"
android:enabled="false" android:enabled="false"
android:layout_margin="10dp" android:layout_margin="10dp"
android:layout_alignParentBottom="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/> app:layout_constraintEnd_toEndOf="parent"/>
......
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="checkout"
type="com.yono.messeripos.models.ProductCartModels" />
<variable
name="subtotal"
type="String" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/itemCheckout"
android:layout_width="200dp"
android:layout_height="wrap_content"
tools:text="@tools:sample/full_names"
android:textSize="20sp"
android:lines="3"
android:text="@{checkout.product_name_orders+` x `+checkout.quantity_orders}"
android:layout_margin="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/itemSubTotal"
android:layout_width="200dp"
android:layout_height="wrap_content"
tools:text="@tools:sample/full_names"
android:textSize="20sp"
android:text="@{subtotal}"
android:textColor="@android:color/black"
android:layout_margin="10dp"
app:layout_constraintStart_toEndOf="@id/itemCheckout"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:textAlignment="textEnd" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="transaction"
type="com.yono.messeripos.models.PaymentsModels" />
<variable
name="date"
type="String" />
</data>
<com.google.android.material.card.MaterialCardView
android:id="@+id/cvHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvPay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
android:textColor="@android:color/black"
android:textStyle="bold"
android:textAllCaps="true"
tools:text="@string/hint_pay"
android:text="@{transaction.paymentType}"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto"
android:textSize="16sp"
tools:text="@tools:sample/date/ddmmyy"
android:text="@{date}"
app:layout_constraintStart_toStartOf="@id/tvPay"
app:layout_constraintTop_toBottomOf="@+id/tvPay" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvOrder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto"
android:textSize="16sp"
android:text="@{transaction.orderId}"
tools:text="#6821739123"
app:layout_constraintStart_toStartOf="@id/tvDate"
app:layout_constraintTop_toBottomOf="@+id/tvDate" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvHistory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="84dp"
android:backgroundTint="#8555DA"
android:text="@{transaction.transactionStatus}"
tools:text="@tools:sample/first_names"
android:textColor="#fff"
android:background="#C60000"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
\ No newline at end of file
...@@ -20,4 +20,10 @@ ...@@ -20,4 +20,10 @@
android:title="Create Product" android:title="Create Product"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/allTransaction"
android:orderInCategory="100"
android:title="All Transaction"
app:showAsAction="never" />
</menu> </menu>
\ No newline at end of file
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
<string name="stock">Stock</string> <string name="stock">Stock</string>
<string name="add">Add</string> <string name="add">Add</string>
<string name="hint_billing">Billing</string> <string name="hint_billing">Billing</string>
<string name="title_success">Success</string>
<string name="hint_pay">cash</string>
<string name="title_next">next</string>
<string-array name="planets_array"> <string-array name="planets_array">
<item>Mercury</item> <item>Mercury</item>
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">@font/roboto</item> <item name="android:fontFamily">@font/roboto</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:actionBarStyle">@style/ThemeActionBar</item> <item name="android:actionBarStyle">@style/ThemeActionBar</item>
<item name="android:windowActionBarOverlay">false</item> <item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentStatus">true</item>
...@@ -18,12 +17,12 @@ ...@@ -18,12 +17,12 @@
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:actionBarStyle">@style/ThemeActionBar</item> <item name="android:actionBarStyle">@style/ThemeActionBar</item>
<item name="android:windowActionBarOverlay">false</item> <item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item> <item name="android:windowTranslucentNavigation">true</item>
<item name="windowActionBarOverlay">true</item> <item name="windowActionBarOverlay">true</item>
<item name="android:fontFamily">@font/poppins_medium</item>
<item name="actionBarStyle">@style/ThemeActionBar</item> <item name="actionBarStyle">@style/ThemeActionBar</item>
</style> </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