Java Code Examples for com.jess.arms.utils.ArmsUtils#findViewByName()
The following examples show how to use
com.jess.arms.utils.ArmsUtils#findViewByName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityLifecycleCallbacksImpl.java From lifecycle-component with Apache License 2.0 | 5 votes |
@Override public void onActivityStarted(Activity activity) { Timber.i(activity + " - onActivityStarted"); if (!activity.getIntent().getBooleanExtra("isInitToolbar", false)) { //由于加强框架的兼容性,故将 setContentView 放到 onActivityCreated 之后,onActivityStarted 之前执行 //而 findViewById 必须在 Activity setContentView() 后才有效,所以将以下代码从之前的 onActivityCreated 中移动到 onActivityStarted 中执行 activity.getIntent().putExtra("isInitToolbar", true); //这里全局给Activity设置toolbar和title,你想象力有多丰富,这里就有多强大,以前放到BaseActivity的操作都可以放到这里 if (ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar") != null) { if (activity instanceof AppCompatActivity) { ((AppCompatActivity) activity).setSupportActionBar(ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar")); ((AppCompatActivity) activity).getSupportActionBar().setDisplayShowTitleEnabled(false); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.setActionBar(ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar")); activity.getActionBar().setDisplayShowTitleEnabled(false); } } } if (ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_title") != null) { ((TextView) ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_title")).setText(activity.getTitle()); } if (ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_back") != null) { ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_back").setOnClickListener(v -> { activity.onBackPressed(); }); } } }
Example 2
Source File: ActivityLifecycleCallbacksImpl.java From Hands-Chopping with Apache License 2.0 | 5 votes |
@Override public void onActivityStarted(Activity activity) { Timber.w(activity + " - onActivityStarted"); if (!activity.getIntent().getBooleanExtra("isInitToolbar", false)) { //由于加强框架的兼容性,故将 setContentView 放到 onActivityCreated 之后,onActivityStarted 之前执行 //而 findViewById 必须在 Activity setContentView() 后才有效,所以将以下代码从之前的 onActivityCreated 中移动到 onActivityStarted 中执行 activity.getIntent().putExtra("isInitToolbar", true); //这里全局给Activity设置toolbar和title,你想象力有多丰富,这里就有多强大,以前放到BaseActivity的操作都可以放到这里 if (ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar") != null) { if (activity instanceof AppCompatActivity) { ((AppCompatActivity) activity).setSupportActionBar(ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar")); ((AppCompatActivity) activity).getSupportActionBar().setDisplayShowTitleEnabled(false); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.setActionBar(ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar")); activity.getActionBar().setDisplayShowTitleEnabled(false); } } } if (ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_title") != null) { ((TextView) ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_title")).setText(activity.getTitle()); } if (ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_back") != null) { ArmsUtils.findViewByName(activity.getApplicationContext(), activity, "public_toolbar_back").setOnClickListener(v -> { activity.onBackPressed(); }); } } }