Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
37 changed files
with
457 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/pavelrekun/rekado/base/BasePreferencesFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.pavelrekun.rekado.base | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.preference.Preference | ||
import androidx.preference.PreferenceFragmentCompat | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.pavelrekun.penza.services.extensions.convertPXToDP | ||
|
||
open class BasePreferencesFragment(private val preferencesLayoutId: Int, private val titleResId: Int) : PreferenceFragmentCompat() { | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
getBaseActivity().supportActionBar?.setTitle(titleResId) | ||
} | ||
|
||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
addPreferencesFromResource(preferencesLayoutId) | ||
} | ||
|
||
override fun <T : Preference> findPreference(key: CharSequence): T { | ||
return super.findPreference(key)!! | ||
} | ||
|
||
override fun onCreateRecyclerView(inflater: LayoutInflater?, parent: ViewGroup?, savedInstanceState: Bundle?): RecyclerView { | ||
val view = super.onCreateRecyclerView(inflater, parent, savedInstanceState) | ||
|
||
view.addOnScrollListener(object : RecyclerView.OnScrollListener() { | ||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { | ||
super.onScrolled(recyclerView, dx, dy) | ||
|
||
if (view.canScrollVertically(SCROLL_DIRECTION_UP)) { | ||
getBaseActivity().supportActionBar?.elevation = 3.convertPXToDP(getBaseActivity()).toFloat() | ||
} else { | ||
getBaseActivity().supportActionBar?.elevation = 0F | ||
} | ||
} | ||
|
||
}) | ||
|
||
return view | ||
} | ||
|
||
fun getBaseActivity() = activity as BaseActivity | ||
|
||
companion object { | ||
private const val SCROLL_DIRECTION_UP = -1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.