android:add api for costomization of DoricActivity
This commit is contained in:
parent
93a207db9f
commit
7c2af8d1aa
@ -26,17 +26,38 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
* @CreateDate: 2019-11-19
|
* @CreateDate: 2019-11-19
|
||||||
*/
|
*/
|
||||||
public class DoricActivity extends AppCompatActivity {
|
public class DoricActivity extends AppCompatActivity {
|
||||||
|
protected DoricFragment mDoricFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.doric_activity);
|
setContentView(R.layout.doric_activity);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
String scheme = getIntent().getStringExtra("scheme");
|
mDoricFragment = DoricFragment.newInstance(getScheme(), getAlias(), getExtra());
|
||||||
String alias = getIntent().getStringExtra("alias");
|
|
||||||
DoricFragment doricFragment = DoricFragment.newInstance(scheme, alias);
|
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.container, doricFragment)
|
.add(R.id.container, mDoricFragment)
|
||||||
.commit();
|
.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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,11 @@ import androidx.navigation.Navigation;
|
|||||||
*/
|
*/
|
||||||
public class DoricFragment extends Fragment {
|
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();
|
Bundle args = new Bundle();
|
||||||
args.putString("scheme", scheme);
|
args.putString("scheme", scheme);
|
||||||
args.putString("alias", alias);
|
args.putString("alias", alias);
|
||||||
|
args.putString("extra", extra);
|
||||||
DoricFragment fragment = new DoricFragment();
|
DoricFragment fragment = new DoricFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
@ -73,6 +74,8 @@ public class DoricFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, 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);
|
FrameLayout maskView = view.findViewById(R.id.doric_mask);
|
||||||
if (this.loadingView != null) {
|
if (this.loadingView != null) {
|
||||||
maskView.addView(this.loadingView);
|
maskView.addView(this.loadingView);
|
||||||
|
Reference in New Issue
Block a user