skin.support.utils.SkinPreference Java Examples
The following examples show how to use
skin.support.utils.SkinPreference.
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: SkinCompatManager.java From Android-skin-support with MIT License | 6 votes |
@Override protected void onPostExecute(String skinName) { synchronized (mLock) { // skinName 为""时,恢复默认皮肤 if (skinName != null) { SkinPreference.getInstance().setSkinName(skinName).setSkinStrategy(mStrategy.getType()).commitEditor(); notifyUpdateSkin(); if (mListener != null) { mListener.onSuccess(); } } else { SkinPreference.getInstance().setSkinName("").setSkinStrategy(SKIN_LOADER_STRATEGY_NONE).commitEditor(); if (mListener != null) { mListener.onFailed("皮肤资源获取失败"); } } mLoading = false; mLock.notifyAll(); } }
Example #2
Source File: PostDetailListAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, final FeedItem item) { //根据偏好设置的背景颜色,设置标题栏位置的背景颜色 if (!SkinPreference.getInstance().getSkinName().equals("night")){ // helper.setBackgroundColor(R.id.container, PostSetting.getBackgroundInt(context)); helper.setBackgroundColor(R.id.post_title, PostSetting.getBackgroundInt(context)); helper.setBackgroundColor(R.id.post_turn, PostSetting.getBackgroundInt(context)); } scrollView = helper.getView(R.id.post_turn); //设置文章内容 PostUtil.setContent(context, item, ((WebView) helper.getView(R.id.post_content)), (ViewGroup) helper.getView(R.id.container)); helper.setText(R.id.post_title, item.getTitle()); helper.setText(R.id.post_time, DateUtil.getTimeStringByInt(item.getDate())); helper.setText(R.id.feed_name, item.getFeedName()); if (!item.isRead()) { //如果这个文章没有阅读过则滚动到顶部 scrollView.fullScroll(ScrollView.FOCUS_UP); } refreshLayout = helper.getView(R.id.refreshLayout); initListener(item); }
Example #3
Source File: FeedCategoryLeftAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, WebsiteCategory item) { if (currentPosition == helper.getAdapterPosition()){ helper.getView(R.id.iv_select).setVisibility(View.VISIBLE); if (SkinPreference.getInstance().getSkinName().equals("night")) { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.white_night)); }else { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.white)); } }else { if (SkinPreference.getInstance().getSkinName().equals("night")) { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.colorPrimary_night)); }else { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.colorPrimary)); } helper.getView(R.id.iv_select).setVisibility(View.GONE); } helper.setText(R.id.tv_item,item.getName()); }
Example #4
Source File: SuspensionDecoration.java From Focus with GNU General Public License v3.0 | 6 votes |
public SuspensionDecoration(Context context, List<? extends ISuspensionInterface> datas) { super(); if(SkinPreference.getInstance().getSkinName().equals("night")){ COLOR_TITLE_BG = Color.parseColor("#212121"); COLOR_TITLE_FONT = Color.parseColor("#eeeeee"); }else { COLOR_TITLE_BG = Color.parseColor("#eeeeee"); COLOR_TITLE_FONT = Color.parseColor("#FF999999"); } mDatas = datas; mPaint = new Paint(); mBounds = new Rect(); mTitleHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, context.getResources().getDisplayMetrics()); mTitleFontSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, context.getResources().getDisplayMetrics()); mPaint.setTextSize(mTitleFontSize); mPaint.setAntiAlias(true); mInflater = LayoutInflater.from(context); }
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: PostDetailActivity.java From Focus with GNU General Public License v3.0 | 6 votes |
private void setLikeButton() { //设置收藏状态 if (currentItemReady && starItemReady && !starIconReady && starItem!=null && currentFeedItem!=null){ ALog.d("设置收藏状态"); if (currentFeedItem.isFavorite()) { starItem.setIcon(R.drawable.star_on); } else { if (SkinPreference.getInstance().getSkinName().equals("night")) { starItem.setIcon(R.drawable.star_off_night); } else { starItem.setIcon(R.drawable.star_off); } } starIconReady = true; } }
Example #7
Source File: PostDetailActivity.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { toolbar.setTitle(""); if (SkinPreference.getInstance().getSkinName().equals("night")) { getMenuInflater().inflate(R.menu.post_night, menu); } else { getMenuInflater().inflate(R.menu.post, menu); } starItem = menu.findItem(R.id.action_star); this. starItemReady = true; setLikeButton(); initToolbarColor(); return true; }
Example #8
Source File: PostDetailActivity.java From Focus with GNU General Public License v3.0 | 6 votes |
private void setLikeButton() { //设置收藏状态 if (currentItemReady && starItemReady && !starIconReady && starItem!=null && currentFeedItem!=null){ ALog.d("设置收藏状态"); if (currentFeedItem.isFavorite()) { starItem.setIcon(R.drawable.star_on); } else { if (SkinPreference.getInstance().getSkinName().equals("night")) { starItem.setIcon(R.drawable.star_off_night); } else { starItem.setIcon(R.drawable.star_off); } } starIconReady = true; } }
Example #9
Source File: PostDetailActivity.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { toolbar.setTitle(""); if (SkinPreference.getInstance().getSkinName().equals("night")) { getMenuInflater().inflate(R.menu.post_night, menu); } else { getMenuInflater().inflate(R.menu.post, menu); } starItem = menu.findItem(R.id.action_star); this. starItemReady = true; setLikeButton(); initToolbarColor(); return true; }
Example #10
Source File: PostDetailListAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, final FeedItem item) { //根据偏好设置的背景颜色,设置标题栏位置的背景颜色 if (!SkinPreference.getInstance().getSkinName().equals("night")){ // helper.setBackgroundColor(R.id.container, PostSetting.getBackgroundInt(context)); helper.setBackgroundColor(R.id.post_title, PostSetting.getBackgroundInt(context)); helper.setBackgroundColor(R.id.post_turn, PostSetting.getBackgroundInt(context)); } scrollView = helper.getView(R.id.post_turn); //设置文章内容 PostUtil.setContent(context, item, ((WebView) helper.getView(R.id.post_content)), (ViewGroup) helper.getView(R.id.container)); helper.setText(R.id.post_title, item.getTitle()); helper.setText(R.id.post_time, DateUtil.getTimeStringByInt(item.getDate())); helper.setText(R.id.feed_name, item.getFeedName()); if (!item.isRead()) { //如果这个文章没有阅读过则滚动到顶部 scrollView.fullScroll(ScrollView.FOCUS_UP); } refreshLayout = helper.getView(R.id.refreshLayout); initListener(item); }
Example #11
Source File: FeedCategoryLeftAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, WebsiteCategory item) { if (currentPosition == helper.getAdapterPosition()){ helper.getView(R.id.iv_select).setVisibility(View.VISIBLE); if (SkinPreference.getInstance().getSkinName().equals("night")) { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.white_night)); }else { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.white)); } }else { if (SkinPreference.getInstance().getSkinName().equals("night")) { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.colorPrimary_night)); }else { helper.setBackgroundColor(R.id.tv_item, UIUtil.getColor(R.color.colorPrimary)); } helper.getView(R.id.iv_select).setVisibility(View.GONE); } helper.setText(R.id.tv_item,item.getName()); }
Example #12
Source File: SuspensionDecoration.java From Focus with GNU General Public License v3.0 | 6 votes |
public SuspensionDecoration(Context context, List<? extends ISuspensionInterface> datas) { super(); if(SkinPreference.getInstance().getSkinName().equals("night")){ COLOR_TITLE_BG = Color.parseColor("#212121"); COLOR_TITLE_FONT = Color.parseColor("#eeeeee"); }else { COLOR_TITLE_BG = Color.parseColor("#eeeeee"); COLOR_TITLE_FONT = Color.parseColor("#FF999999"); } mDatas = datas; mPaint = new Paint(); mBounds = new Rect(); mTitleHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, context.getResources().getDisplayMetrics()); mTitleFontSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, context.getResources().getDisplayMetrics()); mPaint.setTextSize(mTitleFontSize); mPaint.setAntiAlias(true); mInflater = LayoutInflater.from(context); }
Example #13
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
/** * 加载记录的皮肤包,一般在Application中初始化换肤框架后调用. * * @param listener 皮肤包加载监听. * @return */ public AsyncTask loadSkin(SkinLoaderListener listener) { String skin = SkinPreference.getInstance().getSkinName(); int strategy = SkinPreference.getInstance().getSkinStrategy(); if (TextUtils.isEmpty(skin) || strategy == SKIN_LOADER_STRATEGY_NONE) { return null; } return loadSkin(skin, listener, strategy); }
Example #14
Source File: MineFragment.java From Android-skin-support with MIT License | 5 votes |
private void initRg() { String skinName = SkinPreference.getInstance().getSkinName(); int checkedId = R.id.rb_skin_default; if (!TextUtils.isEmpty(skinName)) { switch (skinName) { case Constants.SKIN_NAME.BLACK: checkedId = R.id.rb_skin_black; break; case Constants.SKIN_NAME.BLUE: checkedId = R.id.rb_skin_blue; break; case Constants.SKIN_NAME.GREEN: checkedId = R.id.rb_skin_green; break; case Constants.SKIN_NAME.ORANGE: checkedId = R.id.rb_skin_orange; break; case Constants.SKIN_NAME.PINK: checkedId = R.id.rb_skin_pink; break; case Constants.SKIN_NAME.RED: checkedId = R.id.rb_skin_red; break; case Constants.SKIN_NAME.WHITE: checkedId = R.id.rb_skin_white; break; case Constants.SKIN_NAME.YELLOW: checkedId = R.id.rb_skin_yellow; break; } } mSkinRg.check(checkedId); }
Example #15
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
/** * 加载记录的皮肤包,一般在Application中初始化换肤框架后调用. * * @return */ public AsyncTask loadSkin() { String skin = SkinPreference.getInstance().getSkinName(); int strategy = SkinPreference.getInstance().getSkinStrategy(); if (TextUtils.isEmpty(skin) || strategy == SKIN_LOADER_STRATEGY_NONE) { return null; } return loadSkin(skin, null, strategy); }
Example #16
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
private SkinCompatManager(Application application) { mAppContext = application; SkinPreference.init(mAppContext); SkinCompatResources.init(mAppContext); SkinActivityLifecycle.init(application); initLoaderStrategy(); }
Example #17
Source File: SkinCompatUserThemeManager.java From Android-skin-support with MIT License | 5 votes |
private void startLoadFromSharedPreferences() throws JSONException { String colors = SkinPreference.getInstance().getUserTheme(); if (!TextUtils.isEmpty(colors)) { JSONArray jsonArray = new JSONArray(colors); if (Slog.DEBUG) { Slog.i(TAG, "startLoadFromSharedPreferences: " + jsonArray.toString()); } int count = jsonArray.length(); for (int i = 0; i < count; i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (jsonObject.has(KEY_TYPE)) { String type = jsonObject.getString(KEY_TYPE); if (KEY_TYPE_COLOR.equals(type)) { ColorState state = ColorState.fromJSONObject(jsonObject); if (state != null) { mColorNameStateMap.put(state.colorName, state); } } else if (KEY_TYPE_DRAWABLE.equals(type)) { String drawableName = jsonObject.getString(KEY_DRAWABLE_NAME); String drawablePathAndAngle = jsonObject.getString(KEY_DRAWABLE_PATH_AND_ANGLE); if (!TextUtils.isEmpty(drawableName) && !TextUtils.isEmpty(drawablePathAndAngle)) { mDrawablePathAndAngleMap.put(drawableName, drawablePathAndAngle); } } } } mColorEmpty = mColorNameStateMap.isEmpty(); mDrawableEmpty = mDrawablePathAndAngleMap.isEmpty(); } }
Example #18
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
protected void onPostExecute(String skinName) { synchronized (mLock) { // skinName 为""时,恢复默认皮肤 if (skinName != null) { SkinPreference.getInstance().setSkinName(skinName).setSkinStrategy(mStrategy.getType()).commitEditor(); notifyUpdateSkin(); if (mListener != null) mListener.onSuccess(); } else { SkinPreference.getInstance().setSkinName("").setSkinStrategy(SKIN_LOADER_STRATEGY_NONE).commitEditor(); if (mListener != null) mListener.onFailed("皮肤资源获取失败"); } mLoading = false; mLock.notifyAll(); } }
Example #19
Source File: MainActivity.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { if (SkinPreference.getInstance().getSkinName().equals("night")) { getMenuInflater().inflate(R.menu.main_night, menu); } else { getMenuInflater().inflate(R.menu.main, menu); } MenuItem item = menu.findItem(R.id.action_search); searchView.setMenuItem(item); return true; }
Example #20
Source File: ZipActivity.java From Android-skin-support with MIT License | 5 votes |
@Override protected void onResume() { super.onResume(); if (SkinPreference.getInstance().getSkinStrategy() == ZipSDCardLoader.SKIN_LOADER_STRATEGY_ZIP) { mToolbar.setTitle("图片来自Zip包"); } else { mToolbar.setTitle("图片来自应用本身"); } }
Example #21
Source File: ZipActivity.java From Android-skin-support with MIT License | 5 votes |
@Override protected void onResume() { super.onResume(); if (SkinPreference.getInstance().getSkinStrategy() == ZipSDCardLoader.SKIN_LOADER_STRATEGY_ZIP) { mToolbar.setTitle("图片来自Zip包"); } else { mToolbar.setTitle("图片来自应用本身"); } }
Example #22
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
protected void onPostExecute(String skinName) { synchronized (mLock) { // skinName 为""时,恢复默认皮肤 if (skinName != null) { SkinPreference.getInstance().setSkinName(skinName).setSkinStrategy(mStrategy.getType()).commitEditor(); notifyUpdateSkin(); if (mListener != null) mListener.onSuccess(); } else { SkinPreference.getInstance().setSkinName("").setSkinStrategy(SKIN_LOADER_STRATEGY_NONE).commitEditor(); if (mListener != null) mListener.onFailed("皮肤资源获取失败"); } mLoading = false; mLock.notifyAll(); } }
Example #23
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
/** * 加载记录的皮肤包,一般在Application中初始化换肤框架后调用. * * @param listener 皮肤包加载监听. * @return */ public AsyncTask loadSkin(SkinLoaderListener listener) { String skin = SkinPreference.getInstance().getSkinName(); int strategy = SkinPreference.getInstance().getSkinStrategy(); if (TextUtils.isEmpty(skin) || strategy == SKIN_LOADER_STRATEGY_NONE) { return null; } return loadSkin(skin, listener, strategy); }
Example #24
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
/** * 加载记录的皮肤包,一般在Application中初始化换肤框架后调用. * * @return */ public AsyncTask loadSkin() { String skin = SkinPreference.getInstance().getSkinName(); int strategy = SkinPreference.getInstance().getSkinStrategy(); if (TextUtils.isEmpty(skin) || strategy == SKIN_LOADER_STRATEGY_NONE) { return null; } return loadSkin(skin, null, strategy); }
Example #25
Source File: SkinCompatManager.java From Android-skin-support with MIT License | 5 votes |
/** * 初始化换肤框架. 通过该方法初始化,应用中Activity需继承自{@link skin.support.app.SkinCompatActivity}. * * @param context * @return */ public static SkinCompatManager init(Context context) { if (sInstance == null) { synchronized (SkinCompatManager.class) { if (sInstance == null) { sInstance = new SkinCompatManager(context); } } } SkinPreference.init(context); return sInstance; }
Example #26
Source File: SkinCompatManager.java From AndroidSkinAnimator with MIT License | 5 votes |
public void loadSkin(SkinLoaderListener listener) { String skin = SkinPreference.getInstance().getSkinName(); if (TextUtils.isEmpty(skin)) { return; } loadSkin(skin, listener); }
Example #27
Source File: SkinCompatManager.java From AndroidSkinAnimator with MIT License | 5 votes |
public void loadSkin() { String skin = SkinPreference.getInstance().getSkinName(); if (TextUtils.isEmpty(skin)) { return; } loadSkin(skin, null); }
Example #28
Source File: PersonalFragment.java From DanDanPlayForAndroid with MIT License | 5 votes |
/** * 是否已换肤 */ private boolean isLoadedSkin() { switch (SkinPreference.getInstance().getSkinStrategy()) { case SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS: case SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN: case SkinCompatManager.SKIN_LOADER_STRATEGY_PREFIX_BUILD_IN: return true; case SkinCompatManager.SKIN_LOADER_STRATEGY_NONE: default: return false; } }
Example #29
Source File: StarActivity.java From Focus with GNU General Public License v3.0 | 5 votes |
private void createTabLayout() { loading.setVisibility(View.VISIBLE); new CollectionTabLayoutTask(new CollectionTabLayoutListener() { @Override public void onFinish(List<Fragment> fragmentList, List<String> pageTitleList) { BaseViewPagerAdapter adapter = new BaseViewPagerAdapter(getSupportFragmentManager(), fragmentList, pageTitleList); //设置ViewPager viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(1); tabLayout.setupWithViewPager(viewPager); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); //适配夜间模式 if (SkinPreference.getInstance().getSkinName().equals("night")) { tabLayout.setBackgroundColor(ContextCompat.getColor(StarActivity.this, R.color.colorPrimary_night)); } else { tabLayout.setBackgroundColor(ContextCompat.getColor(StarActivity.this, R.color.colorPrimary)); } //关闭等待加载框 loading.setVisibility(View.GONE); } },StarActivity.this).execute(); }
Example #30
Source File: FeedCategoryActivity.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { if (SkinPreference.getInstance().getSkinName().equals("night")) { getMenuInflater().inflate(R.menu.feed_night, menu); } else { getMenuInflater().inflate(R.menu.feed, menu); } MenuItem item = menu.findItem(R.id.action_search); searchView.setMenuItem(item); return true; }