Iniziata implementazione nuova distribuzione collo
This commit is contained in:
parent
487bcae59f
commit
f560fd7801
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -83,7 +83,7 @@ android {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
dynamicFeatures = [":dynamic__base"]
|
||||
dynamicFeatures = [":dynamic_vgalimenti"]
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import android.view.View;
|
||||
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import it.integry.integrywmsnative.core.REST.watcher.ServerStatusChecker;
|
||||
import it.integry.integrywmsnative.core.class_router.BaseRouter;
|
||||
import it.integry.integrywmsnative.core.interfaces.IFilterableFragment;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
|
||||
@ -75,6 +76,9 @@ public class MainActivity extends AppCompatActivity
|
||||
pop();
|
||||
|
||||
init();
|
||||
|
||||
|
||||
BaseRouter.invokePath(BaseRouter.PATH.DISTRIBUZIONE_COLLO_V, null, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package it.integry.integrywmsnative.core.class_router;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -10,31 +13,42 @@ import it.integry.integrywmsnative.core.class_router.exceptions.MethodParameterT
|
||||
import it.integry.integrywmsnative.core.class_router.exceptions.MethodParamsCountException;
|
||||
import it.integry.integrywmsnative.core.class_router.exceptions.MethodPathAlreadyDeclaredException;
|
||||
import it.integry.integrywmsnative.core.class_router.exceptions.MethodPathNotRegisteredException;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
|
||||
public class BaseRouter {
|
||||
|
||||
public enum PATH {
|
||||
DISTRIBUZIONE_COLLO_V
|
||||
}
|
||||
|
||||
private static List<Pair<String, MethodDTO>> mRoutePaths = new ArrayList<>();
|
||||
private static Context context;
|
||||
|
||||
private static boolean checkIfMethodExists(String path) {
|
||||
private static List<Pair<PATH, MethodDTO>> mRoutePaths = new ArrayList<>();
|
||||
|
||||
public static void init(Context context) {
|
||||
BaseRouter.context = context;
|
||||
}
|
||||
|
||||
private static boolean checkIfMethodExists(PATH path) {
|
||||
boolean methodAlreadyDeclared = false;
|
||||
|
||||
for(int i = 0; i < mRoutePaths.size() && !methodAlreadyDeclared; i++) {
|
||||
if(mRoutePaths.get(i).first.equalsIgnoreCase(path)) methodAlreadyDeclared = true;
|
||||
if(mRoutePaths.get(i).first == path) methodAlreadyDeclared = true;
|
||||
}
|
||||
|
||||
return methodAlreadyDeclared;
|
||||
}
|
||||
|
||||
private static int getMethodIndex(String path) {
|
||||
private static int getMethodIndex(PATH path) {
|
||||
for(int i = 0; i < mRoutePaths.size(); i++) {
|
||||
if(mRoutePaths.get(i).first.equalsIgnoreCase(path)) return i;
|
||||
if(mRoutePaths.get(i).first == path) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void registerPath(String path, MethodDTO method) throws MethodPathAlreadyDeclaredException {
|
||||
public static void registerPath(PATH path, MethodDTO method) throws MethodPathAlreadyDeclaredException {
|
||||
if(checkIfMethodExists(path)) {
|
||||
throw new MethodPathAlreadyDeclaredException(path);
|
||||
}
|
||||
@ -42,15 +56,17 @@ public class BaseRouter {
|
||||
mRoutePaths.add(new Pair<>(path, method));
|
||||
}
|
||||
|
||||
public static void deregisterPath(String path) {
|
||||
public static void deregisterPath(PATH path) {
|
||||
if(checkIfMethodExists(path)) {
|
||||
mRoutePaths.remove(getMethodIndex(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void invokePath(String path, Object... params) throws MethodPathNotRegisteredException, MethodParamsCountException, MethodParameterTypeNotMatchException, InvocationTargetException, IllegalAccessException {
|
||||
if(!checkIfMethodExists(path)) {
|
||||
public static void invokePath(PATH path, Object... params) {
|
||||
try {
|
||||
|
||||
if (!checkIfMethodExists(path)) {
|
||||
throw new MethodPathNotRegisteredException(path);
|
||||
}
|
||||
|
||||
@ -58,20 +74,24 @@ public class BaseRouter {
|
||||
|
||||
Class[] methodParameters = methodDTO.getMethod().getParameterTypes();
|
||||
|
||||
if(methodParameters.length != params.length) {
|
||||
if (methodParameters.length != params.length) {
|
||||
throw new MethodParamsCountException(path);
|
||||
}
|
||||
|
||||
for(int i = 0; i < params.length; i++) {
|
||||
if(params[i].getClass() != methodParameters[i] && methodParameters[i].cast(params[i]) == null) {
|
||||
throw new MethodParameterTypeNotMatchException(params[i].getClass().getCanonicalName(), path, methodParameters[i].getCanonicalName());
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (params[i] != null && params[i].getClass() != methodParameters[i] && methodParameters[i].cast(params[i]) == null) {
|
||||
throw new MethodParameterTypeNotMatchException(path, params[i].getClass().getCanonicalName(), methodParameters[i].getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
final Object newInstance = methodDTO.getMethod().getDeclaringClass().newInstance();
|
||||
|
||||
methodDTO.getMethod().invoke(null, params);
|
||||
|
||||
methodDTO.getMethod().invoke(newInstance, params);
|
||||
|
||||
} catch (Exception ex) {
|
||||
UtilityExceptions.defaultException(context, ex);
|
||||
Logger.e(ex, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package it.integry.integrywmsnative.core.class_router.exceptions;
|
||||
|
||||
import it.integry.integrywmsnative.core.class_router.BaseRouter;
|
||||
|
||||
public class MethodParameterTypeNotMatchException extends Exception{
|
||||
|
||||
public MethodParameterTypeNotMatchException(String path, String type1, String type2) {
|
||||
super(String.format("The given parameter (%s) to %s don't match the required type %s", type1, path, type2));
|
||||
public MethodParameterTypeNotMatchException(BaseRouter.PATH path, String type1, String type2) {
|
||||
super(String.format("The given parameter (%s) to %s don't match the required type %s", type1, path.toString(), type2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package it.integry.integrywmsnative.core.class_router.exceptions;
|
||||
|
||||
import it.integry.integrywmsnative.core.class_router.BaseRouter;
|
||||
|
||||
public class MethodParamsCountException extends Exception {
|
||||
|
||||
public MethodParamsCountException(String path) {
|
||||
super(String.format("Given parameters to path %s do not match the real method declaration", path));
|
||||
public MethodParamsCountException(BaseRouter.PATH path) {
|
||||
super(String.format("Given parameters to path %s do not match the real method declaration", path.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package it.integry.integrywmsnative.core.class_router.exceptions;
|
||||
|
||||
import it.integry.integrywmsnative.core.class_router.BaseRouter;
|
||||
|
||||
public class MethodPathAlreadyDeclaredException extends Exception {
|
||||
|
||||
public MethodPathAlreadyDeclaredException(String path) {
|
||||
public MethodPathAlreadyDeclaredException(BaseRouter.PATH path) {
|
||||
|
||||
super(String.format("Method %s is already declared in this scope", path));
|
||||
super(String.format("Method %s is already declared in this scope", path.toString()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package it.integry.integrywmsnative.core.class_router.exceptions;
|
||||
|
||||
import it.integry.integrywmsnative.core.class_router.BaseRouter;
|
||||
|
||||
public class MethodPathNotRegisteredException extends Exception{
|
||||
|
||||
public MethodPathNotRegisteredException(String path){
|
||||
super(String.format("Method path %s isn't registered at the moment. Please call BaseRouter.registerPath before call invoke.", path));
|
||||
public MethodPathNotRegisteredException(BaseRouter.PATH path){
|
||||
super(String.format("Method path %s isn't registered at the moment. Please call BaseRouter.registerPath before call invoke.", path.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import io.fabric.sdk.android.Fabric;
|
||||
import it.integry.integrywmsnative.BuildConfig;
|
||||
import it.integry.integrywmsnative.core.REST.watcher.ServerStatusChecker;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.class_router.BaseRouter;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecover;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.settings.Stash;
|
||||
@ -94,6 +95,7 @@ public class AppContext {
|
||||
GhostFish.create(mContext);
|
||||
|
||||
try {
|
||||
|
||||
String initMethod = "init";
|
||||
|
||||
Class dynamicContextClass = Class.forName("it.integry.wms.dynamic_customization.DynamicContext");
|
||||
|
||||
@ -23,13 +23,7 @@ public class MainContext {
|
||||
onContextInitialized.run();
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
BaseRouter.invokePath("testToast", mContext);
|
||||
} catch (Exception ex) {
|
||||
Log.e("PIF", ex.getMessage());
|
||||
}
|
||||
|
||||
BaseRouter.init(mContext);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1 +1,2 @@
|
||||
build_azienda.bat _base
|
||||
build_azienda.bat vgalimenti
|
||||
@ -11,12 +11,11 @@ public class DynamicContext {
|
||||
public static void init() {
|
||||
Log.d("DynamicContext", "Caricamento personalizzazioni per Azienda BASE");
|
||||
|
||||
// try {
|
||||
//BaseRouter.registerPath("testToast", MethodDTO.fromName(OrdineVendita.class, "testMe"));
|
||||
try {
|
||||
BaseRouter.registerPath(BaseRouter.PATH.DISTRIBUZIONE_COLLO_V, MethodDTO.fromName(OrdiniVendita.class, "distribuisciCollo"));
|
||||
} catch (MethodPathAlreadyDeclaredException ex) {
|
||||
|
||||
// } catch (MethodPathAlreadyDeclaredException ex) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
Log.d("DynamicContext", "Caricamento personalizzazioni per Azienda BASE COMPLETATO");
|
||||
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package it.integry.wms.dynamic_customization;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityToast;
|
||||
import it.integry.wms.dynamic_customization.interfaces.IOrdiniVendita;
|
||||
|
||||
public class OrdiniVendita implements IOrdiniVendita {
|
||||
|
||||
|
||||
@Override
|
||||
public void distribuisciCollo(ProgressDialog progress, RunnableArgs<List<MtbColt>> onComplete) {
|
||||
UtilityToast.showToast("Avviato metodo in BaseFeature");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.wms.dynamic_customization.interfaces;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
|
||||
public interface IOrdiniVendita {
|
||||
|
||||
void distribuisciCollo(ProgressDialog progress, RunnableArgs<List<MtbColt>> onComplete);
|
||||
|
||||
}
|
||||
@ -28,4 +28,5 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation project(':app')
|
||||
implementation project(':dynamic__base')
|
||||
}
|
||||
|
||||
@ -12,8 +12,7 @@ public class DynamicContext {
|
||||
Log.d("DynamicContext", "Caricamento personalizzazioni per VGAlimenti");
|
||||
|
||||
try {
|
||||
BaseRouter.registerPath("testToast", MethodDTO.fromName(OrdineVendita.class, "testMe"));
|
||||
BaseRouter.registerPath("distribuzioneColloV", MethodDTO.fromName(OrdineVendita.class, "distribuisciColloV"));
|
||||
BaseRouter.registerPath(BaseRouter.PATH.DISTRIBUZIONE_COLLO_V, MethodDTO.fromName(OrdineVendita.class, "distribuisciCollo"));
|
||||
|
||||
} catch (MethodPathAlreadyDeclaredException ex) {
|
||||
|
||||
|
||||
@ -1,18 +1,22 @@
|
||||
package it.integry.wms.dynamic_customization;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class OrdineVendita {
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityToast;
|
||||
import it.integry.wms.dynamic_customization.interfaces.IOrdiniVendita;
|
||||
|
||||
public class OrdineVendita implements IOrdiniVendita {
|
||||
|
||||
@Override
|
||||
public void distribuisciCollo(ProgressDialog progress, RunnableArgs<List<MtbColt>> onComplete) {
|
||||
UtilityToast.showToast("Avviato metodo in VGAlimentiFeature");
|
||||
|
||||
public static void testMe(Context context) {
|
||||
Toast.makeText(context, "Questo è un fottuto test di questo maledetto framework", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void distribuisciColloV() {
|
||||
Log.d("OrdineVendita", "Completata distribuzione collo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user