Completata utilityFocus e dialog ask livello in Versamento
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package it.integry.integrywmsnative.core.utility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class UtilityFocus {
|
||||
|
||||
public static void focusTextBox(Context context, EditText editTextToFocus) {
|
||||
editTextToFocus.requestFocus();
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(editTextToFocus, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class VersamentoMerceViewModel {
|
||||
private void updatePosizione(MtbDepoPosizione mtbDepoPosizione, boolean shouldAskLivello, ProgressDialog progressDialog) {
|
||||
|
||||
if(shouldAskLivello) {
|
||||
DialogAskLivelloPosizione.make(mContext, mtbDepoPosizione, newPosizione -> {
|
||||
DialogAskLivelloPosizione.make(mContext, mtbDepoPosizione, false, newPosizione -> {
|
||||
|
||||
if(newPosizione == null) {
|
||||
updatePosizione(mtbDepoPosizione, shouldAskLivello, progressDialog);
|
||||
|
||||
@@ -3,6 +3,7 @@ package it.integry.integrywmsnative.view.dialogs;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -14,6 +15,7 @@ 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.UtilityFocus;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityPosizione;
|
||||
|
||||
public class DialogAskLivelloPosizione {
|
||||
@@ -29,27 +31,36 @@ public class DialogAskLivelloPosizione {
|
||||
|
||||
private TextInputLayout livelloTextInputLayout;
|
||||
|
||||
public static void make(Context context, MtbDepoPosizione mtbDepoPosizione, RunnableArgs<MtbDepoPosizione> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
new DialogAskLivelloPosizione(context, mtbDepoPosizione, onComplete, onFailed).mAlert.show();
|
||||
private boolean completedFLow = false;
|
||||
|
||||
public static void make(Context context, MtbDepoPosizione mtbDepoPosizione, boolean canAbort, RunnableArgs<MtbDepoPosizione> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
new DialogAskLivelloPosizione(context, mtbDepoPosizione, canAbort, onComplete, onFailed).mAlert.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DialogAskLivelloPosizione(Context context, MtbDepoPosizione mtbDepoPosizione, RunnableArgs<MtbDepoPosizione> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
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_position_of_lu__page2, null, false);
|
||||
View currentView = inflater.inflate(R.layout.dialog_ask_livello_of_position, null, false);
|
||||
|
||||
mAlert = new Dialog(mContext);
|
||||
mAlert.setContentView(currentView);
|
||||
mAlert.setCanceledOnTouchOutside(false);
|
||||
|
||||
mAlert.setOnDismissListener(dialog -> {
|
||||
if(!completedFLow) onComplete.run(null);
|
||||
});
|
||||
|
||||
mAlert.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);
|
||||
@@ -61,6 +72,8 @@ public class DialogAskLivelloPosizione {
|
||||
|
||||
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) {
|
||||
@@ -96,6 +109,7 @@ public class DialogAskLivelloPosizione {
|
||||
if(foundPosizione != null) {
|
||||
resetLevelError();
|
||||
|
||||
completedFLow = true;
|
||||
onComplete.run(foundPosizione);
|
||||
mAlert.dismiss();
|
||||
|
||||
@@ -126,6 +140,7 @@ public class DialogAskLivelloPosizione {
|
||||
|
||||
|
||||
private void onLevelAbort() {
|
||||
completedFLow = true;
|
||||
onComplete.run(null);
|
||||
mAlert.dismiss();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user