forked from LucasGGamerM/moshidon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes LucasGGamerM#100
- Loading branch information
Showing
5 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
mastodon/src/main/java/org/joinmastodon/android/ui/views/NestableScrollView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.joinmastodon.android.ui.views; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.util.Log; | ||
import android.view.MotionEvent; | ||
import android.view.ViewConfiguration; | ||
import android.widget.ScrollView; | ||
|
||
public class NestableScrollView extends ScrollView{ | ||
private float downY, touchslop; | ||
private boolean didDisallow; | ||
|
||
public NestableScrollView(Context context){ | ||
super(context); | ||
init(); | ||
} | ||
|
||
public NestableScrollView(Context context, AttributeSet attrs){ | ||
super(context, attrs); | ||
init(); | ||
} | ||
|
||
public NestableScrollView(Context context, AttributeSet attrs, int defStyleAttr){ | ||
super(context, attrs, defStyleAttr); | ||
init(); | ||
} | ||
|
||
public NestableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
init(); | ||
} | ||
|
||
private void init(){ | ||
touchslop=ViewConfiguration.get(getContext()).getScaledTouchSlop(); | ||
} | ||
|
||
@Override | ||
public boolean onTouchEvent(MotionEvent ev){ | ||
Log.d("111", "onTouchEvent: "+ev); | ||
if(ev.getAction()==MotionEvent.ACTION_DOWN){ | ||
if(canScrollVertically(-1) || canScrollVertically(1)){ | ||
getParent().requestDisallowInterceptTouchEvent(true); | ||
didDisallow=true; | ||
}else{ | ||
didDisallow=false; | ||
} | ||
downY=ev.getY(); | ||
}else if(didDisallow && ev.getAction()==MotionEvent.ACTION_MOVE){ | ||
if(Math.abs(downY-ev.getY())>=touchslop){ | ||
if(!canScrollVertically((int)(downY-ev.getY()))){ | ||
didDisallow=false; | ||
getParent().requestDisallowInterceptTouchEvent(false); | ||
} | ||
} | ||
} | ||
return super.onTouchEvent(ev); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="#D9000000"/> | ||
<corners android:radius="4dp"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters