Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

In this page you can find the example usage for android.view Gravity LEFT.

Prototype

int LEFT

To view the source code for android.view Gravity LEFT.

Click Source Link

Document

Push object to the left of its container, not changing its size.

Usage

From source file:co.taqat.call.LinphoneActivity.java

public void initSideMenu() {
    sideMenu = (DrawerLayout) findViewById(R.id.side_menu);
    sideMenuItems = new ArrayList<String>();
    sideMenuItems.add(getResources().getString(R.string.menu_assistant));
    sideMenuItems.add(getResources().getString(R.string.menu_settings));
    if (getResources().getBoolean(R.bool.enable_in_app_purchase)) {
        sideMenuItems.add(getResources().getString(R.string.inapp));
    }/*w  ww .  ja v a2  s.c o  m*/
    sideMenuItems.add(getResources().getString(R.string.menu_about));
    sideMenuContent = (RelativeLayout) findViewById(R.id.side_menu_content);
    sideMenuItemList = (ListView) findViewById(R.id.item_list);
    menu = (ImageView) findViewById(R.id.side_menu_button);

    sideMenuItemList.setAdapter(new ArrayAdapter<String>(this, R.layout.side_menu_item_cell, sideMenuItems));
    sideMenuItemList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.menu_settings))) {
                LinphoneActivity.instance().displaySettings();
            }
            if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.menu_about))) {
                LinphoneActivity.instance().displayAbout();
            }
            if (sideMenuItemList.getAdapter().getItem(i).toString()
                    .equals(getString(R.string.menu_assistant))) {
                LinphoneActivity.instance().displayAssistant();
            }
            if (getResources().getBoolean(R.bool.enable_in_app_purchase)) {
                if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.inapp))) {
                    LinphoneActivity.instance().displayInapp();
                }
            }
            openOrCloseSideMenu(false);
        }
    });

    initAccounts();

    menu.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (sideMenu.isDrawerVisible(Gravity.LEFT)) {
                sideMenu.closeDrawer(sideMenuContent);
            } else {
                sideMenu.openDrawer(sideMenuContent);
            }
        }
    });

    quitLayout = (RelativeLayout) findViewById(R.id.side_menu_quit);
    quitLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            LinphoneActivity.instance().quit();
        }
    });
}

From source file:com.skytree.epubtest.BookViewActivity.java

public View makeResultItem(SearchResult sr, int mode) {
    int inlineColor = Color.rgb(133, 105, 75);
    int headColor = Color.rgb(94, 61, 34);
    int textColor = Color.rgb(50, 40, 40);

    SkyLayout view = new SkyLayout(this);
    int itemWidth = ps(370);
    int itemHeight = ps(190);

    this.setFrame(view, 0, 0, itemWidth, itemHeight);

    TextView chapterLabel = null;// w  w w  .  ja v a 2s . co  m
    TextView positionLabel = null;
    TextView textLabel = null;
    Button itemButton = null;
    itemButton = new Button(this);
    itemButton.setBackgroundColor(Color.TRANSPARENT);
    itemButton.setOnClickListener(listener);
    this.setFrame(itemButton, 0, 0, itemWidth, itemHeight);

    if (mode == 0) { // Normal case
        int ci = sr.chapterIndex;
        String chapterText = "";
        chapterText = sr.chapterTitle;
        String positionText = String.format("%d/%d", sr.pageIndex + 1, sr.numberOfPagesInChapter);
        if (chapterText == null || chapterText.isEmpty()) {
            chapterText = "Chapter " + ci;
        }
        if (sr.pageIndex < 0 || sr.numberOfPagesInChapter < 0) {
            positionText = "";
        }
        chapterLabel = this.makeLabel(3090, chapterText, Gravity.LEFT, 15, headColor);
        positionLabel = this.makeLabel(3091, positionText, Gravity.LEFT, 15, headColor);
        textLabel = this.makeLabel(3092, sr.text, Gravity.LEFT, 15, textColor);
        itemButton.setId(100000 + searchResults.size());
    } else if (mode == 1) { // Paused
        chapterLabel = this.makeLabel(3090, getString(R.string.searchmore) + "....", Gravity.CENTER, 18,
                headColor);
        //         positionLabel    = this.makeLabel(3091, String.format("%d/%d",sr.pageIndex+1,sr.numberOfPagesInChapter), Gravity.LEFT, 15, headColor);
        textLabel = this.makeLabel(3092, sr.numberOfSearched + " " + getString(R.string.searchfound) + ".",
                Gravity.CENTER, 16, textColor);
        itemButton.setId(3093);
    } else if (mode == 2) { // finished
        chapterLabel = this.makeLabel(3090, getString(R.string.searchfinished), Gravity.CENTER, 18, headColor);
        //         positionLabel    = this.makeLabel(3091, String.format("%d/%d",sr.pageIndex+1,sr.numberOfPagesInChapter), Gravity.LEFT, 15, headColor);
        textLabel = this.makeLabel(3092, sr.numberOfSearched + " " + getString(R.string.searchfound) + ".",
                Gravity.CENTER, 16, textColor);
        itemButton.setId(3094);
    }

    textLabel.setMaxLines(3);

    if (mode == 0) {
        this.setFrame(chapterLabel, ps(20), ps(20), ps(270), ps(30));
        this.setFrame(positionLabel, itemWidth - ps(85), ps(20), ps(70), ps(30));
        this.setFrame(textLabel, ps(20), ps(80), itemWidth - ps(40), itemHeight - ps(80 + 20));
    } else {
        this.setFrame(chapterLabel, ps(20), ps(20), ps(350), ps(40));
        //         this.setFrame(positionLabel, itemWidth-ps(80), ps(20),ps(70),ps(30));
        this.setFrame(textLabel, ps(20), ps(80), itemWidth - ps(40), itemHeight - ps(80 + 20));
    }

    view.addView(chapterLabel);
    if (mode == 0)
        view.addView(positionLabel);
    view.addView(textLabel);
    view.addView(itemButton);

    RectShape crs = new RectShape();
    SkyDrawable cd = new SkyDrawable(crs, Color.TRANSPARENT, inlineColor, 1);
    view.setBackgroundDrawable(cd);

    return view;
}

From source file:com.example.leelay.galleyviewpager.GalleyViewPager.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    final int count = getChildCount();
    int width = r - l;
    int height = b - t;
    int paddingLeft = getPaddingLeft();
    int paddingTop = getPaddingTop();
    int paddingRight = getPaddingRight();
    int paddingBottom = getPaddingBottom();
    final int scrollX = getScrollX();

    int decorCount = 0;

    // First pass - decor views. We need to do this in two passes so that
    // we have the proper offsets for non-decor views later.
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            int childLeft = 0;
            int childTop = 0;
            if (lp.isDecor) {
                final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
                final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
                switch (hgrav) {
                default:
                    childLeft = paddingLeft;
                    break;
                case Gravity.LEFT:
                    childLeft = paddingLeft;
                    paddingLeft += child.getMeasuredWidth();
                    break;
                case Gravity.CENTER_HORIZONTAL:
                    childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft);
                    break;
                case Gravity.RIGHT:
                    childLeft = width - paddingRight - child.getMeasuredWidth();
                    paddingRight += child.getMeasuredWidth();
                    break;
                }//from   w  w w . j av  a  2 s. c om
                switch (vgrav) {
                default:
                    childTop = paddingTop;
                    break;
                case Gravity.TOP:
                    childTop = paddingTop;
                    paddingTop += child.getMeasuredHeight();
                    break;
                case Gravity.CENTER_VERTICAL:
                    childTop = Math.max((height - child.getMeasuredHeight()) / 2, paddingTop);
                    break;
                case Gravity.BOTTOM:
                    childTop = height - paddingBottom - child.getMeasuredHeight();
                    paddingBottom += child.getMeasuredHeight();
                    break;
                }
                childLeft += scrollX;
                child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(),
                        childTop + child.getMeasuredHeight());
                decorCount++;
            }
        }
    }

    final int childWidth = (width - paddingLeft - paddingRight) - mEndWidth - mPageMargin;
    // Page views. Do this once we have the right padding offsets from above.
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            ItemInfo ii;
            if (!lp.isDecor && (ii = infoForChild(child)) != null) {
                int loff = (int) (childWidth * ii.offset);
                int childLeft = paddingLeft + loff;
                int childTop = paddingTop;
                if (lp.needsMeasure) {
                    // This was added during layout and needs measurement.
                    // Do it now that we know what we're working with.
                    lp.needsMeasure = false;
                    final int widthSpec = MeasureSpec.makeMeasureSpec((int) (childWidth * lp.widthFactor),
                            MeasureSpec.EXACTLY);
                    final int heightSpec = MeasureSpec
                            .makeMeasureSpec((int) (height - paddingTop - paddingBottom), MeasureSpec.EXACTLY);
                    child.measure(widthSpec, heightSpec);
                }
                if (DEBUG)
                    Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + ","
                            + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight());
                child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(),
                        childTop + child.getMeasuredHeight());
            }
        }
    }
    mTopPageBounds = paddingTop;
    mBottomPageBounds = height - paddingBottom;
    mDecorChildCount = decorCount;

    if (mFirstLayout) {
        scrollToItem(mCurItem, false, 0, false);
    }
    mFirstLayout = false;
}

From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

/**
 * Close the specified drawer view./*from   w  w  w.j  a  v  a  2 s .  com*/
 *
 * @param drawerView Drawer view to close
 * @param animate Whether closing of the drawer should be animated.
 */
public void closeDrawer(View drawerView, boolean animate) {
    if (!isDrawerView(drawerView)) {
        throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer");
    }

    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if (mFirstLayout) {
        lp.onScreen = 0.f;
        lp.openState = 0;
    } else if (animate) {
        lp.openState |= LayoutParams.FLAG_IS_CLOSING;

        if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) {
            mLeftDragger.smoothSlideViewTo(drawerView, -drawerView.getWidth(), drawerView.getTop());
        } else {
            mRightDragger.smoothSlideViewTo(drawerView, getWidth(), drawerView.getTop());
        }
    } else {
        moveDrawerToOffset(drawerView, 0.f);
        updateDrawerState(lp.gravity, STATE_IDLE, drawerView);
        drawerView.setVisibility(INVISIBLE);
    }
    invalidate();
}

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

private void SlidePowerLayout() {

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    float height = metrics.heightPixels;
    float width = metrics.widthPixels;

    int left500 = (int) ((width / 100) * 39);
    int top200 = (int) ((width / 100) * 15.7);

    final SharedPreferences settings = getSharedPreferences("mysettings", 0);
    final SharedPreferences.Editor editor = settings.edit();
    final Dialog powerdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    powerdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    powerdialog.setContentView(R.layout.powerdialoglayout);
    powerdialog.getWindow().getAttributes().windowAnimations = R.style.PowerDialogAnimation;
    powerdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = powerdialog.getWindow().getAttributes();
    lp.dimAmount = 0f;//  w w w  .  j  av  a  2 s  .com

    final CheckBox chkpower_headLight = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_headLight);
    final CheckBox chkpower_dim = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_dim);
    final CheckBox chkpower_highBeam = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_highBeam);
    final CheckBox chkpower_dashBoardLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_dashBoardLight);
    final CheckBox chkpower_cabinSeatLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_cabinSeatLight);
    final CheckBox chkpower_sideDoorLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_sideDoorLight);
    final CheckBox chkpower_turnSignal = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_turnSignal);
    final CheckBox chkpower_air = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_air);
    final CheckBox chkpower_thermometer = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_thermometer);
    final CheckBox chkpower_horn = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_horn);
    final CheckBox chkpower_wipe = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_wipe);
    final CheckBox chkpower_rainSensor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_rainSensor);
    final CheckBox chkpower_thirdBrakeLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_thirdBrakeLight);
    final CheckBox chkpower_antiFoggyBack = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_antiFoggyBack);
    final CheckBox chkpower_antiFoggySide = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_antiFoggySide);
    final CheckBox chkpower_steeringWheelTest = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_steeringWheelTest);
    final CheckBox chkpower_steeringWheelSet = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_steeringWheelSet);
    final CheckBox chkpower_carStereo = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_carStereo);
    final CheckBox chkpower_electronicWindow = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_electronicWindow);
    final CheckBox chkpower_sideMirror = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_sideMirror);
    final CheckBox chkpower_warnDoor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_warnDoor);
    final CheckBox chkpower_warnSeatBelt = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_warnSeatBelt);
    final CheckBox chkpower_warnHandBrake = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_warnHandBrake);
    final CheckBox chkpower_clock = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_clock);
    final CheckBox chkpower_remoteKey = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_remoteKey);
    final CheckBox chkpower_centralLock = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_centralLock);
    final CheckBox chkpower_transmissionPosition = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_transmissionPosition);

    // change font
    chkpower_headLight.setTypeface(type);
    chkpower_dim.setTypeface(type);
    chkpower_highBeam.setTypeface(type);
    chkpower_dashBoardLight.setTypeface(type);
    chkpower_cabinSeatLight.setTypeface(type);
    chkpower_sideDoorLight.setTypeface(type);
    chkpower_turnSignal.setTypeface(type);
    chkpower_air.setTypeface(type);
    chkpower_thermometer.setTypeface(type);
    chkpower_horn.setTypeface(type);
    chkpower_wipe.setTypeface(type);
    chkpower_rainSensor.setTypeface(type);
    chkpower_thirdBrakeLight.setTypeface(type);
    chkpower_antiFoggyBack.setTypeface(type);
    chkpower_antiFoggySide.setTypeface(type);
    chkpower_steeringWheelTest.setTypeface(type);
    chkpower_steeringWheelSet.setTypeface(type);
    chkpower_carStereo.setTypeface(type);
    chkpower_electronicWindow.setTypeface(type);
    chkpower_sideMirror.setTypeface(type);
    chkpower_warnDoor.setTypeface(type);
    chkpower_warnSeatBelt.setTypeface(type);
    chkpower_warnHandBrake.setTypeface(type);
    chkpower_clock.setTypeface(type);
    chkpower_remoteKey.setTypeface(type);
    chkpower_centralLock.setTypeface(type);
    chkpower_transmissionPosition.setTypeface(type);

    powerdialog.setCanceledOnTouchOutside(true);
    powerdialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            headpower.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800);
            slideoutheadpower.setDuration(500);
            slideoutheadpower.setFillAfter(true);
            headpower.startAnimation(slideoutheadpower);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("power_headLight", chkpower_headLight.isChecked());
            mp.put("power_dim", chkpower_dim.isChecked());
            mp.put("power_highBeam", chkpower_highBeam.isChecked());
            mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked());
            mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked());
            mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked());
            mp.put("power_turnSignal", chkpower_turnSignal.isChecked());
            mp.put("power_air", chkpower_air.isChecked());
            mp.put("power_thermometer", chkpower_thermometer.isChecked());
            mp.put("power_horn", chkpower_horn.isChecked());
            mp.put("power_wipe", chkpower_wipe.isChecked());
            mp.put("power_rainSensor", chkpower_rainSensor.isChecked());
            mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked());
            mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked());
            mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked());
            mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked());
            mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked());
            mp.put("power_carStereo", chkpower_carStereo.isChecked());
            mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked());
            mp.put("power_sideMirror", chkpower_sideMirror.isChecked());
            mp.put("power_warnDoor", chkpower_warnDoor.isChecked());
            mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked());
            mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked());
            mp.put("power_clock", chkpower_clock.isChecked());
            mp.put("power_remoteKey", chkpower_remoteKey.isChecked());
            mp.put("power_centralLock", chkpower_centralLock.isChecked());
            mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked());

            filterStore("power", mp);
            save(mp);

        }
    });

    TextView power = (TextView) powerdialog.getWindow().findViewById(R.id.Power);
    power.setTypeface(type);
    Button powerback = (Button) powerdialog.getWindow().findViewById(R.id.Powerback);
    powerback.setTypeface(type);
    powerback.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            powerdialog.dismiss();

            headpower.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800);
            slideoutheadpower.setDuration(500);
            slideoutheadpower.setFillAfter(true);
            headpower.startAnimation(slideoutheadpower);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("power_headLight", chkpower_headLight.isChecked());
            mp.put("power_dim", chkpower_dim.isChecked());
            mp.put("power_highBeam", chkpower_highBeam.isChecked());
            mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked());
            mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked());
            mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked());
            mp.put("power_turnSignal", chkpower_turnSignal.isChecked());
            mp.put("power_air", chkpower_air.isChecked());
            mp.put("power_thermometer", chkpower_thermometer.isChecked());
            mp.put("power_horn", chkpower_horn.isChecked());
            mp.put("power_wipe", chkpower_wipe.isChecked());
            mp.put("power_rainSensor", chkpower_rainSensor.isChecked());
            mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked());
            mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked());
            mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked());
            mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked());
            mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked());
            mp.put("power_carStereo", chkpower_carStereo.isChecked());
            mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked());
            mp.put("power_sideMirror", chkpower_sideMirror.isChecked());
            mp.put("power_warnDoor", chkpower_warnDoor.isChecked());
            mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked());
            mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked());
            mp.put("power_clock", chkpower_clock.isChecked());
            mp.put("power_remoteKey", chkpower_remoteKey.isChecked());
            mp.put("power_centralLock", chkpower_centralLock.isChecked());
            mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked());

            filterStore("power", mp);
            save(mp);

        }
    });

    chkpower_headLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_dim.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_highBeam.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_dashBoardLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_cabinSeatLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_sideDoorLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_turnSignal.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_air.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_thermometer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_horn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_wipe.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_rainSensor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_thirdBrakeLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_antiFoggyBack.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_antiFoggySide.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_steeringWheelTest.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_steeringWheelSet.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_carStereo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_electronicWindow.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_sideMirror.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_warnDoor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_warnSeatBelt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_warnHandBrake.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_clock.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_remoteKey.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_centralLock.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_transmissionPosition.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    headpower.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheadpower = new TranslateAnimation(0, 0, 800, 200);
    slideheadpower.setDuration(300);
    slideheadpower.setFillAfter(true);
    headpower.startAnimation(slideheadpower);

    powerdialog.show();
    WindowManager.LayoutParams params = powerdialog.getWindow().getAttributes();
    params.y = top200;
    params.x = left500;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    powerdialog.getWindow().setAttributes(params);

    isSaveCheckBox();

    chkpower_headLight.setChecked(load("power_headLight"));
    chkpower_dim.setChecked(load("power_dim"));
    chkpower_highBeam.setChecked(load("power_highBeam"));
    chkpower_dashBoardLight.setChecked(load("power_dashBoardLight"));
    chkpower_cabinSeatLight.setChecked(load("power_cabinSeatLight"));
    chkpower_sideDoorLight.setChecked(load("power_sideDoorLight"));
    chkpower_turnSignal.setChecked(load("power_turnSignal"));
    chkpower_air.setChecked(load("power_air"));
    chkpower_thermometer.setChecked(load("power_thermometer"));
    chkpower_horn.setChecked(load("power_horn"));
    chkpower_wipe.setChecked(load("power_wipe"));
    chkpower_rainSensor.setChecked(load("power_rainSensor"));
    chkpower_thirdBrakeLight.setChecked(load("power_thirdBrakeLight"));
    chkpower_antiFoggyBack.setChecked(load("power_antiFoggyBack"));
    chkpower_antiFoggySide.setChecked(load("power_antiFoggySide"));
    chkpower_steeringWheelTest.setChecked(load("power_steeringWheelTest"));
    chkpower_steeringWheelSet.setChecked(load("power_steeringWheelSet"));
    chkpower_carStereo.setChecked(load("power_carStereo"));
    chkpower_electronicWindow.setChecked(load("power_electronicWindow"));
    chkpower_sideMirror.setChecked(load("power_sideMirror"));
    chkpower_warnDoor.setChecked(load("power_warnDoor"));
    chkpower_warnSeatBelt.setChecked(load("power_warnSeatBelt"));
    chkpower_warnHandBrake.setChecked(load("power_warnHandBrake"));
    chkpower_clock.setChecked(load("power_clock"));
    chkpower_remoteKey.setChecked(load("power_remoteKey"));
    chkpower_centralLock.setChecked(load("power_centralLock"));
    chkpower_transmissionPosition.setChecked(load("power_transmissionPosition"));

}

From source file:com.jecelyin.editor.v2.widget.AnyDrawerLayout.java

void closeDrawers(boolean peekingOnly) {
    boolean needsInvalidate = false;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();

        if (!isDrawerView(child) || (peekingOnly && !lp.isPeeking)) {
            continue;
        }//from  www.  ja  v a  2s .  c  o m

        final int childWidth = child.getWidth();

        if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) {
            needsInvalidate |= mLeftDragger.smoothSlideViewTo(child, -childWidth, child.getTop());
        } else if (checkDrawerViewAbsoluteGravity(child, Gravity.RIGHT)) {
            needsInvalidate |= mRightDragger.smoothSlideViewTo(child, getWidth(), child.getTop());
        } else {
            needsInvalidate |= mBottomDragger.smoothSlideViewTo(child, child.getLeft(),
                    getHeight() - (int) (child.getHeight() * lp.onScreen));
        }

        lp.isPeeking = false;
    }

    mLeftCallback.removeCallbacks();
    mRightCallback.removeCallbacks();
    mBottomCallback.removeCallbacks();

    if (needsInvalidate) {
        invalidate();
    }
}

From source file:android.support.v7.widget.Toolbar.java

private int getChildHorizontalGravity(int gravity) {
    final int ld = ViewCompat.getLayoutDirection(this);
    final int absGrav = GravityCompat.getAbsoluteGravity(gravity, ld);
    final int hGrav = absGrav & Gravity.HORIZONTAL_GRAVITY_MASK;
    switch (hGrav) {
    case Gravity.LEFT:
    case Gravity.RIGHT:
    case Gravity.CENTER_HORIZONTAL:
        return hGrav;
    default://from w w w  .  jav a2s .  com
        return ld == ViewCompat.LAYOUT_DIRECTION_RTL ? Gravity.RIGHT : Gravity.LEFT;
    }
}

From source file:com.dk.view.FolderDrawerLayout.java

private boolean createCache() {
    ViewGroup left = (ViewGroup) findDrawerWithGravity(Gravity.LEFT);

    if (left.getChildCount() > 0 && !(left.getChildAt(0) instanceof MeshImageView)) {
        mDrawingCache = drawViewToBitmap(mDrawingCache, left, left.getWidth(), left.getHeight(), 1,
                new BitmapDrawable());

        if (mCoreCalc == null)
            mCoreCalc = new CoreCalc(left.getWidth(), left.getHeight());
        return true;
    } else {//from  w  w w.  j  ava2 s  .  c  o  m
        return false;
    }

}

From source file:com.android.internal.widget.ViewPager.java

/**
 * This method will be invoked when the current page is scrolled, either as part
 * of a programmatically initiated smooth scroll or a user initiated touch scroll.
 * If you override this method you must call through to the superclass implementation
 * (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled
 * returns./*from   ww w  . j  a v a  2s.  c om*/
 *
 * @param position Position index of the first page currently being displayed.
 *                 Page position+1 will be visible if positionOffset is nonzero.
 * @param offset Value from [0, 1) indicating the offset from the page at position.
 * @param offsetPixels Value in pixels indicating the offset from position.
 */
protected void onPageScrolled(int position, float offset, int offsetPixels) {
    // Offset any decor views if needed - keep them on-screen at all times.
    if (mDecorChildCount > 0) {
        final int scrollX = getScrollX();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        final int width = getWidth();
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.isDecor)
                continue;

            final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
            int childLeft = 0;
            switch (hgrav) {
            default:
                childLeft = paddingLeft;
                break;
            case Gravity.LEFT:
                childLeft = paddingLeft;
                paddingLeft += child.getWidth();
                break;
            case Gravity.CENTER_HORIZONTAL:
                childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft);
                break;
            case Gravity.RIGHT:
                childLeft = width - paddingRight - child.getMeasuredWidth();
                paddingRight += child.getMeasuredWidth();
                break;
            }
            childLeft += scrollX;

            final int childOffset = childLeft - child.getLeft();
            if (childOffset != 0) {
                child.offsetLeftAndRight(childOffset);
            }
        }
    }

    if (mOnPageChangeListener != null) {
        mOnPageChangeListener.onPageScrolled(position, offset, offsetPixels);
    }
    if (mInternalPageChangeListener != null) {
        mInternalPageChangeListener.onPageScrolled(position, offset, offsetPixels);
    }

    if (mPageTransformer != null) {
        final int scrollX = getScrollX();
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();

            if (lp.isDecor)
                continue;

            final float transformPos = (float) (child.getLeft() - scrollX) / getPaddedWidth();
            mPageTransformer.transformPage(child, transformPos);
        }
    }

    mCalledSuper = true;
}

From source file:com.dk.view.FolderDrawerLayout.java

private void replaceView() {
    ViewGroup left = (ViewGroup) findDrawerWithGravity(Gravity.LEFT);
    mLeftCache = left.getChildAt(0);//  w ww .  ja va 2  s . co m
    left.removeAllViews();
    mMeshImageView = new MeshImageView(getContext());
    mMeshImageView.setImageBitmap(mDrawingCache);

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-1, -1);
    left.addView(mMeshImageView, params);
    if (isDrawerOpen(Gravity.LEFT)) {
        mCoreCalc.setDirection(Direction.LEFT);
    } else {
        mCoreCalc.setDirection(Direction.RIGHT);
    }

    mMeshImageView.setMeshVerts(mCoreCalc.createOffsetVerts(1, mInitialMotionY));

    // mMeshImageView.getViewTreeObserver().addOnPreDrawListener(new
    // OnPreDrawListener() {
    //
    // @Override
    // public boolean onPreDraw() {
    //
    //
    // return false;
    // }
    // });
}