diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/mapboxfreezerepro/MainActivity.kt')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/mapboxfreezerepro/MainActivity.kt | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/mapboxfreezerepro/MainActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/mapboxfreezerepro/MainActivity.kt new file mode 100644 index 0000000000..03377e2fb4 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/mapboxfreezerepro/MainActivity.kt @@ -0,0 +1,49 @@ +package com.mapbox.mapboxsdk.testapp.mapboxfreezerepro + +import android.os.Bundle +import android.support.v7.app.AppCompatActivity +import com.mapbox.mapboxsdk.testapp.R +import com.mapbox.mapboxsdk.testapp.mapboxfreezerepro.views.EmptyView +import com.mapbox.mapboxsdk.testapp.mapboxfreezerepro.views.MapView +import kotlinx.android.synthetic.main.activity_main.* +import timber.log.Timber + +class MainActivity : AppCompatActivity() { + + private var empty = true + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + fragmentContainer.addView(EmptyView(this)) + button.setOnClickListener { + Timber.e("removeAllViews") + + if (!empty) { + val fragment = supportFragmentManager.findFragmentByTag(com.mapbox.mapboxsdk.testapp.mapboxfreezerepro.views.TAG) + if (fragment != null) { + supportFragmentManager.beginTransaction() + .remove(fragment) + .commitNowAllowingStateLoss() + } + } + + fragmentContainer.removeAllViews() + if (empty) { + fragmentContainer.addView( + MapView( + this + ) + ) + empty = false + } else { + fragmentContainer.addView( + EmptyView( + this + ) + ) + empty = true + } + } + } +} |