Android Open Source - mobilib Mbl Decor View






From Project

Back to project page mobilib.

License

The source code is released under:

MIT License

If you think the Android project mobilib 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 com.datdo.mobilib.base;
//from  ww  w.  j a  va 2s. c om
import com.datdo.mobilib.event.MblCommonEvents;
import com.datdo.mobilib.event.MblEventCenter;
import com.datdo.mobilib.util.MblUtils;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 * <pre>
 * Root view for activity. This view is mainly for detecting keyboard ON/OFF.
 * At {@link #onSizeChanged(int, int, int, int)}, if screen_size - view_size > 200dp, it is considered "Keyboard ON", otherwise it is "Keyboard OFF".
 * </pre>
 */
public class MblDecorView extends FrameLayout {
    private static final int KB_SHOWN = 1;
    private static final int KB_HIDDEN = 2;
    private static final int MIN_KEYBOARD_HEIGHT = MblUtils.pxFromDp(200);

    private static int sKeyboardStatus = 0;

    private int mMaxDisplaySize;
    private int mMinDisplaySize;
    private MblOnSizeChangedListener mOnSizeChangedListener;


    public MblDecorView(Context context) {
        super(context);
        init();
    }

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

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

    private void init() {
        int[] displaySizes = MblUtils.getDisplaySizes();
        mMaxDisplaySize = Math.max(displaySizes[0], displaySizes[1]);
        mMinDisplaySize = Math.min(displaySizes[0], displaySizes[1]);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if (mOnSizeChangedListener != null) {
            mOnSizeChangedListener.onSizeChanged(w, h, oldw, oldh);
        }

        if (getContext() != MblUtils.getCurrentContext()) {
            return;
        }

        int maxVisibleSize = Math.max(w, h);
        int minVisibleSize = Math.min(w, h);

        int maxDiff = Math.max(Math.abs(mMaxDisplaySize - maxVisibleSize), Math.abs(mMinDisplaySize - minVisibleSize));
        int kbStt = (maxDiff >= MIN_KEYBOARD_HEIGHT) ? KB_SHOWN : KB_HIDDEN;
        if (sKeyboardStatus != kbStt) {
            boolean isShown = kbStt == KB_SHOWN;
            sKeyboardStatus = kbStt;
            MblEventCenter.postEvent(this,
                    isShown ? MblCommonEvents.KEYBOARD_SHOWN : MblCommonEvents.KEYBOARD_HIDDEN);
        }
    }

    public static interface MblOnSizeChangedListener {
        public void onSizeChanged(int w, int h, int oldw, int oldh);
    }

    public void setOnSizeChangedListener(MblOnSizeChangedListener listener) {
        mOnSizeChangedListener = listener;
    }

    /**
     * @return whether keyboard is ON or OFF
     */
    public static boolean isKeyboardOn() {
        return sKeyboardStatus == KB_SHOWN;
    }
}




Java Source Code List

com.datdo.mobilib.api.DBBase.java
com.datdo.mobilib.api.DBHelper.java
com.datdo.mobilib.api.MblApi.java
com.datdo.mobilib.api.MblCache.java
com.datdo.mobilib.api.MblException.java
com.datdo.mobilib.api.MblSSLCertificateUtils.java
com.datdo.mobilib.base.MblActivityPlugin.java
com.datdo.mobilib.base.MblBaseActionBarActivity.java
com.datdo.mobilib.base.MblBaseActivity.java
com.datdo.mobilib.base.MblBaseAdapter.java
com.datdo.mobilib.base.MblBaseApplication.java
com.datdo.mobilib.base.MblBaseFragmentActivity.java
com.datdo.mobilib.base.MblDecorView.java
com.datdo.mobilib.base.MblNetworkStatusChangedReceiver.java
com.datdo.mobilib.event.MblCommonEvents.java
com.datdo.mobilib.event.MblEventCenter.java
com.datdo.mobilib.event.MblEventListener.java
com.datdo.mobilib.event.MblStrongEventListener.java
com.datdo.mobilib.event.MblWeakArrayList.java
com.datdo.mobilib.imageinput.MblAutoResizeSquareImageView.java
com.datdo.mobilib.imageinput.MblDataInputActivity.java
com.datdo.mobilib.imageinput.MblImageFolderScanner.java
com.datdo.mobilib.imageinput.MblImageInput.java
com.datdo.mobilib.imageinput.MblImagePickingScanEngine.java
com.datdo.mobilib.imageinput.MblPickImageActivity.java
com.datdo.mobilib.imageinput.MblPickImageGridViewAdapter.java
com.datdo.mobilib.imageinput.MblTakeImageActivity.java
com.datdo.mobilib.util.MblAsyncTask.java
com.datdo.mobilib.util.MblImageLoader.java
com.datdo.mobilib.util.MblLinkMovementMethod.java
com.datdo.mobilib.util.MblUrlRecognizer.java
com.datdo.mobilib.util.MblUtils.java
com.datdo.mobilib.widget.MblHorizontalViewPager.java
com.datdo.mobilib.widget.MblListViewWithScrollableItems.java
com.datdo.mobilib.widget.MblSequenceImage.java
com.datdo.mobilib.widget.MblSideMenuEnabledLayout.java
com.datdo.mobilib.widget.MblTouchImageView.java