Skip to content

Commit b6a5715

Browse files
committed
Android Gradle Plugin, JUnit, Kotlin and Mapbox updated; removed deprecated 'kotlin-android-extensions' plugin and replaced with 'kotlin-parcelize' (plugin) and viewBinding (demo app)
1 parent 101f493 commit b6a5715

File tree

10 files changed

+36
-27
lines changed

10 files changed

+36
-27
lines changed

.idea/codeStyles/Project.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ An alternative to [Mapbox offline plugin](https://github.com/mapbox/mapbox-plugi
55

66
This plugin is published to [Bintray's JCenter](https://bintray.com/bintray/jcenter). Include it in your `build.gradle` file with
77
```gradle
8-
implementation 'dev.micheleferretti:mapbox-plugin-offline:2.2.3'
8+
implementation 'dev.micheleferretti:mapbox-plugin-offline:2.2.4'
99
```
1010

1111
## Usage

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43

54
android {
65
compileSdkVersion 30
@@ -12,6 +11,9 @@ android {
1211
versionName "1.0"
1312
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1413
}
14+
buildFeatures {
15+
viewBinding true
16+
}
1517
buildTypes {
1618
debug {
1719
buildConfigField('String', 'MAPBOX_ACCESS_TOKEN', '"' + mapbox_access_token + '"' )
@@ -33,7 +35,7 @@ dependencies {
3335
implementation 'androidx.appcompat:appcompat:1.2.0'
3436
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
3537
implementation "androidx.core:core-ktx:$androidx_core_version"
36-
implementation 'androidx.recyclerview:recyclerview:1.1.0'
38+
implementation 'androidx.recyclerview:recyclerview:1.2.0'
3739

3840
// Mapbox
3941
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:$mapbox_version"

app/src/main/java/dev/micheleferretti/mapboxpluginofflinedemo/DemoActivity.kt

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,31 @@ import dev.micheleferretti.mapboxpluginoffline.OfflineService
1616
import dev.micheleferretti.mapboxpluginoffline.model.NotificationOptions
1717
import dev.micheleferretti.mapboxpluginoffline.model.OfflineDownload
1818
import dev.micheleferretti.mapboxpluginoffline.model.OfflineDownloadOptions
19-
import kotlinx.android.synthetic.main.activity_demo.*
19+
import dev.micheleferretti.mapboxpluginofflinedemo.databinding.ActivityDemoBinding
2020

21-
class DemoActivity : AppCompatActivity(R.layout.activity_demo), View.OnClickListener {
21+
class DemoActivity : AppCompatActivity(), View.OnClickListener {
22+
23+
private lateinit var binding: ActivityDemoBinding
2224

2325
private val logAdapter = LogAdapter()
2426
private val receiver = Receiver()
2527

2628
override fun onCreate(savedInstanceState: Bundle?) {
2729
super.onCreate(savedInstanceState)
28-
active_downloads_btn.setOnClickListener(this)
29-
download_btn.setOnClickListener(this)
30-
logs_rv.apply {
30+
binding = ActivityDemoBinding.inflate(layoutInflater)
31+
setContentView(binding.root)
32+
33+
binding.activeDownloadsBtn.setOnClickListener(this)
34+
binding.downloadBtn.setOnClickListener(this)
35+
binding.logsRv.apply {
3136
setHasFixedSize(true)
3237
addItemDecoration(DividerItemDecoration(context, RecyclerView.VERTICAL))
3338
layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, true)
3439
adapter = logAdapter
3540
}
3641

37-
map?.onCreate(savedInstanceState)
38-
map?.getMapAsync { it.setStyle(Style.MAPBOX_STREETS) }
42+
binding.map.onCreate(savedInstanceState)
43+
binding.map.getMapAsync { it.setStyle(Style.MAPBOX_STREETS) }
3944
}
4045

4146
override fun onClick(v: View?) {
@@ -45,7 +50,7 @@ class DemoActivity : AppCompatActivity(R.layout.activity_demo), View.OnClickList
4550
Toast.makeText(v.context, "Count: ${receiver.getActiveDownloads().size}", Toast.LENGTH_SHORT).show()
4651
}
4752
R.id.download_btn -> {
48-
map?.getMapAsync {
53+
binding.map.getMapAsync {
4954
OfflineService.startDownload(this, OfflineDownloadOptions(
5055
OfflineTilePyramidRegionDefinition(
5156
Style.MAPBOX_STREETS,
@@ -73,39 +78,39 @@ class DemoActivity : AppCompatActivity(R.layout.activity_demo), View.OnClickList
7378

7479
override fun onStart() {
7580
super.onStart()
76-
map?.onStart()
81+
binding.map.onStart()
7782
receiver.register(this)
7883
}
7984

8085
override fun onResume() {
8186
super.onResume()
82-
map?.onResume()
87+
binding.map.onResume()
8388
}
8489

8590
override fun onPause() {
8691
super.onPause()
87-
map?.onPause()
92+
binding.map.onPause()
8893
}
8994

9095
override fun onStop() {
9196
super.onStop()
92-
map?.onStop()
97+
binding.map.onStop()
9398
receiver.unregister(this)
9499
}
95100

96101
override fun onSaveInstanceState(outState: Bundle) {
97102
super.onSaveInstanceState(outState)
98-
map?.onSaveInstanceState(outState)
103+
binding.map.onSaveInstanceState(outState)
99104
}
100105

101106
override fun onLowMemory() {
102107
super.onLowMemory()
103-
map?.onLowMemory()
108+
binding.map.onLowMemory()
104109
}
105110

106111
override fun onDestroy() {
107112
super.onDestroy()
108-
map?.onDestroy()
113+
binding.map.onDestroy()
109114
}
110115

111116
// Receiver class

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ buildscript {
44
androidx_test_runner_version = '1.3.0'
55
androidx_test_espresso_version = '3.3.0'
66
androidx_test_junit_version = '1.1.2'
7-
junit_version = '4.12'
8-
kotlin_version = '1.4.10'
9-
mapbox_version = '9.6.0'
7+
junit_version = '4.13.2'
8+
kotlin_version = '1.4.32'
9+
mapbox_version = '9.6.1'
1010

1111
File secretPropsFile = file('secret.properties')
1212
Properties secretProps = new Properties()
@@ -22,7 +22,7 @@ buildscript {
2222
jcenter()
2323
}
2424
dependencies {
25-
classpath 'com.android.tools.build:gradle:4.1.0'
25+
classpath 'com.android.tools.build:gradle:4.1.3'
2626
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
2727
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.10.1'
2828
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

mapboxpluginoffline/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
3+
apply plugin: 'kotlin-parcelize'
44
apply plugin: 'org.jetbrains.dokka'
55
apply plugin: 'maven-publish'
66
apply plugin: 'com.jfrog.bintray'
@@ -16,7 +16,7 @@ android {
1616
minSdkVersion 14
1717
targetSdkVersion 30
1818
versionCode 1
19-
versionName '2.2.3'
19+
versionName '2.2.4'
2020
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2121
archivesBaseName = "$archivesBaseName-$versionName"
2222
}

mapboxpluginoffline/src/main/java/dev/micheleferretti/mapboxpluginoffline/model/NotificationOptions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dev.micheleferretti.mapboxpluginoffline.model
33
import android.os.Parcelable
44
import androidx.annotation.DrawableRes
55
import dev.micheleferretti.mapboxpluginoffline.utils.OfflineUtils
6-
import kotlinx.android.parcel.Parcelize
6+
import kotlinx.parcelize.Parcelize
77

88
/**
99
* This model represents the options for the notification shown by

mapboxpluginoffline/src/main/java/dev/micheleferretti/mapboxpluginoffline/model/OfflineDownload.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.os.Parcelable
44
import com.mapbox.mapboxsdk.offline.OfflineRegion
55
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus
66
import dev.micheleferretti.mapboxpluginoffline.utils.OfflineUtils
7-
import kotlinx.android.parcel.Parcelize
7+
import kotlinx.parcelize.Parcelize
88

99
/**
1010
* This model represents the download managed by

mapboxpluginoffline/src/main/java/dev/micheleferretti/mapboxpluginoffline/model/OfflineDownloadOptions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.os.Parcelable
44
import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition
55
import dev.micheleferretti.mapboxpluginoffline.utils.OfflineUtils
66
import dev.micheleferretti.mapboxpluginoffline.utils.convertToString
7-
import kotlinx.android.parcel.Parcelize
7+
import kotlinx.parcelize.Parcelize
88

99
/**
1010
* This model represents the options for the download managed by

0 commit comments

Comments
 (0)