Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
Remove deprecated startActivityForResult usage
Browse files Browse the repository at this point in the history
  • Loading branch information
schaal committed May 18, 2020
1 parent 5b6dc9d commit 4a4a6dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/email/schaal/ocreader/ListActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ class ListActivity : AppCompatActivity(), ItemViewHolder.OnClickListener, OnRefr
binding.itemsRecyclerview.scrollToPosition(0)
}

private val getLoginResult = registerForActivityResult(object: ActivityResultContract<Unit, String?>() {
override fun createIntent(context: Context, input: Unit): Intent {
return Intent(this@ListActivity, LoginFlowActivity::class.java)
val getLoginResult = registerForActivityResult(object: ActivityResultContract<Void?, String?>() {
override fun createIntent(context: Context, input: Void?): Intent {
return Intent(this@ListActivity, LoginFlowActivity::class.java).apply {
Preferences.URL.getString(PreferenceManager.getDefaultSharedPreferences(this@ListActivity))?.let {
putExtra(LoginFlowActivity.EXTRA_URL, it)
}
}
}

override fun parseResult(resultCode: Int, intent: Intent?): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,4 @@ class ManageFeedsActivity : AppCompatActivity(), FeedManageListener {
progressDialog.show()
return progressDialog
}

companion object {
const val REQUEST_CODE = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@

package email.schaal.ocreader.view

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.invoke
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.preference.PreferenceManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import email.schaal.ocreader.ListActivity
import email.schaal.ocreader.LoginFlowActivity
import email.schaal.ocreader.Preferences
import email.schaal.ocreader.R
import email.schaal.ocreader.database.FeedViewModel
Expand Down Expand Up @@ -69,9 +68,9 @@ class UserBottomSheetDialogFragment: BottomSheetDialogFragment() {
}

headerBinding.button.setOnClickListener {
val loginIntent = Intent(requireActivity(), LoginFlowActivity::class.java)
loginIntent.putExtra(LoginFlowActivity.EXTRA_URL, url)
requireActivity().startActivityForResult(loginIntent, LoginFlowActivity.REQUEST_CODE)
(requireActivity() as? ListActivity)?.let {
it.getLoginResult()
}
dismiss()
}
}
Expand Down

0 comments on commit 4a4a6dd

Please sign in to comment.