Refactoring su DialogBasketLU
This commit is contained in:
parent
f4f7f4a6f0
commit
f68691df6b
@ -1,12 +1,13 @@
|
||||
package it.integry.integrywmsnative.view.dialogs.basket_lu;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
@ -14,65 +15,58 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDialog;
|
||||
import it.integry.integrywmsnative.databinding.DialogBasketLuBinding;
|
||||
import it.integry.integrywmsnative.view.dialogs.basket_lu.pages.page1.DialogBasketLU_Page1_ViewModel;
|
||||
import it.integry.integrywmsnative.view.dialogs.basket_lu.pages.page2.DialogBasketLU_Page2_ViewModel;
|
||||
|
||||
public class DialogBasketLU {
|
||||
public class DialogBasketLU extends BaseDialogFragment {
|
||||
|
||||
private Context mContext;
|
||||
private Dialog mDialog;
|
||||
private DialogBasketLuBinding mBinding;
|
||||
|
||||
private RunnableArgs<MtbColt> mOnComplete;
|
||||
|
||||
public static Dialog make(final Context context, RunnableArgs<MtbColt> onComplete) {
|
||||
return new DialogBasketLU(context, onComplete).mDialog;
|
||||
}
|
||||
private final RunnableArgs<MtbColt> mOnComplete;
|
||||
private DialogBasketLuBinding mBindings;
|
||||
|
||||
|
||||
private DialogBasketLU(Context context, RunnableArgs<MtbColt> onComplete) {
|
||||
mContext = context;
|
||||
|
||||
public DialogBasketLU(RunnableArgs<MtbColt> onComplete) {
|
||||
mOnComplete = onComplete;
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_basket_lu, null, false);
|
||||
|
||||
mDialog = new Dialog(context);
|
||||
|
||||
mDialog.setContentView(mBinding.getRoot());
|
||||
|
||||
mDialog.setCanceledOnTouchOutside(false);
|
||||
mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
UtilityDialog.setTo90PercentWidth(context, mDialog);
|
||||
|
||||
this.initViewPager();
|
||||
}
|
||||
|
||||
private void initViewPager() {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
mBindings = DialogBasketLuBinding.inflate(LayoutInflater.from(requireContext()), null, false);
|
||||
|
||||
var alertDialog = new MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(mBindings.getRoot())
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
this.initViewPager(alertDialog);
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
private void initViewPager(Dialog dialog) {
|
||||
List<Map.Entry<Integer, Class<?>>> views = new ArrayList<>();
|
||||
views.add(new AbstractMap.SimpleEntry<>(R.layout.dialog_basket_lu__page1, DialogBasketLU_Page1_ViewModel.class));
|
||||
views.add(new AbstractMap.SimpleEntry<>(R.layout.dialog_basket_lu__page2, DialogBasketLU_Page2_ViewModel.class));
|
||||
|
||||
DialogBasketLU_ViewPagerAdapter viewPagerAdapter = new DialogBasketLU_ViewPagerAdapter(mContext, views);
|
||||
mBinding.viewpager.setAdapter(viewPagerAdapter);
|
||||
mBinding.viewpager.beginFakeDrag();
|
||||
mBinding.viewpager.addOnPageChangeListener(viewPagerAdapter);
|
||||
mBinding.viewpager.setEnabled(false);
|
||||
|
||||
|
||||
mDialog.setOnShowListener(v -> {
|
||||
DialogBasketLU_ViewPagerAdapter viewPagerAdapter = new DialogBasketLU_ViewPagerAdapter(requireContext(), views);
|
||||
mBindings.viewpager.setAdapter(viewPagerAdapter);
|
||||
mBindings.viewpager.beginFakeDrag();
|
||||
mBindings.viewpager.addOnPageChangeListener(viewPagerAdapter);
|
||||
mBindings.viewpager.setEnabled(false);
|
||||
|
||||
|
||||
dialog.setOnShowListener(v -> {
|
||||
viewPagerAdapter.getViewModel(R.layout.dialog_basket_lu__page2).setOnConfirmClickListener(data -> {
|
||||
MtbColt mtbColt = (MtbColt) data;
|
||||
|
||||
mOnComplete.run(mtbColt);
|
||||
mDialog.dismiss();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -98,9 +98,9 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
|
||||
});
|
||||
|
||||
mBindings.viewBasket.setOnClickListener(v -> {
|
||||
DialogBasketLU.make(getActivity(), mtbColt -> {
|
||||
new DialogBasketLU(mtbColt -> {
|
||||
onLUOpened(mtbColt, false);
|
||||
}).show();
|
||||
}).show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
});
|
||||
|
||||
var alertDialog = new MaterialAlertDialogBuilder(requireContext())
|
||||
|
||||
@ -1,45 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/base_root"
|
||||
android:orientation="vertical"
|
||||
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp">
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/title_text"
|
||||
style="@style/MaterialAlertDialog.Material3.Title.Text.CenterStacked"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="16dp">
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/basket" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextViewMaterial.Dialog.HeadlineText"
|
||||
android:text="@string/basket"
|
||||
android:gravity="center_horizontal"/>
|
||||
<it.integry.integrywmsnative.ui.DeactivatableViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<it.integry.integrywmsnative.ui.DeactivatableViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:animateLayoutChanges="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</it.integry.integrywmsnative.ui.DeactivatableViewPager>
|
||||
</it.integry.integrywmsnative.ui.DeactivatableViewPager>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</layout>
|
||||
@ -1,10 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.model.MtbColt" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityString" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityDate" />
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
@ -12,49 +17,41 @@
|
||||
type="MtbColt" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:clickable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@{mtbColt.numCollo.toString()}"
|
||||
tools:text="22222"
|
||||
android:background="@drawable/badge_round_corner"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:textColor="@android:color/white"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
</RelativeLayout>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:background="@drawable/badge_round_corner"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:layout_gravity="center"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:text="@{mtbColt.numCollo.toString()}"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
tools:text="22222" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
@ -63,25 +60,25 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_toStartOf="@id/posizione_collo"
|
||||
android:layout_alignParentStart="true"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toStartOf="@id/posizione_collo"
|
||||
android:text="@{mtbColt.getDataColloHumanLong()}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
android:text="@{mtbColt.getDataColloHumanLong()}"
|
||||
tools:text="28 ottobre 2018" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/posizione_collo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@{mtbColt.posizione}"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="@{UtilityString.isNullOrEmpty(mtbColt.posizione) ? View.INVISIBLE : View.VISIBLE}"
|
||||
tools:text="A01F01C01L01" />
|
||||
@ -90,16 +87,17 @@
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:text="@{`Preparato da: ` + mtbColt.preparatoDa}"
|
||||
android:textSize="14sp"
|
||||
android:visibility="@{UtilityString.isNullOrEmpty(mtbColt.preparatoDa) ? View.INVISIBLE : View.VISIBLE}"
|
||||
tools:text="Preparato da: Utente" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
@ -45,7 +45,7 @@
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="0.85" />
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
@ -69,7 +69,7 @@
|
||||
android:text="@string/no_lu_found_message"
|
||||
android:layout_marginTop="16dp"
|
||||
style="@style/AppTheme.NewMaterial.Text.Medium"/>
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
@ -106,15 +106,13 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_abort"
|
||||
style="@style/Button.PrimaryOutline"
|
||||
style="@style/Widget.Material3.Button.TextButton.Dialog"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:text="@string/back"
|
||||
app:icon="@drawable/ic_black_back"
|
||||
app:iconGravity="textStart"
|
||||
app:iconSize="24dp"
|
||||
app:layout_constraintEnd_toStartOf="@id/center_buttons_guideline"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
@ -123,15 +121,13 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_confirm"
|
||||
style="@style/Button.PrimaryFull"
|
||||
style="@style/Widget.Material3.Button.TonalButton.Icon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:text="@string/use"
|
||||
app:icon="@drawable/ic_black_tick"
|
||||
app:iconGravity="textStart"
|
||||
app:iconSize="24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/center_buttons_guideline"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user