Skip to content

Commit

Permalink
Modified to androidx
Browse files Browse the repository at this point in the history
  • Loading branch information
pokk committed Jun 21, 2018
1 parent b880174 commit 6f656f2
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 36 deletions.
11 changes: 5 additions & 6 deletions adaptiverecyclerview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -23,8 +22,8 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation "com.android.support:appcompat-v7:$android_version"
implementation "com.android.support:recyclerview-v7:$android_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha3'
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.devrapid.adaptiverecyclerview

import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView

/**
* An adaptive [RecyclerView] which accepts multiple type layout.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.devrapid.adaptiverecyclerview

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
* An abstract view holder.
*
* @author jieyi
* @since 9/6/17
*/
abstract class AdaptiveViewHolder<in VT: ViewTypeFactory, in M: IVisitable<VT>>(view: View):
abstract class AdaptiveViewHolder<in VT : ViewTypeFactory, in M : IVisitable<VT>>(view: View) :
RecyclerView.ViewHolder(view) {
protected val mContext: Context = view.context

Expand All @@ -22,4 +22,4 @@ abstract class AdaptiveViewHolder<in VT: ViewTypeFactory, in M: IVisitable<VT>>(
* @param adapter parent adapter.
*/
abstract fun initView(model: M, position: Int, adapter: Any)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.devrapid.adaptiverecyclerview

import android.support.annotation.LayoutRes
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.ViewHolder
import android.view.View
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder

/**
* A base interface of the multi-view type.
Expand All @@ -22,7 +22,7 @@ abstract class ViewTypeFactory {
* @param itemView a view after inflating.
* @return [RecyclerView.ViewHolder] of recycler view holder.
*/
fun createViewHolder(type: Int, itemView: View): RecyclerView.ViewHolder =
fun createViewHolder(type: Int, itemView: View): androidx.recyclerview.widget.RecyclerView.ViewHolder =
this.transformMap[type]?.second?.invoke(itemView) ?: error("You don't set the viewholder function.")

/**
Expand All @@ -32,4 +32,4 @@ abstract class ViewTypeFactory {
fun getLayoutResource(type: Int): Int = transformMap[type]?.first ?: error("You didn't set this view type.")

protected fun typeToInt(objectName: String): Int = objectName.sumBy(Char::toInt)
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.31'
ext.kotlin_version = '1.2.50'
ext.build_tool_version = '27.0.3'
ext.android_version = '27.1.1'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.android.tools.build:gradle:3.2.0-alpha18'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ proj_name=adaptiverecyclerview
proj_libname=AdaptiveRecyclerview
proj_group=com.devrapid.jieyi
proj_artifactid=adaptiverecyclerview
proj_version=0.0.8
proj_version=1.0.1
proj_description=Create an adaptive recycler view for each of type view.
proj_websiteurl=https://github.com/pokk/AdaptiveRecyclerView
proj_issuetrackerurl=https://github.com/pokk/AdaptiveRecyclerView/issues
Expand All @@ -33,4 +33,6 @@ license_url='http://www.apache.org/licenses/LICENSE-2.0.txt'
## Developer information
developer_id=pokk
developer_name=Jieyi Wu
developer_email=[email protected]
developer_email=[email protected]
android.useAndroidX=true
android.enableJetifier=true
13 changes: 6 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
defaultConfig {
applicationId "com.devrapid.adaptiverecyclerview"
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -24,9 +23,9 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation "com.android.support:appcompat-v7:$android_version"
implementation "com.android.support:recyclerview-v7:$android_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

implementation project(':adaptiverecyclerview')
}
4 changes: 2 additions & 2 deletions sample/src/main/java/com/devrapid/example/ExpandAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devrapid.example

import android.support.v7.util.DiffUtil
import androidx.recyclerview.widget.DiffUtil
import com.devrapid.adaptiverecyclerview.AdaptiveAdapter
import com.devrapid.adaptiverecyclerview.AdaptiveViewHolder
import com.devrapid.example.viewtype.MultiTypeFactory
Expand Down Expand Up @@ -62,4 +62,4 @@ class ExpandAdapter(override var dataList: MutableList<IExpandVisitor>):
private fun changeVisibleChildNumber(index: Int, size: Int) {
this.originalParentPosition[index] = size
}
}
}
10 changes: 6 additions & 4 deletions sample/src/main/java/com/devrapid/example/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.devrapid.example

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.devrapid.example.model.Animal
import com.devrapid.example.model.Person
import kotlinx.android.synthetic.main.activity_main.recyclerView

class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -24,7 +23,10 @@ class MainActivity: AppCompatActivity() {
Person("Airbnb"),
Person("Jieyi"))

recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
recyclerView.layoutManager =
androidx.recyclerview.widget.LinearLayoutManager(this,
androidx.recyclerview.widget.LinearLayoutManager.VERTICAL,
false)
recyclerView.adapter = ExpandAdapter(itemList)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.devrapid.example.viewtype

import android.support.v7.widget.RecyclerView.ViewHolder
import android.view.View
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.devrapid.adaptiverecyclerview.ViewTypeFactory
import com.devrapid.example.R
import com.devrapid.example.model.Animal
Expand Down
6 changes: 3 additions & 3 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.devrapid.example.MainActivity">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
Expand All @@ -21,4 +21,4 @@
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 6f656f2

Please sign in to comment.