Skip to content

Commit

Permalink
[REFACTOR] Migrate to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
André Sousa committed Oct 14, 2019
1 parent db9c066 commit 1fe3bae
Show file tree
Hide file tree
Showing 20 changed files with 342 additions and 209 deletions.
21 changes: 17 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
language: android

branches:
only:
- master

android:
components:
# Uncomment the lines below if you want to
Expand All @@ -7,12 +12,20 @@ android:
- tools

# The BuildTools version used by your project
- build-tools-28.0.3
- build-tools-29.0.2

# The SDK version used to compile your project
- android-28
- android-29

before_install:
- yes | sdkmanager "platforms;android-29"

before_script:
- chmod +x gradlew
- chmod +x gradlew
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- yes | sdkmanager --update
- yes | sdkmanager --licenses

script: "./gradlew build"
script: ./gradlew build assembleDebug
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -22,6 +22,15 @@ allprojects {
}
}

repositories {
flatDir {
dirs 'libs'
}

maven { url "https://nexus.wit-software.com/repository/releases/" }
maven { url "https://nexus.wit-software.com/repository/snapshots/" }
}

task clean(type: Delete) {
delete rootProject.buildDir
}
14 changes: 7 additions & 7 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
applicationId "com.andrefrsousa.supertoolbar.demo"
minSdkVersion 14
targetSdkVersion 28
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -17,8 +17,8 @@ android {
dependencies {
implementation project(path: ':lib')

implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:recyclerview-v7:28.0.0"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
6 changes: 3 additions & 3 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.andrefrsousa.supertoolbar.demo">
package="com.andrefrsousa.supertoolbar.demo">

<application
android:allowBackup="true"
Expand All @@ -12,9 +12,9 @@

<activity android:name=".DemoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
package com.andrefrsousa.supertoolbar.demo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.OnScrollListener
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import kotlinx.android.synthetic.main.activity_demo.*
import kotlinx.android.synthetic.main.list_item.view.*

Expand All @@ -46,14 +44,18 @@ class DemoActivity : AppCompatActivity() {
toolbar.title = getString(R.string.app_name)

listener = object : OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
override fun onScrolled(
recyclerView: androidx.recyclerview.widget.RecyclerView,
dx: Int,
dy: Int
) {
super.onScrolled(recyclerView, dx, dy)
toolbar.setElevationVisibility(recyclerView.canScrollVertically(-1))
}
}

items_list.run {
layoutManager = LinearLayoutManager(this@DemoActivity)
layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this@DemoActivity)
adapter = ItemsAdapter()
}
}
Expand All @@ -71,18 +73,20 @@ class DemoActivity : AppCompatActivity() {

// Inner classes

class ItemsAdapter : RecyclerView.Adapter<ItemsAdapter.ViewHolder>() {
class ItemsAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<ItemsAdapter.ViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(parent.inflate(R.layout.list_item))
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
ViewHolder(parent.inflate(R.layout.list_item))

override fun onBindViewHolder(p0: ViewHolder, p1: Int) {
}

override fun getItemCount() = 15

class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
class ViewHolder(view: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(view) {
val text: TextView = view.text_view
}
}

private fun ViewGroup.inflate(layoutId: Int) = LayoutInflater.from(context).inflate(layoutId, this, false)!!
private fun ViewGroup.inflate(layoutId: Int) =
LayoutInflater.from(context).inflate(layoutId, this, false)!!
6 changes: 3 additions & 3 deletions demo/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0"/>
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
Expand All @@ -30,5 +30,5 @@
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
android:strokeWidth="1" />
</vector>
Loading

0 comments on commit 1fe3bae

Please sign in to comment.