Example usage for android.view WindowManager getDefaultDisplay

List of usage examples for android.view WindowManager getDefaultDisplay

Introduction

In this page you can find the example usage for android.view WindowManager getDefaultDisplay.

Prototype

public Display getDefaultDisplay();

Source Link

Document

Returns the Display upon which this WindowManager instance will create new windows.

Usage

From source file:com.gh4a.utils.HttpImageGetter.java

public HttpImageGetter(Context context) {
    mContext = context;//from  ww w .  j a  v a  2 s  .c o  m
    mCacheDir = context.getCacheDir();

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final Point size = new Point();

    wm.getDefaultDisplay().getSize(size);
    mWidth = size.x;
    mHeight = size.y;

    mLoadingDrawable = ContextCompat.getDrawable(context,
            UiUtils.resolveDrawable(context, R.attr.loadingPictureIcon));
    mLoadingDrawable.setBounds(0, 0, mLoadingDrawable.getIntrinsicWidth(),
            mLoadingDrawable.getIntrinsicHeight());

    mErrorDrawable = ContextCompat.getDrawable(context,
            UiUtils.resolveDrawable(context, R.attr.contentPictureIcon));
    mErrorDrawable.setBounds(0, 0, mErrorDrawable.getIntrinsicWidth(), mErrorDrawable.getIntrinsicHeight());
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetSettingsAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    /* TODO: This definitely needs some huge refactoring
     *//*  w  w  w  .j  ava2  s . com*/
    final int pos = position;

    RelativeLayout widgetView;
    TextView labelTextView;
    ImageView roomEditView;
    int widgetLayout = 0;
    OpenHABWidget openHABWidget = getItem(position);
    switch (this.getItemViewType(position)) {
    case TYPE_FRAME:
        widgetLayout = R.layout.openhabwidgetlist_frameitem;
        break;
    case TYPE_GROUP:
        widgetLayout = R.layout.openhabwidget_settings_item;
        break;

    case TYPE_IMAGE:
        widgetLayout = R.layout.openhabwidgetlist_imageitem;
        break;

    case TYPE_CHART:
        widgetLayout = R.layout.openhabwidgetlist_chartitem;
        break;
    case TYPE_VIDEO:
        widgetLayout = R.layout.openhabwidgetlist_videoitem;
        break;
    case TYPE_WEB:
        widgetLayout = R.layout.openhabwidgetlist_webitem;
        break;
    default:
        widgetLayout = R.layout.openhabwidget_settings_item;
        break;
    }
    if (convertView == null) {
        widgetView = new RelativeLayout(getContext());
        String inflater = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater vi;
        vi = (LayoutInflater) getContext().getSystemService(inflater);
        vi.inflate(widgetLayout, widgetView, true);
    } else {
        widgetView = (RelativeLayout) convertView;
    }
    switch (getItemViewType(position)) {
    case TYPE_FRAME:
        labelTextView = (TextView) widgetView.findViewById(R.id.framelabel);
        if (labelTextView != null)
            labelTextView.setText(openHABWidget.getLabel());
        widgetView.setClickable(false);
        if (openHABWidget.getLabel().length() > 0) { // hide empty frames
            widgetView.setVisibility(View.VISIBLE);
            labelTextView.setVisibility(View.VISIBLE);
        } else {
            widgetView.setVisibility(View.GONE);
            labelTextView.setVisibility(View.GONE);
        }
        break;
    case TYPE_IMAGE:
        MySmartImageView imageImage = (MySmartImageView) widgetView.findViewById(R.id.imageimage);
        imageImage.setImageUrl(ensureAbsoluteURL(openHABBaseUrl, openHABWidget.getUrl()), false);
        if (openHABWidget.getRefresh() > 0) {
            imageImage.setRefreshRate(openHABWidget.getRefresh());
            refreshImageList.add(imageImage);
        }
        break;
    case TYPE_CHART:
        MySmartImageView chartImage = (MySmartImageView) widgetView.findViewById(R.id.chartimage);
        OpenHABItem chartItem = openHABWidget.getItem();
        Random random = new Random();
        String chartUrl = "";
        if (chartItem.getType().equals("GroupItem")) {
            chartUrl = openHABBaseUrl + "rrdchart.png?groups=" + chartItem.getName() + "&period="
                    + openHABWidget.getPeriod() + "&random=" + String.valueOf(random.nextInt());
        }
        Log.i("OpenHABWidgetAdapter", "Chart url = " + chartUrl);
        chartImage.setImageUrl(chartUrl, false);
        // TODO: This is quite dirty fix to make charts look full screen width on all displays
        ViewGroup.LayoutParams chartLayoutParams = chartImage.getLayoutParams();
        int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getWidth();
        chartLayoutParams.height = (int) (screenWidth / 1.88);
        chartImage.setLayoutParams(chartLayoutParams);
        if (openHABWidget.getRefresh() > 0) {
            chartImage.setRefreshRate(openHABWidget.getRefresh());
            refreshImageList.add(chartImage);
        }
        Log.i("OpenHABWidgetAdapter",
                "chart size = " + chartLayoutParams.width + " " + chartLayoutParams.height);
        break;
    case TYPE_VIDEO:
        VideoView videoVideo = (VideoView) widgetView.findViewById(R.id.videovideo);
        Log.i("OpenHABWidgetAdapter", "Opening video at " + openHABWidget.getUrl());
        // TODO: This is quite dirty fix to make video look maximum available size on all screens
        WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        ViewGroup.LayoutParams videoLayoutParams = videoVideo.getLayoutParams();
        videoLayoutParams.height = (int) (wm.getDefaultDisplay().getWidth() / 1.77);
        videoVideo.setLayoutParams(videoLayoutParams);
        // We don't have any event handler to know if the VideoView is on the screen
        // so we manage an array of all videos to stop them when user leaves the page
        if (!videoWidgetList.contains(videoVideo))
            videoWidgetList.add(videoVideo);
        // Start video
        if (!videoVideo.isPlaying()) {
            videoVideo.setVideoURI(Uri.parse(openHABWidget.getUrl()));
            videoVideo.start();
        }
        Log.i("OpenHABWidgetAdapter", "Video height is " + videoVideo.getHeight());
        break;
    case TYPE_WEB:
        WebView webWeb = (WebView) widgetView.findViewById(R.id.webweb);
        if (openHABWidget.getHeight() > 0) {
            ViewGroup.LayoutParams webLayoutParams = webWeb.getLayoutParams();
            webLayoutParams.height = openHABWidget.getHeight() * 80;
            webWeb.setLayoutParams(webLayoutParams);
        }
        webWeb.setWebViewClient(new WebViewClient());
        webWeb.loadUrl(openHABWidget.getUrl());
        break;

    default:
        labelTextView = (TextView) widgetView.findViewById(R.id.itemlabel);
        roomEditView = (ImageView) widgetView.findViewById(R.id.editimg);
        if (null != roomEditView) {
            roomEditView.setVisibility(View.VISIBLE);
            roomEditView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if (null != listItemListener)
                        listItemListener.onEditClickListener(pos);
                }
            });
        }
        if (labelTextView != null)
            labelTextView.setText(openHABWidget.getLabel());
        MySmartImageView sliderImage = (MySmartImageView) widgetView.findViewById(R.id.itemimage);
        sliderImage.setImageUrl(openHABBaseUrl + "images/" + openHABWidget.getIcon() + ".png");
        break;
    }
    LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider);
    if (dividerLayout != null) {
        if (position < this.getCount() - 1) {
            if (this.getItemViewType(position + 1) == TYPE_FRAME) {
                dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets
            } else {
                dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others
            }
        } else { // last widget in the list, hide divider
            dividerLayout.setVisibility(View.GONE);
        }
    }
    return widgetView;
}

From source file:com.i370.ui.view.PagerSlidingTabStrip.java

private void scrollToChild(int position, int offset) {

    //      System.out.println("=====scrollToChild  pos="+position+"  offset="+offset);

    if (tabCount == 0) {
        return;/*from  ww  w.  ja  va 2 s.  com*/
    }

    int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
    int[] location = new int[2];
    tabsContainer.getChildAt(position).getLocationOnScreen(location);
    //      System.out.println("local x="+location[0]+";  y="+location[1]);
    WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    int scWidth = manager.getDefaultDisplay().getWidth();
    if (click2ScrollPage) {//itempage
        //?item???
        if (location[0] < 0 || location[0] + tabsContainer.getChildAt(position).getWidth() > scWidth) {
            newScrollX -= scrollOffset;
            scrollTo(newScrollX, 0);
            //System.out.println("click2ScrollPage scrollTo x="+newScrollX);
        }
    } else {
        if (position > 0 || offset > 0) {
            newScrollX -= scrollOffset;
        }

        if (newScrollX != lastScrollX) {
            lastScrollX = newScrollX;
            scrollTo(newScrollX, 0);
            //            System.out.println("scrollTo x="+newScrollX);
        }
    }

}

From source file:com.taobao.luaview.view.widget.SuperSwipeRefreshLayout.java

@SuppressWarnings("deprecation")
public SuperSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    /**/*w w  w.ja  v  a 2  s  . c  o  m*/
     * getScaledTouchSlop????????
     */
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mHeaderViewWidth = (int) display.getWidth();
    mHeaderViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    createHeaderViewContainer();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    density = metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}

From source file:com.yozio.android.YozioHelper.java

private void setScreenInfo() {
    try {/* w  ww.jav  a  2  s  .  c o m*/
        // This is a backwards compatibility fix for Android 1.5 which has no
        // display metric API.
        // If this is 1.6 or higher, then load the class, otherwise the class
        // never loads and
        // no crash occurs.
        if (Integer.parseInt(android.os.Build.VERSION.SDK) > 3) {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            windowManager.getDefaultDisplay().getMetrics(displayMetrics);
            Configuration configuration = context.getResources().getConfiguration();

            deviceScreenDensity = "" + displayMetrics.densityDpi;
            deviceScreenLayoutSize = "" + (configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);
        }
    } catch (Exception e) {
    }
}

From source file:com.sumavision.talktv2.widget.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);/*  ww w.j av a2 s . c  om*/
    setWillNotDraw(false);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    screenWidth = wm.getDefaultDisplay().getWidth();

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.sumavision.talktv2.ui.widget.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);/*from  w  w w. ja  v  a 2  s  .c  om*/
    setWillNotDraw(false);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    screenWidth = wm.getDefaultDisplay().getWidth();

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    //tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.uzmap.pkg.uzmodules.UIMediaScanner.UIMediaScanner.java

@UzJavascriptMethod
@SuppressWarnings("deprecation")
public void jsmethod_open(UZModuleContext moduleContext) {

    mMContext = moduleContext;//from  www  .  j  a va  2s.co m

    final ConfigInfo config = new ConfigInfo();
    if (!moduleContext.isNull("column")) {
        config.col = moduleContext.optInt("column");
        if (config.col == 0) {
            config.col = 4;
        }
    }

    if (!moduleContext.isNull("max")) {
        config.selectedMax = moduleContext.optInt("max");
    }

    if (!moduleContext.isNull("classify")) {
        config.classify = moduleContext.optBoolean("classify");
    }

    if (!moduleContext.isNull("type")) {
        config.filterType = moduleContext.optString("type");
    }

    if (!moduleContext.isNull("rotation")) {
        config.rotation = moduleContext.optBoolean("rotation");
    }

    /**
     * screen width
     */
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    int width = wm.getDefaultDisplay().getWidth();

    config.mark_size = UZCoreUtil.pixToDip(width / config.col / 3);

    if (!moduleContext.isNull("bounces")) {
        config.isBounces = moduleContext.optBoolean("bounces");
    }

    JSONObject scrollToBottomObj = moduleContext.optJSONObject("scrollToBottom");
    if (scrollToBottomObj != null && !scrollToBottomObj.isNull("intervalTime")) {
        config.intervalTime = scrollToBottomObj.optInt("intervalTime");
    }

    if (!moduleContext.isNull("exchange")) {
        config.exchange = moduleContext.optBoolean("exchange");
    }

    JSONObject sortObj = moduleContext.optJSONObject("sort");
    if (sortObj != null) {
        if (!sortObj.isNull("key")) {
            config.key = sortObj.optString("key");
        }
        if (!sortObj.isNull("order")) {
            config.order = sortObj.optString("order");
        }
    }

    JSONObject dataObj = moduleContext.optJSONObject("texts");
    if (dataObj != null) {
        if (!dataObj.isNull("stateText")) {
            config.navi_title = dataObj.optString("stateText");
        }
        if (!dataObj.isNull("cancelText")) {
            config.cancel_title = dataObj.optString("cancelText");
        }
        if (!dataObj.isNull("finishText")) {
            config.finish_title = dataObj.optString("finishText");
        }
    }

    JSONObject stylesObj = moduleContext.optJSONObject("styles");
    if (stylesObj != null) {
        // bg
        if (!stylesObj.isNull("bg")) {
            config.bgColor = UZUtility.parseCssColor(stylesObj.optString("bg"));
        }
        // mark
        JSONObject markObj = stylesObj.optJSONObject("mark");
        if (markObj != null) {
            if (!markObj.isNull("position")) {
                config.mark_position = markObj.optString("position");
            }
            if (!markObj.isNull("icon")) {
                config.mark_icon = makeRealPath(markObj.optString("icon"));
            }
            if (!markObj.isNull("size")) {
                config.mark_size = markObj.optInt("size");
            }
        }
        // nav
        JSONObject navObj = stylesObj.optJSONObject("nav");
        if (navObj != null) {
            if (!navObj.isNull("bg")) {
                Bitmap naviBgBitmap = getBitmap(makeRealPath(navObj.optString("bg")));
                if (naviBgBitmap != null) {
                    ConfigInfo.navBgBitmap = naviBgBitmap;
                } else {
                    config.navi_bg = UZUtility.parseCssColor(navObj.optString("bg"));
                }
            }

            if (!navObj.isNull("stateColor")) {
                config.navi_title_color = UZUtility.parseCssColor(navObj.optString("stateColor"));
            }

            if (!navObj.isNull("stateSize")) {
                config.navi_title_size = navObj.optInt("stateSize");
            }

            if (!navObj.isNull("cancleBg")) {
                Bitmap cancelBgBitmap = getBitmap(makeRealPath(navObj.optString("cancleBg")));
                if (cancelBgBitmap != null) {
                    ConfigInfo.cancelBgBitmap = getBitmap(makeRealPath(navObj.optString("cancleBg")));
                } else {
                    config.cancel_bg = UZUtility.parseCssColor(navObj.optString("cancleBg"));
                }
            }

            if (!navObj.isNull("cancelColor")) {
                config.cancel_title_color = UZUtility.parseCssColor(navObj.optString("cancelColor"));
            }

            if (!navObj.isNull("cancelSize")) {
                config.cancel_title_size = navObj.optInt("cancelSize");
            }

            // finish button setting
            if (!navObj.isNull("finishBg")) {
                Bitmap finishBgBitmap = getBitmap(makeRealPath(navObj.optString("finishBg")));
                if (finishBgBitmap != null) {
                    ConfigInfo.finishBgBitmap = finishBgBitmap;
                } else {
                    config.finish_bg = UZUtility.parseCssColor(navObj.optString("finishBg"));
                }
            }

            if (!navObj.isNull("finishColor")) {
                config.finish_title_color = UZUtility.parseCssColor(navObj.optString("finishColor"));
            }

            if (!navObj.isNull("finishSize")) {
                config.finish_title_size = navObj.optInt("finishSize");
            }
        }
    }

    Intent intent = new Intent();
    if (config.classify) {
        intent.setClass(getContext(), UzImgFileListActivity.class);
    } else {
        intent.setClass(getContext(), UzImgsActivity.class);
    }
    intent.putExtra(CONFIG_TAG, config);
    startActivityForResult(intent, REQUEST_CODE);
}

From source file:com.fheebiy.view.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);/*from   ww  w .j  a va  2 s.  c o  m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics metric = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(metric);
    displayWidth = metric.widthPixels; // ??

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.linkbubble.ui.BubbleFlowDraggable.java

@Override
public void onOrientationChanged() {
    clearTargetPos();/*from  ww w.  ja v  a2  s  .  c  o m*/

    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getSize(mTempSize);
    configure(mTempSize.x, mItemWidth, mItemHeight);
    updatePositions();
    updateScales(getScrollX());

    setExactPos(0, 0);
    if (null != mCurrentTab) {
        mCurrentTab.getContentView().onOrientationChanged();
    }
}