Skip to content

Commit

Permalink
library update, sdk version 28, kotlin 1.2.71, DimenUtils extended
Browse files Browse the repository at this point in the history
  • Loading branch information
kroegerama committed Oct 6, 2018
1 parent a7e960b commit 7b347a1
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 57 deletions.
56 changes: 28 additions & 28 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 3 additions & 3 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 {
buildscript {
ext {
kotlin_version = '1.2.51'
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.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
12 changes: 6 additions & 6 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 25 18:31:26 CEST 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
#Sat Oct 06 22:29:51 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
compileSdkVersion 28

compileOptions {
kotlinOptions.freeCompilerArgs += ['-module-name', "android.kaiteki"]
Expand All @@ -11,7 +11,7 @@ android {
defaultConfig {
minSdkVersion 17
versionCode 1
versionName "1.2.4"
versionName "1.2.5"
}

buildTypes {
Expand All @@ -23,7 +23,7 @@ android {
}

ext {
supportVersion = "27.1.1"
supportVersion = "28.0.0"
lifecycleVersion = '1.1.1'
}

Expand Down
24 changes: 23 additions & 1 deletion library/src/main/java/com/kroegerama/kaiteki/DimenUtils.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
package com.kroegerama.kaiteki

import android.content.Context
import android.content.res.Resources
import android.support.annotation.DimenRes
import android.support.annotation.Px
import android.util.TypedValue
import com.kroegerama.kaiteki.baseui.BaseFragment

@Px
fun Float.dpToPx() = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this, Resources.getSystem().displayMetrics).toInt()

@Px
fun Float.spToPx() = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, this, Resources.getSystem().displayMetrics).toInt()

fun Float.spToDp() = this.spToPx() / Resources.getSystem().displayMetrics.scaledDensity;
fun Float.spToDp() = this.spToPx() / Resources.getSystem().displayMetrics.scaledDensity

/** @see Resources.getDimension */
fun Context.getDimension(@DimenRes res: Int) = resources.getDimension(res)

/** @see Resources.getDimensionPixelSize */
fun Context.getDimensionPixelSize(@DimenRes res: Int) = resources.getDimensionPixelSize(res)

/** @see Resources.getDimensionPixelOffset */
fun Context.getDimensionPixelOffset(@DimenRes res: Int) = resources.getDimensionPixelOffset(res)

/** @see Resources.getDimension */
fun BaseFragment.getDimension(@DimenRes res: Int) = requireContext().getDimension(res)

/** @see Resources.getDimensionPixelSize */
fun BaseFragment.getDimensionPixelSize(@DimenRes res: Int) = requireContext().getDimensionPixelSize(res)

/** @see Resources.getDimensionPixelOffset */
fun BaseFragment.getDimensionPixelOffset(@DimenRes res: Int) = requireContext().getDimensionPixelOffset(res)

0 comments on commit 7b347a1

Please sign in to comment.