190 lines
5.7 KiB
Java
190 lines
5.7 KiB
Java
#set( $regex = "([a-z])([A-Z]+)")
|
|
#set( $replacement = "$1_$2")
|
|
#set( $dashName = $NAME.replaceAll($regex, $replacement).toLowerCase())
|
|
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.view.LayoutInflater;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import it.integry.integrywmsnative.MainApplication;
|
|
import it.integry.integrywmsnative.core.expansion.BaseMaterialAlertDialogBuilder;
|
|
|
|
public class Dialog${NAME}View extends BaseMaterialAlertDialogBuilder implements DialogInterface.OnShowListener, DialogInterface.OnDismissListener {
|
|
|
|
/*
|
|
Create the following layout resource file [dialog_${dashName}.xml]
|
|
|
|
<?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:orientation="vertical" android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_gravity="center_horizontal"
|
|
app:cardCornerRadius="16dp"
|
|
app:cardElevation="0dp">
|
|
|
|
|
|
<androidx.appcompat.widget.LinearLayoutCompat
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:orientation="vertical"
|
|
android:paddingHorizontal="16dp"
|
|
android:paddingVertical="16dp">
|
|
|
|
<androidx.appcompat.widget.AppCompatImageView
|
|
style="@style/MaterialAlertDialog.Material3.Title.Icon.CenterStacked"
|
|
android:layout_width="36dp"
|
|
android:layout_height="36dp"
|
|
android:src="@drawable/ic_error_white_24dp"
|
|
app:tint="?colorPrimary" />
|
|
|
|
|
|
<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:gravity="center_horizontal"
|
|
android:layout_marginBottom="16dp"
|
|
android:text="Title here" />
|
|
|
|
|
|
<androidx.appcompat.widget.AppCompatTextView
|
|
android:id="@+id/description_text"
|
|
style="@style/TextAppearance.Material3.BodyMedium"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:gravity="center_horizontal"
|
|
android:text="Description here" />
|
|
|
|
|
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
|
</androidx.cardview.widget.CardView>
|
|
</layout>
|
|
|
|
*/
|
|
|
|
|
|
@Inject
|
|
Dialog${NAME}ViewModel mViewModel;
|
|
|
|
//private Dialog${NAME}Binding mBindings;
|
|
private Context mContext;
|
|
|
|
//Pass here all external parameters
|
|
public static Dialog${NAME}View newInstance(@NonNull Context context) {
|
|
return new Dialog${NAME}View(context);
|
|
}
|
|
|
|
/*
|
|
- Add following lines into MainApplicationComponent
|
|
|
|
[a] into @Component
|
|
Dialog${NAME}Module.class
|
|
|
|
[b] into interface body
|
|
Dialog${NAME}Component.Factory dialog${NAME}Component();
|
|
*/
|
|
|
|
private Dialog${NAME}View(@NonNull Context context) {
|
|
super(context);
|
|
this.mContext = context;
|
|
|
|
MainApplication.appComponent
|
|
.dialog${NAME}Component()
|
|
.create()
|
|
.inject(this);
|
|
|
|
//mBindings = Dialog${NAME}Binding.inflate(LayoutInflater.from(this.mContext), null, false);
|
|
|
|
if (context instanceof LifecycleOwner) {
|
|
//mBindings.setLifecycleOwner((LifecycleOwner) context);
|
|
}
|
|
|
|
setCancelable(true);
|
|
|
|
setView(mBindings.getRoot());
|
|
|
|
/*
|
|
setPositiveButton(R.string.ok, (dialog, which) -> {
|
|
onOk();
|
|
});
|
|
|
|
setNegativeButton(R.string.abort, (dialog, which) -> {
|
|
onKo();
|
|
});
|
|
*/
|
|
|
|
//this.setupBarcode();
|
|
}
|
|
|
|
@NonNull
|
|
@Override
|
|
public AlertDialog create() {
|
|
AlertDialog alertDialog = super.create();
|
|
alertDialog.setCanceledOnTouchOutside(false);
|
|
alertDialog.setOnShowListener(this);
|
|
alertDialog.setOnDismissListener(this);
|
|
return alertDialog;
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
public void onShow(DialogInterface dialogInterface) {
|
|
//Init here all data or lists
|
|
//this.initList();
|
|
}
|
|
|
|
@Override
|
|
public void onDismiss(DialogInterface dialog) {
|
|
//BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
|
}
|
|
|
|
/*
|
|
private void setupBarcode() {
|
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
|
|
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
|
.setOnScanSuccessful(onScanSuccessfull)
|
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getContext(), ex, false)));
|
|
|
|
super.initBarcodeManager(mBarcodeScannerInstanceID);
|
|
}
|
|
*/
|
|
|
|
public static class Result {
|
|
private final Object returnData;
|
|
private final boolean isAborted;
|
|
|
|
private Result(Object returnData, boolean isAborted) {
|
|
this.returnData = returnData;
|
|
this.isAborted = isAborted;
|
|
}
|
|
|
|
public static Result completed(Object returnData) {
|
|
return new Result(returnData, false);
|
|
}
|
|
|
|
public static Result aborted() {
|
|
return new Result(null, true);
|
|
}
|
|
|
|
public boolean isAborted() {
|
|
return isAborted;
|
|
}
|
|
|
|
public Object getReturnData() {
|
|
return returnData;
|
|
}
|
|
}
|
|
|
|
} |