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:com.example.sky.test.view.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   w  w  w. ja va  2  s  . c o  m
 *
 * @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.
 */
@CallSuper
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 ViewPager.LayoutParams lp = (ViewPager.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);
            }
        }
    }

    dispatchOnPageScrolled(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 ViewPager.LayoutParams lp = (ViewPager.LayoutParams) child.getLayoutParams();

            if (lp.isDecor)
                continue;
            final float transformPos = (float) (child.getLeft() - scrollX) / getClientWidth();
            mPageTransformer.transformPage(child, transformPos);
        }
    }

    mCalledSuper = true;
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

@Override
protected void onNewIntent(Intent intent) {
    long startTime = 0;
    if (DEBUG_RESUME_TIME) {
        startTime = System.currentTimeMillis();
    }//from w  w w. j a  v  a 2 s .  c  o  m
    super.onNewIntent(intent);

    // Close the menu
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        final boolean alreadyOnHome = mHasFocus && ((intent.getFlags()
                & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

        if (mLauncherDrawer.isDrawerOpen(Gravity.LEFT)) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mLauncherDrawer.closeDrawer(Gravity.LEFT);
                }
            }, 300);

            return;
        } else if (mLauncherDrawer.isDrawerOpen(Gravity.RIGHT)) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mLauncherDrawer.closeDrawer(Gravity.RIGHT);
                }
            }, 300);

            return;
        } else if (!isAllAppsVisible() && alreadyOnHome && mWorkspace.getCurrentPage() == 0
                && !mWorkspace.isInOverviewMode()) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    GestureUtils.runGesture(Launcher.this, Launcher.this, AppSettings.HOME_BUTTON);
                }
            }, 300);

            return;
        }

        // also will cancel mWaitingForResult.
        closeSystemDialogs();

        if (mWorkspace == null) {
            // Can be cases where mWorkspace is null, this prevents a NPE
            return;
        }
        Folder openFolder = mWorkspace.getOpenFolder();
        // In all these cases, only animate if we're already on home
        mWorkspace.exitWidgetResizeMode();

        boolean moveToDefaultScreen = mLauncherCallbacks != null
                ? mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent()
                : true;
        if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && openFolder == null
                && moveToDefaultScreen) {
            mWorkspace.moveToDefaultScreen(true);
        }

        closeFolder();
        exitSpringLoadedDragMode();

        // If we are already on home, then just animate back to the workspace,
        // otherwise, just wait until onResume to set the state back to Workspace
        if (alreadyOnHome) {
            showWorkspace(true);
        } else {
            mOnResumeState = State.WORKSPACE;
        }

        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }

        // Reset the apps view
        if (!alreadyOnHome && mAppsView != null) {
            mAppsView.scrollToTop();
        }

        // Reset the widgets view
        if (!alreadyOnHome && mWidgetsView != null) {
            mWidgetsView.scrollToTop();
        }

        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent();
        }
    }

    if (DEBUG_RESUME_TIME) {
        Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
    }

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onNewIntent(intent);
    }
}

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

private void SlideEngineLayout() {

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

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

    int left840 = (int) ((width / 100) * 65.625);

    final SharedPreferences settings = getSharedPreferences("mysettings", 0);
    final SharedPreferences.Editor editor = settings.edit();
    final Dialog enginedialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    enginedialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    enginedialog.setContentView(R.layout.enginedialoglayout);
    enginedialog.getWindow().getAttributes().windowAnimations = R.style.EngineDialogAnimation;
    enginedialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = enginedialog.getWindow().getAttributes();
    lp.dimAmount = 0f;//ww  w  .  ja v a2  s  . c om

    final CheckBox chkengine_hood = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_hood);
    final CheckBox chkengine_backHood = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_backHood);
    final CheckBox chkengine_underEngine = (CheckBox) enginedialog.getWindow()
            .findViewById(R.id.engine_underEngine);
    final CheckBox chkengine_brakeOil = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_brakeOil);
    final CheckBox chkengine_engineOil = (CheckBox) enginedialog.getWindow()
            .findViewById(R.id.engine_engineOil);
    final CheckBox chkengine_waterCoolant = (CheckBox) enginedialog.getWindow()
            .findViewById(R.id.engine_waterCoolant);
    final CheckBox chkengine_belt = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_belt);
    final CheckBox chkengine_gear = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_gear);
    final CheckBox chkengine_liquidLevel = (CheckBox) enginedialog.getWindow()
            .findViewById(R.id.engine_liquidLevel);
    final CheckBox chkengine_soundOut = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_soundOut);
    final CheckBox chkengine_soundIn = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_soundIn);

    // Change font
    chkengine_hood.setTypeface(type);
    chkengine_backHood.setTypeface(type);
    chkengine_underEngine.setTypeface(type);
    chkengine_brakeOil.setTypeface(type);
    chkengine_engineOil.setTypeface(type);
    chkengine_waterCoolant.setTypeface(type);
    chkengine_belt.setTypeface(type);
    chkengine_gear.setTypeface(type);
    chkengine_liquidLevel.setTypeface(type);
    chkengine_soundOut.setTypeface(type);
    chkengine_soundIn.setTypeface(type);

    enginedialog.setCanceledOnTouchOutside(true);
    enginedialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            headengine.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadengine = new TranslateAnimation(0, 0, 490, -500);
            slideoutheadengine.setDuration(300);
            slideoutheadengine.setFillAfter(true);
            headengine.startAnimation(slideoutheadengine);

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

            mp.put("engine_hood", chkengine_hood.isChecked());
            mp.put("engine_backHood", chkengine_backHood.isChecked());
            mp.put("engine_underEngine", chkengine_underEngine.isChecked());
            mp.put("engine_brakeOil", chkengine_brakeOil.isChecked());
            mp.put("engine_engineOil", chkengine_engineOil.isChecked());
            mp.put("engine_waterCoolant", chkengine_waterCoolant.isChecked());
            mp.put("engine_belt", chkengine_belt.isChecked());
            mp.put("engine_gear", chkengine_gear.isChecked());
            mp.put("engine_liquidLevel", chkengine_liquidLevel.isChecked());
            mp.put("engine_soundOut", chkengine_soundOut.isChecked());
            mp.put("engine_soundIn", chkengine_soundIn.isChecked());

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

        }
    });

    TextView engine = (TextView) enginedialog.getWindow().findViewById(R.id.Engine);
    engine.setTypeface(type);
    Button engineback = (Button) enginedialog.getWindow().findViewById(R.id.Engineback);
    engineback.setTypeface(type);
    engineback.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            enginedialog.dismiss();

            headengine.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadengine = new TranslateAnimation(0, 0, 490, -500);
            slideoutheadengine.setDuration(300);
            slideoutheadengine.setFillAfter(true);
            headengine.startAnimation(slideoutheadengine);

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

            mp.put("engine_hood", chkengine_hood.isChecked());
            mp.put("engine_backHood", chkengine_backHood.isChecked());
            mp.put("engine_underEngine", chkengine_underEngine.isChecked());
            mp.put("engine_brakeOil", chkengine_brakeOil.isChecked());
            mp.put("engine_engineOil", chkengine_engineOil.isChecked());
            mp.put("engine_waterCoolant", chkengine_waterCoolant.isChecked());
            mp.put("engine_belt", chkengine_belt.isChecked());
            mp.put("engine_gear", chkengine_gear.isChecked());
            mp.put("engine_liquidLevel", chkengine_liquidLevel.isChecked());
            mp.put("engine_soundOut", chkengine_soundOut.isChecked());
            mp.put("engine_soundIn", chkengine_soundIn.isChecked());

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

        }
    });

    chkengine_hood.setOnClickListener(new OnClickListener() {

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

    chkengine_backHood.setOnClickListener(new OnClickListener() {

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

    chkengine_underEngine.setOnClickListener(new OnClickListener() {

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

    chkengine_brakeOil.setOnClickListener(new OnClickListener() {

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

    chkengine_engineOil.setOnClickListener(new OnClickListener() {

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

    chkengine_waterCoolant.setOnClickListener(new OnClickListener() {

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

    chkengine_belt.setOnClickListener(new OnClickListener() {

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

    chkengine_gear.setOnClickListener(new OnClickListener() {

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

    chkengine_liquidLevel.setOnClickListener(new OnClickListener() {

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

    chkengine_soundOut.setOnClickListener(new OnClickListener() {

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

    chkengine_soundIn.setOnClickListener(new OnClickListener() {

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

    headengine.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheadengine = new TranslateAnimation(0, 0, 0, 490);
    slideheadengine.setDuration(300);
    slideheadengine.setFillAfter(true);
    headengine.startAnimation(slideheadengine);

    enginedialog.show();

    WindowManager.LayoutParams params = enginedialog.getWindow().getAttributes();
    params.y = 1;
    params.x = left840;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    enginedialog.getWindow().setAttributes(params);

    chkengine_hood.setChecked(load("engine_hood"));
    chkengine_backHood.setChecked(load("engine_backHood"));
    chkengine_underEngine.setChecked(load("engine_underEngine"));
    chkengine_brakeOil.setChecked(load("engine_brakeOil"));
    chkengine_engineOil.setChecked(load("engine_engineOil"));
    chkengine_waterCoolant.setChecked(load("engine_waterCoolant"));
    chkengine_belt.setChecked(load("engine_belt"));
    chkengine_gear.setChecked(load("engine_gear"));
    chkengine_liquidLevel.setChecked(load("engine_liquidLevel"));
    chkengine_soundOut.setChecked(load("engine_soundOut"));
    chkengine_soundIn.setChecked(load("engine_soundIn"));

}

From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java

/**
 * Draws discrete indicator of this SeekBarWidget at its current position updated by
 * {@link #updateDiscreteIndicatorPosition(int, int)} according to the current progress.
 *
 * @param canvas Canvas on which to draw discrete indicator's drawable.
 *//*from www. jav a 2  s. com*/
private void drawDiscreteIndicator(Canvas canvas) {
    if (mDiscreteIndicatorHeight == 0) {
        return;
    }
    // todo: draw according to LTR/RTL layout direction.
    mDiscreteIndicator.draw(canvas);

    // Draw current progress over indicator's graphics.
    final Rect indicatorBounds = mDiscreteIndicator.getBounds();
    final Paint textPaint = DISCRETE_INDICATOR_TEXT_INFO.paint;
    textPaint.getTextBounds("0", 0, 1, mRect);
    final float textSize = mRect.height();
    final Rect textPadding = DISCRETE_INDICATOR_TEXT_INFO.padding;
    final int absoluteTextGravity = WidgetGravity.getAbsoluteGravity(DISCRETE_INDICATOR_TEXT_INFO.gravity,
            ViewCompat.getLayoutDirection(this));

    final float textX, textY;
    // Resolve horizontal text position according to the requested gravity.
    switch (absoluteTextGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        textPaint.setTextAlign(Paint.Align.CENTER);
        textX = indicatorBounds.centerX();
        break;
    case Gravity.RIGHT:
        textPaint.setTextAlign(Paint.Align.RIGHT);
        textX = indicatorBounds.right - textPadding.right;
        break;
    case Gravity.LEFT:
    default:
        textPaint.setTextAlign(Paint.Align.LEFT);
        textX = indicatorBounds.left + textPadding.left;
        break;
    }
    // Resolve vertical text position according to the requested gravity.
    switch (absoluteTextGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.CENTER_VERTICAL:
        textY = indicatorBounds.centerY() + textSize / 2f;
        break;
    case Gravity.BOTTOM:
        textY = indicatorBounds.bottom - textPadding.bottom;
        break;
    case Gravity.TOP:
    default:
        textY = indicatorBounds.top + textSize + textPadding.top;
        break;
    }
    canvas.drawText(Integer.toString(getProgress()), textX, textY, textPaint);
}

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

public void fillContentsList() {
    this.listView.removeAllViews();
    NavPoints nps = rv.getNavPoints();//from  ww w.jav a 2  s  . co m
    for (int i = 0; i < nps.getSize(); i++) {
        NavPoint np = nps.getNavPoint(i);
        Button contentButton = new Button(this);
        contentButton.setBackgroundColor(Color.TRANSPARENT);
        contentButton.setText(np.text);
        Theme theme = getCurrentTheme();
        contentButton.setTextColor(theme.foregroundColor);
        contentButton.setTextSize(14);
        contentButton.setGravity(Gravity.LEFT);
        contentButton.setId(i);
        contentButton.setOnClickListener(contentDelegate);
        listView.addView(contentButton);
        debug("" + i + ":" + np.text);
    }
}

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

public void fillBookmarkList() {
    this.listView.removeAllViews();
    ArrayList<PageInformation> pis = sd.fetchBookmarks(this.bookCode);
    for (int i = 0; i < pis.size(); i++) {
        int textColor = Color.BLACK;
        Theme theme = getCurrentTheme();
        textColor = theme.foregroundColor;
        PageInformation pi = pis.get(i);
        SkyLayout item = new SkyLayout(this);
        setFrame(item, 0, 0, listBox.getWidth(), ps(80));
        ImageButton mark = this.makeImageButton(9898, R.drawable.bookmarked2x, ps(50), ps(90));
        item.addView(mark);//from w ww.j a v  a2 s  . com
        setFrame(mark, ps(10), ps(5), ps(60), ps(120));
        int ci = pi.chapterIndex;
        if (rv.isRTL()) {
            ci = rv.getNumberOfChapters() - ci - 1;
        }
        String chapterTitle = rv.getChapterTitle(ci);
        if (chapterTitle == null || chapterTitle.isEmpty())
            chapterTitle = "Chapter " + ci;
        TextView chapterLabel = this.makeLabel(9899, chapterTitle, Gravity.LEFT, 16, textColor);
        setFrame(chapterLabel, ps(80), ps(5), this.listBox.getWidth() - ps(80), ps(40));
        item.addView(chapterLabel);
        TextView dateLabel = this.makeLabel(9899, pi.datetime, Gravity.LEFT, 12, textColor);
        setFrame(dateLabel, this.listBox.getWidth() - ps(50 + 250), ps(48), this.listBox.getWidth() - ps(40),
                ps(40));
        View lineView = new View(this);
        lineView.setBackgroundColor(Color.LTGRAY);
        setFrame(lineView, 0, ps(79), this.listBox.getWidth(), ps(1));
        item.addView(dateLabel);
        item.addView(lineView);
        item.setSkyLayoutListener(bookmarkListDelegate);
        item.setId(pi.code);
        item.data = pi;

        Button deleteButton = new Button(this);
        GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { 0xffcf666e, 0xff671521 });
        grad.setStroke(ps(2), 0xff282828);
        deleteButton.setBackgroundDrawable(grad);
        deleteButton.setText(getString(R.string.delete));
        deleteButton.setTextSize(12);
        deleteButton.setTypeface(null, Typeface.BOLD);
        deleteButton.setTextColor(Color.WHITE);
        deleteButton.setId(pi.code);
        deleteButton.setVisibility(View.INVISIBLE);
        deleteButton.setVisibility(View.GONE);
        deleteButton.setOnClickListener(deleteBookmarkDelegate);
        int dw = ps(120);
        int dh = ps(50);
        setFrame(deleteButton, this.listView.getWidth() - dw, (ps(80) - dh) / 2, dw, dh);
        item.deleteControl = deleteButton;
        item.addView(deleteButton);

        this.listView.addView(item);
    }
}

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

public void fillHighlightList() {
    Theme theme = getCurrentTheme();/*  ww w. j ava 2  s  . co  m*/
    int textColor = theme.foregroundColor;
    this.listView.removeAllViews();
    Highlights highlights = sd.fetchAllHighlights(this.bookCode);
    for (int i = 0; i < highlights.getSize(); i++) {
        Highlight highlight = highlights.getHighlight(i);
        SkyLayout item = new SkyLayout(this);
        int ci = highlight.chapterIndex;
        if (rv.isRTL()) {
            ci = rv.getNumberOfChapters() - ci - 1;
        }
        String chapterTitle = rv.getChapterTitle(ci);
        if (chapterTitle == null || chapterTitle.isEmpty())
            chapterTitle = "Chapter " + ci;

        TextView chapterLabel = this.makeLabel(9899, chapterTitle, Gravity.LEFT, 16, textColor);
        setFrame(chapterLabel, ps(20), ps(5), this.listView.getWidth() - ps(20), ps(40));
        item.addView(chapterLabel);

        GradientDrawable textGrad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { getBrighterColor(highlight.color), getDarkerColor(highlight.color) });
        TextView textLabel = this.makeLabel(9899, highlight.text, Gravity.LEFT, 16, Color.BLACK);
        setFrame(textLabel, ps(20), ps(5 + 40 + 5), this.listView.getWidth() - ps(20), ps(70));
        textLabel.setBackgroundDrawable(textGrad);
        textLabel.getBackground().setAlpha(180);

        item.addView(textLabel);

        int noteHeight = 0;

        if (highlight.isNote && highlight.note != null && highlight.note.length() != 0
                && !highlight.note.equalsIgnoreCase("null")) {
            TextView noteLabel = this.makeLabel(9899, highlight.note, Gravity.LEFT, 16, Color.BLACK);
            noteLabel.setTextColor(getDarkerColor(highlight.color));
            noteHeight = 70;
            setFrame(noteLabel, ps(20), ps(5 + 40 + 5 + 70 + 5), this.listView.getWidth() - ps(20),
                    ps(noteHeight));
            item.addView(noteLabel);
        }

        TextView dateLabel = this.makeLabel(9899, highlight.datetime, Gravity.RIGHT, 12, textColor);
        int lw = this.listView.getWidth();
        setFrame(dateLabel, 0, ps(5 + 40 + 5 + 70 + 5 + noteHeight + 5), lw, ps(40));
        item.addView(dateLabel);

        int itemHeight = ps(5 + 40 + 5 + 90 + 5 + noteHeight + 5 + 15 + 5);

        View lineView = new View(this);
        lineView.setBackgroundColor(Color.LTGRAY);
        setFrame(lineView, 0, itemHeight - ps(1), this.listView.getWidth(), ps(1));
        item.addView(lineView);

        setFrame(item, 0, 0, listView.getWidth(), itemHeight);
        item.setSkyLayoutListener(highlightListDelegate);
        item.setId(highlight.code);
        item.data = highlight;

        Button deleteButton = new Button(this);
        GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { 0xffcf666e, 0xff671521 });
        grad.setStroke(ps(2), 0xff282828);
        deleteButton.setBackgroundDrawable(grad);
        deleteButton.setText(getString(R.string.delete));
        deleteButton.setTypeface(null, Typeface.BOLD);
        deleteButton.setTextColor(Color.WHITE);
        deleteButton.setTextSize(12);
        deleteButton.setId(highlight.code);
        deleteButton.setVisibility(View.INVISIBLE);
        deleteButton.setVisibility(View.GONE);
        deleteButton.setOnClickListener(deleteHighlightDelegate);
        int dw = ps(120);
        int dh = ps(50);
        setFrame(deleteButton, this.listView.getWidth() - dw, (itemHeight - dh) / 2, dw, dh);
        item.deleteControl = deleteButton;
        item.addView(deleteButton);

        this.listView.addView(item);
    }
}

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

private void SlideExteriorLayout() {
    final SharedPreferences settings = getSharedPreferences("mysettings", 0);
    final SharedPreferences.Editor editor = settings.edit();
    final Dialog exteriordialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    exteriordialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    exteriordialog.setContentView(R.layout.exteriordialoglayout);
    exteriordialog.getWindow().getAttributes().windowAnimations = R.style.ExteriorDialogAnimation;
    exteriordialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = exteriordialog.getWindow().getAttributes();
    lp.dimAmount = 0f;/*from  ww  w . jav  a  2s.  c o m*/

    final CheckBox chkoutside_color = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_color);
    final CheckBox chkoutside_window = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_window);
    final CheckBox chkoutside_doorHood = (CheckBox) exteriordialog.getWindow()
            .findViewById(R.id.outside_doorHood);
    final CheckBox chkoutside_jack = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_jack);
    final CheckBox chkoutside_wrench = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_wrench);
    final CheckBox chkoutside_tires = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_tires);
    final CheckBox chkoutside_light = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_light);
    final CheckBox chkoutside_seal = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_seal);
    final CheckBox chkoutside_tirePart = (CheckBox) exteriordialog.getWindow()
            .findViewById(R.id.outside_tirePart);

    // Change font
    chkoutside_color.setTypeface(type);
    chkoutside_window.setTypeface(type);
    chkoutside_doorHood.setTypeface(type);
    chkoutside_jack.setTypeface(type);
    chkoutside_wrench.setTypeface(type);
    chkoutside_tires.setTypeface(type);
    chkoutside_light.setTypeface(type);
    chkoutside_seal.setTypeface(type);
    chkoutside_tirePart.setTypeface(type);

    exteriordialog.setCanceledOnTouchOutside(true);
    exteriordialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            headexterior.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400);
            slideoutheadexterior.setDuration(500);
            slideoutheadexterior.setFillAfter(true);
            headexterior.startAnimation(slideoutheadexterior);

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

            mp.put("outside_color", chkoutside_color.isChecked());
            mp.put("outside_window", chkoutside_window.isChecked());
            mp.put("outside_doorHood", chkoutside_doorHood.isChecked());
            mp.put("outside_jack", chkoutside_jack.isChecked());
            mp.put("outside_wrench", chkoutside_wrench.isChecked());
            mp.put("outside_tires", chkoutside_tires.isChecked());
            mp.put("outside_light", chkoutside_light.isChecked());
            mp.put("outside_seal", chkoutside_seal.isChecked());
            mp.put("outside_tirePart", chkoutside_tirePart.isChecked());

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

        }
    });

    TextView exterior = (TextView) exteriordialog.getWindow().findViewById(R.id.Exterior);
    exterior.setTypeface(type);
    Button exteriorback = (Button) exteriordialog.getWindow().findViewById(R.id.Exteriorback);
    exteriorback.setTypeface(type);
    exteriorback.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            exteriordialog.dismiss();

            headexterior.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400);
            slideoutheadexterior.setDuration(500);
            slideoutheadexterior.setFillAfter(true);
            headexterior.startAnimation(slideoutheadexterior);

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

            mp.put("outside_color", chkoutside_color.isChecked());
            mp.put("outside_window", chkoutside_window.isChecked());
            mp.put("outside_doorHood", chkoutside_doorHood.isChecked());
            mp.put("outside_jack", chkoutside_jack.isChecked());
            mp.put("outside_wrench", chkoutside_wrench.isChecked());
            mp.put("outside_tires", chkoutside_tires.isChecked());
            mp.put("outside_light", chkoutside_light.isChecked());
            mp.put("outside_seal", chkoutside_seal.isChecked());
            mp.put("outside_tirePart", chkoutside_tirePart.isChecked());

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

        }
    });

    chkoutside_color.setOnClickListener(new OnClickListener() {

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

    chkoutside_window.setOnClickListener(new OnClickListener() {

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

    chkoutside_doorHood.setOnClickListener(new OnClickListener() {

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

    chkoutside_jack.setOnClickListener(new OnClickListener() {

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

    chkoutside_wrench.setOnClickListener(new OnClickListener() {

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

    chkoutside_tires.setOnClickListener(new OnClickListener() {

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

    chkoutside_light.setOnClickListener(new OnClickListener() {

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

    chkoutside_seal.setOnClickListener(new OnClickListener() {

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

    chkoutside_tirePart.setOnClickListener(new OnClickListener() {

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

    headexterior.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheadexterior = new TranslateAnimation(0, 0, 0, 380);
    slideheadexterior.setDuration(500);
    slideheadexterior.setFillAfter(true);
    headexterior.startAnimation(slideheadexterior);

    exteriordialog.show();

    WindowManager.LayoutParams params = exteriordialog.getWindow().getAttributes();
    params.y = 0;
    params.x = 60;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    exteriordialog.getWindow().setAttributes(params);

    chkoutside_color.setChecked(load("outside_color"));
    chkoutside_window.setChecked(load("outside_window"));
    chkoutside_doorHood.setChecked(load("outside_doorHood"));
    chkoutside_jack.setChecked(load("outside_jack"));
    chkoutside_wrench.setChecked(load("outside_wrench"));
    chkoutside_tires.setChecked(load("outside_tires"));
    chkoutside_light.setChecked(load("outside_light"));
    chkoutside_seal.setChecked(load("outside_seal"));
    chkoutside_tirePart.setChecked(load("outside_tirePart"));

}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

@Override
public void onBackPressed() {
    if (mLauncherDrawer.isDrawerOpen(Gravity.LEFT)) {
        mLauncherDrawer.closeDrawer(Gravity.LEFT);
    } else if (mLauncherDrawer.isDrawerOpen(Gravity.RIGHT)) {
        mLauncherDrawer.closeDrawer(Gravity.RIGHT);
    } else if (isAllAppsVisible()) {
        showWorkspace(true);/*  w w w. j  av  a2s  . c  o m*/
    } else if (isWidgetsViewVisible()) {
        showOverviewMode(true);
    } else if (mWorkspace.isInOverviewMode()) {
        showWorkspace(true);
    } else if (mWorkspace.getOpenFolder() != null) {
        Folder openFolder = mWorkspace.getOpenFolder();
        if (openFolder.isEditingName()) {
            openFolder.dismissEditingName();
        } else {
            closeFolder();
        }
    } else {
        // run the gesture for back button
        GestureUtils.runGesture(this, Launcher.this, AppSettings.BACK_BUTTON);
    }
}

From source file:com.bookkos.bircle.CaptureActivity.java

private void setBookRegistView() {
    int bookRegistRelativeLayout_width = displayWidth;
    int bookRegistRelativeLayout_height = displayHeight / 4;
    int bookRegistRelativeLayout_x = 0;
    int bookRegistRelativeLayout_y = displayHeight;
    bookRegistRelativeLayout.setTranslationX(bookRegistRelativeLayout_x);
    bookRegistRelativeLayout.setTranslationY(bookRegistRelativeLayout_y);
    bookRegistRelativeLayout.setLayoutParams(
            new FrameLayout.LayoutParams(bookRegistRelativeLayout_width, bookRegistRelativeLayout_height));

    int bookRegistLinearLayout_width = displayWidth;
    int bookRegistLinearLayout_height = bookRegistRelativeLayout_height / 3;
    bookRegistLinearLayout.setLayoutParams(
            new RelativeLayout.LayoutParams(bookRegistLinearLayout_width, bookRegistLinearLayout_height));
    RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) bookRegistLinearLayout
            .getLayoutParams();//from   w w  w  . j av a 2s. co  m
    params1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    bookRegistLinearLayout.setLayoutParams(params1);

    int bookRegistListViewLinearLayout_width = displayWidth;
    int bookRegistListViewLinearLayout_height = bookRegistRelativeLayout_height * 2 / 3;
    bookRegistListViewLinearLayout.setLayoutParams(new RelativeLayout.LayoutParams(
            bookRegistListViewLinearLayout_width, bookRegistListViewLinearLayout_height));
    RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) bookRegistListViewLinearLayout
            .getLayoutParams();
    params2.addRule(RelativeLayout.BELOW, R.id.book_regist_linear_layout);
    bookRegistListViewLinearLayout.setLayoutParams(params2);

    int bookRegistListView_width = bookRegistListViewLinearLayout_width;
    int bookRegistListView_height = bookRegistListViewLinearLayout_height;
    bookRegistListView.setLayoutParams(
            new LinearLayout.LayoutParams(bookRegistListView_width, bookRegistListView_height));
    bookRegistListView.setAdapter(bookListViewAdapter);

    int bookRegistTextView_width = displayWidth * 4 / 5;
    int bookRegistTextView_height = bookRegistLinearLayout_height;
    int bookRegistTextView_x = 0;
    int bookRegistTextView_y = displayHeight;
    bookRegistTextView.setLayoutParams(
            new LinearLayout.LayoutParams(bookRegistTextView_width, bookRegistTextView_height, Gravity.LEFT));
    bookRegistTextView.setText("??");
    bookRegistTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize - displayInch * 1.5f);

    int bookRegistCancelButton_width = displayWidth / 5;
    int bookRegistCancelButton_height = bookRegistLinearLayout_height;
    int bookRegistCancelButton_x = 0;
    int bookRegistCancelButton_y = displayHeight;
    bookRegistCancelButton.setLayoutParams(new LinearLayout.LayoutParams(bookRegistCancelButton_width,
            bookRegistCancelButton_height, Gravity.RIGHT));
    bookRegistCancelButton.setText("");
    bookRegistCancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize - displayInch * 1.5f);
    bookRegistCancelButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            animateTranslationY(bookRegistRelativeLayout, displayHeight - displayHeight / 4 - titleBarHeight,
                    displayHeight);
            arrayList.clear();
            bookListViewAdapter.clear();
            registButton.setEnabled(true);
            borrowReturnButton.setEnabled(true);
            registButton.setTextColor(Color.WHITE);
        }
    });
}