Search in sources :

Example 6 with DisplayMetrics

use of android.util.DisplayMetrics in project SimplifyReader by chentao0707.

the class BaseLazyFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.inject(this, view);
    if (null != getLoadingTargetView()) {
        mVaryViewHelperController = new VaryViewHelperController(getLoadingTargetView());
    }
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    mScreenDensity = displayMetrics.density;
    mScreenHeight = displayMetrics.heightPixels;
    mScreenWidth = displayMetrics.widthPixels;
    initViewsAndEvents();
}
Also used : VaryViewHelperController(com.github.obsessive.library.loading.VaryViewHelperController) DisplayMetrics(android.util.DisplayMetrics)

Example 7 with DisplayMetrics

use of android.util.DisplayMetrics in project SimplifyReader by chentao0707.

the class BaseAppCompatActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (toggleOverridePendingTransition()) {
        switch(getOverridePendingTransitionMode()) {
            case LEFT:
                overridePendingTransition(R.anim.left_in, R.anim.left_out);
                break;
            case RIGHT:
                overridePendingTransition(R.anim.right_in, R.anim.right_out);
                break;
            case TOP:
                overridePendingTransition(R.anim.top_in, R.anim.top_out);
                break;
            case BOTTOM:
                overridePendingTransition(R.anim.bottom_in, R.anim.bottom_out);
                break;
            case SCALE:
                overridePendingTransition(R.anim.scale_in, R.anim.scale_out);
                break;
            case FADE:
                overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                break;
        }
    }
    super.onCreate(savedInstanceState);
    // base setup
    Bundle extras = getIntent().getExtras();
    if (null != extras) {
        getBundleExtras(extras);
    }
    if (isBindEventBusHere()) {
        EventBus.getDefault().register(this);
    }
    SmartBarUtils.hide(getWindow().getDecorView());
    setTranslucentStatus(isApplyStatusBarTranslucency());
    mContext = this;
    TAG_LOG = this.getClass().getSimpleName();
    BaseAppManager.getInstance().addActivity(this);
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    mScreenDensity = displayMetrics.density;
    mScreenHeight = displayMetrics.heightPixels;
    mScreenWidth = displayMetrics.widthPixels;
    if (getContentViewLayoutID() != 0) {
        setContentView(getContentViewLayoutID());
    } else {
        throw new IllegalArgumentException("You must return a right contentView layout resource Id");
    }
    mNetChangeObserver = new NetChangeObserver() {

        @Override
        public void onNetConnected(NetUtils.NetType type) {
            super.onNetConnected(type);
            onNetworkConnected(type);
        }

        @Override
        public void onNetDisConnect() {
            super.onNetDisConnect();
            onNetworkDisConnected();
        }
    };
    NetStateReceiver.registerObserver(mNetChangeObserver);
    initViewsAndEvents();
}
Also used : NetChangeObserver(com.github.obsessive.library.netstatus.NetChangeObserver) NetUtils(com.github.obsessive.library.netstatus.NetUtils) Bundle(android.os.Bundle) DisplayMetrics(android.util.DisplayMetrics)

Example 8 with DisplayMetrics

use of android.util.DisplayMetrics in project UltimateAndroid by cymcsg.

the class MaterialProgressWheel method parseAttributes.

/**
     * Parse the attributes passed to the view from the XML
     *
     * @param a the attributes to parse
     */
private void parseAttributes(TypedArray a) {
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
    rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
    circleRadius = (int) a.getDimension(R.styleable.MaterialProgressWheel_mpwCircleRadius, circleRadius);
    fillRadius = a.getBoolean(R.styleable.MaterialProgressWheel_mpwFillRadius, false);
    barWidth = (int) a.getDimension(R.styleable.MaterialProgressWheel_mpwBarWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.MaterialProgressWheel_mpwRimWidth, rimWidth);
    float baseSpinSpeed = a.getFloat(R.styleable.MaterialProgressWheel_mpwSpinSpeed, spinSpeed / 360.0f);
    spinSpeed = baseSpinSpeed * 360;
    barSpinCycleTime = a.getInt(R.styleable.MaterialProgressWheel_mpwBarSpinCycleTime, (int) barSpinCycleTime);
    barColor = a.getColor(R.styleable.MaterialProgressWheel_mpwBarColor, barColor);
    rimColor = a.getColor(R.styleable.MaterialProgressWheel_mpwRimColor, rimColor);
    if (a.getBoolean(R.styleable.MaterialProgressWheel_mpwProgressIndeterminate, false)) {
        spin();
    }
    // Recycle
    a.recycle();
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Example 9 with DisplayMetrics

use of android.util.DisplayMetrics in project Launcher3 by chislon.

the class Cling method dispatchDraw.

@Override
protected void dispatchDraw(Canvas canvas) {
    if (mIsInitialized) {
        canvas.save();
        // Get the background override if there is one
        if (mBackground == null) {
            if (mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
                mBackground = getResources().getDrawable(R.drawable.bg_cling5);
            }
        }
        // Draw the background
        Bitmap eraseBg = null;
        Canvas eraseCanvas = null;
        if (mScrimView != null) {
            // Skip drawing the background
            mScrimView.setBackgroundColor(mBackgroundColor);
        } else if (mBackground != null) {
            mBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            mBackground.draw(canvas);
        } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) || mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) || mDrawIdentifier.equals(WORKSPACE_LARGE)) {
            // Initialize the draw buffer (to allow punching through)
            eraseBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Bitmap.Config.ARGB_8888);
            eraseCanvas = new Canvas(eraseBg);
            eraseCanvas.drawColor(mBackgroundColor);
        } else {
            canvas.drawColor(mBackgroundColor);
        }
        // Draw everything else
        DisplayMetrics metrics = new DisplayMetrics();
        mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);
        float alpha = getAlpha();
        View content = getContent();
        if (content != null) {
            alpha *= content.getAlpha();
        }
        if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) || mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE)) {
            // Draw the circle
            View bubbleContent = findViewById(R.id.bubble_content);
            Rect bubbleRect = new Rect();
            bubbleContent.getGlobalVisibleRect(bubbleRect);
            mBubblePaint.setAlpha((int) (255 * alpha));
            float buffer = DynamicGrid.pxFromDp(FIRST_RUN_CIRCLE_BUFFER_DPS, metrics);
            canvas.drawCircle(metrics.widthPixels / 2, bubbleRect.centerY(), (bubbleContent.getMeasuredWidth() + buffer) / 2, mBubblePaint);
        } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) || mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) || mDrawIdentifier.equals(WORKSPACE_LARGE)) {
            int offset = DynamicGrid.pxFromDp(WORKSPACE_CIRCLE_Y_OFFSET_DPS, metrics);
            mErasePaint.setAlpha((int) (128));
            eraseCanvas.drawCircle(metrics.widthPixels / 2, metrics.heightPixels / 2 - offset, DynamicGrid.pxFromDp(WORKSPACE_OUTER_CIRCLE_RADIUS_DPS, metrics), mErasePaint);
            mErasePaint.setAlpha(0);
            eraseCanvas.drawCircle(metrics.widthPixels / 2, metrics.heightPixels / 2 - offset, DynamicGrid.pxFromDp(WORKSPACE_INNER_CIRCLE_RADIUS_DPS, metrics), mErasePaint);
            canvas.drawBitmap(eraseBg, 0, 0, null);
            eraseCanvas.setBitmap(null);
            eraseBg = null;
            // Draw the focused hotseat app icon
            if (mFocusedHotseatAppBounds != null && mFocusedHotseatApp != null) {
                mFocusedHotseatApp.setBounds(mFocusedHotseatAppBounds.left, mFocusedHotseatAppBounds.top, mFocusedHotseatAppBounds.right, mFocusedHotseatAppBounds.bottom);
                mFocusedHotseatApp.setAlpha((int) (255 * alpha));
                mFocusedHotseatApp.draw(canvas);
            }
        }
        canvas.restore();
    }
    // Draw the rest of the cling
    super.dispatchDraw(canvas);
}
Also used : DisplayMetrics(android.util.DisplayMetrics) TextView(android.widget.TextView) View(android.view.View)

Example 10 with DisplayMetrics

use of android.util.DisplayMetrics in project SimplifyReader by chentao0707.

the class PluginInvestigate method updateLayout.

public void updateLayout() {
    if (isOpen) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        mActivity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mInvestigate.getLayoutParams();
        if (!mMediaPlayerDelegate.isFullScreen) {
            if (!UIUtils.isTablet(mActivity)) {
                params.bottomMargin = (int) (displayMetrics.density * MARGIN_BOTTOM_VERTICAL);
            } else {
                params.bottomMargin = (int) (displayMetrics.density * MARGIN_BOTTOM_VERTICAL_PAD);
            }
        } else {
            if (!UIUtils.isTablet(mActivity)) {
                params.bottomMargin = (int) (displayMetrics.density * MARGIN_BOTTOM_HORIZONTAL);
            } else {
                params.bottomMargin = (int) (displayMetrics.density * MARGIN_BOTTOM_HORIZONTAL_PAD);
            }
        }
        params.rightMargin = 0;
        mInvestigate.setLayoutParams(params);
        mInvestigate.requestLayout();
    }
}
Also used : RelativeLayout(android.widget.RelativeLayout) DisplayMetrics(android.util.DisplayMetrics)

Aggregations

DisplayMetrics (android.util.DisplayMetrics)751 WindowManager (android.view.WindowManager)103 Resources (android.content.res.Resources)95 Display (android.view.Display)75 Configuration (android.content.res.Configuration)58 Point (android.graphics.Point)56 View (android.view.View)48 SuppressLint (android.annotation.SuppressLint)44 Paint (android.graphics.Paint)42 Bitmap (android.graphics.Bitmap)41 Activity (android.app.Activity)32 ImageView (android.widget.ImageView)26 TypedArray (android.content.res.TypedArray)25 AssetManager (android.content.res.AssetManager)24 TypedValue (android.util.TypedValue)23 ViewGroup (android.view.ViewGroup)22 TextView (android.widget.TextView)21 Intent (android.content.Intent)20 FrameLayout (android.widget.FrameLayout)19 RelativeLayout (android.widget.RelativeLayout)19