Aggiunti filtri in Recupero Materiale
This commit is contained in:
@@ -240,7 +240,8 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
||||
|
||||
for (FilterChipDTO filterChipDTO : filterList) {
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(this, filterChipDTO.getFilterChipText(), v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
FilterChipView filterChipView = new FilterChipView(this, filterChipDTO.getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
|
||||
if (filterChipDTO.getID() == AccettazioneBollaPickingBindings.DESCR_FILTER_ID) {
|
||||
mAppliedFilterViewModel.getCurrentDescrPredicate().addOnPropertyChangedCallback(new OnGeneralChangedCallback() {
|
||||
@@ -248,13 +249,13 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentDescrPredicate().get() == null) {
|
||||
mViewModel.resetMatchedRows();
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -597,7 +598,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
||||
|
||||
@Override
|
||||
public void onItemDispatched(PickingObjectDTO pickingObjectDTO, MtbAart mtbAart, BigDecimal
|
||||
initialNumCnf, BigDecimal initialQtaCnf, BigDecimal initialQtaTot, BigDecimal
|
||||
initialNumCnf, BigDecimal initialQtaCnf, BigDecimal initialQtaTot, BigDecimal
|
||||
totalQtaOrd, BigDecimal totalNumCnfOrd, BigDecimal qtaCnfOrd, BigDecimal
|
||||
totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, BigDecimal
|
||||
totalQtaAvailable, BigDecimal totalNumCnfAvailable, BigDecimal qtaCnfAvailable, String
|
||||
@@ -629,7 +630,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
||||
mDialogInputQuantityV2View
|
||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||
.setOnComplete(resultDTO -> {
|
||||
if(resultDTO.isAborted()) {
|
||||
if (resultDTO.isAborted()) {
|
||||
this.mViewModel.resetMatchedRows();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,8 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
for (FilterChipDTO filterChipDTO : filterList) {
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(this, filterChipDTO.getFilterChipText(), v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
FilterChipView filterChipView = new FilterChipView(this, filterChipDTO.getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
|
||||
switch (filterChipDTO.getID()) {
|
||||
case AccettazioneOrdiniPickingBindings.COD_ART_FILTER_ID -> {
|
||||
@@ -214,13 +215,13 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentCodArtPredicate().get() == null) {
|
||||
mViewModel.resetMatchedRows();
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -236,13 +237,13 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentDescrPredicate().get() == null) {
|
||||
mViewModel.resetMatchedRows();
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -258,13 +259,13 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentPosPredicate().get() == null) {
|
||||
mViewModel.resetMatchedRows();
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
|
||||
@@ -312,10 +312,8 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
|
||||
for (FilterChipDTO filterChipDTO : filterList) {
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(
|
||||
requireActivity(),
|
||||
filterChipDTO.getFilterChipText(),
|
||||
v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
FilterChipView filterChipView = new FilterChipView(requireActivity(), filterChipDTO.getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
|
||||
switch (filterChipDTO.getID()) {
|
||||
case OrdiniUscitaElencoFilterBindings.DEPOSITO_FILTER_ID -> {
|
||||
@@ -323,13 +321,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentDepositoPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -344,13 +342,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentIdViaggioPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -365,13 +363,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentNumOrdsPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -386,13 +384,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentClientePredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -407,13 +405,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentVettorePredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -428,13 +426,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentAutomezzoPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -449,13 +447,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentPaesePredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -470,13 +468,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentAgentePredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -491,13 +489,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentTermConsPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -512,13 +510,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentDataConsPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -536,13 +534,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentGruppoMercPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -560,13 +558,13 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentCommessaPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
|
||||
@@ -190,8 +190,8 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(
|
||||
requireActivity(),
|
||||
filterChipDTO.getValue().getFilterChipText(),
|
||||
v -> initBottomSheetDialogFilter(filterChipDTO.getValue()));
|
||||
filterChipDTO.getValue().getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO.getValue()));
|
||||
|
||||
switch (filterChipDTO.getKey()) {
|
||||
case ProdOrdineProduzioneElencoBindings.COMMESSA_FILTER_ID:
|
||||
@@ -199,13 +199,13 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFilterViewModel.getCurrentCommPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -220,13 +220,13 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFilterViewModel.getCurrentNumOrdsPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
|
||||
@@ -233,8 +233,8 @@ public class ProdFabbisognoLineeProdFragment extends BaseFragment implements ITi
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(
|
||||
requireActivity(),
|
||||
filterChipDTO.getFilterChipText(),
|
||||
v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
filterChipDTO.getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
|
||||
switch (filterChipDTO.getID()) {
|
||||
case ProdFabbisognoLineeProdBindings.NUM_ORD_FILTER_ID -> {
|
||||
@@ -242,13 +242,13 @@ public class ProdFabbisognoLineeProdFragment extends BaseFragment implements ITi
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFilterViewModel.getCurrentNumOrdsPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
@@ -264,13 +264,13 @@ public class ProdFabbisognoLineeProdFragment extends BaseFragment implements ITi
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFilterViewModel.getCurrentGruppoMercPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
|
||||
@@ -7,15 +7,27 @@ import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.ravikoradiya.liveadapter.LiveAdapter;
|
||||
import com.ravikoradiya.liveadapter.Type;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -37,6 +49,8 @@ import it.integry.integrywmsnative.databinding.FragmentProdRecuperoMaterialeBind
|
||||
import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListItemBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
import it.integry.integrywmsnative.ui.filter_chips.FilterBottomSheetAdapter;
|
||||
import it.integry.integrywmsnative.ui.filter_chips.FilterChipView;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogCommon;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO;
|
||||
@@ -61,6 +75,25 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
private String codJfas;
|
||||
private String fragmentResultKeyString;
|
||||
|
||||
// Fields for filters
|
||||
private List<HistoryVersamentoProdULDTO> originalList = new ArrayList<>();
|
||||
private final MutableLiveData<List<HistoryVersamentoProdULDTO>> filteredList = new MutableLiveData<>();
|
||||
private final Set<String> activeCodJfasFilters = new HashSet<>();
|
||||
private final Set<String> activeCodJcomFilters = new HashSet<>();
|
||||
private final Set<String> activeOrdineCodJcomFilters = new HashSet<>();
|
||||
|
||||
// Lista filtrata corrente basata sui filtri applicati
|
||||
private List<HistoryVersamentoProdULDTO> currentFilteredList = new ArrayList<>();
|
||||
|
||||
private String defaultCodJfasLabelText;
|
||||
private String defaultCodJcomLabelText;
|
||||
private String defaultOrdineCodJcomLabelText;
|
||||
|
||||
// Enum for filter types
|
||||
private enum FilterType {
|
||||
COD_JFAS, COD_JCOM, ORDINE_COD_JCOM
|
||||
}
|
||||
|
||||
public ProdRecuperoMaterialeFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@@ -98,8 +131,35 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
mBinding.setLifecycleOwner(getViewLifecycleOwner());
|
||||
mBinding.setView(this);
|
||||
|
||||
// Initialize default chip labels
|
||||
defaultCodJfasLabelText = getString(R.string.filter_cod_jfas_label);
|
||||
defaultCodJcomLabelText = getString(R.string.filter_cod_jcom_label);
|
||||
defaultOrdineCodJcomLabelText = getString(R.string.filter_ordine_cod_jcom_label);
|
||||
|
||||
mBinding.chipFilterCodJfas.setText(defaultCodJfasLabelText);
|
||||
mBinding.chipFilterCodJcom.setText(defaultCodJcomLabelText);
|
||||
mBinding.chipFilterOrdineCodJcom.setText(defaultOrdineCodJcomLabelText);
|
||||
|
||||
// Update initial chip visual state (colors and close icon visibility)
|
||||
updateChipVisuals(FilterType.COD_JFAS);
|
||||
updateChipVisuals(FilterType.COD_JCOM);
|
||||
updateChipVisuals(FilterType.ORDINE_COD_JCOM);
|
||||
|
||||
setupFilterChips();
|
||||
|
||||
// Observe the original list from ViewModel
|
||||
mViewModel.getOrderList().observe(getViewLifecycleOwner(), newList -> {
|
||||
originalList.clear();
|
||||
if (newList != null) {
|
||||
originalList.addAll(newList);
|
||||
}
|
||||
// When original list changes, re-apply filters and update UI
|
||||
applyFilters();
|
||||
});
|
||||
|
||||
|
||||
this.initBarcodeReader();
|
||||
this.initRecyclerView();
|
||||
this.initRecyclerView(); // Call after filteredList is initialized and observer is set up
|
||||
|
||||
this.addOnPreDestroy(() -> {
|
||||
if (!UtilityString.isNullOrEmpty(fragmentResultKeyString)) {
|
||||
@@ -123,7 +183,7 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
});
|
||||
|
||||
mViewModel.init(codJfas);
|
||||
mViewModel.refreshData();
|
||||
mViewModel.refreshData(); // This will eventually trigger the LiveData observer for getOrderList
|
||||
|
||||
mBinding.swiperefresh.setOnRefreshListener(() -> {
|
||||
mViewModel.refreshData();
|
||||
@@ -193,7 +253,7 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
);
|
||||
itemType.areContentsTheSame(HistoryVersamentoProdULDTO::equals);
|
||||
|
||||
new LiveAdapter(this.mViewModel.getOrderList(), this)
|
||||
new LiveAdapter(this.filteredList, this) // Observe filteredList
|
||||
.map(HistoryVersamentoProdULDTO.class, itemType)
|
||||
.onNoData(x -> {
|
||||
mBinding.emptyView.setVisibility(x ? View.VISIBLE : View.GONE);
|
||||
@@ -206,6 +266,241 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
|
||||
}
|
||||
|
||||
private void setupFilterChips() {
|
||||
mBinding.chipFilterCodJfas.setOnClickListener(v -> showFilterDialog(FilterType.COD_JFAS));
|
||||
mBinding.chipFilterCodJfas.setOnCloseIconClickListener(v -> resetFilter(FilterType.COD_JFAS));
|
||||
|
||||
mBinding.chipFilterCodJcom.setOnClickListener(v -> showFilterDialog(FilterType.COD_JCOM));
|
||||
mBinding.chipFilterCodJcom.setOnCloseIconClickListener(v -> resetFilter(FilterType.COD_JCOM));
|
||||
|
||||
mBinding.chipFilterOrdineCodJcom.setOnClickListener(v -> showFilterDialog(FilterType.ORDINE_COD_JCOM));
|
||||
mBinding.chipFilterOrdineCodJcom.setOnCloseIconClickListener(v -> resetFilter(FilterType.ORDINE_COD_JCOM));
|
||||
}
|
||||
|
||||
private List<String> getUniqueValuesForFilter(FilterType filterType) {
|
||||
if (originalList == null || originalList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// Determina quale lista utilizzare come base per i filtri
|
||||
List<HistoryVersamentoProdULDTO> sourceList;
|
||||
|
||||
// Se ci sono già dei filtri applicati (tranne quello corrente), usa la lista filtrata corrente
|
||||
boolean hasOtherActiveFilters = false;
|
||||
switch (filterType) {
|
||||
case COD_JFAS:
|
||||
hasOtherActiveFilters = !activeCodJcomFilters.isEmpty() || !activeOrdineCodJcomFilters.isEmpty();
|
||||
break;
|
||||
case COD_JCOM:
|
||||
hasOtherActiveFilters = !activeCodJfasFilters.isEmpty() || !activeOrdineCodJcomFilters.isEmpty();
|
||||
break;
|
||||
case ORDINE_COD_JCOM:
|
||||
hasOtherActiveFilters = !activeCodJfasFilters.isEmpty() || !activeCodJcomFilters.isEmpty();
|
||||
break;
|
||||
}
|
||||
|
||||
// Se ci sono altri filtri attivi, usa la lista filtrata corrente
|
||||
sourceList = hasOtherActiveFilters && !currentFilteredList.isEmpty() ? currentFilteredList : originalList;
|
||||
|
||||
Set<String> uniqueValues = new TreeSet<>(); // TreeSet per ordinamento naturale
|
||||
for (HistoryVersamentoProdULDTO item : sourceList) {
|
||||
if (item == null) continue;
|
||||
switch (filterType) {
|
||||
case COD_JFAS:
|
||||
if (!UtilityString.isNullOrEmpty(item.getCodJfas())) {
|
||||
uniqueValues.add(item.getCodJfas());
|
||||
}
|
||||
break;
|
||||
case COD_JCOM:
|
||||
if (!UtilityString.isNullOrEmpty(item.getCodJcom())) {
|
||||
uniqueValues.add(item.getCodJcom());
|
||||
}
|
||||
break;
|
||||
case ORDINE_COD_JCOM:
|
||||
if (item.getOrdini() != null) {
|
||||
for (HistoryVersamentoProdULDTO.OrdineDto ordine : item.getOrdini()) {
|
||||
if (ordine != null && !UtilityString.isNullOrEmpty(ordine.getCodJcom())) {
|
||||
uniqueValues.add(ordine.getCodJcom());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(uniqueValues);
|
||||
}
|
||||
|
||||
private boolean[] getCheckedItemsForDialog(List<String> allPossibleValues, Set<String> activeFilters) {
|
||||
boolean[] checkedItems = new boolean[allPossibleValues.size()];
|
||||
for (int i = 0; i < allPossibleValues.size(); i++) {
|
||||
checkedItems[i] = activeFilters.contains(allPossibleValues.get(i));
|
||||
}
|
||||
return checkedItems;
|
||||
}
|
||||
|
||||
private void showFilterDialog(FilterType filterType) {
|
||||
List<String> uniqueValues = getUniqueValuesForFilter(filterType);
|
||||
if (uniqueValues.isEmpty()) {
|
||||
if (getContext() != null) {
|
||||
Toast.makeText(getContext(), R.string.no_filter_values_available, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(requireContext());
|
||||
View bottomSheetView = LayoutInflater.from(getContext()).inflate(R.layout.bottom_sheet_filter_layout, null);
|
||||
bottomSheetDialog.setContentView(bottomSheetView);
|
||||
|
||||
TextView bottomSheetTitle = bottomSheetView.findViewById(R.id.bottom_sheet_filter_title);
|
||||
RecyclerView filterRecyclerView = bottomSheetView.findViewById(R.id.bottom_sheet_filter_recyclerview);
|
||||
Button buttonReset = bottomSheetView.findViewById(R.id.button_reset_filters);
|
||||
// Button buttonCancel = bottomSheetView.findViewById(R.id.button_cancel_filters);
|
||||
Button buttonApply = bottomSheetView.findViewById(R.id.button_apply_filters);
|
||||
|
||||
Set<String> currentActiveFiltersSet;
|
||||
String dialogTitleString;
|
||||
|
||||
switch (filterType) {
|
||||
case COD_JFAS:
|
||||
currentActiveFiltersSet = activeCodJfasFilters;
|
||||
dialogTitleString = getString(R.string.filter_dialog_title_cod_jfas);
|
||||
break;
|
||||
case COD_JCOM:
|
||||
currentActiveFiltersSet = activeCodJcomFilters;
|
||||
dialogTitleString = getString(R.string.filter_dialog_title_cod_jcom);
|
||||
break;
|
||||
case ORDINE_COD_JCOM:
|
||||
currentActiveFiltersSet = activeOrdineCodJcomFilters;
|
||||
dialogTitleString = getString(R.string.filter_dialog_title_ordine_cod_jcom);
|
||||
break;
|
||||
default:
|
||||
bottomSheetDialog.dismiss(); // Chiudi se il tipo di filtro è sconosciuto
|
||||
return;
|
||||
}
|
||||
bottomSheetTitle.setText(dialogTitleString);
|
||||
|
||||
// Set temporaneo per mantenere le selezioni fatte nel bottom sheet
|
||||
// Inizializzato con una copia dei filtri attualmente attivi per questo tipo
|
||||
Set<String> selectedValuesInSheet = new HashSet<>(currentActiveFiltersSet);
|
||||
|
||||
FilterBottomSheetAdapter adapter = new FilterBottomSheetAdapter(uniqueValues, selectedValuesInSheet, (item, isSelected) -> {
|
||||
if (isSelected) {
|
||||
selectedValuesInSheet.add(item);
|
||||
} else {
|
||||
selectedValuesInSheet.remove(item);
|
||||
}
|
||||
});
|
||||
filterRecyclerView.setAdapter(adapter);
|
||||
// LinearLayoutManager è già impostato in bottom_sheet_filter_layout.xml tramite app:layoutManager
|
||||
|
||||
buttonReset.setOnClickListener(v -> {
|
||||
selectedValuesInSheet.clear(); // Pulisci le selezioni nel sheet
|
||||
currentActiveFiltersSet.clear(); // Pulisci i filtri attivi effettivi per questo tipo
|
||||
updateChipVisuals(filterType); // Aggiorna l'aspetto del chip
|
||||
applyFilters(); // Riapplica i filtri alla lista principale
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
// buttonCancel.setOnClickListener(v -> bottomSheetDialog.dismiss()); // Chiudi semplicemente, nessuna modifica applicata
|
||||
|
||||
buttonApply.setOnClickListener(v -> {
|
||||
currentActiveFiltersSet.clear(); // Pulisci i vecchi filtri attivi
|
||||
currentActiveFiltersSet.addAll(selectedValuesInSheet); // Applica le nuove selezioni dallo sheet
|
||||
updateChipVisuals(filterType);
|
||||
applyFilters();
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
|
||||
private void updateChipVisuals(FilterType filterType) {
|
||||
switch (filterType) {
|
||||
case COD_JFAS:
|
||||
updateChipVisual(mBinding.chipFilterCodJfas, activeCodJfasFilters, defaultCodJfasLabelText);
|
||||
break;
|
||||
case COD_JCOM:
|
||||
updateChipVisual(mBinding.chipFilterCodJcom, activeCodJcomFilters, defaultCodJcomLabelText);
|
||||
break;
|
||||
case ORDINE_COD_JCOM:
|
||||
updateChipVisual(mBinding.chipFilterOrdineCodJcom, activeOrdineCodJcomFilters, defaultOrdineCodJcomLabelText);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateChipVisual(FilterChipView chip, Set<String> activeFilters, String defaultLabelText) {
|
||||
if (activeFilters.isEmpty()) {
|
||||
chip.setFilterAsDisabled();
|
||||
} else {
|
||||
chip.setFilterAsEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetFilter(FilterType filterType) {
|
||||
switch (filterType) {
|
||||
case COD_JFAS:
|
||||
activeCodJfasFilters.clear();
|
||||
break;
|
||||
case COD_JCOM:
|
||||
activeCodJcomFilters.clear();
|
||||
break;
|
||||
case ORDINE_COD_JCOM:
|
||||
activeOrdineCodJcomFilters.clear();
|
||||
break;
|
||||
}
|
||||
updateChipVisuals(filterType);
|
||||
applyFilters();
|
||||
}
|
||||
|
||||
private void applyFilters() {
|
||||
List<HistoryVersamentoProdULDTO> filtered = new ArrayList<>();
|
||||
for (HistoryVersamentoProdULDTO item : originalList) {
|
||||
if (item == null) continue;
|
||||
|
||||
boolean matchesCodJfas = activeCodJfasFilters.isEmpty() || activeCodJfasFilters.contains(item.getCodJfas());
|
||||
boolean matchesCodJcom = activeCodJcomFilters.isEmpty() || activeCodJcomFilters.contains(item.getCodJcom());
|
||||
boolean matchesOrdineCodJcom = activeOrdineCodJcomFilters.isEmpty() || (item.getOrdini() != null && item.getOrdini().stream()
|
||||
.anyMatch(ordine -> activeOrdineCodJcomFilters.contains(ordine.getCodJcom())));
|
||||
|
||||
if (matchesCodJfas && matchesCodJcom && matchesOrdineCodJcom) {
|
||||
filtered.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiorna la lista filtrata corrente per i filtri successivi
|
||||
currentFilteredList.clear();
|
||||
currentFilteredList.addAll(filtered);
|
||||
|
||||
// Aggiorna la UI
|
||||
filteredList.setValue(filtered);
|
||||
|
||||
// Aggiorna le etichette dei chip con i conteggi
|
||||
updateChipLabels();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna le etichette dei chip con il conteggio dei valori filtrati
|
||||
*/
|
||||
private void updateChipLabels() {
|
||||
if (activeCodJfasFilters.isEmpty()) {
|
||||
mBinding.chipFilterCodJfas.setText(defaultCodJfasLabelText);
|
||||
} else {
|
||||
mBinding.chipFilterCodJfas.setText(defaultCodJfasLabelText + " (" + activeCodJfasFilters.size() + ")");
|
||||
}
|
||||
|
||||
if (activeCodJcomFilters.isEmpty()) {
|
||||
mBinding.chipFilterCodJcom.setText(defaultCodJcomLabelText);
|
||||
} else {
|
||||
mBinding.chipFilterCodJcom.setText(defaultCodJcomLabelText + " (" + activeCodJcomFilters.size() + ")");
|
||||
}
|
||||
|
||||
if (activeOrdineCodJcomFilters.isEmpty()) {
|
||||
mBinding.chipFilterOrdineCodJcom.setText(defaultOrdineCodJcomLabelText);
|
||||
} else {
|
||||
mBinding.chipFilterOrdineCodJcom.setText(defaultOrdineCodJcomLabelText + " (" + activeOrdineCodJcomFilters.size() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDispatched(HistoryVersamentoProdULDTO item,
|
||||
MtbColt sourceMtbColt,
|
||||
@@ -319,6 +614,7 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
public void onDataRefreshEnded() {
|
||||
handler.post(() -> {
|
||||
mBinding.swiperefresh.setRefreshing(false);
|
||||
// applyFilters(); // Non strettamente necessario qui se l'observer di getOrderList() fa il suo dovere
|
||||
});
|
||||
}
|
||||
|
||||
@@ -328,3 +624,4 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
||||
onDataRefreshEnded();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
|
||||
@@ -275,6 +276,53 @@ public class HistoryVersamentoProdULDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se questa istanza di HistoryVersamentoProdULDTO corrisponde ai filtri specificati.
|
||||
* Un filtro null o vuoto (o solo spazi) viene ignorato per quel criterio specifico.
|
||||
* Il confronto delle stringhe è case-sensitive.
|
||||
*
|
||||
* @param filterCodJfas Filtro per il campo codJfas. Se null o vuoto, questo filtro non viene applicato.
|
||||
* @param filterCodJcom Filtro per il campo codJcom dell'oggetto principale. Se null o vuoto, questo filtro non viene applicato.
|
||||
* @param filterOrdineCodJcom Filtro per il campo codJcom di almeno uno degli ordini associati. Se null o vuoto, questo filtro non viene applicato.
|
||||
* @return {@code true} se l'oggetto corrisponde a tutti i filtri attivi (non null/vuoti), {@code false} altrimenti.
|
||||
*/
|
||||
public boolean matchesFilters(Set<String> filterCodJfas, Set<String> filterCodJcom, Set<String> filterOrdineCodJcom) {
|
||||
// Filtro per CodJfas
|
||||
if (filterCodJfas != null && !filterCodJfas.isEmpty()) {
|
||||
if (this.codJfas == null || !filterCodJfas.contains(this.codJfas)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filtro per CodJcom (campo diretto di HistoryVersamentoProdULDTO)
|
||||
if (filterCodJcom != null && !filterCodJcom.isEmpty()) {
|
||||
if (this.codJcom == null || !filterCodJcom.contains(this.codJcom)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filtro per CodJcom (all'interno di un oggetto OrdineDto nella lista this.ordini)
|
||||
if (filterOrdineCodJcom != null && !filterOrdineCodJcom.isEmpty()) {
|
||||
if (this.ordini == null || this.ordini.isEmpty()) {
|
||||
return false; // Non può corrispondere se non ci sono ordini e il filtro è attivo
|
||||
}
|
||||
boolean ordineMatchFound = false;
|
||||
for (HistoryVersamentoProdULDTO.OrdineDto ordine : this.ordini) {
|
||||
if (ordine != null && ordine.getCodJcom() != null && filterOrdineCodJcom.contains(ordine.getCodJcom())) {
|
||||
ordineMatchFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ordineMatchFound) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Se tutti i controlli dei filtri attivi sono stati superati (o nessun filtro era attivo),
|
||||
// l'oggetto è una corrispondenza.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
@@ -149,8 +149,8 @@ public class ProdRientroMerceOrderListFragment extends Fragment {
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(
|
||||
requireActivity(),
|
||||
filterChipDTO.getFilterChipText(),
|
||||
v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
filterChipDTO.getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO));
|
||||
|
||||
switch (filterChipDTO.getID()) {
|
||||
|
||||
@@ -159,13 +159,13 @@ public class ProdRientroMerceOrderListFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAppliedFilterViewModel.getCurrentCommessaPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
|
||||
@@ -172,21 +172,21 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
||||
|
||||
FilterChipView filterChipView = new FilterChipView(
|
||||
requireActivity(),
|
||||
filterChipDTO.getValue().getFilterChipText(),
|
||||
v -> initBottomSheetDialogFilter(filterChipDTO.getValue()));
|
||||
filterChipDTO.getValue().getFilterChipText())
|
||||
.setOnClicked(v -> initBottomSheetDialogFilter(filterChipDTO.getValue()));
|
||||
|
||||
if (filterChipDTO.getKey() == ProdRiposizionamentoDaProdBindings.POSITIONS_FILTER_ID) {
|
||||
mFilterViewModel.getCurrentPositionPredicate().addOnPropertyChangedCallback(new OnGeneralChangedCallback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFilterViewModel.getCurrentPositionPredicate().get() == null) {
|
||||
filterChipView.disableCloseIcon();
|
||||
filterChipView.setFilterAsDisabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView);
|
||||
mBindings.filterChips.smoothScrollTo(0, 0);
|
||||
} else {
|
||||
filterChipView.enableCloseIcon();
|
||||
filterChipView.setFilterAsEnabled();
|
||||
|
||||
mBindings.filterChipsGroup.removeView(filterChipView);
|
||||
mBindings.filterChipsGroup.addView(filterChipView, 0);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package it.integry.integrywmsnative.ui.filter_chips;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
|
||||
public class FilterBottomSheetAdapter extends RecyclerView.Adapter<FilterBottomSheetAdapter.ViewHolder> {
|
||||
|
||||
private final List<String> items;
|
||||
private final Set<String> selectedItems;
|
||||
private final OnItemClickListener listener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(String item, boolean isSelected);
|
||||
}
|
||||
|
||||
public FilterBottomSheetAdapter(List<String> items, Set<String> selectedItems, OnItemClickListener listener) {
|
||||
this.items = items;
|
||||
this.selectedItems = selectedItems;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.bottom_sheet_filter_item_layout, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
String item = items.get(position);
|
||||
holder.textView.setText(item);
|
||||
holder.checkBox.setChecked(selectedItems.contains(item));
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
boolean isSelected = !holder.checkBox.isChecked();
|
||||
holder.checkBox.setChecked(isSelected);
|
||||
listener.onItemClick(item, isSelected);
|
||||
});
|
||||
holder.checkBox.setOnClickListener(v -> {
|
||||
// La logica è già gestita dal click sull'itemView
|
||||
// ma per sicurezza, se l'utente clicca direttamente sulla checkbox
|
||||
listener.onItemClick(item, holder.checkBox.isChecked());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView textView;
|
||||
CheckBox checkBox;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
textView = itemView.findViewById(R.id.filter_item_text);
|
||||
checkBox = itemView.findViewById(R.id.filter_item_checkbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,70 +2,113 @@ package it.integry.integrywmsnative.ui.filter_chips;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import com.google.android.material.chip.Chip;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class FilterChipView extends Chip {
|
||||
|
||||
public BindableString primaryText = new BindableString();
|
||||
|
||||
private final Context mContext;
|
||||
private Runnable onResetClicked;
|
||||
private RunnableArgs<FilterChipView> onClicked;
|
||||
|
||||
private final ColorStateList defaultChipBackgroundColor;
|
||||
private final ColorStateList defaultChipTextColor;
|
||||
private ColorStateList defaultChipBackgroundColor;
|
||||
private ColorStateList defaultChipTextColor;
|
||||
private ColorStateList defaultChipStrokeColor;
|
||||
private float defaultChipStrokeWidth;
|
||||
|
||||
public FilterChipView(Context context, String text, RunnableArgs<FilterChipView> onClicked) {
|
||||
public FilterChipView(Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
|
||||
commonInit();
|
||||
}
|
||||
|
||||
public FilterChipView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
commonInit();
|
||||
}
|
||||
|
||||
public FilterChipView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
commonInit();
|
||||
}
|
||||
|
||||
public FilterChipView(Context context, String text) {
|
||||
this(context);
|
||||
super.setText(text);
|
||||
|
||||
commonInit();
|
||||
}
|
||||
|
||||
private void commonInit() {
|
||||
this.defaultChipBackgroundColor = getChipBackgroundColor();
|
||||
this.defaultChipTextColor = getTextColors();
|
||||
this.defaultChipStrokeColor = getChipStrokeColor();
|
||||
this.defaultChipStrokeWidth = getChipStrokeWidth();
|
||||
|
||||
// setShapeAppearanceModel(
|
||||
// getShapeAppearanceModel()
|
||||
// .withCornerSize(4)
|
||||
// .toBuilder()
|
||||
// .build());
|
||||
//
|
||||
// setChipMinHeight(getChipMinHeight() * 1.25f);
|
||||
setCheckable(false); // Rende il chip checkable per gestire gli stati
|
||||
setCheckedIconVisible(false); // Nasconde l'icona del check di default
|
||||
|
||||
setOnCloseIconClickListener(v -> {
|
||||
if (onResetClicked != null) onResetClicked.run();
|
||||
});
|
||||
setOnClickListener(v -> onClicked.run(this));
|
||||
|
||||
setOnClickListener(v -> {
|
||||
if (onClicked != null) onClicked.run(this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void enableCloseIcon() {
|
||||
public void setFilterAsEnabled() {
|
||||
setChecked(true);
|
||||
setCloseIconVisible(true);
|
||||
setTextColor(ContextCompat.getColor(this.mContext, android.R.color.white));
|
||||
setChipBackgroundColor(ColorStateList.valueOf(ContextCompat.getColor(this.mContext, R.color.colorPrimary)));
|
||||
setCloseIconTint(ColorStateList.valueOf(ContextCompat.getColor(this.mContext, android.R.color.white)));
|
||||
|
||||
// Utilizza gli attributi del tema Material 3 per lo stato attivo/checked
|
||||
setChipBackgroundColor(getColorFromAttr(getContext(), com.google.android.material.R.attr.colorPrimaryContainer));
|
||||
setTextColor(getColorFromAttr(getContext(), com.google.android.material.R.attr.colorOnPrimaryContainer));
|
||||
setCloseIconTint(getColorFromAttr(getContext(), com.google.android.material.R.attr.colorOnPrimaryContainer));
|
||||
// Se vuoi un bordo specifico per lo stato attivo, puoi impostarlo qui.
|
||||
// Altrimenti, potrebbe ereditare o non avere un bordo a seconda dello stile di base.
|
||||
// Esempio: setChipStrokeColor(getColorFromAttr(getContext(), com.google.android.material.R.attr.colorOnPrimaryContainer));
|
||||
setChipStrokeWidth(0f); // Esempio di spessore del bordo
|
||||
}
|
||||
|
||||
public void disableCloseIcon() {
|
||||
public void setFilterAsDisabled() {
|
||||
setChecked(false);
|
||||
setCloseIconVisible(false);
|
||||
|
||||
// Ripristina i colori di default salvati
|
||||
setTextColor(defaultChipTextColor);
|
||||
setChipBackgroundColor(defaultChipBackgroundColor);
|
||||
// setCloseIconTint(ColorStateList.valueOf(ContextCompat.getColor(this.mContext, R.color.colorPrimary)));
|
||||
}
|
||||
|
||||
|
||||
public Runnable getOnResetClicked() {
|
||||
return onResetClicked;
|
||||
setChipStrokeColor(defaultChipStrokeColor);
|
||||
// Ripristina la tinta dell'icona di chiusura al colore del testo di default (o un altro colore di default se necessario)
|
||||
if (defaultChipTextColor != null) {
|
||||
setCloseIconTint(defaultChipTextColor);
|
||||
}
|
||||
setChipStrokeWidth(defaultChipStrokeWidth);
|
||||
}
|
||||
|
||||
public FilterChipView setOnResetClicked(Runnable onResetClicked) {
|
||||
this.onResetClicked = onResetClicked;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterChipView setOnClicked(RunnableArgs<FilterChipView> onClicked) {
|
||||
this.onClicked = onClicked;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Funzione di utilità per ottenere un colore da un attributo del tema
|
||||
private int getColorResourceFromAttr(Context context, int attrRes) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(attrRes, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
private ColorStateList getColorFromAttr(Context context, int attrRes) {
|
||||
return ColorStateList.valueOf(getColorResourceFromAttr(context, attrRes));
|
||||
}
|
||||
}
|
||||
|
||||
25
app/src/main/res/layout/bottom_sheet_filter_item_layout.xml
Normal file
25
app/src/main/res/layout/bottom_sheet_filter_item_layout.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/filter_item_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/filter_item_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||
tools:text="Descrizione lunga"/>
|
||||
|
||||
</LinearLayout>
|
||||
51
app/src/main/res/layout/bottom_sheet_filter_layout.xml
Normal file
51
app/src/main/res/layout/bottom_sheet_filter_layout.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_filter_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?attr/textAppearanceTitleLarge"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="Seleziona Filtri" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/bottom_sheet_filter_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="300dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
android:layout_marginBottom="16dp"
|
||||
tools:listitem="@layout/bottom_sheet_filter_item_layout"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_reset_filters"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/reset"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_apply_filters"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:text="@string/confirm" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -17,11 +17,56 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".gest.prod_recupero_materiale.ProdRecuperoMaterialeFragment">
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/filters_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:layout_alignParentTop="true">
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/filter_chip_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
app:singleLine="true">
|
||||
|
||||
<it.integry.integrywmsnative.ui.filter_chips.FilterChipView
|
||||
android:id="@+id/chip_filter_cod_jfas"
|
||||
style="@style/Widget.Material3.Chip.Filter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/filter_cod_jfas_label"
|
||||
app:closeIconVisible="true" />
|
||||
<!-- android:checkable=false perché il dialogo gestirà la selezione. Cambieremo il testo. -->
|
||||
<!-- L'icona di chiusura servirà per resettare il filtro specifico -->
|
||||
|
||||
<it.integry.integrywmsnative.ui.filter_chips.FilterChipView
|
||||
android:id="@+id/chip_filter_cod_jcom"
|
||||
style="@style/Widget.Material3.Chip.Filter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/filter_cod_jcom_label"
|
||||
app:closeIconVisible="true" />
|
||||
|
||||
<it.integry.integrywmsnative.ui.filter_chips.FilterChipView
|
||||
android:id="@+id/chip_filter_ordine_cod_jcom"
|
||||
style="@style/Widget.Material3.Chip.Filter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/filter_ordine_cod_jcom_label"
|
||||
app:closeIconVisible="true" />
|
||||
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
</HorizontalScrollView>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swiperefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_below="@id/filters_scroll_view"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
@@ -89,4 +134,5 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</layout>
|
||||
</layout>
|
||||
|
||||
|
||||
@@ -501,4 +501,14 @@
|
||||
|
||||
<string name="switch_depo_title">Cambia deposito</string>
|
||||
<string name="switch_depo_description">Cambia il deposito principale su cui stai lavorando tra quelli a te disponibili</string>
|
||||
|
||||
|
||||
<string name="filter_cod_jfas_label">Fase</string>
|
||||
<string name="filter_cod_jcom_label">Commessa</string>
|
||||
<string name="filter_ordine_cod_jcom_label">Commessa Ordine</string>
|
||||
<string name="no_filter_values_available">Nessun valore per il filtro</string>
|
||||
<string name="filter_dialog_title_cod_jfas">Filtra per Fase</string>
|
||||
<string name="filter_dialog_title_cod_jcom">Filtra per Commessa</string>
|
||||
<string name="filter_dialog_title_ordine_cod_jcom">Filtra per Comm. Ordine</string>
|
||||
<string name="filter_chip_text_format">%1$s: %2$d sel.</string>
|
||||
</resources>
|
||||
@@ -507,4 +507,14 @@
|
||||
|
||||
<string name="switch_depo_title">Change deposit</string>
|
||||
<string name="switch_depo_description">Change the main deposit you are working on among those available to you</string>
|
||||
|
||||
|
||||
<string name="filter_cod_jfas_label">Fase</string>
|
||||
<string name="filter_cod_jcom_label">Commessa</string>
|
||||
<string name="filter_ordine_cod_jcom_label">Commessa Ordine</string>
|
||||
<string name="no_filter_values_available">Nessun valore per il filtro</string>
|
||||
<string name="filter_dialog_title_cod_jfas">Filtra per Fase</string>
|
||||
<string name="filter_dialog_title_cod_jcom">Filtra per Commessa</string>
|
||||
<string name="filter_dialog_title_ordine_cod_jcom">Filtra per Comm. Ordine</string>
|
||||
<string name="filter_chip_text_format">%1$s: %2$d sel.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user