Completata gestione del contenuto UL in BottomSheetFragment
This commit is contained in:
@@ -315,23 +315,23 @@ public class MainActivity extends BaseActivity
|
||||
|
||||
private void init(){
|
||||
|
||||
ServerStatusChecker.getInstance().addCallback(value -> {
|
||||
if(value && (!mIsOnline || firstCheckExecution)){
|
||||
|
||||
SettingsManager.loadDBVariables(() -> {
|
||||
mIsOnline = true;
|
||||
firstCheckExecution = false;
|
||||
|
||||
}, ex -> {
|
||||
//mNoConnectionLayout.expand(true);
|
||||
if(mIsOnline) mIsOnline = false;
|
||||
}
|
||||
);
|
||||
|
||||
} else if(!value && mIsOnline){
|
||||
mIsOnline = false;
|
||||
}
|
||||
});
|
||||
// ServerStatusChecker.getInstance().addCallback(value -> {
|
||||
// if(value && (!mIsOnline || firstCheckExecution)){
|
||||
//
|
||||
// SettingsManager.loadDBVariables(() -> {
|
||||
// mIsOnline = true;
|
||||
// firstCheckExecution = false;
|
||||
//
|
||||
// }, ex -> {
|
||||
// //mNoConnectionLayout.expand(true);
|
||||
// if(mIsOnline) mIsOnline = false;
|
||||
// }
|
||||
// );
|
||||
//
|
||||
// } else if(!value && mIsOnline){
|
||||
// mIsOnline = false;
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ public class UtilityLogger {
|
||||
public static void errorMe(Exception ex, String additionalText, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
if(!BuildConfig.DEBUG) FirebaseCrashlytics.getInstance().recordException(ex);
|
||||
|
||||
logMe(ex.getMessage());
|
||||
|
||||
// if ((!(ex instanceof SocketTimeoutException) && !(ex.getCause() instanceof SocketTimeoutException)) ||
|
||||
// (!(ex instanceof SocketException) && !(ex.getCause() instanceof SocketException)) ||
|
||||
// (!(ex instanceof IOException) && !(ex.getCause() instanceof IOException))) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.tfb.fbtoast.FBToast;
|
||||
@@ -35,13 +36,11 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||
import it.integry.integrywmsnative.core.rest.model.SitArtOrdDTO;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
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.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.ActivitySpedizioneBinding;
|
||||
@@ -51,7 +50,6 @@ import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
|
||||
import it.integry.integrywmsnative.gest.vendita.dto.OrdineVenditaInevasoDTO;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentView;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentViewModel;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.exceptions.BottomSheetFragmentViewNotInitializedException;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_should_print.DialogAskShouldPrint;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleInputHelper;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper;
|
||||
@@ -61,7 +59,7 @@ import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQua
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2ResultDTO;
|
||||
|
||||
public class SpedizioneActivity extends AppCompatActivity implements SpedizioneViewModel.Listeners, BottomSheetFragmentLUContentViewModel.Listener {
|
||||
public class SpedizioneActivity extends AppCompatActivity implements SpedizioneViewModel.Listeners, BottomSheetFragmentLUContentViewModel.Listener, BottomSheetFragmentLUContentView.Listener {
|
||||
|
||||
private ActivitySpedizioneBinding mBindings;
|
||||
|
||||
@@ -117,9 +115,9 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
|
||||
mBindings.setLifecycleOwner(this);
|
||||
mBindings.setSpedizioneView(this);
|
||||
|
||||
mBindings.bottomSheetLuContent.init(mBindings.bottomSheetLuContent);
|
||||
mBindings.bottomSheetLuContent.setListener(this);
|
||||
mBindings.bottomSheetLuContent.init(mBindings.bottomSheetLuContent, null);
|
||||
mBottomSheetFragmentLUContentViewModel = mBindings.bottomSheetLuContent.getViewModelInstance();
|
||||
mBottomSheetFragmentLUContentViewModel.setListener(this);
|
||||
|
||||
|
||||
this.initVars();
|
||||
@@ -505,4 +503,14 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
|
||||
public void onBottomSheetLUClose() {
|
||||
this.mViewmodel.closeLU(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||
Toast.makeText(this, "Edit", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtbColrDelete(MtbColr mtbColr) {
|
||||
Toast.makeText(this, "Delete", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,12 +675,11 @@ public class SpedizioneViewModel {
|
||||
if (UtilityBigDecimal.lowerThan(mtbColrToDispatch.getQtaCol(), qtaDaEvadere)) {
|
||||
numCnfDaPrelevare = mtbColrToDispatch.getNumCnf();
|
||||
qtaColDaPrelevare = mtbColrToDispatch.getQtaCol();
|
||||
qtaCnfDaPrelevare = mtbColrToDispatch.getQtaCnf();
|
||||
} else {
|
||||
numCnfDaPrelevare = numCnfDaEvadere;
|
||||
qtaColDaPrelevare = qtaDaEvadere;
|
||||
qtaCnfDaPrelevare = qtaCnfDaEvadere;
|
||||
}
|
||||
qtaCnfDaPrelevare = mtbColrToDispatch.getQtaCnf();
|
||||
|
||||
|
||||
totalQtaAvailable = mtbColrToDispatch.getQtaCol();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
public class AutoCloseBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
|
||||
|
||||
public AutoCloseBottomSheetBehavior(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN &&
|
||||
getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
|
||||
Rect outRect = new Rect();
|
||||
child.getGlobalVisibleRect(outRect);
|
||||
|
||||
if (!outRect.contains((int) event.getRawX(), (int) event.getRawY())) {
|
||||
setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
}
|
||||
return super.onInterceptTouchEvent(parent, child, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__base.exceptions.BottomSheetFragmentViewNotInitializedException;
|
||||
|
||||
public abstract class BottomSheetFragmentBaseView extends ConstraintLayout {
|
||||
|
||||
protected Context mContext;
|
||||
protected View parentView;
|
||||
|
||||
protected BottomSheetBehavior mBottomSheetBehavior;
|
||||
|
||||
public BottomSheetFragmentBaseView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BottomSheetFragmentBaseView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public BottomSheetFragmentBaseView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs);
|
||||
}
|
||||
|
||||
public BottomSheetFragmentBaseView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
this(context, attrs);
|
||||
}
|
||||
|
||||
|
||||
public void init(View view, View backgroundView) {
|
||||
this.parentView = view;
|
||||
this.mBottomSheetBehavior = BottomSheetBehavior.from(this.parentView);
|
||||
|
||||
this.mBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||
if (newState == BottomSheetBehavior.STATE_COLLAPSED && backgroundView != null)
|
||||
backgroundView.setVisibility(View.GONE);
|
||||
|
||||
onStateChangedCallback(mapState(newState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
|
||||
if(backgroundView != null) {
|
||||
backgroundView.setVisibility(View.VISIBLE);
|
||||
backgroundView.setAlpha(slideOffset);
|
||||
}
|
||||
|
||||
onSlideCallback(1 - slideOffset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void expand() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
return;
|
||||
}
|
||||
|
||||
this.mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
|
||||
public void collapse() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
return;
|
||||
}
|
||||
|
||||
this.mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return this.getState() == State.EXPANDED;
|
||||
}
|
||||
|
||||
public boolean isCollapsed() {
|
||||
return this.getState() == State.COLLAPSED;
|
||||
}
|
||||
|
||||
|
||||
public State getState() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
return null;
|
||||
}
|
||||
|
||||
return mapState(this.mBottomSheetBehavior.getState());
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
if(isExpanded()) collapse();
|
||||
else expand();
|
||||
}
|
||||
|
||||
protected State mapState(int stateInt) {
|
||||
if(stateInt == BottomSheetBehavior.STATE_DRAGGING) return State.DRAGGING;
|
||||
if(stateInt == BottomSheetBehavior.STATE_SETTLING) return State.SETTLING;
|
||||
if(stateInt == BottomSheetBehavior.STATE_EXPANDED) return State.EXPANDED;
|
||||
if(stateInt == BottomSheetBehavior.STATE_COLLAPSED) return State.COLLAPSED;
|
||||
if(stateInt == BottomSheetBehavior.STATE_HIDDEN) return State.HIDDEN;
|
||||
if(stateInt == BottomSheetBehavior.STATE_HALF_EXPANDED) return State.HALF_EXPANDED;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract void onStateChangedCallback(State newState);
|
||||
|
||||
protected abstract void onSlideCallback(float slideOffset);
|
||||
|
||||
public enum State {
|
||||
DRAGGING,
|
||||
SETTLING,
|
||||
EXPANDED,
|
||||
COLLAPSED,
|
||||
HIDDEN,
|
||||
HALF_EXPANDED
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__lu_content.exceptions;
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__base.exceptions;
|
||||
|
||||
public class BottomSheetFragmentViewNotInitializedException extends Exception {
|
||||
public BottomSheetFragmentViewNotInitializedException() {
|
||||
@@ -11,6 +11,7 @@ import androidx.databinding.Observable;
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.WeakReferenceOnListChangedCallback;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
@@ -40,7 +41,6 @@ public class BottomSheetFragmentLUContentListAdapter extends BaseAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void onLUChangedCallback() {
|
||||
if(this.mtbColt.get() != null) {
|
||||
this.mtbColt.get().getMtbColr().addOnListChangedCallback(onListChangedCallback);
|
||||
|
||||
@@ -7,38 +7,30 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.Observable;
|
||||
import androidx.databinding.ObservableList;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.linearlistview.LinearListView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.BottomSheetFragmentLuContentBinding;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.exceptions.BottomSheetFragmentViewNotInitializedException;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__base.BottomSheetFragmentBaseView;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditView;
|
||||
|
||||
public class BottomSheetFragmentLUContentView extends ConstraintLayout {
|
||||
|
||||
private final Context mContext;
|
||||
private BottomSheetBehavior mBottomSheetBehavior;
|
||||
public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseView implements BottomSheetMtbColrEditView.Listener {
|
||||
|
||||
private BottomSheetFragmentLuContentBinding mBinding;
|
||||
private BottomSheetFragmentLUContentViewModel mViewModel;
|
||||
|
||||
private BottomSheetFragmentLUContentListAdapter mAdapter;
|
||||
|
||||
|
||||
public BottomSheetFragmentLUContentView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
private Listener mListener;
|
||||
|
||||
public BottomSheetFragmentLUContentView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -51,41 +43,26 @@ public class BottomSheetFragmentLUContentView extends ConstraintLayout {
|
||||
mViewModel = new BottomSheetFragmentLUContentViewModel();
|
||||
mBinding.setViewModel(mViewModel);
|
||||
|
||||
mBinding.bottomSheetMtbColrEdit.setListener(this);
|
||||
mBinding.bottomSheetMtbColrEdit.init(mBinding.bottomSheetMtbColrEdit, mBinding.bottomSheetMtbColrEditBackground);
|
||||
|
||||
this.initAdapter();
|
||||
this.initCallbacks();
|
||||
}
|
||||
|
||||
public BottomSheetFragmentLUContentView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs);
|
||||
}
|
||||
|
||||
public BottomSheetFragmentLUContentView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
this(context, attrs);
|
||||
}
|
||||
|
||||
public BottomSheetFragmentLUContentViewModel getViewModelInstance() {
|
||||
return mViewModel;
|
||||
}
|
||||
|
||||
public void init(View view) {
|
||||
this.mBottomSheetBehavior = BottomSheetBehavior.from(view);
|
||||
|
||||
this.mBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||
onStateChangedCallback(mapState(newState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
|
||||
onSlideCallback(1 - slideOffset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initAdapter() {
|
||||
this.mAdapter = new BottomSheetFragmentLUContentListAdapter(this.mContext, this.mViewModel.getObservableMtbColt());
|
||||
this.mBinding.linearListview.setAdapter(this.mAdapter);
|
||||
|
||||
this.mBinding.linearListview.setOnItemClickListener((parent, view, position, id) -> {
|
||||
this.mBinding.bottomSheetMtbColrEdit.setMtbColr(this.mViewModel.getObservableMtbColt().get().getMtbColr().get(position));
|
||||
this.mBinding.bottomSheetMtbColrEdit.expand();
|
||||
});
|
||||
}
|
||||
|
||||
private void initCallbacks() {
|
||||
@@ -112,53 +89,13 @@ public class BottomSheetFragmentLUContentView extends ConstraintLayout {
|
||||
mBinding.textviewArtDescription.setText(mContext.getResources().getQuantityString(R.plurals.articles, mtbColrs.size()));
|
||||
}
|
||||
|
||||
private State mapState(int stateInt) {
|
||||
if(stateInt == BottomSheetBehavior.STATE_DRAGGING) return State.DRAGGING;
|
||||
if(stateInt == BottomSheetBehavior.STATE_SETTLING) return State.SETTLING;
|
||||
if(stateInt == BottomSheetBehavior.STATE_EXPANDED) return State.EXPANDED;
|
||||
if(stateInt == BottomSheetBehavior.STATE_COLLAPSED) return State.COLLAPSED;
|
||||
if(stateInt == BottomSheetBehavior.STATE_HIDDEN) return State.HIDDEN;
|
||||
if(stateInt == BottomSheetBehavior.STATE_HALF_EXPANDED) return State.HALF_EXPANDED;
|
||||
|
||||
return null;
|
||||
public BottomSheetFragmentLUContentView setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
return null;
|
||||
}
|
||||
|
||||
return mapState(this.mBottomSheetBehavior.getState());
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return this.getState() == State.EXPANDED;
|
||||
}
|
||||
|
||||
public boolean isCollapsed() {
|
||||
return this.getState() == State.COLLAPSED;
|
||||
}
|
||||
|
||||
public void expand() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
return;
|
||||
}
|
||||
|
||||
this.mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
|
||||
public void collapse() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
return;
|
||||
}
|
||||
|
||||
this.mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
|
||||
private void onStateChangedCallback(State newState) {
|
||||
@Override
|
||||
protected void onStateChangedCallback(State newState) {
|
||||
switch (newState) {
|
||||
case EXPANDED:
|
||||
this.mBinding.btnCloseLu.setClickable(false);
|
||||
@@ -172,24 +109,27 @@ public class BottomSheetFragmentLUContentView extends ConstraintLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void onSlideCallback(float slideOffset) {
|
||||
@Override
|
||||
protected void onSlideCallback(float slideOffset) {
|
||||
this.mBinding.btnCloseLu.setAlpha(slideOffset);
|
||||
// mBinding.tapActionLayout.setAlpha(1-slideOffset);
|
||||
}
|
||||
|
||||
|
||||
public void toggle() {
|
||||
if(isExpanded()) collapse();
|
||||
else expand();
|
||||
@Override
|
||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||
if(mListener != null) this.mListener.onMtbColrEdit(mtbColr);
|
||||
}
|
||||
|
||||
public enum State {
|
||||
DRAGGING,
|
||||
SETTLING,
|
||||
EXPANDED,
|
||||
COLLAPSED,
|
||||
HIDDEN,
|
||||
HALF_EXPANDED
|
||||
@Override
|
||||
public void onMtbColrDelete(MtbColr mtbColr) {
|
||||
if(mListener != null) this.mListener.onMtbColrDelete(mtbColr);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
void onMtbColrEdit(MtbColr mtbColr);
|
||||
|
||||
void onMtbColrDelete(MtbColr mtbColr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class BottomSheetFragmentLUContentViewModel {
|
||||
|
||||
public ObservableField<MtbColt> mtbColt = new ObservableField<>();
|
||||
private Listener mListener;
|
||||
private MtbColrListener mMtbColrListener;
|
||||
|
||||
public void closeCurrentLU() {
|
||||
if(this.mListener != null) this.mListener.onBottomSheetLUClose();
|
||||
@@ -27,7 +28,16 @@ public class BottomSheetFragmentLUContentViewModel {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetFragmentLUContentViewModel setMtbColrListener(MtbColrListener mtbColrListener) {
|
||||
this.mMtbColrListener = mtbColrListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onBottomSheetLUClose();
|
||||
}
|
||||
|
||||
public interface MtbColrListener {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.databinding.BottomSheetMtbColrEditBinding;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__base.BottomSheetFragmentBaseView;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.exceptions.NullMtbColrException;
|
||||
|
||||
public class BottomSheetMtbColrEditView extends BottomSheetFragmentBaseView {
|
||||
|
||||
private BottomSheetMtbColrEditBinding mBinding;
|
||||
private BottomSheetMtbColrEditViewModel mViewModel;
|
||||
|
||||
|
||||
private Listener mListener;
|
||||
|
||||
public BottomSheetMtbColrEditView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.bottom_sheet__mtb_colr_edit, this, true);
|
||||
|
||||
|
||||
mViewModel = new BottomSheetMtbColrEditViewModel();
|
||||
mBinding.setViewModel(mViewModel);
|
||||
mBinding.setView(this);
|
||||
}
|
||||
|
||||
public void setMtbColr(MtbColr mtbColr) {
|
||||
this.mBinding.invalidateAll();
|
||||
this.mViewModel.setMtbColr(mtbColr);
|
||||
this.mBinding.executePendingBindings();
|
||||
|
||||
this.parentView.requestLayout();
|
||||
}
|
||||
|
||||
public void editMtbColr() {
|
||||
if(this.mListener != null) this.mListener.onMtbColrEdit(this.mViewModel.getMtbColr());
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
public void deleteMtbColr() {
|
||||
if(this.mListener != null) this.mListener.onMtbColrDelete(this.mViewModel.getMtbColr());
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void expand() {
|
||||
if(this.mViewModel.getMtbColr() == null) {
|
||||
UtilityLogger.errorMe(new NullMtbColrException());
|
||||
return;
|
||||
}
|
||||
|
||||
super.expand();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStateChangedCallback(State newState) {
|
||||
if(newState == State.COLLAPSED) this.mViewModel.setMtbColr(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSlideCallback(float slideOffset) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public BottomSheetMtbColrEditViewModel getViewModelInstance() {
|
||||
return this.mViewModel;
|
||||
}
|
||||
|
||||
|
||||
public BottomSheetMtbColrEditView setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
|
||||
void onMtbColrEdit(MtbColr mtbColr);
|
||||
|
||||
void onMtbColrDelete(MtbColr mtbColr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit;
|
||||
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
|
||||
public class BottomSheetMtbColrEditViewModel {
|
||||
|
||||
private ObservableField<MtbColr> mtbColr = new ObservableField<>();
|
||||
|
||||
|
||||
public MtbColr getMtbColr() {
|
||||
return mtbColr.get();
|
||||
}
|
||||
|
||||
public BottomSheetMtbColrEditViewModel setMtbColr(MtbColr mtbColr) {
|
||||
this.mtbColr.set(mtbColr);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.exceptions;
|
||||
|
||||
public class NullMtbColrException extends Exception {
|
||||
|
||||
public NullMtbColrException() {
|
||||
super("Please set MtbColr before opening the BottomSheet");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user