Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PodcastSlidingUpPanelLayout.java « view « owncloudnewsreader « luhmer « de « java « main « src « News-Android-App - github.com/nextcloud/news-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 650869c42e71832bfb578ca2110a594770956111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package de.luhmer.owncloudnewsreader.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

import com.sothree.slidinguppanel.SlidingUpPanelLayout;

/**
 * Created by David on 21.06.2014.
 */
public class PodcastSlidingUpPanelLayout extends SlidingUpPanelLayout{
    public PodcastSlidingUpPanelLayout(Context context) {
        super(context);
    }

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

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

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return super.onInterceptTouchEvent(ev);

        //return isDragViewHit((int)ev.getX(), (int)ev.getY());
    }

    private View mDragView;
    private View mSlideableView;

    public void setSlideableView(View view) {
        this.mSlideableView = view;
    }

    @Override
    public void setDragView(View dragView) {
        this.mDragView = dragView;
        super.setDragView(dragView);
    }


    private boolean isDragViewHit(int x, int y) {



        //original implementation - only allow dragging on mDragView
        View v = isPanelExpanded() ? mDragView : mSlideableView;
        if (v == null) return false;
        int[] viewLocation = new int[2];
        v.getLocationOnScreen(viewLocation);
        int[] parentLocation = new int[2];
        this.getLocationOnScreen(parentLocation);
        int screenX = parentLocation[0] + x;
        int screenY = parentLocation[1] + y;
        return screenX >= viewLocation[0] && screenX < viewLocation[0] + v.getWidth() &&
                screenY >= viewLocation[1] && screenY < viewLocation[1] + v.getHeight();

    }
}