[FEAT] Implementata descrizione testuale delle quantità di cui fare pick

[BUG] Risolto strano problema che faceva selezionare ordini random in avantielenco spedizione
This commit is contained in:
Giuseppe Scorrano 2019-07-02 19:05:59 +02:00
parent 637cd659ec
commit 503e057eff
11 changed files with 471 additions and 28 deletions

Binary file not shown.

View File

@ -99,7 +99,7 @@ dependencies {
implementation 'com.orhanobut:logger:2.2.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-perf:18.0.0'
implementation 'com.google.firebase:firebase-perf:18.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
@ -147,6 +147,7 @@ dependencies {
//AppUpdate
implementation 'com.github.javiersantos:AppUpdater:2.7'
//Barcode
implementation project(':pointmobilescannerlibrary')
implementation project(':zebrascannerlibrary')

View File

@ -1,16 +1,83 @@
package it.integry.integrywmsnative.core.di;
import androidx.annotation.NonNull;
import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.databinding.Observable;
import androidx.databinding.PropertyChangeRegistry;
public class BindableBoolean implements Observable {
public class BindableBoolean extends BaseObservable {
boolean mValue;
public BindableBoolean() {}
private transient PropertyChangeRegistry mCallbacks;
public BindableBoolean() {
}
public BindableBoolean(boolean startValue) {
this.mValue = startValue;
}
@Override
public void addOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) {
synchronized (this) {
if (mCallbacks == null) {
mCallbacks = new PropertyChangeRegistry();
}
}
mCallbacks.add(callback);
}
@Override
public void removeOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) {
synchronized (this) {
if (mCallbacks == null) {
return;
}
}
mCallbacks.remove(callback);
}
public void resetOnPropertyChangedCallback() {
synchronized (this) {
if (mCallbacks == null) {
return;
}
}
mCallbacks.clear();
mCallbacks = null;
}
/**
* Notifies listeners that all properties of this instance have changed.
*/
public void notifyChange() {
synchronized (this) {
if (mCallbacks == null) {
return;
}
}
mCallbacks.notifyCallbacks(this, 0, null);
}
/**
* Notifies listeners that a specific property has changed. The getter for the property
* that changes should be marked with {@link Bindable} to generate a field in
* <code>BR</code> to be used as <code>fieldId</code>.
*
* @param fieldId The generated BR id for the Bindable field.
*/
public void notifyPropertyChanged(int fieldId) {
synchronized (this) {
if (mCallbacks == null) {
return;
}
}
mCallbacks.notifyCallbacks(this, fieldId, null);
}
public boolean get() {
return mValue;
}

View File

@ -29,8 +29,6 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter<MainLis
private Context mContext;
private HashMap<BindableBoolean, Observable.OnPropertyChangedCallback> mCallbacksDictionary = new HashMap<>();
private List<OrdineVenditaInevasoDTO> mDataset;
private RunnableArgs<OrdineVenditaInevasoDTO> mOnSingleSelectionChanged;
@ -103,6 +101,10 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter<MainLis
.filter(x -> x.getCodAnagOrd().equals(mDataset.get(nextItemPosition).getCodAnagOrd()))
.anyMatch(OrdineVenditaInevasoDTO::isSelected);
List<OrdineVenditaInevasoDTO> ordersToSelect =
Stream.of(mDataset)
.filter(x -> x.getCodAnagOrd().equals(mDataset.get(nextItemPosition).getCodAnagOrd())).toList();
Stream.of(mDataset)
.filter(x -> x.getCodAnagOrd().equals(mDataset.get(nextItemPosition).getCodAnagOrd()))
.forEach(x -> x.setSelected(!anySelected));
@ -110,14 +112,15 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter<MainLis
}
@Override
public void onBindItemViewHolder(SingleItemViewHolder holder, int itemPosition) {
OrdineVenditaInevasoDTO ordine = mDataset.get(itemPosition);
public void onBindItemViewHolder(SingleItemViewHolder h, int itemPosition) {
final OrdineVenditaInevasoDTO ordine = mDataset.get(itemPosition);
final SingleItemViewHolder holder = h;
holder.binding.venditaMainListGroupItemContainerCheckBox.setTag(ordine.getNumOrd());
holder.binding.venditaMainListGroupItemContainerCheckBox.setOnCheckedChangeListener(null);
if (mCallbacksDictionary.containsKey(ordine.selected)) {
ordine.selected.removeOnPropertyChangedCallback(mCallbacksDictionary.get(ordine.selected));
}
ordine.selected.resetOnPropertyChangedCallback();
holder.binding.emptyView.setBackgroundColor(ResourcesCompat.getColor(mContext.getResources(), ordine.flagExistCollo() ? R.color.colorPrimary : android.R.color.transparent, null));
@ -138,19 +141,22 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter<MainLis
holder.binding.venditaMainListGroupItemContainerCheckBox.setChecked(ordine.isSelected());
mCallbacksDictionary.put(ordine.selected, new Observable.OnPropertyChangedCallback() {
//Bindable to View
ordine.selected.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
if(holder.binding.venditaMainListGroupItemContainerCheckBox.getTag().equals(ordine.getNumOrd())) {
holder.binding.venditaMainListGroupItemContainerCheckBox.setChecked(((BindableBoolean) sender).get());
}
}
});
//View to Bindable
holder.binding.venditaMainListGroupItemContainerCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
ordine.setSelected(isChecked);
mOnSingleSelectionChanged.run(ordine);
});
ordine.selected.addOnPropertyChangedCallback(mCallbacksDictionary.get(ordine.selected));
}

View File

@ -0,0 +1,293 @@
package it.integry.integrywmsnative.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.ViewDebug;
import androidx.annotation.ArrayRes;
import androidx.appcompat.widget.AppCompatCheckBox;
import it.integry.integrywmsnative.R;
public class CheckBoxThreeStates extends AppCompatCheckBox {
private boolean mBroadcasting;
private boolean mIndeterminate;
private OnCheckedChangeListener mOnCheckedChangeListener;
private static final int[] INDETERMINATE_STATE_SET = {
// R.attr.state_indeterminate
};
private static final int[] DEFAULT_CYCLE = {
1, 0, 1, 0
};
private int[] mCycle = DEFAULT_CYCLE;
// public CheckBoxThreeStates(final Context context) {
// this(context, null);
// }
// public CheckBoxThreeStates(final Context context, final AttributeSet attrs) {
// this(context, attrs, R.attr.checkbox3Style);
// }
public CheckBoxThreeStates(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
/*
final TypedArray a =
context.obtainStyledAttributes(attrs, R.styleable.CheckBox3, defStyleAttr, R.style.Widget_Checkbox3);
try {
if (a.hasValue(R.styleable.CheckBox3_checkbox3_checkableCycle)) {
int cycleRes = a.getResourceId(R.styleable.CheckBox3_checkbox3_checkableCycle, 0);
if (cycleRes != 0) {
setCycle(getResources().getIntArray(cycleRes));
}
}
if (a.hasValue(R.styleable.CheckBox3_android_fontFamily)) {
final String font = a.getString(R.styleable.CheckBox3_android_fontFamily);
setTypeface(TypefaceUtils.loadFromAsset(getResources().getAssets(), font));
}
final boolean indeterminate = a.getBoolean(R.styleable.CheckBox3_checkbox3_indeterminate, false);
final boolean checked = a.getBoolean(R.styleable.CheckBox3_android_checked, false);
mBroadcasting = true;
int index = getStateIndex(checked, indeterminate);
if (!isValidStateIndex(index)) {
index = getFirstValidStateIndex(index);
}
moveToState(index);
} finally {
a.recycle();
}
*/
}
public void setCycle(@ArrayRes final int cycleRes) {
setCycle(getResources().getIntArray(cycleRes));
}
/**
* Change the cycle used to determine the next state of the checkbox when the user
* click the component, or when the {@link #toggle()} is called.<br />
* The value passed is an array of 4 integer elements, representing the state of the checkbox.<br />
* The value of each element can be 0 or 1, with 0 to disable the state and 1 to enable the state.<br />
* The states are (in order):
* <ul>
* <li>Checked</li>
* <li>Indeterminate (checked)</li>
* <li>Unchecked</li>
* <li>Indeterminate (unchecked)</li>
* </ul>
* So if a cycle like this one is used:
* <code>int[] cycle = new int[]{1,0,1,0}</code>
* the checkbox will only cycle between checked and unchecked state.
* The default cycle is: <code>{1,0,1,0}</code>
* <p>
* <p>The method throws an exception if the array is not valid. A valid array must match the following rules:
* <ul>
* <li>If not null, must have 4 elements</li>
* <li>At least 2 elements must be not equal to 0</li>
* </ul></p>
*
* @param cycle change the cycle
*/
public void setCycle(final int[] cycle) {
validateCycle(cycle);
mCycle = cycle == null ? DEFAULT_CYCLE : cycle;
}
/**
* Move to the next state of the checkbox
*/
@Override
public void toggle() {
if (null == mCycle) return;
final int currentIndex = getCurrentStateIndex();
moveToNextState(currentIndex);
}
@Override
public void setChecked(boolean checked) {
if (null == mCycle) return;
int index = getStateIndex(checked, isIndeterminate());
if (!isValidStateIndex(index)) {
return;
}
super.setChecked(checked);
}
/**
* Change the state of the checkbox
*
* @param checked
* @param indeterminate
*/
public void setChecked(boolean checked, boolean indeterminate) {
if (null == mCycle) return;
if (isChecked() == checked) {
setIndeterminate(indeterminate);
} else {
mIndeterminate = indeterminate;
}
setChecked(checked);
}
@ViewDebug.ExportedProperty
public boolean isIndeterminate() {
return mIndeterminate;
}
public void setIndeterminate(boolean indeterminate) {
if (null == mCycle) return;
int index = getStateIndex(isChecked(), indeterminate);
if (!isValidStateIndex(index)) {
return;
}
setIndeterminateImpl(indeterminate, true);
}
private void moveToNextState(final int index) {
int nextIndex = getNextValidIndex(index);
boolean checked = nextIndex < 2;
mIndeterminate = nextIndex == 1 || nextIndex == 3;
setChecked(checked);
}
private void moveToState(final int nextIndex) {
if (!isValidStateIndex(nextIndex)) {
}
boolean checked = nextIndex < 2;
mIndeterminate = nextIndex == 1 || nextIndex == 3;
setChecked(checked);
}
private void validateCycle(final int[] cycle) {
if (null == cycle) {
return;
}
if (cycle.length != 4) {
throw new IllegalArgumentException("Invalid cycle length. Expected 4 an array or 4 int");
}
int total = 0;
for (final int i1 : cycle) {
if (i1 != 0) {
total++;
}
}
if (total < 2) {
throw new IllegalArgumentException("Invalid cycle. At least 2 elements must be positive");
}
}
private int getCurrentStateIndex() {
return getStateIndex(isChecked(), isIndeterminate());
}
private int getStateIndex(boolean checked, boolean indeterminate) {
int index = 0;
if (checked) {
index += indeterminate ? 1 : 0;
} else {
index = indeterminate ? 3 : 2;
}
return index;
}
private int getFirstValidStateIndex(int index) {
int i = index;
while (i >= 0) {
if (mCycle[i] != 0) return i;
i--;
}
i = index;
while (i < mCycle.length) {
if (mCycle[i] != 0) return i;
i++;
}
return -1;
}
private boolean isValidStateIndex(int index) {
return mCycle[index] != 0;
}
private int getNextValidIndex(int index) {
int nextIndex = index + 1 >= mCycle.length ? 0 : index + 1;
if (mCycle[nextIndex] != 0) {
return nextIndex;
}
return getNextValidIndex(nextIndex);
}
@Override
public void setOnCheckedChangeListener(final OnCheckedChangeListener listener) {
super.setOnCheckedChangeListener(listener);
mOnCheckedChangeListener = listener;
}
@Override
protected int[] onCreateDrawableState(int extraSpace) {
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
if (isIndeterminate()) {
mergeDrawableStates(drawableState, INDETERMINATE_STATE_SET);
}
return drawableState;
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
}
private void setIndeterminateImpl(boolean indeterminate, boolean notify) {
if (mIndeterminate != indeterminate) {
mIndeterminate = indeterminate;
refreshDrawableState();
if (notify) {
notifyStateListener();
}
}
}
private void notifyStateListener() {
if (mBroadcasting) {
return;
}
mBroadcasting = true;
if (mOnCheckedChangeListener != null) {
mOnCheckedChangeListener.onCheckedChanged(this, isChecked());
}
mBroadcasting = false;
}
@Override
public CharSequence getAccessibilityClassName() {
return CheckBoxThreeStates.class.getName();
}
}

View File

@ -5,6 +5,7 @@ import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.res.ColorStateList;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.Observable;
@ -40,6 +41,7 @@ import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import it.integry.integrywmsnative.core.utility.UtilityNumber;
import it.integry.integrywmsnative.core.utility.UtilityProgress;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.DialogInputQuantityArticoloBinding;
@ -371,6 +373,8 @@ public class DialogInputQuantity {
quantityDTO.expireDate = c.getTime();
}
refreshQtaDescriptionText();
}
@ -502,6 +506,8 @@ public class DialogInputQuantity {
}
}
// refreshQtaDescriptionText();
}
});
@ -537,6 +543,7 @@ public class DialogInputQuantity {
}
}
// refreshQtaDescriptionText();
}
});
@ -567,6 +574,8 @@ public class DialogInputQuantity {
}
}
// refreshQtaDescriptionText();
}
});
@ -627,6 +636,42 @@ public class DialogInputQuantity {
}
private void refreshQtaDescriptionText() {
int numConf = (int) (currentQuantityDto.qtaDaEvadere.get() / currentQuantityDto.qtaCnf.get());
float qtaTot = currentQuantityDto.qtaDaEvadere.get().floatValue();
float mod = qtaTot % numConf;
String text = "";
if(numConf > 0) {
text += "<b>" + numConf + " " + currentContext.getResources().getQuantityString(R.plurals.item_package, numConf).toUpperCase() + "</b>";
}
if(numConf > 0 && mod > 0) {
text += " e ";
}
if(mod > 0) {
text += "<b>" + UtilityNumber.decimalToString(mod) + " ";
if(mod == 1) {
text += currentContext.getResources().getQuantityString(R.plurals.pieces, (int) mod).toUpperCase();
} else {
text += currentContext.getString(R.string.piece).toUpperCase();
}
text += "</b>";
}
currentBinding.qtaDescriptionText.setText(Html.fromHtml(text));
}
private void onConfirm(Context context, QuantityDTO quantityDTO, RunnableArgss<QuantityDTO, Boolean> dialogCallback, boolean closeUL){
if(currentDTO.mtbAart.isFlagTracciabilita() && (quantityDTO.batchLot == null || quantityDTO.batchLot.get().trim().length() == 0)){

View File

@ -213,6 +213,15 @@
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/qta_description_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center_horizontal"
android:paddingTop="4dp"
tools:text="2 CARTONI e 3 PEZZI"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

View File

@ -14,7 +14,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingStart="2dp"
android:paddingEnd="4dp">
@ -30,7 +30,7 @@
android:background="@color/full_white">
<CheckBox
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/vendita_main_list_group_item_container_checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -77,6 +77,8 @@
<View
android:id="@+id/empty_view"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_width="8dp"
android:layout_height="wrap_content"
android:layout_alignTop="@id/vendita_main_list_group_item_container_root"

View File

@ -6,15 +6,15 @@
xmlns:tools="http://schemas.android.com/tools">
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp">
<!--<androidx.cardview.widget.CardView-->
<!--xmlns:card_view="http://schemas.android.com/apk/res-auto"-->
<!--android:id="@+id/card_view"-->
<!--android:layout_gravity="center"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--card_view:cardUseCompatPadding="true"-->
<!--card_view:cardCornerRadius="4dp"-->
<!--card_view:cardElevation="4dp">-->
<LinearLayout
android:layout_width="match_parent"
@ -25,7 +25,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/mainOrange"
android:padding="8dp">
android:paddingStart="12dp"
android:paddingTop="8dp"
android:paddingEnd="8dp"
android:paddingBottom="8dp">
<CheckBox
android:layout_width="wrap_content"
@ -57,7 +60,7 @@
</LinearLayout>
</androidx.cardview.widget.CardView>
<!--</androidx.cardview.widget.CardView>-->
</LinearLayout>

View File

@ -77,6 +77,14 @@
<item quantity="one"><![CDATA[&#200; stato selezionato <b>%d</b> ordine]]></item>
<item quantity="other"><![CDATA[Sono stati selezionati <b>%d</b> ordini]]></item>
</plurals>
<plurals name="pieces">
<item quantity="one">@string/piece</item>
<item quantity="other">pezzi</item>
</plurals>
<plurals name="item_package">
<item quantity="one">confezione</item>
<item quantity="other">confezioni</item>
</plurals>
<string name="action_close_ul">Chiudi UL</string>
<string name="already_read_articles">Articoli presenti</string>
<string name="orders">Ordini</string>
@ -85,6 +93,7 @@
<string name="date_text">Data</string>
<string name="position_text">Posizione</string>
<string name="prepared_by_text">Preparato da</string>
<string name="piece">Pezzo</string>

View File

@ -75,6 +75,14 @@
<item quantity="one"><![CDATA[<b>%d</b> order selected]]></item>
<item quantity="other"><![CDATA[<b>%d</b> orders selected]]></item>
</plurals>
<plurals name="pieces">
<item quantity="one">@string/piece</item>
<item quantity="other">pieces</item>
</plurals>
<plurals name="item_package">
<item quantity="one">package</item>
<item quantity="other">packages</item>
</plurals>
<string name="action_close_ul">Close LU</string>
<string name="already_read_articles">Submitted items</string>
<string name="orders">Orders</string>
@ -86,7 +94,7 @@
<string name="picking_not_available">Picking not available</string>
<string name="scan_item">Please scan an <b>item</b> barcode</string>
<string name="extra_item">Extra item</string>
<string name="piece">Piece</string>
<string name="password_error_length">between 3 and 30 alphanumeric characters</string>
<string name="username_error_not_valid">enter a valid username</string>