Rimosso vecchio dialog livello posizione
This commit is contained in:
parent
993191c083
commit
6f06eaf0a0
@ -1,162 +0,0 @@
|
|||||||
package it.integry.integrywmsnative.view.dialogs;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
|
||||||
|
|
||||||
import it.integry.integrywmsnative.R;
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityDialog;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityFocus;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityPosizione;
|
|
||||||
|
|
||||||
public class DialogAskLivelloPosizione {
|
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private MtbDepoPosizione mtbDepoPosizione;
|
|
||||||
|
|
||||||
private Dialog mDialog;
|
|
||||||
|
|
||||||
private RunnableArgs<MtbDepoPosizione> onComplete;
|
|
||||||
private RunnableArgs<Exception> onFailed;
|
|
||||||
|
|
||||||
private TextInputLayout livelloTextInputLayout;
|
|
||||||
|
|
||||||
private boolean completedFLow = false;
|
|
||||||
|
|
||||||
public static void make(FragmentActivity activity, MtbDepoPosizione mtbDepoPosizione, boolean canAbort, RunnableArgs<MtbDepoPosizione> onComplete, RunnableArgs<Exception> onFailed) {
|
|
||||||
activity.runOnUiThread(() -> {
|
|
||||||
new DialogAskLivelloPosizione(activity, mtbDepoPosizione, canAbort, onComplete, onFailed).mDialog.show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DialogAskLivelloPosizione(Context context, MtbDepoPosizione mtbDepoPosizione, boolean canAbort, RunnableArgs<MtbDepoPosizione> onComplete, RunnableArgs<Exception> onFailed) {
|
|
||||||
mContext = context;
|
|
||||||
this.mtbDepoPosizione = mtbDepoPosizione;
|
|
||||||
this.onComplete = onComplete;
|
|
||||||
this.onFailed = onFailed;
|
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
|
||||||
View currentView = inflater.inflate(R.layout.dialog_ask_livello_posizione, null, false);
|
|
||||||
|
|
||||||
mDialog = new Dialog(mContext);
|
|
||||||
mDialog.setContentView(currentView);
|
|
||||||
mDialog.setCanceledOnTouchOutside(false);
|
|
||||||
mDialog.setCancelable(false);
|
|
||||||
mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
||||||
|
|
||||||
UtilityDialog.setTo90PercentWidth(mContext, mDialog);
|
|
||||||
|
|
||||||
mDialog.setOnDismissListener(dialog -> {
|
|
||||||
if(!completedFLow) onComplete.run(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
mDialog.setOnShowListener(dialog -> {
|
|
||||||
|
|
||||||
if(!canAbort) currentView.findViewById(R.id.button_abort).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
|
|
||||||
currentView.findViewById(R.id.button_confirm).setOnClickListener(v -> {
|
|
||||||
String levelNumber = ((TextView)currentView.findViewById(R.id.level_number)).getText().toString();
|
|
||||||
onLevelConfirm(levelNumber);
|
|
||||||
});
|
|
||||||
|
|
||||||
currentView.findViewById(R.id.button_abort).setOnClickListener(v -> {
|
|
||||||
onLevelAbort();
|
|
||||||
});
|
|
||||||
|
|
||||||
livelloTextInputLayout = currentView.findViewById(R.id.level_number_layout);
|
|
||||||
|
|
||||||
|
|
||||||
UtilityFocus.focusTextBox(mContext, livelloTextInputLayout.getEditText());
|
|
||||||
livelloTextInputLayout.getEditText().addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
if(livelloTextInputLayout.getEditText().getText() != null) {
|
|
||||||
validateLevel(livelloTextInputLayout.getEditText().getText().toString());
|
|
||||||
} else resetLevelError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void onLevelConfirm(String levelString) {
|
|
||||||
|
|
||||||
String newPosizione = mtbDepoPosizione.getPosizione().substring(0, mtbDepoPosizione.getPosizione().length()-1);
|
|
||||||
newPosizione += levelString;
|
|
||||||
|
|
||||||
MtbDepoPosizione foundPosizione = UtilityPosizione.getFromCache(newPosizione);
|
|
||||||
|
|
||||||
if(foundPosizione != null) {
|
|
||||||
resetLevelError();
|
|
||||||
|
|
||||||
completedFLow = true;
|
|
||||||
onComplete.run(foundPosizione);
|
|
||||||
mDialog.dismiss();
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
setLevelError(mContext.getResources().getString(R.string.not_valid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void validateLevel(String levelString) {
|
|
||||||
String newPosizione = mtbDepoPosizione.getPosizione().substring(0, mtbDepoPosizione.getPosizione().length()-1);
|
|
||||||
newPosizione += levelString;
|
|
||||||
|
|
||||||
if(UtilityPosizione.getFromCache(newPosizione) != null) {
|
|
||||||
resetLevelError();
|
|
||||||
} else setLevelError(mContext.getResources().getString(R.string.not_valid));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setLevelError(String message){
|
|
||||||
livelloTextInputLayout.setErrorEnabled(true);
|
|
||||||
livelloTextInputLayout.setError(message);
|
|
||||||
livelloTextInputLayout.setErrorIconDrawable(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetLevelError() {
|
|
||||||
livelloTextInputLayout.setError(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void onLevelAbort() {
|
|
||||||
completedFLow = true;
|
|
||||||
onComplete.run(null);
|
|
||||||
mDialog.dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user