Skip to content

Commit

Permalink
migrate to androidx
Browse files Browse the repository at this point in the history
  • Loading branch information
collin-livefront committed Aug 5, 2019
1 parent 5994455 commit 23615fa
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Add the JitPack repository to your root build.gradle
Add the dependency to your module's build.gradle
```
dependencies {
implementation 'com.github.cdflynn:turn-layout-manager:v1.2'
implementation 'com.github.cdflynn:turn-layout-manager:v1.3'
}
```

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':turn')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cdflynn.android.sample.turn;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.2'

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

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
Expand Down
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 @@
#Thu Nov 01 10:46:36 CDT 2018
#Mon Aug 05 12:23:57 CDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
10 changes: 5 additions & 5 deletions turn/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 4
versionName "1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -20,6 +20,6 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.support.annotation.Dimension;
import android.support.annotation.IntDef;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

Expand All @@ -33,15 +33,15 @@ public class TurnLayoutManager extends LinearLayoutManager {
}

/**
* Orientation as defined in {@link LinearLayoutManager}
* Orientation as defined in {@link RecyclerView}
*/
@IntDef(value = {
Orientation.VERTICAL,
Orientation.HORIZONTAL
})
public @interface Orientation {
int VERTICAL = LinearLayoutManager.VERTICAL;
int HORIZONTAL = LinearLayoutManager.HORIZONTAL;
int VERTICAL = RecyclerView.VERTICAL;
int HORIZONTAL = RecyclerView.HORIZONTAL;
}

@Gravity
Expand Down Expand Up @@ -117,7 +117,7 @@ public class TurnLayoutManager extends LinearLayoutManager {
*
* @param gravity The {@link Gravity} that will define where the anchor point is for this layout manager. The
* gravity point is the point around which items orbit.
* @param orientation The orientation as defined in {@link LinearLayoutManager}, and enforced by {@link Orientation}
* @param orientation The orientation as defined in {@link RecyclerView}, and enforced by {@link Orientation}
* @param radius The radius of the rotation angle, which helps define the curvature of the turn. This value
* will be clamped to {@code [0, MAX_INT]} inclusive.
* @param peekDistance The absolute extra distance from the {@link Gravity} edge after which this layout manager will start
Expand Down Expand Up @@ -231,7 +231,7 @@ private double resolveOffsetX(double radius, double viewY, Point center, int pee

/**
* Find the absolute vertical distance by which a view at {@code viewX} should offset to
* align with the circle {@code center} with {@ode radius}, account for {@code peekDistance}.
* align with the circle {@code center} with {@code radius}, account for {@code peekDistance}.
*/
private double resolveOffsetY(double radius, double viewX, Point center, int peekDistance) {
final double adjacent = Math.abs(center.x - viewX);
Expand Down Expand Up @@ -269,7 +269,7 @@ private void setChildOffsetsVertical(@Gravity int gravity,
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int xOffset = (int) resolveOffsetX(radius, child.getY() + child.getHeight() / 2, center, peekDistance);
final int xOffset = (int) resolveOffsetX(radius, child.getY() + child.getHeight() / 2.0f, center, peekDistance);
final int x = gravity == Gravity.START ? xOffset + getMarginStart(layoutParams)
: getWidth() - xOffset - child.getWidth() - getMarginStart(layoutParams);
child.layout(x, child.getTop(), child.getWidth() + x, child.getBottom());
Expand All @@ -292,7 +292,7 @@ private void setChildRotationVertical(@Gravity int gravity, View child, int radi
} else {
directionMult = childPastCenter ? 1 : -1;
}
final float opposite = Math.abs(child.getY() + child.getHeight() / 2 - center.y);
final float opposite = Math.abs(child.getY() + child.getHeight() / 2.0f - center.y);
child.setRotation((float) (directionMult * Math.toDegrees(Math.asin(opposite / radius))));
}

Expand All @@ -306,7 +306,7 @@ private void setChildOffsetsHorizontal(@Gravity int gravity,
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int yOffset = (int) resolveOffsetY(radius, child.getX() + child.getWidth() / 2, center, peekDistance);
final int yOffset = (int) resolveOffsetY(radius, child.getX() + child.getWidth() / 2.0f, center, peekDistance);
final int y = gravity == Gravity.START ? yOffset + getMarginStart(layoutParams)
: getHeight() - yOffset - child.getHeight() - getMarginStart(layoutParams);

Expand All @@ -330,7 +330,7 @@ private void setChildRotationHorizontal(@Gravity int gravity, View child, int ra
} else {
directionMult = childPastCenter ? -1 : 1;
}
final float opposite = Math.abs(child.getX() + child.getWidth() / 2 - center.x);
final float opposite = Math.abs(child.getX() + child.getWidth() / 2.0f - center.x);
child.setRotation((float) (directionMult * Math.toDegrees(Math.asin(opposite / radius))));
}

Expand Down

0 comments on commit 23615fa

Please sign in to comment.