Skip to content

Commit

Permalink
update dependency libraries; remove jCenter as it has reached end of …
Browse files Browse the repository at this point in the history
…life
  • Loading branch information
mumayank committed Mar 7, 2021
1 parent 200422d commit 079f07c
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 49 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

2 changes: 1 addition & 1 deletion .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.

11 changes: 5 additions & 6 deletions airlocationlibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.mumayank'

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
api 'com.google.android.gms:play-services-location:17.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.30"
api 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.github.mumayank:AirPermissionsLibraryProject:3.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class AirLocation(

fusedLocationClient = LocationServices.getFusedLocationProviderClient(activityTemp)
val task = fusedLocationClient.lastLocation
task?.addOnSuccessListener { location: Location? ->
task.addOnSuccessListener { location: Location? ->
if (activityWeakReference.get() == null) {
return@addOnSuccessListener
}
Expand All @@ -156,7 +156,7 @@ class AirLocation(
} else {
addLifecycleListener()
}
}?.addOnFailureListener {
}.addOnFailureListener {
if (activityWeakReference.get() == null) {
return@addOnFailureListener
}
Expand Down Expand Up @@ -222,7 +222,7 @@ class AirLocation(
isLocationRequiredOnlyOneTime
),
locationCallback,
Looper.myLooper()
Looper.getMainLooper()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class GooglePlayApiHelper(
private val onSuccess: (() -> Unit)?,
private val onFailure: (() -> Unit)?
) {
companion object {
private const val REQUEST_CODE = 1237
}

private val activityWeakReference = WeakReference(activity)

fun makeItAvailable() {
Expand All @@ -34,7 +38,7 @@ class GooglePlayApiHelper(
) {
onFailure?.invoke()
}
errorDialog.show()
errorDialog?.show()
}

}
Expand All @@ -48,8 +52,4 @@ class GooglePlayApiHelper(
makeItAvailable()
}
}

companion object {
private const val REQUEST_CODE = 1237
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class LocationOptimizationPermissionHelper(
locationInterval: Long,
isLocationRequiredOnlyOneTime: Boolean
): LocationRequest {
return LocationRequest().apply {
return LocationRequest.create().apply {
interval = locationInterval
fastestInterval = locationInterval
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
Expand Down
14 changes: 8 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId "mumayank.com.airlocationproject"
minSdkVersion 17
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.30"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation project(":airlocationlibrary")
}
21 changes: 12 additions & 9 deletions app/src/main/java/mumayank/com/airlocationproject/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,41 @@ import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.main_activity.*
import mumayank.com.airlocationlibrary.AirLocation
import mumayank.com.airlocationproject.databinding.MainActivityBinding
import java.util.*

class MainActivity : AppCompatActivity() {

private lateinit var binding: MainActivityBinding

private val airLocation = AirLocation(this, object : AirLocation.Callback {
override fun onSuccess(locations: ArrayList<Location>) {
progressBar.visibility = View.GONE
binding.progressBar.visibility = View.GONE
var string = "\n"
for (location in locations) {
string = "${location.longitude}, ${location.latitude}\n$string"
}
string = "$string${textView2.text}"
textView2.text = string
string = "$string${binding.textView2.text}"
binding.textView2.text = string
}

override fun onFailure(locationFailedEnum: AirLocation.LocationFailedEnum) {
progressBar.visibility = View.GONE
binding.progressBar.visibility = View.GONE
Toast.makeText(this@MainActivity, locationFailedEnum.name, Toast.LENGTH_SHORT)
.show()
}
})

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
binding = MainActivityBinding.inflate(layoutInflater)
setContentView(binding.root)

progressBar.visibility = View.GONE
binding.progressBar.visibility = View.GONE

button2.setOnClickListener {
progressBar.visibility = View.VISIBLE
binding.button2.setOnClickListener {
binding.progressBar.visibility = View.VISIBLE
airLocation.start()
}

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
classpath 'com.android.tools.build:gradle:7.0.0-alpha08'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-6.8.2-all.zip

0 comments on commit 079f07c

Please sign in to comment.