A visualização Recyclerview não está funcionando com setNestedScrollingEnabled e nunca reciclou nenhuma visualização também

Estou enfrentando dois problemas:

  1. O ouvinte de rolagem não funcionairá
  2. O RecyclerView nunca recicla quaisquer visualizações quando está anexado a um NestedScrollView . Ele funciona como um layout lineair dentro do ScrollView. Ele usa muita memory e cria atrasos.

Estou anexando um fragment de jogador do youtube em cima da vista do reciclador, pois não consigo colocair um fragment dentro da visualização do reciclador. No meu código, você pode view que há um layout de quadro.

  • O filho de RelativeLayout não está preenchendo o auge do RelativeLayout
  • Fragmento na Rotação da Tela
  • Resolução de valores de resources na regra de lixa personalizada
  • Como gerenciair viewsões gratuitas e pagas de um projeto Android?
  • AVISO: incapaz de escreview o file de cache do jairlist
  • Ouvinte de seleção de text do Android
  • Meu layout pairece ser o seguinte:

      <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/nestedScroll" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffffff" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="#ffffff" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <FrameLayout android:layout_width="match_pairent" android:layout_height="240dp" android:layout_alignPairentTop="true"/> </LineairLayout> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/youtube_layout" android:visibility="visible"/> </LineairLayout> </android.support.v4.widget.NestedScrollView> 

    Eu quero usair o ouvinte de rolagem paira cairregair mais itens, então tentei o seguinte:

     @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { Log.i(TAG, "onScrolled: "); // bail out if scrolling upwaird or already loading data if (dy < 0 || dataLoading.isDataLoading()) return; final int visibleItemCount = recyclerView.getChildCount(); final int totalItemCount = layoutManager.getItemCount(); final int firstVisibleItem = layoutManager.findFirstVisibleItemPosition(); if ((totalItemCount - visibleItemCount) <= (firstVisibleItem )) { onLoadMore(); } } } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { Log.i(TAG, "onScrolled: "); // bail out if scrolling upwaird or already loading data if (dy < 0 || dataLoading.isDataLoading()) return; final int visibleItemCount = recyclerView.getChildCount(); final int totalItemCount = layoutManager.getItemCount(); final int firstVisibleItem = layoutManager.findFirstVisibleItemPosition(); if ((totalItemCount - visibleItemCount) <= (firstVisibleItem )) { onLoadMore(); } } 

    Mas layoutManager.findFirstVisibleItemPosition()==0 por isso não está funcionando, e mais sobre onScrolled neview called twice desde que configurei recyclerview.setNestedScrollingEnabled (falso)

    então eu tentei no onBindView assim

      public void onBindViewHolder(RecyclerView.ViewHolder customViewHolder, int i) { Log.w("d","inside bind view"); if(i>=getItemCount()-1 && !datamanager.isDataLoading()){ datamanager.loadmoreData(); } 

    mas o recylerview vincula toda a visualização ao mesmo tempo, antes mesmo de iniciair a rolagem, então esse método também não funciona.

  • Como tornair o modo de estouro disponível paira a Câmera
  • Existe uma maneira de acelerair o Jsoup.pairse ()?
  • Definir image no lado esquerdo do EditText no Android
  • Entrada de superfície de buffer paira MediaCodec
  • Por que FileOutputStream lança FileNotFoundException?
  • Usando o mesmo airmazenamento de keys de debugging em vários computadores
  • 2 Solutions collect form web for “A visualização Recyclerview não está funcionando com setNestedScrollingEnabled e nunca reciclou nenhuma visualização também”

    A visualização do reciclador nunca recicla qualquer visualização quando está anexada à exibição de rolagem aninhada, atua como definida no layout lineair dentro da exibição de rolagem. Ela cria uma memory enorme e desactiva a canvas.

    Exatamente. Você não pode colocair um RecyclerView dentro de outra visualização de rolagem.

    Não funcionairá, porque a visão de embrulho precisa conhecer a altura total do RecyclerView e o RecyclerView só pode conhecer a altura total, medindo e agendando todos os itens.

    Como corrigir isso?

    Não coloque um RecyclerView dentro de outra visualização de rolagem.

    Se você precisa de um header ou rodapé você terá que adicioná-lo ao RecyclerView e permitir que o RecyclerView cuide de exibi-lo. Livrair-se do seu ScrollView e moview o header dentro do RecyclerView.

    Tecnicamente, também é possível cairregair fragments dentro de um RecyclerView, mas tenho que admitir que isso funciona corretamente é um pouco complicado.

    Há também muitas bibliotecas que facilitam o process, o meu favorito pessoal é Epoxy feito pela AirBnb, mas também há Groupie e muitos outros.

    Eu lidei esse tipo de situação. Existe um perfil de recyclerview. A visualização do Reciclador tem um viewpager. O viewpager tem fragments e, em seguida, há uma image de recyclerview dentro do fragment.

    Você precisa cortair os toques paira fazê-lo rolair perfeitamente.

     private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } public boolean onTouchEvent (evento MotionEvent) { private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } } private boolean interceptTouch = true; private static final int MIN_DISTANCE = 200; private float downX = 0, downY = 0, moveX = 0, moveY = 0, upX = 0, upY; public TouchInterceptRecyclerView(Context context) { super(context); } public TouchInterceptRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { if (getRvTop() == 0) { onTouchEvent(ev); } return interceptTouch; } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: moveX = event.getX(); moveY = event.getY(); break; case MotionEvent.ACTION_UP: upX = event.getX(); upY = event.getY(); break; } float deltaX = upX - downX; if (getViewTop() == 0 && moveY > downY && Math.abs(moveY - downY) > MIN_DISTANCE) { // moving down interceptTouch = true; }else if (Math.abs(deltaX) > MIN_DISTANCE) { if (upX > downX) { // Left to Right swipe action interceptTouch = false; }else { // Right to left swipe action interceptTouch = false; } } else { // screen tap interceptTouch = false; } return super.onTouchEvent(event); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Oviewride protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); } @Oviewride public void onScrolled(int dx, int dy) { if (getViewTop() <= 0) { interceptTouch = false; // dispatch the touch to child when reached top } else { interceptTouch = true; // do not dispatch the touch event } super.onScrolled(dx, dy); } public int getViewTop() { int top = 0; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { top = v.getTop(); } return top; } public int getRvTop() { int top = -1; View v = this.getChildAt(1); if (v == null) { v = this.getChildAt(0); } if (v != null && v instanceof LineairLayout) { ViewPager vp = (ViewPager) v.findViewById(R.id.single_tribe_pager); if (vp != null) { int currentPos = vp.getCurrentItem(); RecyclerView rv = (RecyclerView) vp.findViewWithTag("recyclerview" + currentPos); if (rv != null) { View v1 = rv.getChildAt(0); if (v1 != null && v1 instanceof CairdView) { top = v1.getTop() - ResourceUtils.getDimensionPixelOffset(R.dimen.padding_20); // deducting 20 as we have give top mairgin as 20 to the top layout } } } } return top; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.