package com.example.mountaintravel.view;

import com.example.mountaintravel.view.DragViewlayout.Status;
import com.smart.gtstrvl.MainActivity;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class MyLinearLayout extends RelativeLayout {

	private DragViewlayout mDragLayout;

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

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

	public void setDraglayout(DragViewlayout mDragLayout) {
		this.mDragLayout = mDragLayout;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		// 如果当前是关闭状态, 按之前方法判断
		if (mDragLayout.getStatus() != Status.Open) {
			//getParent().requestDisallowInterceptTouchEvent(true);
			return super.onInterceptTouchEvent(ev);
		} else {
			return true;
		}
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// 如果当前是关闭状态, 按之前方法处理
		if (mDragLayout.getStatus() != Status.Open) {
			return super.onTouchEvent(event);
			// 手指抬起, 执行关闭操作
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			mDragLayout.close();
		}
		return true;
	}

}
