Skip to content

Commit

Permalink
Migrate to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 authored Nov 21, 2018
2 parents 67708fc + b09840d commit a10ff7c
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 101 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.2.41'
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# 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.
# This option should only be used with decoupled projects. More details, visit
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 @@
#Tue Mar 20 20:09:11 PDT 2018
#Wed Nov 21 04:18:10 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
23 changes: 11 additions & 12 deletions indicator-fast-scroll/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ apply plugin: 'kotlin-android'
def libraryVersionName = '1.0.1'

android {
compileSdkVersion 27
compileSdkVersion 28

defaultConfig {
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName libraryVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
Expand All @@ -23,16 +23,15 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

def supportLibVersion = "27.1.1"
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation "com.android.support:support-dynamic-animation:$supportLibVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'androidx.core:core-ktx:0.3'
implementation 'androidx.core:core-ktx:1.0.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation "androidx.test.ext:junit:1.0.0"
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.reddit.indicatorfastscroll

import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.AppCompatTextView
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.reddit.indicatorfastscroll.test.R

class TestActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reddit.indicatorfastscroll

import android.support.v7.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView

internal class TestItemIndicatorsBuilder : ItemIndicatorsBuilder() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.reddit.indicatorfastscroll

import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import com.reddit.indicatorfastscroll.test.R
import org.hamcrest.Matchers.*
import org.junit.Assert.assertEquals
Expand Down
2 changes: 1 addition & 1 deletion indicator-fast-scroll/src/androidTest/res/layout/test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
>

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/test_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reddit.indicatorfastscroll

import android.support.annotation.DrawableRes
import androidx.annotation.DrawableRes

sealed class FastScrollItemIndicator {
data class Icon(@DrawableRes val iconRes: Int) : FastScrollItemIndicator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.GradientDrawable
import android.os.Build
import android.support.animation.DynamicAnimation
import android.support.animation.SpringAnimation
import android.support.animation.SpringForce
import android.support.constraint.ConstraintLayout
import android.support.v4.widget.TextViewCompat
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.res.getColorOrThrow
import androidx.core.content.res.getColorStateListOrThrow
import androidx.core.content.res.getResourceIdOrThrow
import androidx.core.content.res.use
import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible
import androidx.core.widget.TextViewCompat
import androidx.dynamicanimation.animation.DynamicAnimation
import androidx.dynamicanimation.animation.SpringAnimation
import androidx.dynamicanimation.animation.SpringForce

/**
* Companion view for a [fast scroller][FastScrollerView] that shows its currently pressed indicator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.os.Build
import android.support.v4.widget.TextViewCompat
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
import android.view.Gravity
import android.view.HapticFeedbackConstants
Expand All @@ -21,6 +19,8 @@ import androidx.core.content.res.getResourceIdOrThrow
import androidx.core.content.res.use
import androidx.core.view.children
import androidx.core.view.updatePadding
import androidx.core.widget.TextViewCompat
import androidx.recyclerview.widget.RecyclerView

typealias ItemIndicatorWithPosition = Pair<FastScrollItemIndicator, Int>

Expand Down Expand Up @@ -161,7 +161,10 @@ class FastScrollerView @JvmOverloads constructor(
this.useDefaultScroller = useDefaultScroller

updateItemIndicators()
recyclerView.adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
val adapter = recyclerView.adapter ?: throw IllegalArgumentException(
"RecyclerView needs to have an adapter before setting up its fast scroller."
)
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
override fun onChanged() {
postUpdateItemIndicators()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reddit.indicatorfastscroll

import android.support.v7.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView

internal open class ItemIndicatorsBuilder {

Expand All @@ -9,7 +9,7 @@ internal open class ItemIndicatorsBuilder {
getItemIndicator: (Int) -> FastScrollItemIndicator?,
showIndicator: ((FastScrollItemIndicator, Int, Int) -> Boolean)?
): List<ItemIndicatorWithPosition> {
return (0 until recyclerView.adapter.itemCount)
return (0 until recyclerView.adapter!!.itemCount)
.mapNotNull { position ->
getItemIndicator(position)?.let { ItemIndicatorWithPosition(it, position) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package com.reddit.indicatorfastscroll

import android.content.Context
import android.content.res.ColorStateList
import android.support.annotation.AttrRes
import android.support.annotation.DimenRes
import android.support.annotation.StyleRes
import android.support.v4.content.ContextCompat
import android.view.View
import androidx.annotation.AttrRes
import androidx.annotation.DimenRes
import androidx.annotation.StyleRes
import androidx.core.content.ContextCompat
import androidx.core.content.res.getResourceIdOrThrow
import androidx.core.content.res.use
import java.lang.IllegalArgumentException

internal fun Context.getColorFromAttr(@AttrRes attrId: Int): Int {
return ContextCompat.getColor(this, getResId(attrId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
tools:layout_height="match_parent"
tools:layout_width="@dimen/fast_scroller_thumb_size"
tools:parentTag="android.support.constraint.ConstraintLayout"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"
>

<FrameLayout
Expand Down
13 changes: 6 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
compileSdkVersion 28
defaultConfig {
applicationId "com.reddit.indicatorfastscroll.sample"
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -18,12 +18,11 @@ dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

def supportLibVersion = "27.1.1"
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'androidx.core:core-ktx:0.3'
implementation 'androidx.core:core-ktx:1.0.1'

implementation 'com.thedeanda:lorem:2.1'
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.reddit.indicatorfastscroll.sample

import android.graphics.Rect
import android.support.v7.widget.RecyclerView
import android.view.View
import androidx.recyclerview.widget.RecyclerView

class HeaderSpacerItemDecoration(
val getListItem: (Int) -> ListItem
Expand All @@ -12,9 +12,8 @@ class HeaderSpacerItemDecoration(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State?
state: RecyclerView.State
) {

val position = parent.getChildAdapterPosition(view)
val listItem = getListItem(position)
outRect.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package com.reddit.indicatorfastscroll.sample

import android.os.AsyncTask
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.view.ViewGroup
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.view.isGone
import com.reddit.indicatorfastscroll.sample.examples.*
import androidx.fragment.app.Fragment
import com.reddit.indicatorfastscroll.sample.examples.CustomScrollFragment
import com.reddit.indicatorfastscroll.sample.examples.FilteredFragment
import com.reddit.indicatorfastscroll.sample.examples.JustTextFragment
import com.reddit.indicatorfastscroll.sample.examples.StyledFragment
import com.reddit.indicatorfastscroll.sample.examples.TextWithIconFragment
import com.thedeanda.lorem.LoremIpsum

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.reddit.indicatorfastscroll.sample

import android.os.Build
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.view.updatePaddingRelative
import androidx.recyclerview.widget.RecyclerView

class SampleAdapter(
private val data: List<ListItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.reddit.indicatorfastscroll.sample.examples

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.LinearSmoothScroller
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
import com.reddit.indicatorfastscroll.FastScrollerThumbView
import com.reddit.indicatorfastscroll.FastScrollerView
import com.reddit.indicatorfastscroll.sample.ListItem
import com.reddit.indicatorfastscroll.sample.R
import com.reddit.indicatorfastscroll.sample.SAMPLE_DATA_TEXT
import com.reddit.indicatorfastscroll.sample.SampleAdapter
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
import com.reddit.indicatorfastscroll.FastScrollerThumbView
import com.reddit.indicatorfastscroll.FastScrollerView

class CustomScrollFragment : Fragment() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.reddit.indicatorfastscroll.sample.examples

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
import com.reddit.indicatorfastscroll.FastScrollerThumbView
import com.reddit.indicatorfastscroll.FastScrollerView
import com.reddit.indicatorfastscroll.sample.ListItem
import com.reddit.indicatorfastscroll.sample.R
import com.reddit.indicatorfastscroll.sample.SAMPLE_DATA_TEXT
import com.reddit.indicatorfastscroll.sample.SampleAdapter
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
import com.reddit.indicatorfastscroll.FastScrollerThumbView
import com.reddit.indicatorfastscroll.FastScrollerView

class FilteredFragment : Fragment() {

Expand Down
Loading

0 comments on commit a10ff7c

Please sign in to comment.