Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] nullcheck region metadata in example activity, enable debug…
Browse files Browse the repository at this point in the history
… mode for MergeOfflineRegionsActivity
  • Loading branch information
LukasPaczos committed Sep 26, 2018
1 parent 1c6c7d5 commit 5e747ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
companion object {
private const val LOG_TAG = "Mbgl-MergeOfflineRegionsActivity"
private const val TEST_DB_FILE_NAME = "offline.db"
private const val TEST_STYLE = Style.SATELLITE
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -26,12 +27,15 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
// forcing offline state
Mapbox.setConnected(false)

mapView.setStyleUrl(Style.SATELLITE)
mapView.setStyleUrl(TEST_STYLE)

mapView.onCreate(savedInstanceState)
load_region_btn.setOnClickListener {
copyAsset()
}
mapView.getMapAsync {
it.isDebugActive = true
}
}

private fun copyAsset() {
Expand All @@ -55,7 +59,7 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
FileSource.getResourcesCachePath(this) + "/" + TEST_DB_FILE_NAME,
object : OfflineManager.MergeOfflineRegionsCallback {
override fun onMerge(offlineRegions: Array<OfflineRegion>) {
mapView.setStyleUrl(Style.SATELLITE)
mapView.setStyleUrl(TEST_STYLE)
Toast.makeText(
this@MergeOfflineRegionsActivity,
String.format("Merged %d regions.", offlineRegions.size),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.offline.OfflineManager;
import com.mapbox.mapboxsdk.offline.OfflineRegion;
Expand Down Expand Up @@ -57,7 +58,9 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
final EditText input = new EditText(this);
input.setText(metadata);
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setSelection(metadata.length());
if (metadata != null) {
input.setSelection(metadata.length());
}
builder.setView(input);

builder.setPositiveButton("OK", (dialog, which) ->
Expand Down

0 comments on commit 5e747ea

Please sign in to comment.