Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.5.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
6 changes: 3 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "com.michaelflisar.dragselectrecyclerview.demo"
Expand All @@ -22,8 +21,9 @@ android {

dependencies {

compile project(':library')
implementation project(':library')

compile "com.android.support:appcompat-v7:25.2.0"
implementation "com.android.support:appcompat-v7:25.2.0"
implementation "com.android.support:recyclerview-v7:25.2.0"

}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Mar 04 17:15:41 CET 2017
#Fri Feb 14 10:52:43 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
5 changes: 2 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ android {
else
{
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
Expand All @@ -37,7 +36,7 @@ android {
}

dependencies {
compile "com.android.support:support-core-ui:${versions.supportLib}"
implementation "com.android.support:support-core-ui:${versions.supportLib}"
// compile "com.android.support:appcompat-v7:${versions.supportLib}"
compile "com.android.support:recyclerview-v7:${versions.supportLib}"
implementation "com.android.support:recyclerview-v7:${versions.supportLib}"
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.michaelflisar.dragselectrecyclerview;

import android.content.Context;
import android.content.res.Resources;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ScrollerCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.LinearInterpolator;

/**
* Created by flisar on 24.01.2017.
Expand All @@ -28,13 +25,13 @@ public class DragSelectTouchListener implements RecyclerView.OnItemTouchListener

private OnDragSelectListener mSelectListener;
private RecyclerView mRecyclerView;
private ScrollerCompat mScroller;
private boolean mIsScrolling;
private Runnable mScrollRunnable = new Runnable()
{
@Override
public void run()
{
if (mScroller != null && mScroller.computeScrollOffset())
if (mIsScrolling)
{
scrollBy(mScrollDistance);
ViewCompat.postOnAnimation(mRecyclerView, mScrollRunnable);
Expand Down Expand Up @@ -214,27 +211,20 @@ public void startAutoScroll()
if (mRecyclerView == null)
return;

initScroller(mRecyclerView.getContext());
if (mScroller.isFinished())
if (!mIsScrolling)
{
mRecyclerView.removeCallbacks(mScrollRunnable);
mScroller.startScroll(0, mScroller.getCurrY(), 0, 5000, 100000);
mIsScrolling = true;
ViewCompat.postOnAnimation(mRecyclerView, mScrollRunnable);
}
}

private void initScroller(Context context)
{
if (mScroller == null)
mScroller = ScrollerCompat.create(context, new LinearInterpolator());
}

public void stopAutoScroll()
{
if (mScroller != null && !mScroller.isFinished())
if (mIsScrolling)
{
mRecyclerView.removeCallbacks(mScrollRunnable);
mScroller.abortAnimation();
mIsScrolling = false;
}
}

Expand Down