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
22 changes: 11 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ if (file('signing.gradle').exists()) {
ext {
okHttpVersion = '3.5.0'
retrofitVersion = '2.1.0'
supportLibraryVersion = '25.0.1'
supportLibraryVersion = '1.0.0-beta01'
}


android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 28
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.thoughtbot.tropos"
minSdkVersion 19
targetSdkVersion 25
targetSdkVersion 28
versionCode 6
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
Expand Down Expand Up @@ -75,9 +75,9 @@ dependencies {
compile 'org.jetbrains.anko:anko-common:0.8.3'

//android
compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
compile "com.android.support:design:${supportLibraryVersion}"
compile "com.android.support:recyclerview-v7:${supportLibraryVersion}"
compile "androidx.appcompat:appcompat:${supportLibraryVersion}"
compile "com.google.android.material:material:${supportLibraryVersion}"
compile "androidx.recyclerview:recyclerview:${supportLibraryVersion}"
compile 'com.google.android.gms:play-services-location:10.0.0'

//unit tests
Expand All @@ -90,9 +90,9 @@ dependencies {
testCompile "com.nhaarman:mockito-kotlin:1.1.0"

//automation tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
androidTestCompile 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
androidTestCompile 'androidx.test:runner:1.1.0-alpha4'
androidTestCompile "androidx.annotation:annotation:${supportLibraryVersion}"

//networking
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.thoughtbot.tropos.adapters

import android.support.v7.widget.GridLayoutManager.SpanSizeLookup
import android.support.v7.widget.RecyclerView.Adapter
import android.support.v7.widget.RecyclerView.ViewHolder
import androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import android.view.LayoutInflater.from
import android.view.ViewGroup
import com.thoughtbot.tropos.R.layout
Expand All @@ -25,21 +25,21 @@ class WeatherAdapter : Adapter<ViewHolder>() {
}
}

override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
when (viewType) {
layout.grid_item_current_weather -> {
val view = from(parent!!.context).inflate(layout.grid_item_current_weather, parent, false)
val view = from(parent.context).inflate(layout.grid_item_current_weather, parent, false)
return CurrentWeatherViewHolder(view)
}
layout.grid_item_forecast -> {
val view = from(parent!!.context).inflate(layout.grid_item_forecast, parent, false)
val view = from(parent.context).inflate(layout.grid_item_forecast, parent, false)
return ForecastViewHolder(view)
}
else -> throw IllegalArgumentException("$viewType is not a valid viewType")
}
}

override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
when (holder) {
is CurrentWeatherViewHolder -> weather?.let { holder.bind(it.today, it.yesterday) }
is ForecastViewHolder -> weather?.let { holder.bind(forecast(it, position)) }
Expand Down Expand Up @@ -68,4 +68,4 @@ class WeatherAdapter : Adapter<ViewHolder>() {
return weather.nextThreeDays[position - 1]
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.thoughtbot.tropos.commons

import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import com.thoughtbot.tropos.R
import uk.co.chrisjenx.calligraphy.CalligraphyConfig
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.thoughtbot.tropos.extensions
import android.content.Context
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.support.v4.content.ContextCompat
import androidx.core.content.ContextCompat

fun Context.hasPermission(permission: String): Boolean {
return ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.thoughtbot.tropos.extensions

import android.graphics.Color
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.SnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
Expand All @@ -24,6 +24,6 @@ fun String.colorSubString(subString: String, color: Int): SpannableStringBuilder
return stringBuilder
}

fun RecyclerView.attachSnapHelper(snapHelper: SnapHelper) {
fun androidx.recyclerview.widget.RecyclerView.attachSnapHelper(snapHelper: androidx.recyclerview.widget.SnapHelper) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be fully qualified, right? It makes it very noisy.

snapHelper.attachToRecyclerView(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.thoughtbot.tropos.permissions

import android.app.Activity
import android.content.pm.PackageManager
import android.support.v4.app.ActivityCompat
import androidx.core.app.ActivityCompat
import android.util.Log

fun Activity.getPermissionResults(permission: Permission, results: PermissionResults,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Point
import android.support.v4.content.ContextCompat
import androidx.core.content.ContextCompat
import android.util.AttributeSet
import android.view.View
import android.view.WindowManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import android.graphics.RectF
import android.graphics.Region.Op
import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.support.v4.content.ContextCompat
import androidx.core.content.ContextCompat
import com.thoughtbot.tropos.R

class ProgressCircleDrawable(context: Context) : Drawable(), Animatable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.thoughtbot.tropos.refresh

import android.content.Context
import android.graphics.drawable.Drawable
import android.support.v4.view.MotionEventCompat
import android.support.v4.view.NestedScrollingChildHelper
import android.support.v4.view.NestedScrollingParentHelper
import android.support.v4.view.ViewCompat
import androidx.core.view.MotionEventCompat
import androidx.core.view.NestedScrollingChildHelper
import androidx.core.view.NestedScrollingParentHelper
import androidx.core.view.ViewCompat
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
Expand All @@ -17,6 +17,7 @@ import android.view.animation.Animation
import android.view.animation.DecelerateInterpolator
import android.view.animation.Transformation
import android.widget.AbsListView
import java.lang.RuntimeException

class PullToRefreshLayout : ViewGroup, Animation.AnimationListener {

Expand Down Expand Up @@ -408,9 +409,9 @@ class PullToRefreshLayout : ViewGroup, Animation.AnimationListener {
override fun requestDisallowInterceptTouchEvent(b: Boolean) {
// if this is a List < L or another view that doesn't support nested
// scrolling, ignore this request so that the vertical scroll event
// isn't stolen
// isn't stole
if (android.os.Build.VERSION.SDK_INT < 21 && target is AbsListView || target != null && !ViewCompat.isNestedScrollingEnabled(
target)) {
target!!)) {
// Nope.
} else {
super.requestDisallowInterceptTouchEvent(b)
Expand Down Expand Up @@ -565,4 +566,4 @@ class PullToRefreshLayout : ViewGroup, Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {}

override fun onAnimationRepeat(animation: Animation?) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import android.graphics.Rect
import android.graphics.Region
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.support.v4.graphics.drawable.DrawableCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.thoughtbot.tropos.refresh.PullToRefreshLayout.ProgressStateListener
import com.thoughtbot.tropos.refresh.PullToRefreshLayout.ProgressStateListener.Companion.INACTIVE
import com.thoughtbot.tropos.refresh.PullToRefreshLayout.ProgressStateListener.Companion.PROGRESSING
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package com.thoughtbot.tropos.scrolling

import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.OnItemTouchListener
import android.support.v7.widget.StaggeredGridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import android.view.MotionEvent
import com.thoughtbot.tropos.scrolling.OverScroller.OverScrollDirection.END

class RecyclerViewScroller(override val view: RecyclerView) : Scroller {
class RecyclerViewScroller(override val view: androidx.recyclerview.widget.RecyclerView) : Scroller {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here


val layoutManager = view.layoutManager
val orientation = (layoutManager as? LinearLayoutManager)?.orientation ?: (layoutManager as StaggeredGridLayoutManager).orientation
val orientation = (layoutManager as? androidx.recyclerview.widget.LinearLayoutManager)?.orientation ?: (layoutManager as androidx.recyclerview.widget.StaggeredGridLayoutManager).orientation

init {
if (layoutManager !is LinearLayoutManager && layoutManager !is StaggeredGridLayoutManager) {
if (layoutManager !is androidx.recyclerview.widget.LinearLayoutManager && layoutManager !is androidx.recyclerview.widget.StaggeredGridLayoutManager) {
throw IllegalArgumentException("Recycler views with custom layout managers are not supported")
}
}

override fun isInAbsoluteStart(): Boolean {
if (orientation == LinearLayoutManager.HORIZONTAL) {
if (orientation == androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL) {
return !view.canScrollHorizontally(-1)
} else {
return !view.canScrollVertically(-1)
}
}

override fun isInAbsoluteEnd(): Boolean {
if (orientation == LinearLayoutManager.HORIZONTAL) {
if (orientation == androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL) {
return !view.canScrollHorizontally(1)
} else {
return !view.canScrollVertically(1)
Expand All @@ -36,17 +36,17 @@ class RecyclerViewScroller(override val view: RecyclerView) : Scroller {

}

fun RecyclerView.setVerticalEndOverScroller() {
fun androidx.recyclerview.widget.RecyclerView.setVerticalEndOverScroller() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here but I'm going to stop commenting it now :)

val overScroller = VerticalOverScroller(RecyclerViewScroller(this), END)
addOnItemTouchListener(object : OnItemTouchListener {
override fun onTouchEvent(rv: RecyclerView?, e: MotionEvent?) {
override fun onTouchEvent(rv: androidx.recyclerview.widget.RecyclerView, e: MotionEvent) {
overScroller.onTouch(rv, e)
}

override fun onInterceptTouchEvent(rv: RecyclerView?, e: MotionEvent?): Boolean {
override fun onInterceptTouchEvent(rv: androidx.recyclerview.widget.RecyclerView, e: MotionEvent): Boolean {
return overScroller.onTouch(rv, e)
}

override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
})
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.thoughtbot.tropos.scrolling

import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.LinearSnapHelper
import android.support.v7.widget.OrientationHelper
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.LayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.OrientationHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.LayoutManager
import android.view.View

/**
Expand All @@ -14,18 +14,18 @@ import android.view.View
* The implementation will snap to either completely show or hide the {@link ForecastViewHolder}
* depending on how much of it is visible on when user releases their touch
**/
class WeatherSnapHelper : LinearSnapHelper() {
class WeatherSnapHelper : androidx.recyclerview.widget.LinearSnapHelper() {

override fun findSnapView(layoutManager: LayoutManager?): View? {
layoutManager as LinearLayoutManager
layoutManager as androidx.recyclerview.widget.LinearLayoutManager

val lastChildIndex = layoutManager.findLastVisibleItemPosition()
if (lastChildIndex == RecyclerView.NO_POSITION) {
if (lastChildIndex == androidx.recyclerview.widget.RecyclerView.NO_POSITION) {
return null
}

val lastChild = layoutManager.findViewByPosition(lastChildIndex)
val orientationHelper = OrientationHelper.createVerticalHelper(layoutManager)
val orientationHelper = androidx.recyclerview.widget.OrientationHelper.createVerticalHelper(layoutManager)
val lastChildStart = orientationHelper.getDecoratedStart(lastChild)
val lastChildHeight = orientationHelper.getDecoratedMeasurement(lastChild)
val recyclerViewHeight = layoutManager.height
Expand All @@ -46,8 +46,8 @@ class WeatherSnapHelper : LinearSnapHelper() {
out[0] = 0

val targetViewType = layoutManager.getItemViewType(target)
val weatherViewType = layoutManager.getItemViewType(layoutManager.findViewByPosition(0))
val orientationHelper = OrientationHelper.createVerticalHelper(layoutManager)
val weatherViewType = layoutManager.getItemViewType(layoutManager.findViewByPosition(0)!!)
val orientationHelper = androidx.recyclerview.widget.OrientationHelper.createVerticalHelper(layoutManager)

if (targetViewType == weatherViewType) {
// snap to show weather
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.thoughtbot.tropos.settings

import android.content.Context
import android.os.Bundle
import android.support.v4.app.ActivityCompat
import android.support.v7.widget.Toolbar
import androidx.core.app.ActivityCompat
import androidx.appcompat.widget.Toolbar
import android.view.Menu
import android.view.MenuItem
import com.thoughtbot.tropos.R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.thoughtbot.tropos.splash
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.ActivityCompat.finishAfterTransition
import androidx.core.app.ActivityCompat.finishAfterTransition
import com.thoughtbot.tropos.R
import com.thoughtbot.tropos.commons.BaseActivity
import com.thoughtbot.tropos.permissions.getPermissionResults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.R.attr
import android.animation.Animator
import android.content.Context
import android.graphics.Point
import android.support.annotation.IdRes
import androidx.annotation.IdRes
import android.transition.TransitionValues
import android.transition.Visibility
import android.util.AttributeSet
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/kotlin/com/thoughtbot/tropos/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.thoughtbot.tropos.ui
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.ActivityOptionsCompat
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.Toolbar
import androidx.core.app.ActivityOptionsCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.appcompat.widget.Toolbar
import android.view.Menu
import android.view.MenuItem
import android.view.View
Expand Down Expand Up @@ -40,9 +40,11 @@ class MainActivity : BaseActivity(), MainView {
}

val presenter: MainPresenter by lazy { MainPresenter(this, intent) }
val recyclerView: RecyclerView by lazy { findViewById(R.id.recycler_view) as RecyclerView }
val recyclerView: androidx.recyclerview.widget.RecyclerView by lazy { findViewById(R.id.recycler_view) as androidx.recyclerview.widget.RecyclerView }
val adapter: WeatherAdapter by lazy { WeatherAdapter() }
val layoutManager: GridLayoutManager by lazy { GridLayoutManager(this, 3) }
val layoutManager: androidx.recyclerview.widget.GridLayoutManager by lazy {
androidx.recyclerview.widget.GridLayoutManager(this, 3)
}
val pullToRefreshLayout by lazy { find<PullToRefreshLayout>(R.id.pull_to_refresh) }

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -104,7 +106,7 @@ class MainActivity : BaseActivity(), MainView {
toolbar_last_update.text = it.toolbarViewModel.subtitle()

adapter.weather = it.weather
recyclerView.itemAnimator.isRunning {
recyclerView.itemAnimator?.isRunning {
pullToRefreshLayout.setRefreshing(false)
}

Expand Down
Loading