skin.support.SkinCompatManager Java Examples
The following examples show how to use
skin.support.SkinCompatManager.
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: App.java From Android-skin-support with MIT License | 6 votes |
@Override public void onCreate() { super.onCreate(); // SkinCircleImageViewManager.init(this); // SkinMaterialManager.init(this); // SkinConstraintManager.init(this); // SkinCardViewManager.init(this); // SkinFlycoTabLayoutManager.init(this); // SkinCompatManager.init(this).loadSkin(); // SkinCompatManager.init(this) // 框架换肤日志打印 Slog.DEBUG = true; SkinCompatManager.withoutActivity(this) .addStrategy(new CustomSDCardLoader()) // 自定义加载策略,指定SDCard路径 .addStrategy(new ZipSDCardLoader()) // 自定义加载策略,获取zip包中的资源 .addInflater(new SkinMaterialViewInflater()) // material design .addInflater(new SkinConstraintViewInflater()) // ConstraintLayout .addInflater(new SkinCardViewInflater()) // CardView v7 .addInflater(new SkinCircleImageViewInflater()) // hdodenhof/CircleImageView .addInflater(new SkinFlycoTabLayoutInflater()) // H07000223/FlycoTabLayout .setSkinStatusBarColorEnable(true) // 关闭状态栏换肤 // .setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤 // .setSkinAllActivityEnable(false) // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤 .loadSkin(); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); }
Example #2
Source File: SkinApp.java From Android-skin-support with MIT License | 6 votes |
@Override public void onCreate() { super.onCreate(); Slog.DEBUG = BuildConfig.DEBUG; AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); SkinCompatManager.withoutActivity(this) // .addStrategy(new CustomSDCardLoader()) // 自定义加载策略,指定SDCard路径 // .addStrategy(new ZipSDCardLoader()) // 自定义加载策略,获取zip包中的资源 .addInflater(new SkinAppCompatViewInflater()) // 基础控件换肤 .addInflater(new SkinMaterialViewInflater()) // material design .addInflater(new SkinConstraintViewInflater()) // ConstraintLayout .addInflater(new SkinCardViewInflater()) // CardView v7 // .setSkinStatusBarColorEnable(true) // 关闭状态栏换肤 // .setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤 // .setSkinAllActivityEnable(false) // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤 .loadSkin(); }
Example #3
Source File: PersonalFragment.java From DanDanPlayForAndroid with MIT License | 6 votes |
/** * 切换皮肤 */ private void switchSkin() { EventBus.getDefault().post(UpdateFragmentEvent.updatePlay(PlayFragment.UPDATE_DATABASE_DATA)); SwitchThemeAnimView.create(skinIv).setDuration(800).start(); if (isLoadedSkin()) { SkinCompatManager.getInstance() .restoreDefaultTheme(); skinIv.setImageResource(R.mipmap.ic_skin_dark); skinTv.setTextColor(CommonUtils.getResColor(R.color.immutable_text_black)); skinTv.setText("夜间模式"); } else { SkinCompatManager.getInstance() .loadSkin("night", SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN); skinIv.setImageResource(R.mipmap.ic_skin_light); skinTv.setTextColor(CommonUtils.getResColor(R.color.immutable_text_orange)); skinTv.setText("日间模式"); } }
Example #4
Source File: ZipActivity.java From Android-skin-support with MIT License | 6 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.default_theme: SkinCompatManager.getInstance().restoreDefaultTheme(); mToolbar.setTitle("图片来自应用本身"); break; case R.id.default_zip_theme: SkinCompatManager.getInstance().loadSkin("", ZipSDCardLoader.SKIN_LOADER_STRATEGY_ZIP); mToolbar.setTitle("图片来自Zip包"); break; case R.id.zip_theme: SkinCompatManager.getInstance().loadSkin("night.skin", ZipSDCardLoader.SKIN_LOADER_STRATEGY_ZIP); mToolbar.setTitle("图片来自Zip包"); break; } }
Example #5
Source File: MainActivity.java From AndroidSkinAnimator with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initToolbar(); initConfigAnimatorDialog(); configFragments(); findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (TextUtils.isEmpty(SkinPreference.getInstance().getSkinName())) { SkinCompatManager.getInstance().loadSkin("red.skin", null); } else { SkinCompatManager.getInstance().restoreDefaultTheme(); } } }); }
Example #6
Source File: MyApplication.java From Mp3Cutter with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); instances = this; mAppComponent = DaggerAppComponent .builder() .appModule(new AppModule(this)) .build(); initDatabase(); // CoverLoader.getInstance().init(instances); //logger if(LogUtils.isApkDebugable(this)) { Logger.addLogAdapter(new AndroidLogAdapter()); } //umeng analytics MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL); SkinCompatManager.withoutActivity(this) // 基础控件换肤初始化 .addInflater(new SkinMaterialViewInflater()) // material design 控件换肤初始化[可选] .setSkinStatusBarColorEnable(false) // 关闭状态栏换肤,默认打开[可选] .setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤,默认打开[可选] .loadSkin(); }
Example #7
Source File: ZipActivity.java From Android-skin-support with MIT License | 6 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.default_theme: SkinCompatManager.getInstance().restoreDefaultTheme(); mToolbar.setTitle("图片来自应用本身"); break; case R.id.default_zip_theme: SkinCompatManager.getInstance().loadSkin("", ZipSDCardLoader.SKIN_LOADER_STRATEGY_ZIP); mToolbar.setTitle("图片来自Zip包"); break; case R.id.zip_theme: SkinCompatManager.getInstance().loadSkin("night.skin", ZipSDCardLoader.SKIN_LOADER_STRATEGY_ZIP); mToolbar.setTitle("图片来自Zip包"); break; } }
Example #8
Source File: ThemeColorSelectDialog.java From Mp3Cutter with GNU General Public License v3.0 | 6 votes |
private void initListener(DialogThemeColorBinding binding){ mThemeColorAdapter.setOnItemClickListener(new EasyRecyclerViewAdapter.OnItemClickListener() { @Override public void OnItemClick(View view, int position, Object data) { for (ThemeColor themeColor : mThemeColorList) { themeColor.setChosen(false); } mThemeColorList.get(position).setChosen(true); mThemeColorAdapter.notifyDataSetChanged(); } }); binding.tvSure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SkinCompatManager.getInstance().loadSkin( mThemeColorList.get(mThemeColorAdapter.getPosition()).getName(), null, SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN); dismiss(); } }); }
Example #9
Source File: SkinSDCardLoader.java From Android-skin-support with MIT License | 6 votes |
@Override public String loadSkinInBackground(Context context, String skinName) { if (TextUtils.isEmpty(skinName)) { return skinName; } String skinPkgPath = getSkinPath(context, skinName); if (SkinFileUtils.isFileExists(skinPkgPath)) { String pkgName = SkinCompatManager.getInstance().getSkinPackageName(skinPkgPath); Resources resources = SkinCompatManager.getInstance().getSkinResources(skinPkgPath); if (resources != null && !TextUtils.isEmpty(pkgName)) { SkinCompatResources.getInstance().setupSkin( resources, pkgName, skinName, this); return skinName; } } return null; }
Example #10
Source File: SkinCompatResources.java From Android-skin-support with MIT License | 5 votes |
public void reset(SkinCompatManager.SkinLoaderStrategy strategy) { mResources = SkinCompatManager.getInstance().getContext().getResources(); mSkinPkgName = ""; mSkinName = ""; mStrategy = strategy; isDefaultSkin = true; SkinCompatUserThemeManager.get().clearCaches(); for (SkinResources skinResources : mSkinResources) { skinResources.clear(); } }
Example #11
Source File: App.java From Android-skin-support with MIT License | 5 votes |
@Override public void onCreate() { super.onCreate(); // SkinCircleImageViewManager.init(this); // SkinMaterialManager.init(this); // SkinConstraintManager.init(this); // SkinCardViewManager.init(this); // SkinFlycoTabLayoutManager.init(this); // SkinCompatManager.init(this).loadSkin(); // SkinCompatManager.init(this) // 框架换肤日志打印 Slog.DEBUG = BuildConfig.DEBUG; SkinCompatManager.withoutActivity(this) .addStrategy(new CustomSDCardLoader()) // 自定义加载策略,指定SDCard路径 .addStrategy(new ZipSDCardLoader()) // 自定义加载策略,获取zip包中的资源 .addInflater(new SkinAppCompatViewInflater()) // 基础控件换肤 .addInflater(new SkinMaterialViewInflater()) // material design .addInflater(new SkinConstraintViewInflater()) // ConstraintLayout .addInflater(new SkinCardViewInflater()) // CardView v7 .addInflater(new SkinCircleImageViewInflater()) // hdodenhof/CircleImageView .addInflater(new SkinFlycoTabLayoutInflater()) // H07000223/FlycoTabLayout .setSkinStatusBarColorEnable(true) // 关闭状态栏换肤 // .setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤 // .setSkinAllActivityEnable(false) // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤 .loadSkin(); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); }
Example #12
Source File: SkinCompatResources.java From Android-skin-support with MIT License | 5 votes |
public void setupSkin(Resources resources, String pkgName, String skinName, SkinCompatManager.SkinLoaderStrategy strategy) { if (resources == null || TextUtils.isEmpty(pkgName) || TextUtils.isEmpty(skinName)) { reset(strategy); return; } mResources = resources; mSkinPkgName = pkgName; mSkinName = skinName; mStrategy = strategy; isDefaultSkin = false; SkinCompatUserThemeManager.get().clearCaches(); for (SkinResources skinResources : mSkinResources) { skinResources.clear(); } }
Example #13
Source File: SkinCompatViewInflater.java From Android-skin-support with MIT License | 5 votes |
private View createViewFromHackInflater(Context context, String name, AttributeSet attrs) { View view = null; for (SkinLayoutInflater inflater : SkinCompatManager.getInstance().getHookInflaters()) { view = inflater.createView(context, name, attrs); if (view == null) { continue; } else { break; } } return view; }
Example #14
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
private void updateWindowBackground(Activity activity) { if (SkinCompatManager.getInstance().isSkinWindowBackgroundEnable()) { int windowBackgroundResId = SkinCompatThemeUtils.getWindowBackgroundResId(activity); if (checkResourceId(windowBackgroundResId) != INVALID_ID) { Drawable drawable = SkinCompatResources.getInstance().getDrawable(windowBackgroundResId); if (drawable != null) { activity.getWindow().setBackgroundDrawable(drawable); } } } }
Example #15
Source File: SkinCompatViewInflater.java From Android-skin-support with MIT License | 5 votes |
private View createViewFromInflater(Context context, String name, AttributeSet attrs) { View view = null; for (SkinLayoutInflater inflater : SkinCompatManager.getInstance().getInflaters()) { view = inflater.createView(context, name, attrs); if (view == null) { continue; } else { break; } } return view; }
Example #16
Source File: SkinCompatDelegate.java From Android-skin-support with MIT License | 5 votes |
public View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs) { if (mSkinCompatViewInflater == null) { mSkinCompatViewInflater = new SkinCompatViewInflater(); } List<SkinWrapper> wrapperList = SkinCompatManager.getInstance().getWrappers(); for (SkinWrapper wrapper : wrapperList) { Context wrappedContext = wrapper.wrapContext(mContext, parent, attrs); if (wrappedContext != null) { context = wrappedContext; } } return mSkinCompatViewInflater.createView(parent, name, context, attrs); }
Example #17
Source File: SkinCompatViewInflater.java From Android-skin-support with MIT License | 5 votes |
private View createViewFromHackInflater(Context context, String name, AttributeSet attrs) { View view = null; for (SkinLayoutInflater inflater : SkinCompatManager.getInstance().getHookInflaters()) { view = inflater.createView(context, name, attrs); if (view == null) { continue; } else { break; } } return view; }
Example #18
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
@Override public void onActivityDestroyed(Activity activity) { if (isContextSkinEnable(activity)) { SkinCompatManager.getInstance().deleteObserver(getObserver(activity)); mSkinObserverMap.remove(activity); mSkinDelegateMap.remove(activity); } }
Example #19
Source File: MyApplication.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); LitePal.initialize(this); LitePal.getDatabase().disableWriteAheadLogging(); mContext = this; initALog(); initErrorHandle(); BlockDetectByPrinter.start(); ImageLoaderManager.init(this); Toasty.Config.getInstance() .allowQueue(true) // optional (prevents several Toastys from queuing) .apply(); // required SkinCompatManager.withoutActivity(this) // 基础控件换肤初始化 .addInflater(new SkinMaterialViewInflater()) // material design 控件换肤初始化[可选] // .addInflater(new SkinConstraintViewInflater()) // ConstraintLayout 控件换肤初始化[可选] .addInflater(new SkinCardViewInflater()) // CardView v7 控件换肤初始化[可选] .setSkinStatusBarColorEnable(true) // 关闭状态栏换肤,默认打开[可选] .setSkinWindowBackgroundEnable(true) // 关闭windowBackground换肤,默认打开[可选] .loadSkin(); UserPreference.initCacheMap(); }
Example #20
Source File: SkinCompatViewInflater.java From Android-skin-support with MIT License | 5 votes |
private View createViewFromInflater(Context context, String name, AttributeSet attrs) { View view = null; for (SkinLayoutInflater inflater : SkinCompatManager.getInstance().getInflaters()) { view = inflater.createView(context, name, attrs); if (view == null) { continue; } else { break; } } return view; }
Example #21
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
@Override public void onActivityResumed(Activity activity) { mCurActivityRef = new WeakReference<>(activity); if (isContextSkinEnable(activity)) { LazySkinObserver observer = getObserver(activity); SkinCompatManager.getInstance().addObserver(observer); observer.updateSkinIfNeeded(); } }
Example #22
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
@Override public void onActivityDestroyed(Activity activity) { if (isContextSkinEnable(activity)) { SkinCompatManager.getInstance().deleteObserver(getObserver(activity)); mSkinObserverMap.remove(activity); mSkinDelegateMap.remove(activity); } }
Example #23
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
private void updateStatusBarColor(Activity activity) { if (SkinCompatManager.getInstance().isSkinStatusBarColorEnable() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int statusBarColorResId = SkinCompatThemeUtils.getStatusBarColorResId(activity); int colorPrimaryDarkResId = SkinCompatThemeUtils.getColorPrimaryDarkResId(activity); if (checkResourceId(statusBarColorResId) != INVALID_ID) { activity.getWindow().setStatusBarColor(SkinCompatResources.getColor(activity, statusBarColorResId)); } else if (checkResourceId(colorPrimaryDarkResId) != INVALID_ID) { activity.getWindow().setStatusBarColor(SkinCompatResources.getColor(activity, colorPrimaryDarkResId)); } } }
Example #24
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
private void updateWindowBackground(Activity activity) { if (SkinCompatManager.getInstance().isSkinWindowBackgroundEnable()) { int windowBackgroundResId = SkinCompatThemeUtils.getWindowBackgroundResId(activity); if (checkResourceId(windowBackgroundResId) != INVALID_ID) { Drawable drawable = SkinCompatResources.getDrawableCompat(activity, windowBackgroundResId); if (drawable != null) { activity.getWindow().setBackgroundDrawable(drawable); } } } }
Example #25
Source File: SkinCompatUserThemeManager.java From Android-skin-support with MIT License | 5 votes |
private String getEntryName(int resId, String entryType) { Context context = SkinCompatManager.getInstance().getContext(); String type = context.getResources().getResourceTypeName(resId); if (entryType.equalsIgnoreCase(type)) { return context.getResources().getResourceEntryName(resId); } return null; }
Example #26
Source File: SkinCompatResources.java From Android-skin-support with MIT License | 5 votes |
public void reset(SkinCompatManager.SkinLoaderStrategy strategy) { mResources = SkinCompatManager.getInstance().getContext().getResources(); mSkinPkgName = ""; mSkinName = ""; mStrategy = strategy; isDefaultSkin = true; SkinCompatUserThemeManager.get().clearCaches(); SkinCompatDrawableManager.get().clearCaches(); }
Example #27
Source File: SkinCompatResources.java From Android-skin-support with MIT License | 5 votes |
public void setupSkin(Resources resources, String pkgName, String skinName, SkinCompatManager.SkinLoaderStrategy strategy) { if (resources == null || TextUtils.isEmpty(pkgName) || TextUtils.isEmpty(skinName)) { reset(strategy); return; } mResources = resources; mSkinPkgName = pkgName; mSkinName = skinName; mStrategy = strategy; isDefaultSkin = false; SkinCompatUserThemeManager.get().clearCaches(); SkinCompatDrawableManager.get().clearCaches(); }
Example #28
Source File: SkinCompatViewInflater.java From Android-skin-support with MIT License | 5 votes |
private View createViewFromHackInflater(Context context, String name, AttributeSet attrs) { View view = null; for (SkinLayoutInflater inflater : SkinCompatManager.getInstance().getHookInflaters()) { view = inflater.createView(context, name, attrs); if (view != null) break; } return view; }
Example #29
Source File: SkinCompatViewInflater.java From Android-skin-support with MIT License | 5 votes |
private View createViewFromInflater(Context context, String name, AttributeSet attrs) { View view = null; for (SkinLayoutInflater inflater : SkinCompatManager.getInstance().getInflaters()) { view = inflater.createView(context, name, attrs); if (view != null) break; } return view; }
Example #30
Source File: SkinActivityLifecycle.java From Android-skin-support with MIT License | 5 votes |
@Override public void onActivityDestroyed(Activity activity) { if (isContextSkinEnable(activity)) { SkinCompatManager.getInstance().deleteObserver(getObserver(activity)); mSkinObserverMap.remove(activity); mSkinDelegateMap.remove(activity); } }