Android Open Source - ExampleApp Static Drawer






From Project

Back to project page ExampleApp.

License

The source code is released under:

Copyright (c) 2014, Altinn All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redis...

If you think the Android project ExampleApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.simonvt.menudrawer;
//  ww  w . jav a2s. c  o m
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

public class StaticDrawer extends MenuDrawer {

    public StaticDrawer(Context context) {
        super(context);
    }

    public StaticDrawer(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

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

    @Override
    protected void initDrawer(Context context, AttributeSet attrs, int defStyle) {
        super.initDrawer(context, attrs, defStyle);
        super.addView(mMenuContainer, -1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        super.addView(mContentContainer, -1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        mIsStatic = true;
    }

    @Override
    protected void drawOverlay(Canvas canvas) {
        // NO-OP
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        final int width = r - l;
        final int height = b - t;

        switch (mPosition) {
            case LEFT:
                mMenuContainer.layout(0, 0, mMenuSize, height);
                mContentContainer.layout(mMenuSize, 0, width, height);
                break;

            case RIGHT:
                mMenuContainer.layout(width - mMenuSize, 0, width, height);
                mContentContainer.layout(0, 0, width - mMenuSize, height);
                break;

            case TOP:
                mMenuContainer.layout(0, 0, width, mMenuSize);
                mContentContainer.layout(0, mMenuSize, width, height);
                break;

            case BOTTOM:
                mMenuContainer.layout(0, height - mMenuSize, width, height);
                mContentContainer.layout(0, 0, width, height - mMenuSize);
                break;
        }
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
        final int heightMode = MeasureSpec.getMode(heightMeasureSpec);

        if (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED) {
            throw new IllegalStateException("Must measure with an exact size");
        }

        final int width = MeasureSpec.getSize(widthMeasureSpec);
        final int height = MeasureSpec.getSize(heightMeasureSpec);

        switch (mPosition) {
            case LEFT:
            case RIGHT: {
                final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);

                final int menuWidth = mMenuSize;
                final int menuWidthMeasureSpec = MeasureSpec.makeMeasureSpec(menuWidth, MeasureSpec.EXACTLY);

                final int contentWidth = width - menuWidth;
                final int contentWidthMeasureSpec = MeasureSpec.makeMeasureSpec(contentWidth, MeasureSpec.EXACTLY);

                mContentContainer.measure(contentWidthMeasureSpec, childHeightMeasureSpec);
                mMenuContainer.measure(menuWidthMeasureSpec, childHeightMeasureSpec);
                break;
            }

            case TOP:
            case BOTTOM: {
                final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);

                final int menuHeight = mMenuSize;
                final int menuHeightMeasureSpec = MeasureSpec.makeMeasureSpec(menuHeight, MeasureSpec.EXACTLY);

                final int contentHeight = height - menuHeight;
                final int contentHeightMeasureSpec = MeasureSpec.makeMeasureSpec(contentHeight, MeasureSpec.EXACTLY);

                mContentContainer.measure(childWidthMeasureSpec, contentHeightMeasureSpec);
                mMenuContainer.measure(childWidthMeasureSpec, menuHeightMeasureSpec);
                break;
            }
        }

        setMeasuredDimension(width, height);
    }

    @Override
    public void toggleMenu(boolean animate) {
        // NO-OP
    }

    @Override
    public void openMenu(boolean animate) {
        // NO-OP
    }

    @Override
    public void closeMenu(boolean animate) {
        // NO-OP
    }

    @Override
    public boolean isMenuVisible() {
        return true;
    }

    @Override
    public void setMenuSize(int size) {
        mMenuSize = size;
        requestLayout();
        invalidate();
    }

    @Override
    public void setOffsetMenuEnabled(boolean offsetMenu) {
        // NO-OP
    }

    @Override
    public boolean getOffsetMenuEnabled() {
        return false;
    }

    @Override
    public void peekDrawer() {
        // NO-OP
    }

    @Override
    public void peekDrawer(long delay) {
        // NO-OP
    }

    @Override
    public void peekDrawer(long startDelay, long delay) {
        // NO-OP
    }

    @Override
    public void setHardwareLayerEnabled(boolean enabled) {
        // NO-OP
    }

    @Override
    public int getTouchMode() {
        return TOUCH_MODE_NONE;
    }

    @Override
    public void setTouchMode(int mode) {
        // NO-OP
    }

    @Override
    public void setTouchBezelSize(int size) {
        // NO-OP
    }

    @Override
    public int getTouchBezelSize() {
        return 0;
    }

    @Override
    public void setSlideDrawable(int drawableRes) {
        // NO-OP
    }

    @Override
    public void setSlideDrawable(Drawable drawable) {
        // NO-OP
    }

    @Override
    public void setupUpIndicator(Activity activity) {
        // NO-OP
    }

    @Override
    public void setDrawerIndicatorEnabled(boolean enabled) {
        // NO-OP
    }

    @Override
    public boolean isDrawerIndicatorEnabled() {
        return false;
    }
}




Java Source Code List

com.altinn.apps.fisher.AppContext.java
com.altinn.apps.fisher.CacheManager.java
com.altinn.apps.fisher.common.AppConstants.java
com.altinn.apps.fisher.common.IStatusMessage.java
com.altinn.apps.fisher.common.MenuItem.java
com.altinn.apps.fisher.common.StatusMessage.java
com.altinn.apps.fisher.db.DataBaseHelper.java
com.altinn.apps.fisher.db.FactoryDBHelper.java
com.altinn.apps.fisher.db.FishCategoryDBHelper.java
com.altinn.apps.fisher.db.FormDBHelper.java
com.altinn.apps.fisher.db.IDBHelper.java
com.altinn.apps.fisher.db.RegsDBHelper.java
com.altinn.apps.fisher.db.VesselDBHelper.java
com.altinn.apps.fisher.gps.CLocationProvider.java
com.altinn.apps.fisher.gps.ILocationUpdateListner.java
com.altinn.apps.fisher.models.CaughtInfoData.java
com.altinn.apps.fisher.models.InfoData.java
com.altinn.apps.fisher.models.ReportInfoData.java
com.altinn.apps.fisher.models.UserProfile.java
com.altinn.apps.fisher.net.AbstractWorkerTask.java
com.altinn.apps.fisher.net.CookieHelper.java
com.altinn.apps.fisher.net.IParser.java
com.altinn.apps.fisher.net.JSParser.java
com.altinn.apps.fisher.net.ParseManager.java
com.altinn.apps.fisher.net.TaskNotifier.java
com.altinn.apps.fisher.net.jsobj.AttachmentObj.java
com.altinn.apps.fisher.net.jsobj.FormObj.java
com.altinn.apps.fisher.net.jsobj.JSConstants.java
com.altinn.apps.fisher.net.jsobj.JsonObj.java
com.altinn.apps.fisher.net.jsobj.LinkItemObj.java
com.altinn.apps.fisher.net.jsobj.LinkObj.java
com.altinn.apps.fisher.net.jsobj.MessageObj.java
com.altinn.apps.fisher.net.jsobj.MessagesEmbedded.java
com.altinn.apps.fisher.net.jsobj.OrganisationObj.java
com.altinn.apps.fisher.net.tasks.LoginTask.java
com.altinn.apps.fisher.net.tasks.RefreshTokenTask.java
com.altinn.apps.fisher.net.tasks.SendReportTask.java
com.altinn.apps.fisher.net.tasks.UserProfileTask.java
com.altinn.apps.fisher.settings.FactoryDetails.java
com.altinn.apps.fisher.settings.FishDetails.java
com.altinn.apps.fisher.settings.SettingItem.java
com.altinn.apps.fisher.settings.VesselsDetails.java
com.altinn.apps.fisher.ui.component.DurationTimePickDialog.java
com.altinn.apps.fisher.ui.component.RAutoCompleteTextView.java
com.altinn.apps.fisher.ui.component.RButton.java
com.altinn.apps.fisher.ui.component.REditText.java
com.altinn.apps.fisher.ui.component.RTextView.java
com.altinn.apps.fisher.ui.screen.BaseActivity.java
com.altinn.apps.fisher.ui.screen.BrowserActivity.java
com.altinn.apps.fisher.ui.screen.FactoryDetailsActivity.java
com.altinn.apps.fisher.ui.screen.HomeActivity.java
com.altinn.apps.fisher.ui.screen.InformationActivity.java
com.altinn.apps.fisher.ui.screen.MenuNavigationActivity.java
com.altinn.apps.fisher.ui.screen.ReportActivity.java
com.altinn.apps.fisher.ui.screen.ReportReceivedFishActivity.java
com.altinn.apps.fisher.ui.screen.ReportSendDetailActivity.java
com.altinn.apps.fisher.ui.screen.SplashActivity.java
com.altinn.apps.fisher.ui.screen.UserProfileActivity.java
com.altinn.apps.fisher.utils.PreferenceUtils.java
com.altinn.apps.fisher.utils.Utils.java
net.simonvt.menudrawer.BuildLayerFrameLayout.java
net.simonvt.menudrawer.ColorDrawable.java
net.simonvt.menudrawer.DraggableDrawer.java
net.simonvt.menudrawer.FloatScroller.java
net.simonvt.menudrawer.MenuDrawer.java
net.simonvt.menudrawer.NoClickThroughFrameLayout.java
net.simonvt.menudrawer.OverlayDrawer.java
net.simonvt.menudrawer.PeekInterpolator.java
net.simonvt.menudrawer.Position.java
net.simonvt.menudrawer.Scroller.java
net.simonvt.menudrawer.SinusoidalInterpolator.java
net.simonvt.menudrawer.SlideDrawable.java
net.simonvt.menudrawer.SlidingDrawer.java
net.simonvt.menudrawer.SmoothInterpolator.java
net.simonvt.menudrawer.StaticDrawer.java
net.simonvt.menudrawer.ViewHelper.java
net.simonvt.menudrawer.compat.ActionBarHelperCompat.java
net.simonvt.menudrawer.compat.ActionBarHelperNative.java
net.simonvt.menudrawer.compat.ActionBarHelper.java