update with cleaner code
This commit is contained in:
parent
a9fea4e74a
commit
3ea33b460c
20
app/app.iml
20
app/app.iml
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,5 @@
|
|||
package com.eleith.hashtagit
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -10,10 +8,6 @@ import androidx.lifecycle.ViewModelProviders
|
|||
|
||||
class HashTagItActivity : AppCompatActivity() {
|
||||
|
||||
val sharedPrefs : SharedPreferences by lazy {
|
||||
getSharedPreferences("splash", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_hash_tag_it)
|
||||
|
|
|
@ -14,17 +14,13 @@ import android.view.inputmethod.EditorInfo
|
|||
|
||||
class InputFragment: Fragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_input, container, false)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mEditText.setOnEditorActionListener() { _, actionId, _ ->
|
||||
mEditText.setOnEditorActionListener { _, actionId, _ ->
|
||||
if(actionId == EditorInfo.IME_ACTION_DONE){
|
||||
button.performClick();
|
||||
true
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import kotlinx.coroutines.*
|
||||
|
@ -19,7 +20,6 @@ class SplashFragment: Fragment() {
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
uiScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
delay(2000)
|
||||
|
|
|
@ -31,27 +31,24 @@ class SubmissionFragment : Fragment() {
|
|||
if (activity?.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE) {
|
||||
arguments?.apply {
|
||||
textView.text = SubmissionFragmentArgs.fromBundle(this).writtenText
|
||||
textView.measure(0,0)
|
||||
textView.measure(0, 0)
|
||||
|
||||
putIntoLeanBackMode()
|
||||
|
||||
|
||||
val difference = getTextViewWidthDifferenceFromParent(textView, activity)
|
||||
Log.e("DIFFERENCE", "" + difference);
|
||||
|
||||
when (Bounds.toBounds(difference)) {
|
||||
Bounds.OUT_OF_BOUNDS -> {
|
||||
val abs = Math.abs(difference)
|
||||
|
||||
val animator = ObjectAnimator.ofInt(horizontalScroll, "scrollX", abs)
|
||||
ObjectAnimator.ofInt(horizontalScroll, "scrollX", abs).apply {
|
||||
// how big the word will easy determines length of animation
|
||||
// for readability
|
||||
duration = (10.0 * abs).toLong()
|
||||
repeatMode = ValueAnimator.REVERSE
|
||||
repeatCount = ValueAnimator.INFINITE
|
||||
start()
|
||||
}
|
||||
|
||||
// how big the word will easy determines length of animation
|
||||
// for readability
|
||||
animator.duration = (10.0 * abs).toLong()
|
||||
|
||||
animator.repeatMode = ValueAnimator.REVERSE
|
||||
animator.repeatCount = ValueAnimator.INFINITE
|
||||
animator.start()
|
||||
}
|
||||
Bounds.IN_BOUNDS -> {
|
||||
|
||||
|
@ -65,7 +62,9 @@ class SubmissionFragment : Fragment() {
|
|||
|
||||
// https://developer.android.com/training/system-ui/immersive#leanback
|
||||
private fun putIntoLeanBackMode() {
|
||||
activity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
activity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
}
|
||||
|
||||
private fun getTextViewWidthDifferenceFromParent(tv: TextView, act: Activity?): Int {
|
||||
|
|
Reference in New Issue