forked from google/iosched
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Fix opening Map screen from session detail"
- Loading branch information
Showing
15 changed files
with
286 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
mobile/src/main/java/com/google/samples/apps/iosched/ui/map/LoadGeoJsonFeaturesUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.samples.apps.iosched.ui.map | ||
|
||
import android.content.Context | ||
import android.text.TextUtils | ||
import com.google.android.gms.maps.GoogleMap | ||
import com.google.maps.android.data.geojson.GeoJsonFeature | ||
import com.google.maps.android.data.geojson.GeoJsonLayer | ||
import com.google.samples.apps.iosched.shared.domain.UseCase | ||
import javax.inject.Inject | ||
|
||
/** Parameters for this use case. */ | ||
typealias LoadGeoJsonParams = Pair<GoogleMap, Int> | ||
|
||
/** Data loaded by this use case. */ | ||
data class GeoJsonData( | ||
val geoJsonLayer: GeoJsonLayer, | ||
val featureMap: Map<String, GeoJsonFeature> | ||
) | ||
|
||
/** Use case that loads a GeoJsonLayer and its features. */ | ||
class LoadGeoJsonFeaturesUseCase @Inject constructor( | ||
private val context: Context | ||
): UseCase<LoadGeoJsonParams, GeoJsonData>() { | ||
|
||
override fun execute(parameters: LoadGeoJsonParams): GeoJsonData { | ||
val layer = GeoJsonLayer(parameters.first, parameters.second, context) | ||
processGeoJsonLayer(layer, context) | ||
layer.isLayerOnMap | ||
return GeoJsonData(layer, buildFeatureMap(layer)) | ||
} | ||
|
||
private fun buildFeatureMap(layer: GeoJsonLayer): Map<String, GeoJsonFeature> { | ||
val featureMap: MutableMap<String, GeoJsonFeature> = mutableMapOf() | ||
layer.features.forEach { | ||
val id = it.getProperty("id") | ||
if (!TextUtils.isEmpty(id)) { | ||
featureMap[id] = it | ||
} | ||
} | ||
return featureMap | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
mobile/src/main/java/com/google/samples/apps/iosched/ui/map/MapActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.samples.apps.iosched.ui.map | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.text.TextUtils | ||
import com.google.samples.apps.iosched.R | ||
import com.google.samples.apps.iosched.shared.util.inTransaction | ||
import dagger.android.support.DaggerAppCompatActivity | ||
|
||
/** Shell activity hosting a [MapFragment] */ | ||
class MapActivity : DaggerAppCompatActivity() { | ||
|
||
companion object { | ||
const val EXTRA_FEATURE_ID = "extra.FEATURE_ID" | ||
|
||
fun starterIntent(context: Context, featureId: String): Intent { | ||
return Intent(context, MapActivity::class.java).apply { | ||
putExtra(EXTRA_FEATURE_ID, featureId) | ||
} | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_map) | ||
|
||
if (savedInstanceState == null) { | ||
val featureId = intent.getStringExtra(EXTRA_FEATURE_ID) | ||
val fragment = if (!TextUtils.isEmpty(featureId)) { | ||
MapFragment.newInstance(featureId) | ||
} else { | ||
MapFragment() | ||
} | ||
supportFragmentManager.inTransaction { | ||
add(R.id.fragment_container, fragment) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.