当前位置: 首页>>代码示例>>Java>>正文


Java SharedPreferencesUtil类代码示例

本文整理汇总了Java中com.justwayward.reader.utils.SharedPreferencesUtil的典型用法代码示例。如果您正苦于以下问题:Java SharedPreferencesUtil类的具体用法?Java SharedPreferencesUtil怎么用?Java SharedPreferencesUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SharedPreferencesUtil类属于com.justwayward.reader.utils包,在下文中一共展示了SharedPreferencesUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutId());
    if (statusBarColor == 0) {
        statusBarView = StatusBarCompat.compat(this, ContextCompat.getColor(this, R.color.colorPrimaryDark));
    } else if (statusBarColor != -1) {
        statusBarView = StatusBarCompat.compat(this, statusBarColor);
    }
    transparent19and20();
    mContext = this;
    ButterKnife.bind(this);
    setupActivityComponent(ReaderApplication.getsInstance().getAppComponent());
    mCommonToolbar = ButterKnife.findById(this, R.id.common_toolbar);
    if (mCommonToolbar != null) {
        initToolBar();
        setSupportActionBar(mCommonToolbar);
    }
    initDatas();
    configViews();
    mNowMode = SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BaseActivity.java

示例2: changedMode

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
private void changedMode(boolean isNight, int position) {
    SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, isNight);
    AppCompatDelegate.setDefaultNightMode(isNight ? AppCompatDelegate.MODE_NIGHT_YES
            : AppCompatDelegate.MODE_NIGHT_NO);

    if (position >= 0) {
        curTheme = position;
    } else {
        curTheme = SettingManager.getInstance().getReadTheme();
    }
    gvAdapter.select(curTheme);

    mPageWidget.setTheme(isNight ? ThemeManager.NIGHT : curTheme);
    mPageWidget.setTextColor(ContextCompat.getColor(mContext, isNight ? R.color.chapter_content_night : R.color.chapter_content_day),
            ContextCompat.getColor(mContext, isNight ? R.color.chapter_title_night : R.color.chapter_title_day));

    mTvBookReadMode.setText(getString(isNight ? R.string.book_read_mode_day_manual_setting
            : R.string.book_read_mode_night_manual_setting));
    Drawable drawable = ContextCompat.getDrawable(this, isNight ? R.drawable.ic_menu_mode_day_manual
            : R.drawable.ic_menu_mode_night_manual);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    mTvBookReadMode.setCompoundDrawables(null, drawable, null, null);

    ThemeManager.setReaderTheme(curTheme, mRlBookReadRoot);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ReadActivity.java

示例3: initDatas

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
@Override
public void initDatas() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            final String cachesize = CacheManager.getInstance().getCacheSize();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mTvCacheSize.setText(cachesize);
                }
            });

        }
    }).start();
    mTvSort.setText(getResources().getStringArray(R.array.setting_dialog_sort_choice)[
            SharedPreferencesUtil.getInstance().getBoolean(Constant.ISBYUPDATESORT, true) ? 0 : 1]);
    mTvFlipStyle.setText(getResources().getStringArray(R.array.setting_dialog_style_choice)[
            SharedPreferencesUtil.getInstance().getInt(Constant.FLIP_STYLE, 0)]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:SettingActivity.java

示例4: onClickBookShelfSort

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
@OnClick(R.id.bookshelfSort)
public void onClickBookShelfSort() {
    new AlertDialog.Builder(mContext)
            .setTitle("书架排序方式")
            .setSingleChoiceItems(getResources().getStringArray(R.array.setting_dialog_sort_choice),
                    SharedPreferencesUtil.getInstance().getBoolean(Constant.ISBYUPDATESORT, true) ? 0 : 1,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mTvSort.setText(getResources().getStringArray(R.array.setting_dialog_sort_choice)[which]);
                            SharedPreferencesUtil.getInstance().putBoolean(Constant.ISBYUPDATESORT, which == 0);
                            EventManager.refreshCollectionList();
                            dialog.dismiss();
                        }
                    })
            .create().show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:SettingActivity.java

示例5: onClickFlipStyle

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
@OnClick(R.id.rlFlipStyle)
public void onClickFlipStyle() {
    new AlertDialog.Builder(mContext)
            .setTitle("阅读页翻页效果")
            .setSingleChoiceItems(getResources().getStringArray(R.array.setting_dialog_style_choice),
                    SharedPreferencesUtil.getInstance().getInt(Constant.FLIP_STYLE, 0),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mTvFlipStyle.setText(getResources().getStringArray(R.array.setting_dialog_style_choice)[which]);
                            SharedPreferencesUtil.getInstance().putInt(Constant.FLIP_STYLE, which);
                            dialog.dismiss();
                        }
                    })
            .create().show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SettingActivity.java

示例6: onResume

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false) != mNowMode) {
        if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false)) {
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        } else {
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        recreate();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:BaseActivity.java

示例7: initNightMode

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
protected void initNightMode() {
    boolean isNight = SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false);
    LogUtils.d("isNight=" + isNight);
    if (isNight) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    } else {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ReaderApplication.java

示例8: getReadProgress

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
/**
 * 获取上次阅读章节及位置
 *
 * @param bookId
 * @return
 */
public int[] getReadProgress(String bookId) {
    int lastChapter = SharedPreferencesUtil.getInstance().getInt(getChapterKey(bookId), 1);
    int startPos = SharedPreferencesUtil.getInstance().getInt(getStartPosKey(bookId), 0);
    int endPos = SharedPreferencesUtil.getInstance().getInt(getEndPosKey(bookId), 0);

    return new int[]{lastChapter, startPos, endPos};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:SettingManager.java

示例9: addBookMark

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
public boolean addBookMark(String bookId, BookMark mark) {
    List<BookMark> marks = SharedPreferencesUtil.getInstance().getObject(getBookMarksKey(bookId), ArrayList.class);
    if (marks != null && marks.size() > 0) {
        for (BookMark item : marks) {
            if (item.chapter == mark.chapter && item.startPos == mark.startPos) {
                return false;
            }
        }
    } else {
        marks = new ArrayList<>();
    }
    marks.add(mark);
    SharedPreferencesUtil.getInstance().putObject(getBookMarksKey(bookId), marks);
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:SettingManager.java

示例10: getCollectionListBySort

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
/**
 * 按排序方式获取收藏列表
 *
 * @return
 */
public List<Recommend.RecommendBooks> getCollectionListBySort() {
    List<Recommend.RecommendBooks> list = getCollectionList();
    if (list == null) {
        return null;
    } else {
        if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISBYUPDATESORT, true)) {
            Collections.sort(list, new LatelyUpdateTimeComparator());
        } else {
            Collections.sort(list, new RecentReadingTimeComparator());
        }
        return list;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CollectionsManager.java

示例11: clearCache

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
/**
 * 清除缓存
 *
 * @param clearReadPos 是否删除阅读记录
 */
public synchronized void clearCache(boolean clearReadPos, boolean clearCollect) {
    try {
        // 删除内存缓存
        String cacheDir = AppUtils.getAppContext().getCacheDir().getPath();
        FileUtils.deleteFileOrDirectory(new File(cacheDir));
        if (FileUtils.isSdCardAvailable()) {
            // 删除SD书籍缓存
            FileUtils.deleteFileOrDirectory(new File(Constant.PATH_DATA));
        }
        // 删除阅读记录(SharePreference)
        if (clearReadPos) {
            //防止再次弹出性别选择框,sp要重写入保存的性别
            String chooseSex = SettingManager.getInstance().getUserChooseSex();
            SharedPreferencesUtil.getInstance().removeAll();
            SettingManager.getInstance().saveUserChooseSex(chooseSex);
        }
        // 清空书架
        if (clearCollect) {
            CollectionsManager.getInstance().clear();
        }
        // 清除其他缓存
        ACache.get(AppUtils.getAppContext()).clear();
    } catch (Exception e) {
        LogUtils.e(e.toString());
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:CacheManager.java

示例12: onClickChangeMode

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
/***************Bottom Bar*****************/

    @OnClick(R.id.tvBookReadMode)
    public void onClickChangeMode() { // 日/夜间模式切换
        gone(rlReadAaSet, rlReadMark);

        boolean isNight = !SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false);
        changedMode(isNight, -1);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ReadActivity.java

示例13: saveReadBrightness

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
/**
 * 保存阅读界面屏幕亮度
 *
 * @param percent 亮度比例 0~100
 */
public void saveReadBrightness(int percent) {
    if(percent > 100){
        ToastUtils.showToast("saveReadBrightnessErr CheckRefs");
        percent = 100;
    }
    SharedPreferencesUtil.getInstance().putInt(getLightnessKey(), percent);
}
 
开发者ID:JustWayward,项目名称:BookReader,代码行数:13,代码来源:SettingManager.java

示例14: initPrefs

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
/**
 * 初始化SharedPreference
 */
protected void initPrefs() {
    SharedPreferencesUtil.init(getApplicationContext(), getPackageName() + "_preference", Context.MODE_MULTI_PROCESS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:ReaderApplication.java

示例15: getReadFontSize

import com.justwayward.reader.utils.SharedPreferencesUtil; //导入依赖的package包/类
public int getReadFontSize(String bookId) {
    return SharedPreferencesUtil.getInstance().getInt(getFontSizeKey(bookId), ScreenUtils.dpToPxInt(16));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:SettingManager.java


注:本文中的com.justwayward.reader.utils.SharedPreferencesUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。