Skip to content

Commit

Permalink
Upgrade deps (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jintin authored Nov 1, 2023
1 parent 9eac80c commit be35275
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

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

1 change: 0 additions & 1 deletion .idea/misc.xml

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

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Then you can create the custom provider and transform it into LiveData or Flow.
```kotlin
private val locationProvider: ILocationProvider = LocationProvider(context, locationRequest)

@ExperimentalCoroutinesApi
val locationFlow: LocationFlow = locationProvider.asFlow()
val locationLiveData: LocationLiveData = locationProvider.asLiveData()
```
Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ plugins {
}

android {
compileSdkVersion 33
buildToolsVersion "33.0.2"
namespace "com.jintin.fancylocation.app"

defaultConfig {

compileSdk 34
buildToolsVersion = "34.0.0"
applicationId "com.jintin.fancylocation.app"
minSdkVersion 23
targetSdkVersion 33
targetSdkVersion 34
versionCode 1
versionName "1.0"

Expand All @@ -40,14 +40,14 @@ dependencies {

// implementation 'com.github.jintin:FancyLocationProvider:1.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.activity:activity-ktx:1.8.0'
implementation "com.github.permissions-dispatcher:permissionsdispatcher:4.8.0"
kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:4.8.0"

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.lifecycle.AndroidViewModel
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.Priority
import com.jintin.fancylocation.*
import kotlinx.coroutines.ExperimentalCoroutinesApi

class MainViewModel(application: Application) : AndroidViewModel(application) {
private val locationRequest =
Expand All @@ -15,15 +14,13 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
.setMaxUpdateDelayMillis(3000)
.build()

// @ExperimentalCoroutinesApi
// val locationFlow = LocationFlow(application, locationRequest)
// val locationStateFlow = LocationFlow(application, locationRequest)
// val locationLiveData = LocationLiveData(application, locationRequest)

// we can also provide custom vendor by create your own LocationProvider
private val locationProvider: ILocationProvider = LocationProvider(application, locationRequest)

@ExperimentalCoroutinesApi
val locationFlow = locationProvider.asFlow()
val locationLiveData = locationProvider.asLiveData()
val locationStateFlow = locationProvider.asStateFlow()
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.9.0"
ext.kotlin_version = "1.9.10"
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
10 changes: 4 additions & 6 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ plugins {
}

android {
compileSdkVersion 33
buildToolsVersion "33.0.2"
namespace "com.jintin.fancylocation"

defaultConfig {
minSdkVersion 16
targetSdkVersion 33
versionCode 1
versionName "1.0"
compileSdk 34
buildToolsVersion = "34.0.0"
targetSdkVersion 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -36,7 +34,7 @@ android {
dependencies {

implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.13.2'
Expand Down
6 changes: 3 additions & 3 deletions lib/src/main/java/com/jintin/fancylocation/LocationData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.jintin.fancylocation
import android.location.Location

sealed class LocationData {
object Init : LocationData()
object Loading : LocationData()
data object Init : LocationData()
data object Loading : LocationData()
data class Success(val location: Location) : LocationData()
object Fail : LocationData()
data object Fail : LocationData()
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.jintin.fancylocation

import kotlinx.coroutines.ExperimentalCoroutinesApi

fun ILocationProvider.asLiveData(): LocationLiveData {
return LocationLiveData(this)
}

@ExperimentalCoroutinesApi
fun ILocationProvider.asFlow(): LocationFlow {
return LocationFlow(this)
}
Expand Down
6 changes: 2 additions & 4 deletions lib/src/main/java/com/jintin/fancylocation/LocationFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import android.content.Context
import android.location.Location
import androidx.annotation.RequiresPermission
import com.google.android.gms.location.LocationRequest
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.channelFlow

@ExperimentalCoroutinesApi
class LocationFlow(
private val locationProvider: ILocationProvider
) {
Expand All @@ -23,7 +21,7 @@ class LocationFlow(
) : this(LocationProvider(context, locationRequest))

@RequiresPermission(anyOf = [Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION])
fun get(): Flow<LocationData> = channelFlow {
fun get(): Flow<LocationData> = callbackFlow {
channel.trySendBlocking(LocationData.Loading)
locationProvider.requestLocationUpdates(object : ILocationObserver {
override fun onLocationResult(location: Location) {
Expand Down

0 comments on commit be35275

Please sign in to comment.