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


Java ScreenUtils类代码示例

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


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

示例1: BaseReadView

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
public BaseReadView(Context context, String bookId, List<BookMixAToc.mixToc.Chapters> chaptersList,
                    OnReadStateChangeListener listener) {
    super(context);
    this.listener = listener;
    this.bookId = bookId;

    mScreenWidth = ScreenUtils.getScreenWidth();
    mScreenHeight = ScreenUtils.getScreenHeight();

    mCurPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.ARGB_8888);
    mNextPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.ARGB_8888);
    mCurrentPageCanvas = new Canvas(mCurPageBitmap);
    mNextPageCanvas = new Canvas(mNextPageBitmap);

    mScroller = new Scroller(getContext());

    pagefactory = new PageFactory(getContext(), bookId, chaptersList);
    pagefactory.setOnReadStateChangeListener(listener);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BaseReadView.java

示例2: convertBetteryBitmap

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
public void convertBetteryBitmap() {
    batteryView = (ProgressBar) LayoutInflater.from(mContext).inflate(R.layout.layout_battery_progress, null);
    batteryView.setProgressDrawable(ContextCompat.getDrawable(mContext,
            SettingManager.getInstance().getReadTheme() < 4 ?
                    R.drawable.seekbar_battery_bg : R.drawable.seekbar_battery_night_bg));
    batteryView.setProgress(battery);
    batteryView.setDrawingCacheEnabled(true);
    batteryView.measure(View.MeasureSpec.makeMeasureSpec(ScreenUtils.dpToPxInt(26), View.MeasureSpec.EXACTLY),
            View.MeasureSpec.makeMeasureSpec(ScreenUtils.dpToPxInt(14), View.MeasureSpec.EXACTLY));
    batteryView.layout(0, 0, batteryView.getMeasuredWidth(), batteryView.getMeasuredHeight());
    batteryView.buildDrawingCache();
    //batteryBitmap = batteryView.getDrawingCache();
    // tips: @link{https://github.com/JustWayward/BookReader/issues/109}
    batteryBitmap = Bitmap.createBitmap(batteryView.getDrawingCache());
    batteryView.setDrawingCacheEnabled(false);
    batteryView.destroyDrawingCache();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:PageFactory.java

示例3: getThemeDrawable

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
public static Bitmap getThemeDrawable(int theme) {
    Bitmap bmp = Bitmap.createBitmap(ScreenUtils.getScreenWidth(), ScreenUtils.getScreenHeight(), Bitmap.Config.ARGB_8888);
    switch (theme) {
        case NORMAL:
            bmp.eraseColor(ContextCompat.getColor(AppUtils.getAppContext(), R.color.read_theme_white));
            break;
        case YELLOW:
            bmp.eraseColor(ContextCompat.getColor(AppUtils.getAppContext(), R.color.read_theme_yellow));
            break;
        case GREEN:
            bmp.eraseColor(ContextCompat.getColor(AppUtils.getAppContext(), R.color.read_theme_green));
            break;
        case LEATHER:
            bmp = BitmapFactory.decodeResource(AppUtils.getAppContext().getResources(), R.drawable.theme_leather_bg);
            break;
        case GRAY:
            bmp.eraseColor(ContextCompat.getColor(AppUtils.getAppContext(), R.color.read_theme_gray));
            break;
        case NIGHT:
            bmp.eraseColor(ContextCompat.getColor(AppUtils.getAppContext(), R.color.read_theme_night));
            break;
        default:
            break;
    }
    return bmp;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:ThemeManager.java

示例4: convert

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
@Override
public void convert(EasyLVHolder holder, int position, String s) {
    holder.setText(R.id.tvMinorItem, s);

    if (current == position) {
        holder.setVisible(R.id.ivMinorChecked, true);
    } else {
        holder.setVisible(R.id.ivMinorChecked, false);
    }

    if (position != 0) { // 子项右移
        TextView textView = holder.getView(R.id.tvMinorItem);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams();
        params.leftMargin = ScreenUtils.dpToPxInt(25);
        textView.setLayoutParams(params);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:MinorAdapter.java

示例5: BaseReadView

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
public BaseReadView(Context context, String bookId, List<BookMixAToc.mixToc.Chapters> chaptersList,
                    OnReadStateChangeListener listener) {
    super(context);
    this.listener = listener;
    this.bookId = bookId;

    mScreenWidth = ScreenUtils.getScreenWidth();
    mScreenHeight = ScreenUtils.getScreenHeight();

    mCurPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.ARGB_8888);
    mNextPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.ARGB_8888);
    mCurrentPageCanvas = new Canvas(mCurPageBitmap);
    mNextPageCanvas = new Canvas(mNextPageBitmap);

    mScroller = new Scroller(getContext());


    pagefactory = new PageFactory(getContext(), bookId, chaptersList);
    pagefactory.setOnReadStateChangeListener(listener);
}
 
开发者ID:JustWayward,项目名称:BookReader,代码行数:21,代码来源:BaseReadView.java

示例6: PageFactory

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
public PageFactory(Context context, int width, int height, int fontSize, String bookId,
                   List<BookMixAToc.mixToc.Chapters> chaptersList) {
    mContext = context;
    mWidth = width;
    mHeight = height;
    mFontSize = fontSize;
    mLineSpace = mFontSize / 5 * 2;
    mNumFontSize = ScreenUtils.dpToPxInt(16);
    marginWidth = ScreenUtils.dpToPxInt(15);
    marginHeight = ScreenUtils.dpToPxInt(15);
    mVisibleHeight = mHeight - marginHeight * 2 - mNumFontSize * 2 - mLineSpace * 2;
    mVisibleWidth = mWidth - marginWidth * 2;
    mPageLineCount = mVisibleHeight / (mFontSize + mLineSpace);
    rectF = new Rect(0, 0, mWidth, mHeight);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setTextSize(mFontSize);
    mPaint.setTextSize(ContextCompat.getColor(context, R.color.chapter_content_day));
    mPaint.setColor(Color.BLACK);
    mTitlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTitlePaint.setTextSize(mNumFontSize);
    mTitlePaint.setColor(ContextCompat.getColor(AppUtils.getAppContext(), R.color.chapter_title_day));
    timeLen = (int) mTitlePaint.measureText("00:00");
    percentLen = (int) mTitlePaint.measureText("00.00%");
    // Typeface typeface = Typeface.createFromAsset(context.getAssets(),"fonts/FZBYSK.TTF");
    // mPaint.setTypeface(typeface);
    // mNumPaint.setTypeface(typeface);

    this.bookId = bookId;
    this.chaptersList = chaptersList;

    time = dateFormat.format(new Date());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:PageFactory.java

示例7: XLHRatingBar

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
public XLHRatingBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.XlHRatingBar);
    countNum = typedArray.getInt(R.styleable.XlHRatingBar_starCount, 5);
    countSelected = typedArray.getInt(R.styleable.XlHRatingBar_countSelected, 0);
    canEdit = typedArray.getBoolean(R.styleable.XlHRatingBar_canEdit, false);
    differentSize = typedArray.getBoolean(R.styleable.XlHRatingBar_differentSize, false);
    widthAndHeight = typedArray.getDimension(R.styleable.XlHRatingBar_widthAndHeight, ScreenUtils.dpToPxInt(0));
    dividerWidth = typedArray.getDimension(R.styleable.XlHRatingBar_dividerWidth, ScreenUtils.dpToPxInt(0));
    stateResId = typedArray.getResourceId(R.styleable.XlHRatingBar_stateResId, -1);
    initView();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:XLHRatingBar.java

示例8: configViews

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
@Override
public void configViews() {
    hideStatusBar();
    decodeView = getWindow().getDecorView();
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mLlBookReadTop.getLayoutParams();
    params.topMargin = ScreenUtils.getStatusBarHeight(this) - 2;
    mLlBookReadTop.setLayoutParams(params);

    initTocList();

    initAASet();

    initPagerWidget();

    mPresenter.attachView(this);
    // 本地收藏  直接打开
    if (isFromSD) {
        BookMixAToc.mixToc.Chapters chapters = new BookMixAToc.mixToc.Chapters();
        chapters.title = recommendBooks.title;
        mChapterList.add(chapters);
        showChapterRead(null, currentChapter);
        //本地书籍隐藏社区、简介、缓存按钮
        gone(mTvBookReadCommunity, mTvBookReadChangeSource, mTvBookReadDownload);
        return;
    }
    mPresenter.getBookMixAToc(bookId, "chapters");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:ReadActivity.java

示例9: initAASet

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
private void initAASet() {
    curTheme = SettingManager.getInstance().getReadTheme();
    ThemeManager.setReaderTheme(curTheme, mRlBookReadRoot);

    seekbarFontSize.setMax(10);
    //int fontSizePx = SettingManager.getInstance().getReadFontSize(bookId);
    int fontSizePx = SettingManager.getInstance().getReadFontSize();
    int progress = (int) ((ScreenUtils.pxToDpInt(fontSizePx) - 12) / 1.7f);
    seekbarFontSize.setProgress(progress);
    seekbarFontSize.setOnSeekBarChangeListener(new SeekBarChangeListener());

    seekbarLightness.setMax(100);
    seekbarLightness.setOnSeekBarChangeListener(new SeekBarChangeListener());
    seekbarLightness.setProgress(SettingManager.getInstance().getReadBrightness());
    isAutoLightness = ScreenUtils.isAutoBrightness(this);
    if (SettingManager.getInstance().isAutoBrightness()) {
        startAutoLightness();
    } else {
        stopAutoLightness();
    }

    cbVolume.setChecked(SettingManager.getInstance().isVolumeFlipEnable());
    cbVolume.setOnCheckedChangeListener(new ChechBoxChangeListener());

    cbAutoBrightness.setChecked(SettingManager.getInstance().isAutoBrightness());
    cbAutoBrightness.setOnCheckedChangeListener(new ChechBoxChangeListener());

    gvAdapter = new ReadThemeAdapter(this, (themes = ThemeManager.getReaderThemeData(curTheme)), curTheme);
    gvTheme.setAdapter(gvAdapter);
    gvTheme.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position < themes.size() - 1) {
                changedMode(false, position);
            } else {
                changedMode(true, position);
            }
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:ReadActivity.java

示例10: brightnessMinus

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
/***************Setting Menu*****************/

    @OnClick(R.id.ivBrightnessMinus)
    public void brightnessMinus() {
        int curBrightness = SettingManager.getInstance().getReadBrightness();
        if (curBrightness > 2 && !SettingManager.getInstance().isAutoBrightness()) {
            seekbarLightness.setProgress((curBrightness = curBrightness - 2));
            ScreenUtils.setScreenBrightness(curBrightness, ReadActivity.this);
            SettingManager.getInstance().saveReadBrightness(curBrightness);
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:ReadActivity.java

示例11: brightnessPlus

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
@OnClick(R.id.ivBrightnessPlus)
public void brightnessPlus() {
    int curBrightness = SettingManager.getInstance().getReadBrightness();
    if (curBrightness < 99 && !SettingManager.getInstance().isAutoBrightness()) {
        seekbarLightness.setProgress((curBrightness = curBrightness + 2));
        ScreenUtils.setScreenBrightness(curBrightness, ReadActivity.this);
        SettingManager.getInstance().saveReadBrightness(curBrightness);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ReadActivity.java

示例12: onDestroy

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
@Override
protected void onDestroy() {
    super.onDestroy();
    if (mTtsPlayer.getPlayerState() == TTSCommonPlayer.PLAYER_STATE_PLAYING)
        mTtsPlayer.stop();

    EventManager.refreshCollectionIcon();
    EventManager.refreshCollectionList();
    EventBus.getDefault().unregister(this);

    try {
        unregisterReceiver(receiver);
    } catch (Exception e) {
        LogUtils.e("Receiver not registered");
    }

    if (isAutoLightness) {
        ScreenUtils.startAutoBrightness(ReadActivity.this);
    } else {
        ScreenUtils.stopAutoBrightness(ReadActivity.this);
    }

    if (mPresenter != null) {
        mPresenter.detachView();
    }

    // 观察内存泄漏情况
    ReaderApplication.getRefWatcher(this).watch(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:ReadActivity.java

示例13: onProgressChanged

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (seekBar.getId() == seekbarFontSize.getId() && fromUser) {
        calcFontSize(progress);
    } else if (seekBar.getId() == seekbarLightness.getId() && fromUser
            && !SettingManager.getInstance().isAutoBrightness()) { // 非自动调节模式下 才可调整屏幕亮度
        ScreenUtils.setScreenBrightness(progress, ReadActivity.this);
        SettingManager.getInstance().saveReadBrightness(progress);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ReadActivity.java

示例14: stopAutoLightness

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
private void stopAutoLightness() {
    SettingManager.getInstance().saveAutoBrightness(false);
    ScreenUtils.stopAutoBrightness(ReadActivity.this);
    int value = SettingManager.getInstance().getReadBrightness();
    seekbarLightness.setProgress(value);
    ScreenUtils.setScreenBrightness(value, ReadActivity.this);
    seekbarLightness.setEnabled(true);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ReadActivity.java

示例15: calcFontSize

import com.justwayward.reader.utils.ScreenUtils; //导入依赖的package包/类
private void calcFontSize(int progress) {
    // progress range 1 - 10
    if (progress >= 0 && progress <= 10) {
        seekbarFontSize.setProgress(progress);
        mPageWidget.setFontSize(ScreenUtils.dpToPxInt(12 + 1.7f * progress));
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:ReadActivity.java


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