Skip to content

Commit

Permalink
Migrate to AndroidX #12
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmigloz committed Nov 26, 2018
1 parent 42e7572 commit 8c63fbc
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 37 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Changelog drag-to-close

## `1.0` (09/07/18)
## `0.3.0` (26/11/18)

- Migrate to AndroidX #12 (only compatible with projects that have been migrated to androidx)

## `0.2.0` (09/07/18)

- Update gradle, compileSdkVersion, buildToolsVersion and targetSdkVersion
- Check if draggableContainer or draggableView is null #16

## `0.1` (24/06/17)
## `0.1.0` (24/06/17)

- Initial release
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.4.0-alpha04'
}
}

Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX
android.enableJetifier=true
android.useAndroidX=true
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 Jun 17 19:13:12 CEST 2017
#Fri Nov 23 16:45:22 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-rc-2-all.zip
14 changes: 8 additions & 6 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
targetSdkVersion 28
versionCode 3
versionName "0.3.0"
}
buildTypes {
release {
Expand All @@ -19,5 +19,7 @@ android {
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'androidx.core:core:1.0.1'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.customview:customview:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/
package com.davidmiguel.dragtoclose;

import android.support.v4.widget.ViewDragHelper;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.customview.widget.ViewDragHelper;

import static com.davidmiguel.dragtoclose.DragToClose.HEIGHT_THRESHOLD_TO_CLOSE;
import static com.davidmiguel.dragtoclose.DragToClose.SPEED_THRESHOLD_TO_CLOSE;

Expand Down Expand Up @@ -71,7 +73,7 @@ public void onViewDragStateChanged(int state) {
* based on the vertical position while the view is being vertical dragged.
*/
@Override
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
public void onViewPositionChanged(@NonNull View changedView, int left, int top, int dx, int dy) {
topBorderDraggableContainer = top;
dragToClose.changeDragViewViewAlpha();
}
Expand All @@ -83,7 +85,7 @@ public void onViewPositionChanged(View changedView, int left, int top, int dx, i
* Else if the top
*/
@Override
public void onViewReleased(View releasedChild, float xVel, float yVel) {
public void onViewReleased(@NonNull View releasedChild, float xVel, float yVel) {
// If view is in its original position or out of range, don't do anything
if (topBorderDraggableContainer == 0 || topBorderDraggableContainer >= dragToClose.getDraggableRange()) {
return;
Expand All @@ -108,15 +110,15 @@ public void onViewReleased(View releasedChild, float xVel, float yVel) {
* Sets the vertical draggable range.
*/
@Override
public int getViewVerticalDragRange(View child) {
public int getViewVerticalDragRange(@NonNull View child) {
return dragToClose.getDraggableRange();
}

/**
* Configures which is going to be the draggable container.
*/
@Override
public boolean tryCaptureView(View child, int pointerId) {
public boolean tryCaptureView(@NonNull View child, int pointerId) {
return child.equals(draggableContainer);
}

Expand All @@ -125,15 +127,15 @@ public boolean tryCaptureView(View child, int pointerId) {
* DragToClose padding must be taken into consideration.
*/
@Override
public int clampViewPositionHorizontal(View child, int left, int dx) {
public int clampViewPositionHorizontal(@NonNull View child, int left, int dx) {
return child.getLeft();
}

/**
* Defines clamped position for top border.
*/
@Override
public int clampViewPositionVertical(View child, int top, int dy) {
public int clampViewPositionVertical(@NonNull View child, int top, int dy) {
final int topBound = dragToClose.getPaddingTop(); // Top limit
final int bottomBound = dragToClose.getDraggableRange(); // Bottom limit
return Math.min(Math.max(top, topBound), bottomBound);
Expand Down
12 changes: 6 additions & 6 deletions lib/src/main/java/com/davidmiguel/dragtoclose/DragToClose.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.AttrRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import androidx.annotation.AttrRes;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.customview.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
Expand Down
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
applicationId "com.davidmiguel.dragtoclose"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
Expand All @@ -22,5 +22,5 @@ android {

dependencies {
implementation project(':lib')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.davidmiguel.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.davidmiguel.dragtoclose.DragListener;
import com.davidmiguel.dragtoclose.DragToClose;

import androidx.appcompat.app.AppCompatActivity;

/**
* In this example the activity is closed when the card is dragged out.
* Dragging events are logged.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.davidmiguel.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.davidmiguel.dragtoclose.DragToClose;

import androidx.appcompat.app.AppCompatActivity;

/**
* In this example the card can be dragged out card but the activity is not closed.
* A label allows to reopen the card.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.davidmiguel.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import androidx.appcompat.app.AppCompatActivity;

/**
* In this example, DragToClose is used inside a fragment and the user can
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.davidmiguel.sample;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -17,7 +18,7 @@ public Card3Fragment() {
// Required empty constructor
}

public static Card3Fragment newInstance() {
static Card3Fragment newInstance() {
return new Card3Fragment();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

@Override
Expand Down
1 change: 0 additions & 1 deletion sample/src/main/res/layout/fragment_card3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@
</LinearLayout>
</ScrollView>
</LinearLayout>

</com.davidmiguel.dragtoclose.DragToClose>

0 comments on commit 8c63fbc

Please sign in to comment.