Open sikandercb opened 9 years ago
Landscape mode is not supported right now with ResizeTransformer. There is an issues requesting that feature.
thanks to reply sir can you please tell me how can i disable the dragging ...? mean setenable(false) or some thing like this. there should be function like this setDraggedToMinimizeEnabled(false)
Hi sikandercb, i did try disable draggable view with the solution: In draggable view, declare : private boolean isDisableDraggableView = false;
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if(isDisableDraggableView) return false; // -> add to this if (!isEnabled()) { return false; } }
@Override public boolean onTouchEvent(MotionEvent ev) { if(isDisableDraggableView) return false; // -> add to this int actionMasked = MotionEventCompat.getActionMasked(ev); }
and use it: disable : draggableView.setIsDisableDraggableView(true); draggableView.setEnable(false);
and enable draggableView.setIsDisableDraggableView(false); draggableView.setEnable(true);
Hi @DuongNTdev I see you already have a patch? Are you going to send a PR?
thanks i have already done this..:)
/*
import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.view.MotionEventCompat; import android.support.v4.view.ViewCompat; import android.support.v4.widget.ViewDragHelper; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.RelativeLayout; import com.github.pedrovgs.transformer.Transformer; import com.github.pedrovgs.transformer.TransformerFactory; import com.nineoldandroids.view.ViewHelper;
/**
@author Pedro Vicente Gómez Sánchez */ public class DraggableView extends RelativeLayout {
private static final int DEFAULT_SCALE_FACTOR = 2; private static final int DEFAULT_TOP_VIEW_MARGIN = 30; private static final int DEFAULT_TOP_VIEW_HEIGHT = -1; private static final float SLIDE_TOP = 0f; private static final float SLIDE_BOTTOM = 1f; private static final float MIN_SLIDE_OFFSET = 0.1f; private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT = true; private static final boolean DEFAULT_ENABLE_CLICK_TO_MAXIMIZE = false; private static final boolean DEFAULT_ENABLE_CLICK_TO_MINIMIZE = false; private static final boolean DEFAULT_ENABLE_TOUCH_LISTENER = true; private static final int MIN_SLIDING_DISTANCE_ON_CLICK = 10; private static final int ONE_HUNDRED = 100; private static final float SENSITIVITY = 1f; private static final boolean DEFAULT_TOP_VIEW_RESIZE = false; private static final int INVALID_POINTER = -1; s private int activePointerId = INVALID_POINTER; private float lastTouchActionDownXPosition;
private View dragView; private View secondView; private TypedArray attributes;
private FragmentManager fragmentManager; private ViewDragHelper viewDragHelper; private Transformer transformer;
private boolean enableHorizontalAlphaEffect; private boolean topViewResize; private boolean enableClickToMaximize; private boolean enableClickToMinimize; private boolean touchEnabled;
private DraggableListener listener;
public DraggableView(Context context) { super(context); }
public DraggableView(Context context, AttributeSet attrs) { super(context, attrs); initializeAttributes(attrs); }
public DraggableView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); initializeAttributes(attrs); }
//DuontNT : workaround issue can't disable draggable view private boolean isDisableDraggableView = false;
public boolean isDisableDraggableView() { return isDisableDraggableView; }
public void setIsDisableDraggableView(boolean isDisableDraggableView) { this.isDisableDraggableView = isDisableDraggableView; }
public void disableDraggableView(){ setIsDisableDraggableView(true); setEnabled(false); }
public void enableDraggableView(){ setIsDisableDraggableView(false); setEnabled(true); } //end DuontNT
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
private void analyzeTouchToMaximizeIfNeeded(MotionEvent ev, boolean isDragViewHit) { switch(ev.getAction()) { case MotionEvent.ACTION_DOWN: lastTouchActionDownXPosition = ev.getX(); break; case MotionEvent.ACTION_UP: float clickOffset = ev.getX() - lastTouchActionDownXPosition; if (shouldMaximizeOnClick(ev, clickOffset, isDragViewHit)) { if (isMinimized() && isClickToMaximizeEnabled()) { maximize(); } else if (isMaximized() && isClickToMinimizeEnabled()) { minimize(); } } break; default: break; } }
public boolean shouldMaximizeOnClick(MotionEvent ev, float deltaX, boolean isDragViewHit) { return (Math.abs(deltaX) < MIN_SLIDING_DISTANCE_ON_CLICK) && ev.getAction() != MotionEvent.ACTION_MOVE && isDragViewHit; }
/**
/**
/**
private void mapGUI(TypedArray attributes) { int dragViewId = attributes.getResourceId(R.styleable.draggable_view_top_view_id, R.id.drag_view); int secondViewId = attributes.getResourceId(R.styleable.draggable_view_bottom_view_id, R.id.second_view); dragView = findViewById(dragViewId); secondView = findViewById(secondViewId); }
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
public int getDraggedViewHeightPlusMarginTop() { return transformer.getMinHeightPlusMargin(); } }
I can't commit to your git because i dont' have permission
@DuongNTdev Please remove your comment, do a fork and implement anythink that you want, then, open a pull request.
this works
draggableView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mMediaController.dispatchTouchEvent(event); return true; }else{ return false; } } });
hi, how can i draggable view en-ability false lansdscape mode .