AND-149
This commit is contained in:
parent
8ea4c84a29
commit
ce427d2a0b
|
@ -1,5 +1,6 @@
|
|||
package org.joinmastodon.android.fragments.discover;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
@ -18,6 +19,7 @@ import org.joinmastodon.android.ui.DividerItemDecoration;
|
|||
import org.joinmastodon.android.ui.OutlineProviders;
|
||||
import org.joinmastodon.android.ui.drawables.BlurhashCrossfadeDrawable;
|
||||
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
|
||||
import org.joinmastodon.android.ui.utils.HorizontalScrollingTouchListener;
|
||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -81,6 +83,7 @@ public class DiscoverNewsFragment extends BaseRecyclerFragment<CardViewModel> im
|
|||
.exec(accountID);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
protected RecyclerView.Adapter getAdapter(){
|
||||
cardsList=new UsableRecyclerView(getActivity());
|
||||
|
@ -98,6 +101,7 @@ public class DiscoverNewsFragment extends BaseRecyclerFragment<CardViewModel> im
|
|||
});
|
||||
cardsList.setSelector(R.drawable.bg_rect_12dp_ripple);
|
||||
cardsList.setDrawSelectorOnTop(true);
|
||||
cardsList.setOnTouchListener(new HorizontalScrollingTouchListener(getActivity()));
|
||||
|
||||
mergeAdapter=new MergeRecyclerAdapter();
|
||||
bannerHelper.maybeAddBanner(list, mergeAdapter);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package org.joinmastodon.android.ui.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
public class HorizontalScrollingTouchListener implements View.OnTouchListener{
|
||||
private float downX, touchslop;
|
||||
private boolean didDisallow;
|
||||
|
||||
public HorizontalScrollingTouchListener(Context context){
|
||||
touchslop=ViewConfiguration.get(context).getScaledTouchSlop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent ev){
|
||||
if(ev.getAction()==MotionEvent.ACTION_DOWN){
|
||||
if(v.canScrollHorizontally(-1) || v.canScrollHorizontally(1)){
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
didDisallow=true;
|
||||
}else{
|
||||
didDisallow=false;
|
||||
}
|
||||
downX=ev.getX();
|
||||
}else if(didDisallow && ev.getAction()==MotionEvent.ACTION_MOVE){
|
||||
if(Math.abs(downX-ev.getX())>=touchslop){
|
||||
if(!v.canScrollHorizontally((int) (downX-ev.getX()))){
|
||||
didDisallow=false;
|
||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue