正在查看: EFFICIENT POS v1.5.7 应用的 SupplierActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: EFFICIENT POS v1.5.7 应用的 SupplierActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package dev.gtr.pos.activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import dev.gtr.pos.R;
import dev.gtr.pos.adapter.AdapterSupplier;
import dev.gtr.pos.api.ApiClient;
import dev.gtr.pos.config.Constant;
import dev.gtr.pos.config.LinearLayoutWrapper;
import dev.gtr.pos.model.CustomerType;
import dev.gtr.pos.model.Supplier;
import dev.gtr.pos.model.SupplierList;
import es.dmoral.toasty.Toasty;
import java.net.SocketTimeoutException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class SupplierActivity extends AppCompatActivity implements View.OnClickListener {
AdapterSupplier adapterSupply;
AlertDialog alertDialogAdd;
AlertDialog alertDialogDel;
AlertDialog.Builder builderAdd;
AlertDialog.Builder builderDel;
Calendar calendar;
CardView cardViewFrom;
CardView cardViewTo;
ConstraintLayout constraintLayoutAdd;
ConstraintLayout constraintLayoutDate;
ConstraintLayout constraintLayoutDel;
ConstraintLayout constraintLayoutEdit;
ConstraintLayout constraintLayoutSearch;
ConstraintLayout constraintLayoutView;
List<String> cookies;
int currentItem;
ArrayList<CustomerType> custGroup;
ArrayList<CustomerType> custType;
SimpleDateFormat dateFormat;
EditText editTextSearch;
int flag;
String fromSupp;
ImageView imageViewAdd;
ImageView imageViewBack;
ImageView imageViewDel;
ImageView imageViewEdit;
ImageView imageViewSearch;
ImageView imageViewView;
ArrayList<SupplierList> items;
LinearLayoutWrapper linearLayoutManager;
DatePickerDialog.OnDateSetListener onDateSetListenerFrom;
DatePickerDialog.OnDateSetListener onDateSetListenerTo;
ProgressBar progressBar;
RecyclerView recyclerView;
String selectedCustText;
String selectedGroupText;
String selectedValueCust;
String selectedValueGroup;
String supplyId;
String supplyName;
TextView textViewFromDate;
TextView textViewTitle;
TextView textViewToDate;
int total_Item;
int selectedPosition = -1;
int pages = 0;
int size = 10;
boolean isSupplierCalling = true;
boolean isFirstTime = true;
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_supplier);
this.recyclerView = findViewById(R.id.recyclerview_customer);
this.imageViewBack = (ImageView) findViewById(R.id.imageView_back);
this.imageViewAdd = (ImageView) findViewById(R.id.imageview_add);
this.imageViewDel = (ImageView) findViewById(R.id.imageview_paylist);
this.imageViewEdit = (ImageView) findViewById(R.id.imageview_rec);
this.constraintLayoutAdd = findViewById(2131296331);
this.constraintLayoutEdit = findViewById(R.id.rec_pay);
this.constraintLayoutDel = findViewById(R.id.pay);
this.imageViewView = (ImageView) findViewById(R.id.imageView_view);
this.constraintLayoutView = findViewById(R.id.view);
this.textViewTitle = (TextView) findViewById(R.id.textView_title);
this.editTextSearch = (EditText) findViewById(R.id.editText_search);
this.imageViewSearch = (ImageView) findViewById(R.id.imageview_search);
this.textViewToDate = (TextView) findViewById(R.id.textView_toDate);
this.textViewFromDate = (TextView) findViewById(R.id.textView_fromDate);
this.constraintLayoutSearch = findViewById(R.id.search);
this.progressBar = (ProgressBar) findViewById(R.id.progress_cust);
this.cardViewTo = findViewById(R.id.cardView_toDate);
this.cardViewFrom = findViewById(R.id.cardView_fromDate);
this.constraintLayoutDate = findViewById(R.id.constraintLayout23);
this.imageViewBack.setOnClickListener(this);
this.imageViewSearch.setOnClickListener(this);
this.constraintLayoutDel.setOnClickListener(this);
this.constraintLayoutEdit.setOnClickListener(this);
this.constraintLayoutAdd.setOnClickListener(this);
this.imageViewView.setOnClickListener(this);
this.imageViewEdit.setOnClickListener(this);
this.imageViewAdd.setOnClickListener(this);
this.imageViewDel.setOnClickListener(this);
this.cardViewFrom.setOnClickListener(this);
this.cardViewTo.setOnClickListener(this);
init();
getSupplyList(".", 0);
getSuppGroup();
getSuppType();
}
public void init() {
if (Constant.IsCreateSupplier.toLowerCase(Locale.ROOT).equals("true")) {
this.constraintLayoutAdd.setVisibility(0);
} else {
this.constraintLayoutAdd.setVisibility(8);
}
if (Constant.IsEditSupplier.toLowerCase(Locale.ROOT).equals("true")) {
this.constraintLayoutEdit.setVisibility(0);
} else {
this.constraintLayoutEdit.setVisibility(8);
}
if (Constant.IsDeleteSupplier.toLowerCase(Locale.ROOT).equals("true")) {
this.constraintLayoutDel.setVisibility(0);
} else {
this.constraintLayoutDel.setVisibility(8);
}
Intent intent = getIntent();
this.flag = intent.getIntExtra(Constant.REQ_PURCHASE_ORDER_TO_SupplyDetails, 0);
this.fromSupp = intent.getStringExtra("FROMSUPP");
this.textViewTitle.setText("Supplier");
this.items = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
this.calendar = calendar;
int i = calendar.get(1);
int i2 = this.calendar.get(2);
int i3 = this.calendar.get(5);
this.dateFormat = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
this.calendar.set(i, i2, i3);
this.textViewToDate.setText(this.dateFormat.format(this.calendar.getTime()));
this.textViewFromDate.setText(this.dateFormat.format(this.calendar.getTime()));
this.onDateSetListenerTo = new DatePickerDialog.OnDateSetListener() {
@Override
public final void onDateSet(DatePicker datePicker, int i4, int i5, int i6) {
SupplierActivity.this.m173lambda$init$0$devgtrposactivitySupplierActivity(datePicker, i4, i5, i6);
}
};
this.onDateSetListenerFrom = new DatePickerDialog.OnDateSetListener() {
@Override
public final void onDateSet(DatePicker datePicker, int i4, int i5, int i6) {
SupplierActivity.this.m174lambda$init$1$devgtrposactivitySupplierActivity(datePicker, i4, i5, i6);
}
};
AdapterSupplier adapterSupplier = new AdapterSupplier(this.items, this);
this.adapterSupply = adapterSupplier;
adapterSupplier.setOnItemClick(new AdapterSupplier.OnItemClick() {
@Override
public void onViewClick(SupplierList supplierList, int i4, View view) {
}
@Override
public void onClick(SupplierList supplierList, int i4) {
if (SupplierActivity.this.flag == 1) {
SupplierActivity.this.supplyId = supplierList.getId();
SupplierActivity.this.supplyName = supplierList.getName();
Intent intent2 = new Intent();
intent2.putExtra(Constant.SUPP_ID, SupplierActivity.this.supplyId);
intent2.putExtra(Constant.SuppName, SupplierActivity.this.supplyName);
SupplierActivity.this.setResult(-1, intent2);
SupplierActivity.this.finish();
return;
}
SupplierActivity.this.items.get(i4).setSelected(Boolean.valueOf(!SupplierActivity.this.items.get(i4).getSelected().booleanValue()));
if (SupplierActivity.this.items.get(i4).getSelected().booleanValue()) {
SupplierActivity.this.items.get(i4).setColor(R.drawable.shape_cust_select);
SupplierActivity.this.constraintLayoutDate.setVisibility(0);
} else {
SupplierActivity.this.items.get(i4).setColor(R.drawable.shape_cust_customer);
SupplierActivity.this.constraintLayoutDate.setVisibility(8);
}
for (int i5 = 0; i5 < SupplierActivity.this.items.size(); i5++) {
if (i4 != i5 || !SupplierActivity.this.items.get(i5).getSelected().booleanValue()) {
SupplierActivity.this.items.get(i5).setSelected(false);
SupplierActivity.this.items.get(i5).setColor(R.drawable.shape_cust_customer);
}
}
SupplierActivity.this.adapterSupply.notifyDataSetChanged();
}
@Override
public void onLonClick(SupplierList supplierList, int i4, View view) {
Intent intent2 = new Intent(SupplierActivity.this.getApplicationContext(), (Class<?>) AccountTransactionsActivity.class);
intent2.putExtra(Constant.TransacId, supplierList.getId());
intent2.putExtra(Constant.BySupplier, true);
intent2.putExtra(Constant.FromSupplierActivity, true);
intent2.putExtra(Constant.SuppName, supplierList.getName());
SupplierActivity.this.startActivity(intent2);
}
});
LinearLayoutWrapper linearLayoutWrapper = new LinearLayoutWrapper(getApplicationContext());
this.linearLayoutManager = linearLayoutWrapper;
this.recyclerView.setLayoutManager(linearLayoutWrapper);
this.recyclerView.setAdapter(this.adapterSupply);
this.recyclerView.setHasFixedSize(true);
this.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(RecyclerView recyclerView, int i4, int i5) {
super.onScrolled(recyclerView, i4, i5);
SupplierActivity supplierActivity = SupplierActivity.this;
supplierActivity.currentItem = supplierActivity.linearLayoutManager.getChildCount();
SupplierActivity supplierActivity2 = SupplierActivity.this;
supplierActivity2.total_Item = supplierActivity2.linearLayoutManager.getItemCount();
int findFirstVisibleItemPosition = SupplierActivity.this.linearLayoutManager.findFirstVisibleItemPosition();
if (SupplierActivity.this.currentItem + findFirstVisibleItemPosition + 1 > SupplierActivity.this.total_Item && i5 > 0 && SupplierActivity.this.editTextSearch.getText().toString().isEmpty() && !SupplierActivity.this.isSupplierCalling) {
SupplierActivity.this.isSupplierCalling = true;
SupplierActivity.this.adapterSupply.setLoading(true);
SupplierActivity.this.adapterSupply.notifyItemInserted(SupplierActivity.this.items.size());
SupplierActivity supplierActivity3 = SupplierActivity.this;
supplierActivity3.getSupplyList(".", supplierActivity3.total_Item);
return;
}
if (SupplierActivity.this.currentItem + findFirstVisibleItemPosition + 1 <= SupplierActivity.this.total_Item || i5 <= 0 || SupplierActivity.this.editTextSearch.getText().toString().isEmpty() || SupplierActivity.this.isSupplierCalling) {
return;
}
SupplierActivity.this.isSupplierCalling = true;
SupplierActivity.this.adapterSupply.setLoading(true);
SupplierActivity.this.adapterSupply.notifyItemInserted(SupplierActivity.this.items.size());
SupplierActivity supplierActivity4 = SupplierActivity.this;
supplierActivity4.getSupplyList(supplierActivity4.editTextSearch.getText().toString(), SupplierActivity.this.total_Item);
}
});
this.editTextSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean z) {
if (z) {
SupplierActivity.this.constraintLayoutEdit.setVisibility(8);
SupplierActivity.this.constraintLayoutDel.setVisibility(8);
SupplierActivity.this.constraintLayoutAdd.setVisibility(8);
SupplierActivity.this.constraintLayoutView.setVisibility(8);
return;
}
SupplierActivity.this.constraintLayoutEdit.setVisibility(0);
SupplierActivity.this.constraintLayoutDel.setVisibility(0);
SupplierActivity.this.constraintLayoutAdd.setVisibility(0);
SupplierActivity.this.constraintLayoutView.setVisibility(0);
SupplierActivity.this.editTextSearch.setVisibility(8);
}
});
this.editTextSearch.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i4, int i5, int i6) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i4, int i5, int i6) {
}
@Override
public void afterTextChanged(Editable editable) {
if (!editable.toString().isEmpty()) {
SupplierActivity.this.pages = 1;
SupplierActivity.this.items.clear();
SupplierActivity.this.getSupplyList(editable.toString(), 0);
} else {
SupplierActivity.this.pages = 1;
SupplierActivity.this.items.clear();
SupplierActivity.this.getSupplyList(".", 0);
}
SupplierActivity.this.adapterSupply.notifyDataSetChanged();
}
});
}
void m173lambda$init$0$devgtrposactivitySupplierActivity(DatePicker datePicker, int i, int i2, int i3) {
this.dateFormat = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
Calendar calendar = Calendar.getInstance();
calendar.set(i, i2, i3);
this.textViewToDate.setText(this.dateFormat.format(calendar.getTime()));
}
void m174lambda$init$1$devgtrposactivitySupplierActivity(DatePicker datePicker, int i, int i2, int i3) {
this.dateFormat = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
Calendar calendar = Calendar.getInstance();
calendar.set(i, i2, i3);
this.textViewFromDate.setText(this.dateFormat.format(calendar.getTime()));
}
public void ShowDate(DatePickerDialog.OnDateSetListener onDateSetListener) {
Calendar calendar = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(this, R.style.customsDate, onDateSetListener, calendar.get(1), calendar.get(2), calendar.get(5));
datePickerDialog.show();
datePickerDialog.getButton(-2).setTextColor(getResources().getColor(R.color.black_mart));
datePickerDialog.getButton(-1).setTextColor(getResources().getColor(R.color.black_mart));
}
public void AddSupplier(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8) {
ApiClient.getInstance(getApplicationContext()).getApi().createSupplier("Bearer " + Constant.Token, str, str2, str3, str4, str5, str6, str7, str8).enqueue(new Callback<String>() {
@Override
public void onFailure(Call<String> call, Throwable th) {
}
@Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) {
if (response.body().contains("true")) {
SupplierActivity.this.progressBar.setVisibility(8);
SupplierActivity.this.items.clear();
SupplierActivity.this.pages = 1;
SupplierActivity.this.progressBar.setVisibility(0);
SupplierActivity.this.getSupplyList(".", 0);
Toasty.success(SupplierActivity.this.getApplicationContext(), "Added Successfully", 0).show();
return;
}
SupplierActivity.this.progressBar.setVisibility(8);
Toasty.error(SupplierActivity.this.getApplicationContext(), "Can't Add", 0).show();
}
}
});
}
public void updateSupplier(String str, final String str2, final int i, String str3, final String str4, final String str5, final String str6, final String str7, final String str8, final String str9, final String str10, String str11) {
ApiClient.getInstance(getApplicationContext()).getApi().updateSupplier("Bearer " + Constant.Token, str3, str4, str5, str6, str7, str8, str9, str10, str11).enqueue(new Callback<String>() {
@Override
public void onFailure(Call<String> call, Throwable th) {
}
@Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) {
if (response.body().contains("true")) {
SupplierActivity.this.progressBar.setVisibility(8);
SupplierActivity.this.items.get(i).setParentCust(str2);
SupplierActivity.this.items.get(i).setsAddress(str8);
SupplierActivity.this.items.get(i).setNote(str9);
SupplierActivity.this.items.get(i).setCust(str10);
SupplierActivity.this.items.get(i).setpAddress(str7);
SupplierActivity.this.items.get(i).setPhone(str6);
SupplierActivity.this.items.get(i).setEmail(str5);
SupplierActivity.this.items.get(i).setName(str4);
SupplierActivity.this.adapterSupply.notifyItemChanged(i);
Toasty.success(SupplierActivity.this.getApplicationContext(), "Updated Successfully", 0).show();
SupplierActivity.this.adapterSupply.notifyDataSetChanged();
return;
}
SupplierActivity.this.progressBar.setVisibility(8);
Toasty.error(SupplierActivity.this.getApplicationContext(), "Can't Update", 0).show();
}
}
});
}
private void getSingleSupplier(String str) {
ApiClient.getInstance(getApplicationContext()).getApi().getSingleSupply(Constant.Token, str).enqueue(new Callback<SupplierList>() {
@Override
public void onFailure(Call<SupplierList> call, Throwable th) {
}
@Override
public void onResponse(Call<SupplierList> call, Response<SupplierList> response) {
if (response.isSuccessful()) {
int i = SupplierActivity.this.selectedPosition;
}
}
});
}
public void getSupplyList(String str, final int i) {
ApiClient.getInstance(getApplicationContext()).getApi().getAllSupplier("Bearer " + Constant.Token, this.pages, this.size, str).enqueue(new Callback<Supplier>() {
@Override
public void onResponse(Call<Supplier> call, Response<Supplier> response) {
if (response.isSuccessful()) {
SupplierActivity.this.isSupplierCalling = false;
SupplierActivity.this.cookies = response.headers().values("set-Cookie");
SupplierActivity.this.progressBar.setVisibility(8);
if (SupplierActivity.this.items.size() > 0) {
SupplierActivity.this.adapterSupply.setLoading(false);
SupplierActivity.this.adapterSupply.notifyItemRemoved(SupplierActivity.this.items.size() - 1);
}
if (SupplierActivity.this.pages <= Integer.parseInt(response.body().getPageInfo().getPageCount())) {
for (SupplierList supplierList : response.body().getSupplierList()) {
SupplierActivity.this.items.add(new SupplierList(supplierList.getName(), supplierList.getId(), supplierList.getEmail(), supplierList.getPhone(), supplierList.getSales(), supplierList.getCollection(), supplierList.getCust(), supplierList.getpAddress(), supplierList.getsAddress(), supplierList.getReturnValue(), supplierList.getTotalAmount(), supplierList.getTotalDue(), supplierList.getNote(), supplierList.getParentCust()));
}
SupplierActivity.this.adapterSupply.notifyItemRangeInserted(i, SupplierActivity.this.items.size());
SupplierActivity.this.pages++;
}
if (SupplierActivity.this.items.size() > 0) {
SupplierActivity.this.adapterSupply.notifyDataSetChanged();
SupplierActivity.this.textViewTitle.setText("Supplier( " + SupplierActivity.this.items.size() + " )");
}
if (response.code() == 500) {
SupplierActivity.this.progressBar.setVisibility(8);
if (SupplierActivity.this.items.size() > 0) {
SupplierActivity.this.adapterSupply.setLoading(false);
SupplierActivity.this.adapterSupply.notifyItemRemoved(SupplierActivity.this.items.size() - 1);
}
Toasty.error(SupplierActivity.this.getApplicationContext(), "Internal Server Error", 0).show();
} else {
Log.e("cust", "" + response.code());
}
}
SupplierActivity.this.isFirstTime = false;
}
@Override
public void onFailure(Call<Supplier> call, Throwable th) {
SupplierActivity.this.progressBar.setVisibility(8);
if (SupplierActivity.this.items.size() > 0) {
SupplierActivity.this.adapterSupply.setLoading(false);
SupplierActivity.this.adapterSupply.notifyItemRemoved(SupplierActivity.this.items.size() - 1);
}
SupplierActivity.this.isFirstTime = false;
if (th instanceof SocketTimeoutException) {
Toast.makeText((Context) SupplierActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
}
}
});
}
public void DeleteSupplier(String str, final int i) {
ApiClient.getInstance(getApplicationContext()).getApi().deleteSupplier("Bearer " + Constant.Token, str).enqueue(new Callback<String>() {
@Override
public void onFailure(Call<String> call, Throwable th) {
}
@Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) {
if (response.body().equals("true")) {
SupplierActivity.this.progressBar.setVisibility(8);
SupplierActivity.this.items.remove(i);
SupplierActivity.this.adapterSupply.notifyItemRemoved(i);
SupplierActivity.this.adapterSupply.notifyItemRangeChanged(i, SupplierActivity.this.items.size() - 1);
if (SupplierActivity.this.items.size() > 0) {
SupplierActivity.this.textViewTitle.setText("Supplier( " + SupplierActivity.this.items.size() + " )");
}
Toasty.success(SupplierActivity.this.getApplicationContext(), "Deleted Successfully", 0).show();
return;
}
return;
}
SupplierActivity.this.progressBar.setVisibility(8);
Toasty.error(SupplierActivity.this.getApplicationContext(), "Can't delete", 0).show();
}
});
}
private void getSuppType() {
ApiClient.getInstance(getApplicationContext()).getApi().getSuppTypeDropDown("Bearer " + Constant.Token).enqueue(new Callback<List<CustomerType>>() {
@Override
public void onFailure(Call<List<CustomerType>> call, Throwable th) {
}
@Override
public void onResponse(Call<List<CustomerType>> call, Response<List<CustomerType>> response) {
if (response.isSuccessful()) {
SupplierActivity.this.custType = new ArrayList<>();
for (CustomerType customerType : response.body()) {
Log.e("value", "" + customerType.getValue());
SupplierActivity.this.custType.add(new CustomerType(customerType.getDisable(), customerType.getGroup(), customerType.getSelect(), customerType.getText(), customerType.getValue()));
}
}
}
});
}
private void getSuppGroup() {
ApiClient.getInstance(getApplicationContext()).getApi().supplyDropDown("Bearer " + Constant.Token).enqueue(new Callback<List<CustomerType>>() {
@Override
public void onFailure(Call<List<CustomerType>> call, Throwable th) {
}
@Override
public void onResponse(Call<List<CustomerType>> call, Response<List<CustomerType>> response) {
if (response.isSuccessful()) {
SupplierActivity.this.custGroup = new ArrayList<>();
SupplierActivity.this.custGroup.add(new CustomerType("-1", "-1", "-1", "Select--", "-1"));
for (CustomerType customerType : response.body()) {
Log.e("val", "" + customerType.getValue());
SupplierActivity.this.custGroup.add(new CustomerType(customerType.getDisable(), customerType.getGroup(), customerType.getSelect(), customerType.getText(), customerType.getValue()));
}
}
}
});
}
@Override
public void onClick(android.view.View r21) {
throw new UnsupportedOperationException("Method not decompiled: dev.gtr.pos.activity.SupplierActivity.onClick(android.view.View):void");
}
public void onBackPressed() {
super.onBackPressed();
}
protected void onResume() {
if (this.isFirstTime) {
this.pages = 1;
this.items.clear();
this.adapterSupply.notifyDataSetChanged();
this.progressBar.setVisibility(0);
getSupplyList(".", 0);
}
super.onResume();
}
}