diff --git a/Project/.idea/gradle.xml b/Project/.idea/gradle.xml index 5cd135a..9bba60d 100644 --- a/Project/.idea/gradle.xml +++ b/Project/.idea/gradle.xml @@ -14,6 +14,7 @@ diff --git a/Project/app/src/main/java/org/ionproject/android/ExceptionHandlingActivity.kt b/Project/app/src/main/java/org/ionproject/android/ExceptionHandlingActivity.kt index df9affd..e30eb5e 100644 --- a/Project/app/src/main/java/org/ionproject/android/ExceptionHandlingActivity.kt +++ b/Project/app/src/main/java/org/ionproject/android/ExceptionHandlingActivity.kt @@ -5,8 +5,7 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.fasterxml.jackson.core.JsonProcessingException import org.ionproject.android.common.IonApplication -import org.ionproject.android.error.ERROR_KEY -import org.ionproject.android.error.ErrorActivity +import org.ionproject.android.error.* import java.io.IOException abstract class ExceptionHandlingActivity : AppCompatActivity() { @@ -31,15 +30,15 @@ abstract class ExceptionHandlingActivity : AppCompatActivity() { val intent = Intent(this, ErrorActivity::class.java) when (throwable) { is JsonProcessingException -> intent.putExtra( - ERROR_KEY, + ERROR_ACTIVITY_EXCEPTION_KEY, resources.getString(R.string.label_error_loading_error) ) is IOException -> intent.putExtra( - ERROR_KEY, + ERROR_ACTIVITY_EXCEPTION_KEY, resources.getString(R.string.label_no_connectivity_loading_error) ) else -> intent.putExtra( - ERROR_KEY, + ERROR_ACTIVITY_EXCEPTION_KEY, resources.getString(R.string.label_error_loading_error) ) } diff --git a/Project/app/src/main/java/org/ionproject/android/error/ErrorActivity.kt b/Project/app/src/main/java/org/ionproject/android/error/ErrorActivity.kt index 7710c97..65b7859 100644 --- a/Project/app/src/main/java/org/ionproject/android/error/ErrorActivity.kt +++ b/Project/app/src/main/java/org/ionproject/android/error/ErrorActivity.kt @@ -6,8 +6,7 @@ import kotlinx.android.synthetic.main.activity_error.* import org.ionproject.android.R import org.ionproject.android.common.addGradientBackground -// Random value key used to pass the error message to [ErrorActivity] via the intent -const val ERROR_KEY = "12xp3m91x0meh1" +const val ERROR_ACTIVITY_EXCEPTION_KEY = "ErrorActivity.Exception.Extra" class ErrorActivity : AppCompatActivity() { @@ -22,7 +21,7 @@ class ErrorActivity : AppCompatActivity() { } // Apply error message if it was passed via the intent - intent.getStringExtra(ERROR_KEY)?.apply { + intent.getStringExtra(ERROR_ACTIVITY_EXCEPTION_KEY)?.apply { textview_error_activity_message.text = this } diff --git a/Project/app/src/main/java/org/ionproject/android/loading/LoadingActivity.kt b/Project/app/src/main/java/org/ionproject/android/loading/LoadingActivity.kt index ce57f02..0808782 100644 --- a/Project/app/src/main/java/org/ionproject/android/loading/LoadingActivity.kt +++ b/Project/app/src/main/java/org/ionproject/android/loading/LoadingActivity.kt @@ -8,11 +8,9 @@ import org.ionproject.android.ExceptionHandlingActivity import org.ionproject.android.R import org.ionproject.android.common.addGradientBackground import org.ionproject.android.error.ErrorActivity +import org.ionproject.android.main.MAIN_ACTIVITY_ROOT_EXTRA import org.ionproject.android.main.MainActivity -// Random value key used to pass the root object from [LoadingActivity] to [MainActivity] via the intent -const val ROOT_KEY = "m0192exe1gxe12x1" - class LoadingActivity : ExceptionHandlingActivity() { private val loadingViewModel by lazy(LazyThreadSafetyMode.NONE) { @@ -28,7 +26,7 @@ class LoadingActivity : ExceptionHandlingActivity() { loadingViewModel.observeRootLiveData(this) { if (it != null) { val intent = Intent(this, MainActivity::class.java) - intent.putExtra(ROOT_KEY, it) + intent.putExtra(MAIN_ACTIVITY_ROOT_EXTRA, it) this.startActivity(intent) } else { val intent = Intent(this, ErrorActivity::class.java) diff --git a/Project/app/src/main/java/org/ionproject/android/main/MainActivity.kt b/Project/app/src/main/java/org/ionproject/android/main/MainActivity.kt index 990154d..8af381e 100644 --- a/Project/app/src/main/java/org/ionproject/android/main/MainActivity.kt +++ b/Project/app/src/main/java/org/ionproject/android/main/MainActivity.kt @@ -30,9 +30,10 @@ import org.ionproject.android.SharedViewModelProvider import org.ionproject.android.common.IonApplication import org.ionproject.android.common.addGradientBackground import org.ionproject.android.common.model.Root -import org.ionproject.android.loading.ROOT_KEY import org.ionproject.android.search.SearchSuggestionsProvider +const val MAIN_ACTIVITY_ROOT_EXTRA = "MainActivity.Root.Extra" + class MainActivity : ExceptionHandlingActivity(), DeleteSuggestionsDialogFragment.OnDeleteSuggestionsDialogListener { @@ -73,7 +74,7 @@ class MainActivity : ExceptionHandlingActivity(), super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) main_activity.addGradientBackground() - val root = intent.getParcelableExtra(ROOT_KEY) + val root = intent.getParcelableExtra(MAIN_ACTIVITY_ROOT_EXTRA) if (root != null) { sharedViewModel.root = root setupTopBarBehaviour()