Prima implementazione di RettificaGiacenze
This commit is contained in:
parent
17165b75e3
commit
02d22ed99f
@ -13,14 +13,18 @@ import android.view.ViewGroup;
|
||||
import butterknife.ButterKnife;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.databinding.FragmentRettificaGiacenzeBinding;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.core.RettificaGiacenzeHelper;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.viewmodel.RettificaGiacenzeViewModel;
|
||||
|
||||
public class RettificaGiacenzeFragment extends Fragment implements ITitledFragment {
|
||||
|
||||
private RettificaGiacenzeHelper mHelper;
|
||||
private FragmentRettificaGiacenzeBinding mBinding = null;
|
||||
|
||||
private RettificaGiacenzeViewModel mRettificaGiacenzeViewModel = null;
|
||||
|
||||
public RettificaGiacenzeFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@ -34,7 +38,6 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,14 +45,27 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_rettifica_giacenze, container, false);
|
||||
mRettificaGiacenzeViewModel = new RettificaGiacenzeViewModel();
|
||||
mRettificaGiacenzeViewModel.init(getActivity(), mBinding);
|
||||
|
||||
mBinding.setView(this);
|
||||
mBinding.setViewmodel(mRettificaGiacenzeViewModel);
|
||||
|
||||
ButterKnife.bind(this, mBinding.getRoot());
|
||||
|
||||
init();
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mHelper = new RettificaGiacenzeHelper(getActivity());
|
||||
|
||||
mHelper.loadListaFornitori(listaFornitori -> {
|
||||
mRettificaGiacenzeViewModel.setupListaFornitori(listaFornitori);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
|
||||
@ -1,4 +1,52 @@
|
||||
package it.integry.integrywmsnative.gest.rettifica_giacenze.core;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.databinding.ObservableArrayList;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.REST.consumers.ISimpleOperationCallback;
|
||||
import it.integry.integrywmsnative.core.REST.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDB;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
|
||||
|
||||
public class RettificaGiacenzeHelper {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public RettificaGiacenzeHelper(Context context){
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
|
||||
public void loadListaFornitori(RunnableArgs<ArrayList<FornitoreDTO>> onComplete) {
|
||||
final ProgressDialog progress = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
progress.show();
|
||||
|
||||
String sql = "SELECT cod_alis as 'codAlis', descrizione FROM atb_list WHERE flag_attivo = 'S'";
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<FornitoreDTO>>() {}.getType();
|
||||
SystemRESTConsumer.processSql(sql, typeOfObjectsList, new ISimpleOperationCallback<ArrayList<FornitoreDTO>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<FornitoreDTO> value) {
|
||||
progress.dismiss();
|
||||
|
||||
if(onComplete != null) onComplete.run(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
UtilityExceptions.defaultException(mContext, ex, progress);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
package it.integry.integrywmsnative.gest.rettifica_giacenze.core.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.databinding.ObservableArrayList;
|
||||
import android.databinding.ObservableList;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.databinding.RettificaGiacenzeAutocompleteFornitoreLayoutBinding;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
|
||||
|
||||
public class AutoCompleteFornitoreAdapter extends ArrayAdapter<FornitoreDTO> {
|
||||
|
||||
private ArrayList<FornitoreDTO> items;
|
||||
private ArrayList<FornitoreDTO> itemsAll;
|
||||
private ArrayList<FornitoreDTO> suggestions;
|
||||
|
||||
public AutoCompleteFornitoreAdapter(@NonNull Context context, @NonNull ArrayList<FornitoreDTO> items) {
|
||||
super(context, 0 , items);
|
||||
this.items = items;
|
||||
this.itemsAll = (ArrayList<FornitoreDTO>) items.clone();
|
||||
this.suggestions = new ArrayList<>();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return fornitoreFilter;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
|
||||
RettificaGiacenzeAutocompleteFornitoreLayoutBinding binding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(getContext()),
|
||||
R.layout.rettifica_giacenze_autocomplete_fornitore_layout, parent, false);
|
||||
|
||||
binding.setFornitore(items.get(position));
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Filter fornitoreFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
if(constraint != null) {
|
||||
suggestions.clear();
|
||||
for (FornitoreDTO fornitore : itemsAll) {
|
||||
String tmpDescr = fornitore.getCodAlis() + " " + fornitore.getDescrizione();
|
||||
|
||||
if(tmpDescr.toLowerCase().contains(constraint.toString().toLowerCase())){
|
||||
suggestions.add(fornitore);
|
||||
}
|
||||
}
|
||||
FilterResults filterResults = new FilterResults();
|
||||
filterResults.values = suggestions;
|
||||
filterResults.count = suggestions.size();
|
||||
return filterResults;
|
||||
} else {
|
||||
return new FilterResults();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
ArrayList<FornitoreDTO> filteredList = (ArrayList<FornitoreDTO>) results.values;
|
||||
if(results != null && results.count > 0) {
|
||||
clear();
|
||||
for (FornitoreDTO c : filteredList) {
|
||||
add(c);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence convertResultToString(Object resultValue) {
|
||||
return ((FornitoreDTO) resultValue).getCodAlis();
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package it.integry.integrywmsnative.gest.rettifica_giacenze.dto;
|
||||
|
||||
public class FornitoreDTO implements Cloneable {
|
||||
|
||||
private String codAlis;
|
||||
private String descrizione;
|
||||
|
||||
public String getCodAlis() {
|
||||
return codAlis;
|
||||
}
|
||||
|
||||
public FornitoreDTO setCodAlis(String codAlis) {
|
||||
this.codAlis = codAlis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public FornitoreDTO setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,29 @@
|
||||
package it.integry.integrywmsnative.gest.rettifica_giacenze.viewmodel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.databinding.ObservableArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.databinding.FragmentRettificaGiacenzeBinding;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.core.adapter.AutoCompleteFornitoreAdapter;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
|
||||
|
||||
public class RettificaGiacenzeViewModel {
|
||||
|
||||
private Context mContext;
|
||||
private FragmentRettificaGiacenzeBinding mBinding;
|
||||
|
||||
public void init(Context context, FragmentRettificaGiacenzeBinding binding) {
|
||||
mContext = context;
|
||||
mBinding = binding;
|
||||
}
|
||||
|
||||
public void setupListaFornitori(ArrayList<FornitoreDTO> listaFornitori) {
|
||||
AutoCompleteFornitoreAdapter autoCompleteFornitoreAdapter = new AutoCompleteFornitoreAdapter(mContext, listaFornitori);
|
||||
mBinding.autoCompleteFornitori.setAdapter(autoCompleteFornitoreAdapter);
|
||||
mBinding.autoCompleteFornitori.setDropDownWidth(mContext.getResources().getDisplayMetrics().widthPixels);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,14 +7,58 @@
|
||||
<data>
|
||||
<import type="android.databinding.ObservableList"/>
|
||||
<variable name="view" type="it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeFragment" />
|
||||
<variable
|
||||
name="viewmodel"
|
||||
type="it.integry.integrywmsnative.gest.rettifica_giacenze.viewmodel.RettificaGiacenzeViewModel" />
|
||||
</data>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/full_white"
|
||||
tools:context=".gest.rettifica_giacenze.RettificaGiacenzeFragment">
|
||||
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.constraint.Guideline
|
||||
android:id="@+id/guide_line_fornitore"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="0.40"/>
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/autoCompleteFornitori"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:completionThreshold="2"
|
||||
android:hint="@string/supplier"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/guide_line_fornitore"/>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_cod_art_descr_forn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:hintTextAppearance="@style/hint_text"
|
||||
app:layout_constraintStart_toEndOf="@id/guide_line_fornitore"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:hint="@string/cod_art_or_description"/>
|
||||
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</layout>
|
||||
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="fornitore"
|
||||
type="it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{fornitore.codAlis + ` - ` + fornitore.descrizione}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="0001 - LISTINO PARMALAT"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
@ -129,4 +129,7 @@
|
||||
<string name="filtered_arts_in_list">Filtro articoli applicato</string>
|
||||
<string name="remove_filter_button">Rimuovi filtro</string>
|
||||
|
||||
<string name="supplier">Fornitore</string>
|
||||
<string name="cod_art_or_description">Cod art / Descrizione</string>
|
||||
|
||||
</resources>
|
||||
@ -137,4 +137,8 @@
|
||||
<string name="filtered_arts_in_list">Item filter applied</string>
|
||||
<string name="remove_filter_button">Remove filter</string>
|
||||
|
||||
|
||||
<string name="supplier">Supplier</string>
|
||||
<string name="cod_art_or_description">Item code / Description</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user