diff --git a/doric-android/doric/src/main/java/pub/doric/DoricActivity.java b/doric-android/doric/src/main/java/pub/doric/DoricActivity.java index 266d04e6..80d22371 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricActivity.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricActivity.java @@ -26,17 +26,38 @@ import androidx.appcompat.app.AppCompatActivity; * @CreateDate: 2019-11-19 */ public class DoricActivity extends AppCompatActivity { + protected DoricFragment mDoricFragment; + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.doric_activity); if (savedInstanceState == null) { - String scheme = getIntent().getStringExtra("scheme"); - String alias = getIntent().getStringExtra("alias"); - DoricFragment doricFragment = DoricFragment.newInstance(scheme, alias); + mDoricFragment = DoricFragment.newInstance(getScheme(), getAlias(), getExtra()); getSupportFragmentManager().beginTransaction() - .add(R.id.container, doricFragment) + .add(R.id.container, mDoricFragment) .commit(); } } + + /** + * @return Scheme for DoricFragment to load. + */ + protected String getScheme() { + return getIntent().getStringExtra("scheme"); + } + + /** + * @return Alias used for JS error message. + */ + protected String getAlias() { + return getIntent().getStringExtra("alias"); + } + + /** + * @return Extra data used for JS Panel in JSON format. + */ + protected String getExtra() { + return getIntent().getStringExtra("extra"); + } } diff --git a/doric-android/doric/src/main/java/pub/doric/DoricFragment.java b/doric-android/doric/src/main/java/pub/doric/DoricFragment.java index 0cc9a665..1c84c02e 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricFragment.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricFragment.java @@ -35,10 +35,11 @@ import androidx.navigation.Navigation; */ public class DoricFragment extends Fragment { - public static DoricFragment newInstance(String scheme, String alias) { + public static DoricFragment newInstance(String scheme, String alias, String extra) { Bundle args = new Bundle(); args.putString("scheme", scheme); args.putString("alias", alias); + args.putString("extra", extra); DoricFragment fragment = new DoricFragment(); fragment.setArguments(args); return fragment; @@ -73,6 +74,8 @@ public class DoricFragment extends Fragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host); + navController.setGraph(R.navigation.doric_navigation, getArguments()); FrameLayout maskView = view.findViewById(R.id.doric_mask); if (this.loadingView != null) { maskView.addView(this.loadingView);