Java 类android.support.v7.app.WindowDecorActionBar 实例源码
项目:app-theme-engine-master
文件:Util.java
@Nullable
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
if (ab == null || !(ab instanceof WindowDecorActionBar)) return null;
try {
WindowDecorActionBar decorAb = (WindowDecorActionBar) ab;
Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar");
field.setAccessible(true);
ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb);
field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar");
field.setAccessible(true);
return (Toolbar) field.get(wrapper);
} catch (Throwable t) {
throw new RuntimeException("Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t);
}
}
项目:Superuser-UI
文件:ToolbarContentTintHelper.java
@Nullable
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
if (ab == null || !(ab instanceof WindowDecorActionBar)) return null;
try {
WindowDecorActionBar decorAb = (WindowDecorActionBar) ab;
Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar");
field.setAccessible(true);
ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb);
field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar");
field.setAccessible(true);
return (Toolbar) field.get(wrapper);
} catch (Throwable t) {
throw new RuntimeException("Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t);
}
}