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.routing; /* www . ja v a 2s. c o m*/ import com.android_mvc.framework.controller.action.ActionResult; import com.android_mvc.framework.controller.validation.ValidationResult; import android.app.Activity; import android.content.Intent; /** * ??????????????????????????????????????????? * @author id:language_and_engineering * */ public class Router { // Intent??????????????????????????????? public static final String EXTRA_KEY_VALIDATION_RESULT = "_ValidationResult"; public static final String EXTRA_KEY_ACTION_RESULT = "_ActionResult"; // TODO: ?????????????????Intent???????????????????????? /** * ???????????????????????????? * Intent??????????????????? */ public static void go(Activity fromActivity, Class<? extends Activity> toActivity) { Intent intent = new Intent( fromActivity.getApplicationContext(), toActivity ); fromActivity.startActivity(intent); } /** * Intent???????????????????????????????????? */ public static void goWithData(Activity fromActivity, Class<? extends Activity> toActivity, Intent src) { Intent intent = new Intent( fromActivity.getApplicationContext(), toActivity ); // Extra????? intent.putExtras(src); fromActivity.startActivity(intent); } // ?????FW?????? /** * ?????????????????? */ public static void goWhenValidationFailed( Activity from_activity, Class<? extends Activity> to_activity, ValidationResult vres ) { Intent intent = new Intent( from_activity.getApplicationContext(), to_activity ); // ??????????????? intent.putExtra(EXTRA_KEY_VALIDATION_RESULT, vres); from_activity.startActivity(intent); } /** * BL??????????????? * ??????????????????????????????????????????? */ public static void switchByActionResult( Activity from_activity, ActionResult ares, RoutingTable routingTable ) { // ??????????????? String route_id = ares.getRouteId(); // ????????Activity??????????? Class<? extends Activity> to_activity = routingTable.getActivityByRouteId(route_id); if( to_activity != null ) { // ??????? Intent intent = new Intent( from_activity.getApplicationContext(), to_activity ); // ?????????????? intent.putExtra(EXTRA_KEY_ACTION_RESULT, ares); from_activity.startActivity(intent); // BL???????????????? ares.onNextActivityStarted(from_activity); } else { // ????????null?????????????????????????????????????? } } }