java - Android - cannot inherit from final GestureDetectorCompat -


i receive error "cannot inherit final gesturedetectorcompat" when change api version in gradle file. if use api 22 works fine if use api 23 i've got error, why?

here code: file clickitemtouchlistener.java

package com.ddfilms.dado.recyclerview.utils;  import android.content.context; import android.os.build; import android.support.v4.view.gesturedetectorcompat; import android.support.v4.view.motioneventcompat; import android.support.v7.widget.recyclerview; import android.support.v7.widget.recyclerview.onitemtouchlistener; import android.view.gesturedetector.simpleongesturelistener; import android.view.motionevent; import android.view.view;  abstract class clickitemtouchlistener implements onitemtouchlistener {     private static final string logtag = "clickitemtouchlistener";      private final gesturedetectorcompat mgesturedetector;      clickitemtouchlistener(recyclerview hostview) {         mgesturedetector = new itemclickgesturedetector(hostview.getcontext(),                 new itemclickgesturelistener(hostview));     }      private boolean isattachedtowindow(recyclerview hostview) {         if (build.version.sdk_int >= 19) {             return hostview.isattachedtowindow();         } else {             return (hostview.gethandler() != null);         }     }      private boolean hasadapter(recyclerview hostview) {         return (hostview.getadapter() != null);     }      @override     public boolean onintercepttouchevent(recyclerview recyclerview, motionevent event) {         if (!isattachedtowindow(recyclerview) || !hasadapter(recyclerview)) {             return false;         }          mgesturedetector.ontouchevent(event);         return false;     }      @override     public void ontouchevent(recyclerview recyclerview, motionevent event) {         // can silently track tap , and long presses silently         // intercepting touch events in host recyclerview.     }      abstract boolean performitemclick(recyclerview parent, view view, int position, long id);      abstract boolean performitemlongclick(recyclerview parent, view view, int position, long id);      private class itemclickgesturedetector extends gesturedetectorcompat {         private final itemclickgesturelistener mgesturelistener;          public itemclickgesturedetector(context context, itemclickgesturelistener listener) {             super(context, listener);             mgesturelistener = listener;         }          @override         public boolean ontouchevent(motionevent event) {             final boolean handled = super.ontouchevent(event);              final int action = event.getaction() & motioneventcompat.action_mask;             if (action == motionevent.action_up) {                 mgesturelistener.dispatchsingletapupifneeded(event);             }              return handled;         }     }      private class itemclickgesturelistener extends simpleongesturelistener {         private final recyclerview mhostview;         private view mtargetchild;          public itemclickgesturelistener(recyclerview hostview) {             mhostview = hostview;         }          public void dispatchsingletapupifneeded(motionevent event) {             // when long press hook called long press listener             // returns false, target child left around             // handled later. in case, should still treat gesture             // potential item click.             if (mtargetchild != null) {                 onsingletapup(event);             }         }          @override         public boolean ondown(motionevent event) {             final int x = (int) event.getx();             final int y = (int) event.gety();              mtargetchild = mhostview.findchildviewunder(x, y);             return (mtargetchild != null);         }          @override         public void onshowpress(motionevent event) {             if (mtargetchild != null) {                 mtargetchild.setpressed(true);             }         }          @override         public boolean onsingletapup(motionevent event) {             boolean handled = false;              if (mtargetchild != null) {                 mtargetchild.setpressed(false);                  final int position = mhostview.getchildposition(mtargetchild);                 final long id = mhostview.getadapter().getitemid(position);                 handled = performitemclick(mhostview, mtargetchild, position, id);                  mtargetchild = null;             }              return handled;         }          @override         public boolean onscroll(motionevent event, motionevent event2, float v, float v2) {             if (mtargetchild != null) {                 mtargetchild.setpressed(false);                 mtargetchild = null;                  return true;             }              return false;         }          @override         public void onlongpress(motionevent event) {             if (mtargetchild == null) {                 return;             }              final int position = mhostview.getchildposition(mtargetchild);             final long id = mhostview.getadapter().getitemid(position);             final boolean handled = performitemlongclick(mhostview, mtargetchild, position, id);              if (handled) {                 mtargetchild.setpressed(false);                 mtargetchild = null;             }         }     } } 

and gradle file:

apply plugin: 'com.android.application'  android {     compilesdkversion 22     buildtoolsversion "22.0.1"      defaultconfig {         applicationid "com.ddfilms.dado"         minsdkversion 16         targetsdkversion 22         versioncode 4         versionname "2.0"         multidexenabled true     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     }     dexoptions {         predexlibraries = false     } }  dependencies {     compile 'com.android.support:appcompat-v7:22.1.0'     compile 'com.android.support:cardview-v7:22.+'     compile 'com.squareup.picasso:picasso:2.5.+'     compile 'com.android.support:recyclerview-v7:22.1.0'     compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar:3.1.2'     compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'     compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')     compile files('libs/android-query-full.0.26.7.jar') } 

with code work, if change in gradle api 23 i've got error

...     compilesdkversion 23     buildtoolsversion "23.0.3" ...         targetsdkversion 23 ...     compile 'com.android.support:appcompat-v7:23.4.0'     compile 'com.android.support:cardview-v7:23.+'     compile 'com.squareup.picasso:picasso:2.5.+'     compile 'com.android.support:recyclerview-v7:23.4.0' ... 

can me? thanks

rewrite gesturedetectorcompat.java, delete final this:

public class gesturedetectorcompat {     .... } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -