Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package powercom.androidcustomerapp
- import android.content.Intent
- import android.os.Bundle
- import android.support.v7.app.AppCompatActivity
- import android.view.View
- import android.widget.Toast
- import com.google.gson.Gson
- import kotlinx.android.synthetic.main.activity_startup.*
- import powercom.androidcustomerapp.controllers.StartupController
- import powercom.androidcustomerapp.interfaces.IControllers
- import powercom.androidcustomerapp.network.entities.Language
- import powercom.androidcustomerapp.network.entities.ServerRegion
- import powercom.androidcustomerapp.interfaces.IViews
- class StartupActivity : AppCompatActivity(), IViews.Startup{
- private var nextActivityBundle: Bundle = Bundle()
- private val controller: IControllers.Startup = StartupController(this)
- private val gson = Gson()
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_startup)
- if (hasRegion())
- toMain()
- else
- controller.getStartupData()
- }
- override fun toRegions() {
- var intent = Intent(this, RegionActivity::class.java)
- intent.putExtras(nextActivityBundle)
- intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
- startActivity(intent)
- finish()
- }
- private fun toMain() {
- var intent = Intent(this, MainActivity::class.java)
- intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
- startActivity(intent)
- finish()
- }
- override fun showProgress(isShowing: Boolean) {
- if (isShowing) {
- this.progress_layout.visibility = View.VISIBLE
- }
- else {
- this.progress_layout.visibility = View.GONE
- }
- }
- override fun showToast(msg: String) {
- Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
- }
- override fun updateLanguages(languages: List<Language>) {
- nextActivityBundle.putString("languages", this.gson.toJson(languages))
- }
- override fun updateRegions(regions: List<ServerRegion>) {
- nextActivityBundle.putString("regions", this.gson.toJson(regions))
- }
- override fun updateStatusText(text: String) {
- this.progress_text.text = text
- }
- private fun hasRegion(): Boolean {
- return prefs.region.id != -1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement