Back to project page android-mvc-framework.
The source code is released under:
Apache License
If you think the Android project android-mvc-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android_mvc.framework.controller; /* w w w.j a v a 2s. c o m*/ import android.app.Activity; import com.android_mvc.framework.activities.IBaseActivity; import com.android_mvc.framework.common.FWUtil; import com.android_mvc.framework.controller.action.ActionResult; import com.android_mvc.framework.controller.action.BLExecutor; import com.android_mvc.framework.controller.routing.Router; import com.android_mvc.framework.controller.routing.RoutingTable; import com.android_mvc.framework.controller.validation.ValidationResult; import com.android_mvc.framework.controller.validation.ValidationExecutor; import com.android_mvc.framework.task.AsyncTasksRunner; import com.android_mvc.framework.task.RunnerFollower; import com.android_mvc.framework.task.SequentialAsyncTask; /** * ??????????????????????? */ public class ControlFlowDetail<T_ActivityClass> { // NOTE: T_ActivityClass -> Activity???????????????????? protected T_ActivityClass from_activity; private ValidationExecutor validation_executor; private BLExecutor bl_executor; private RoutingTable routingTable; protected ActionResult action_result; /** * ???? */ public ControlFlowDetail(T_ActivityClass fromActivity) { this.from_activity = fromActivity; } /** * ????????????????????? */ public ControlFlowDetail<T_ActivityClass> setValidation( ValidationExecutor validationExecutor ) { this.validation_executor = validationExecutor; return this; } /** * BL??????????? */ public ControlFlowDetail<T_ActivityClass> setBL( BLExecutor blExecutor ) { this.bl_executor = blExecutor; return this; } /** * BL??????????????????????? * ??????????????????????????????????????????? */ public ControlFlowDetail<T_ActivityClass> onBLExecuted( RoutingTable routingTable ) { this.routingTable = routingTable; return this; } /** * ????????? * ?????????????????????????????????????????????????????????????????????????????? */ public void startControl() { // ActionResult??????? final ControlFlowDetail<T_ActivityClass> parentFlow = this; // ????????????? new AsyncTasksRunner( new SequentialAsyncTask[]{ // ??????????????????????????? new SequentialAsyncTask(){ public boolean main(){ ValidationResult vres; // ?????????????????????????? if( validation_executor != null ) { // Activity???params??????? validation_executor.execAndStoreValidationResult(); vres = validation_executor.validation_result; } else { // ????????????????????????????????????? vres = new ValidationResult().setSuccess(); } storeData( "validation_result", vres ); // ??????????????????????????????? if( vres.isSuccess() ) { FWUtil.d("???????????????????????????BL????????????????????"); // BL??????????? return CONTINUE_TASKS; } else { FWUtil.d("??????????????????????????BL????????????????????????"); // ????????????????? validation_executor.from_activity = (Activity)from_activity; validation_executor.onValidationFailed(); // ?????????????????? return BREAK_TASKS; } } } , // ????????????BL??????????????????? // DB????NW???????????? new SequentialAsyncTask(){ public boolean main(){ // ?????????????????????????????????? ValidationResult vres = (ValidationResult)getDataFromRunner("validation_result"); // ?????????????????????BL?????????????????????????? if( vres.permitsExecitionOfBL() ) { FWUtil.d("BL??????????????????"); // BL??? bl_executor.execAndStoreActionResult(); // BL?????????? storeData( "action_result", bl_executor.action_result ); parentFlow.action_result = bl_executor.action_result; FWUtil.d("ActionResult????????????????????????"); } // BL??????????????????????????????????????????????true return CONTINUE_TASKS; } } , // ???????????????????????? new SequentialAsyncTask(){ public boolean main(){ // ???????????????????????? if( routingTable != null ) { // BL???????????????? ActionResult ares = (ActionResult)getDataFromRunner("action_result"); // BL???????????????????????? Router.switchByActionResult( (Activity)from_activity, ares, routingTable ); } else { // ???????????????????????????????????????????? } return CONTINUE_TASKS; } } }) .withSimpleDialog("????????", (Activity)from_activity) // ???????????????????????????????????? .whenAllTasksCompleted(new RunnerFollower(){ @Override protected void exec() { ActionResult ares = parentFlow.action_result; // BL???????????????? if( ares != null ) { // BL????????????????????UI??????????????????? ((IBaseActivity)from_activity).afterBLExecuted(ares); // NOTE: Intent???????????????????????Intent????ActionResult???????????????????????? // ???????????????UI?????????????????????? // ??????????BL??????????????????????????????????????????????????BL???????? // UI????????UI?????????????????????????????????????????? } } }) .begin(); // ??????????????????? // TODO: ?????????????????????????????? } }