X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2FRecyclerItemListener.java;h=2a266b937940b66b6aa39554db472b532e726822;hb=HEAD;hp=64427c2e2cf3b1d2d9c1dc6a5d529fed488d9e58;hpb=0bbdc409d82da31324c031f36607510f17d992e6;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/RecyclerItemListener.java b/app/src/main/java/net/ktnx/mobileledger/ui/RecyclerItemListener.java index 64427c2e..2a266b93 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/RecyclerItemListener.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/RecyclerItemListener.java @@ -1,43 +1,36 @@ /* - * Copyright © 2018 Damyan Ivanov. - * This file is part of Mobile-Ledger. - * Mobile-Ledger is free software: you can distribute it and/or modify it + * Copyright © 2020 Damyan Ivanov. + * This file is part of MoLe. + * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your opinion), any later version. * - * Mobile-Ledger is distributed in the hope that it will be useful, + * MoLe is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License terms for details. * * You should have received a copy of the GNU General Public License - * along with Mobile-Ledger. If not, see . + * along with MoLe. If not, see . */ package net.ktnx.mobileledger.ui; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.RecyclerView.OnItemTouchListener; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; -public class RecyclerItemListener implements OnItemTouchListener { - private RecyclerTouchListener listener; - private GestureDetector gd; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener; - public interface RecyclerTouchListener { - void onClickItem(View v, int position); - void onLongClickItem(View v, int position); - } +public class RecyclerItemListener implements OnItemTouchListener { + private final GestureDetector gd; public RecyclerItemListener(Context ctx, RecyclerView rv, RecyclerTouchListener listener) { - this.listener = listener; - this.gd = new GestureDetector( - ctx, new GestureDetector.SimpleOnGestureListener() { + this.gd = new GestureDetector(ctx, new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { View v = rv.findChildViewUnder(e.getX(), e.getY()); @@ -50,24 +43,26 @@ public class RecyclerItemListener implements OnItemTouchListener { listener.onClickItem(v, rv.getChildAdapterPosition(v)); return true; } - } - ); + }); } - @Override public boolean onInterceptTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) { View v = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY()); return (v != null) && gd.onTouchEvent(motionEvent); } - @Override public void onTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) { } - @Override public void onRequestDisallowInterceptTouchEvent(boolean b) { } + + public interface RecyclerTouchListener { + void onClickItem(View v, int position); + + void onLongClickItem(View v, int position); + } }