Skip to content

Commit

Permalink
Upgraded: update to androidx.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokk committed Jul 18, 2018
1 parent a4097e1 commit 72d95a1
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 181 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ implementation('com.devrapid.jieyi:kotlinknifer:1.5.7', {
})
```

### For Androidx

```gradle
implementation('com.devrapid.jieyi:kotlinknifer:2.0.0', {
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.github.bumptech.glide', module: 'glide'
})
```

```gradle
implementation('com.devrapid.jieyi:kotlinshaverr:0.2.2', {
exclude group: 'io.reactivex.rxjava2', module: 'rxjava'
Expand Down
4 changes: 2 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.31'
ext.kotlin_version = '1.2.51'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.android.tools.build:gradle:3.2.0-beta04'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true

#### For JCenter ####
## Project information
proj_repo=maven
proj_name=kotlinknifer
proj_libname=KotlinKnifer
proj_group=com.devrapid.jieyi
proj_artifactid=kotlinknifer
proj_version=1.5.7
proj_version=2.0.0
proj_description=For developing an Android conveniently and rapidly.
proj_websiteurl=https://github.com/pokk/KotlinKnifer
proj_issuetrackerurl=https://github.com/pokk/KotlinKnifer/issues
Expand All @@ -36,4 +39,4 @@ [email protected]
proj_kotlin_name=kotlinshaver
proj_kotlin_libname=KotlinShaver
proj_kotlin_artifactid=kotlinshaver
proj_kotlin_version=0.2.2
proj_kotlin_version=1.0.0
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 @@
#Wed Jan 24 11:07:46 JST 2018
#Wed Jul 18 12:01:20 JST 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.8-all.zip
21 changes: 10 additions & 11 deletions kotlinknifer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ 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
}
buildTypes {
release {
Expand All @@ -27,15 +26,15 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// 'compile' can also import to the new project with this.
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.github.bumptech.glide:glide:4.6.1'
compile 'com.github.bumptech.glide:glide:4.7.1'
// 'implementation' can't import to the new project.
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.22.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5'
implementation 'org.jetbrains.anko:anko-commons:0.10.4'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:palette-v7:27.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.23.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.23.3'
implementation 'org.jetbrains.anko:anko-commons:0.10.5'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'androidx.palette:palette:1.0.0-beta01'
compile project(':kotlinshaver')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.support.annotation.DrawableRes
import androidx.annotation.DrawableRes

/**
* @author jieyi
Expand Down Expand Up @@ -49,4 +49,4 @@ fun Bitmap.resizeImageAsRatio(aspectRatio: Double): Bitmap = also {
it.width = (aspectRatio * it.height).toInt()
else
it.height = (it.width / aspectRatio).toInt()
}
}
6 changes: 3 additions & 3 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package com.devrapid.kotlinknifer

import android.content.Context
import android.graphics.Color
import android.support.annotation.ColorInt
import android.support.annotation.ColorRes
import android.support.v4.content.ContextCompat
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import android.renderscript.Allocation
import android.renderscript.Element
import android.renderscript.RenderScript
import android.renderscript.ScriptIntrinsicBlur
import android.support.annotation.DrawableRes
import android.support.v7.graphics.Palette
import androidx.annotation.DrawableRes
import androidx.palette.graphics.Palette

/**
* @author jieyi
Expand Down
22 changes: 7 additions & 15 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/Fragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

package com.devrapid.kotlinknifer

import android.annotation.TargetApi
import android.app.Fragment
import android.app.FragmentManager
import android.app.FragmentTransaction
import android.os.Build
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import java.util.Stack

/**
Expand Down Expand Up @@ -70,21 +68,20 @@ inline fun FragmentManager.popAllFragment(fragmentStack: Stack<Fragment>? = null
* Remove a specific [Fragment] from [FragmentManager]'s fragments.
* NOTE: Don't mix this function with [popFragment] or [popAllFragment].
*
* @param manager [FragmentManager].
* @param manager support v4 [FragmentManager].
*/
inline fun Fragment.removeFrom(manager: FragmentManager) = manager.transaction { remove(this@removeFrom) }

/**
* Remove all fragments.
*/
@TargetApi(Build.VERSION_CODES.O)
inline fun FragmentManager.removeLastFragment() = fragments.lastOrNull()?.removeFrom(this)

/**
* Add a [Fragment] and hide the current presenting fragment.
* NOTE: Don't mix this function with [popFragment] or [popAllFragment].
*
* @param manager [FragmentManager].
* @param manager support v4 [FragmentManager].
*/
inline fun Fragment.appendTo(manager: FragmentManager) = manager.transaction {
hide(this@appendTo)
Expand All @@ -94,7 +91,7 @@ inline fun Fragment.appendTo(manager: FragmentManager) = manager.transaction {
/**
* Hide a assigned [Fragment].
*
* @param manager [FragmentManager].
* @param manager support v4 [FragmentManager].
*/
inline fun Fragment.hideFrom(manager: FragmentManager) = manager.transaction { hide(this@hideFrom) }

Expand All @@ -108,9 +105,4 @@ inline fun FragmentManager.transaction(block: FragmentTransaction.() -> Unit) =
* Decorator between [beginTransaction] and [commitNow].
*/
inline fun FragmentManager.transactionNow(block: FragmentTransaction.() -> Unit) =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
beginTransaction().apply(block).commitNow()
}
else {
TODO("VERSION.SDK_INT < N")
}
beginTransaction().apply(block).commitNow()
15 changes: 7 additions & 8 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/View.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import android.app.Activity
import android.content.Context
import android.graphics.Rect
import android.os.Build
import android.support.annotation.ColorInt
import android.support.annotation.ColorRes
import android.support.v7.app.AlertDialog
import android.view.View
import android.view.View.GONE
import android.view.View.INVISIBLE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.Window
import android.view.WindowManager
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.appcompat.app.AlertDialog
import com.example.kotlinknifer.R

/**
Expand All @@ -31,19 +30,19 @@ inline fun View.resizeView(width: Int? = null, height: Int? = null) {
layoutParams = newLayoutParams
}

inline fun View.visiable() {
inline fun View.visible() {
visibility = VISIBLE
}

inline fun View.invisiable() {
inline fun View.invisible() {
visibility = INVISIBLE
}

inline fun View.gone() {
visibility = GONE
}

inline fun View.isVisiable() = VISIBLE == visibility
inline fun View.isVisible() = VISIBLE == visibility

fun View.waitForMeasure(func: (v: View, w: Int, h: Int) -> Unit) {
if (0 < width && 0 < height) {
Expand Down Expand Up @@ -115,4 +114,4 @@ internal inline fun Activity.setStatusBarColorBy(block: Window.() -> Unit) {
else {
TODO("Don't support the sdk version is less than 21 yet.")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.devrapid.kotlinknifer.recyclerview

import android.content.Context
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.devrapid.kotlinknifer.loge
import com.devrapid.kotlinknifer.logw

Expand All @@ -29,4 +29,4 @@ class WrapContentLinearLayoutManager : LinearLayoutManager {
loge(e)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.devrapid.kotlinknifer.recyclerview.itemdecorator

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

/**
* The item decorator for grid type recycler view.
Expand Down Expand Up @@ -39,4 +39,4 @@ class GridSpacingItemDecorator(private val spanCount: Int, private val spacing:
outRect.top = spacing
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.devrapid.kotlinknifer.recyclerview.itemdecorator

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

/**
* The item decorator for horizontal recycler view.
Expand All @@ -21,4 +21,4 @@ class HorizontalItemDecorator(private val space: Int) : RecyclerView.ItemDecorat
else -> outRect.set(space / 2, space, space / 2, space)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.devrapid.kotlinknifer.recyclerview.itemdecorator

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

/**
* The item decorator for vertical type recycler view.
Expand All @@ -24,4 +24,4 @@ class VerticalItemDecorator(
else -> outRect.set(leftRight, topBottom / 2, leftRight, topBottom / 2)
}
}
}
}
Loading

0 comments on commit 72d95a1

Please sign in to comment.