Skip to content

Commit 880c2ad

Browse files
committed
Code cleanup
1 parent 8120e50 commit 880c2ad

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/src/main/java/com/dan/perspective/AppFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.dan.perspective
33
import androidx.fragment.app.Fragment
44

55
open class AppFragment(val activity: MainActivity) : Fragment() {
6-
open fun onBack(backButton: Boolean) {
6+
open fun onBack(homeButton: Boolean) {
77
}
88

99
fun showToast(message: String) {

app/src/main/java/com/dan/perspective/MainActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class MainActivity : AppCompatActivity() {
2929
private val stack = mutableListOf<Pair<String, AppFragment>>()
3030
val settings: Settings by lazy { Settings(this) }
3131

32-
private fun popView(callOnBack: Boolean = false, backButton: Boolean = false): Boolean {
32+
private fun popView(homeButton: Boolean = false): Boolean {
3333
if (stack.size <= 1) return false
3434

3535
val prevFragment = stack.removeLast().second
3636
val item = stack.last()
3737

38-
if (callOnBack) prevFragment.onBack(backButton)
38+
prevFragment.onBack(homeButton)
3939

4040
val transaction = supportFragmentManager.beginTransaction()
4141
transaction.show(item.second)
@@ -71,15 +71,15 @@ class MainActivity : AppCompatActivity() {
7171

7272
override fun onOptionsItemSelected(item: MenuItem): Boolean {
7373
if (android.R.id.home == item.itemId) {
74-
popView(true, true)
74+
popView(true)
7575
return true
7676
}
7777

7878
return super.onOptionsItemSelected(item)
7979
}
8080

8181
override fun onBackPressed() {
82-
if (!popView(true, false)) super.onBackPressed()
82+
if (!popView(false)) super.onBackPressed()
8383
}
8484

8585
fun giveHapticFeedback(view: View) {

app/src/main/java/com/dan/perspective/SettingsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SettingsFragment(activity: MainActivity) : AppFragment(activity) {
2222
private val settings = activity.settings
2323
private lateinit var binding: SettingsFragmentBinding
2424

25-
override fun onBack(backButton: Boolean) {
25+
override fun onBack(homeButton: Boolean) {
2626
if (binding.radioPng.isChecked) activity.settings.outputType = Settings.OUTPUT_TYPE_PNG
2727
else if (binding.radioTiff.isChecked) activity.settings.outputType = Settings.OUTPUT_TYPE_TIFF
2828
else activity.settings.outputType = Settings.OUTPUT_TYPE_JPEG

0 commit comments

Comments
 (0)