Android Open Source - LimeLight Manual Position Frame Layout






From Project

Back to project page LimeLight.

License

The source code is released under:

GNU General Public License

If you think the Android project LimeLight 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

/**
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0, as well as to the Additional Term regarding proper
 attribution. The latter is located in Term 11 of the License.
 If a copy of the MPL with the Additional Term was not distributed
 with this file, You can obtain one at http://static.fuzzhq.com/licenses/MPL
 *///  ww w .  j a  va2  s  .c  om

package com.fuzz.android.limelight.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

/**
 * @author Leonard Collins (Fuzz)
 */
public class ManualPositionFrameLayout extends FrameLayout {
    private boolean mDoSuperOnInterceptEvent;

    public ManualPositionFrameLayout(Context context) {
        super(context);
        setClipChildren(false);
    }

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

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

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return (mDoSuperOnInterceptEvent ? super.onInterceptTouchEvent(ev) : false);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        final int count = getChildCount();

        final int parentLeft = 0;
        final int parentRight = right - left;

        final int parentTop = 0;
        final int parentBottom = bottom - top;


        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                final MPLayoutParams lp = (MPLayoutParams) child.getLayoutParams();

                final int width = child.getMeasuredWidth();
                final int height = child.getMeasuredHeight();

                int childLeft = lp.absoluteXPosition;
                int childTop = lp.absoluteYPosition;

                int gravity = lp.gravity;
                if (gravity == -1) {
                    gravity = 0;
                } else if (gravity == Gravity.RIGHT) {
                    childLeft -= child.getMeasuredWidth();
                }

                child.layout(childLeft, childTop, childLeft + width, childTop + height);
            }
        }
    }

    protected void setDoSuperOnInterceptEvent(boolean touchBoolean) {
        mDoSuperOnInterceptEvent = touchBoolean;
    }


    public static class MPLayoutParams extends FrameLayout.LayoutParams {
        public int absoluteXPosition;
        public int absoluteYPosition;

        public MPLayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);
        }

        public MPLayoutParams(int width, int height) {
            super(width, height);
        }

        public MPLayoutParams(int width, int height, int gravity) {
            super(width, height, gravity);
        }

        public MPLayoutParams(ViewGroup.LayoutParams source) {
            super(source);
        }

        public MPLayoutParams(ViewGroup.MarginLayoutParams source) {
            super(source);
        }
    }

}




Java Source Code List

com.fuzz.android.limelight.LimeLight.java
com.fuzz.android.limelight.animation.AnimationHolder.java
com.fuzz.android.limelight.animation.LeftRightAnimation.java
com.fuzz.android.limelight.animation.UpDownAnimation.java
com.fuzz.android.limelight.automate.DrawerAutomator.java
com.fuzz.android.limelight.automate.ViewAutomator.java
com.fuzz.android.limelight.model.ActToViewHelper.java
com.fuzz.android.limelight.model.Act.java
com.fuzz.android.limelight.model.BaseChapter.java
com.fuzz.android.limelight.model.Book.java
com.fuzz.android.limelight.model.ChapterTransition.java
com.fuzz.android.limelight.model.Chapter.java
com.fuzz.android.limelight.model.ModelHelper.java
com.fuzz.android.limelight.model.Text.java
com.fuzz.android.limelight.model.Transition.java
com.fuzz.android.limelight.recorder.FontListAdapter.java
com.fuzz.android.limelight.recorder.RecorderClickListener.java
com.fuzz.android.limelight.recorder.RecorderWindow.java
com.fuzz.android.limelight.recorder.Recorder.java
com.fuzz.android.limelight.recorder.widget.color.ColorHueSlider.java
com.fuzz.android.limelight.recorder.widget.color.ColorPickDialog.java
com.fuzz.android.limelight.recorder.widget.color.ColorSquareView.java
com.fuzz.android.limelight.recorder.widget.color.OnColorChangedListener.java
com.fuzz.android.limelight.recorder.widget.drag.DragAndEditView.java
com.fuzz.android.limelight.recorder.widget.drag.EditorFrameLayout.java
com.fuzz.android.limelight.recorder.widget.drag.OffSetChangeListener.java
com.fuzz.android.limelight.recorder.widget.editor.ActEditor.java
com.fuzz.android.limelight.recorder.widget.editor.ActIconAdapter.java
com.fuzz.android.limelight.recorder.widget.editor.operations.BaseOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeAnimationOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeBackgroundColorOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeIconOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.SetTextColorOperation.java
com.fuzz.android.limelight.recorder.widget.filedialog.FileDirectoryDialog.java
com.fuzz.android.limelight.recorder.widget.filedialog.OnDirectorySelectListener.java
com.fuzz.android.limelight.recorder.widget.snap.SnapHelper.java
com.fuzz.android.limelight.recorder.widget.snap.SnapInfo.java
com.fuzz.android.limelight.text.PrimeTextWatcher.java
com.fuzz.android.limelight.util.FontUtils.java
com.fuzz.android.limelight.util.IOUtils.java
com.fuzz.android.limelight.util.JSONTool.java
com.fuzz.android.limelight.util.LimeLightLog.java
com.fuzz.android.limelight.util.ViewUtils.java
com.fuzz.android.limelight.view.PrimeClickListener.java
com.fuzz.android.limelight.widget.ManualPositionFrameLayout.java