mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
refactor: move resource heavy functions into launch lifecycle scope
This commit is contained in:
parent
0d25ad8561
commit
18d8261e33
@ -10,9 +10,7 @@ import android.os.Bundle
|
|||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.RelativeLayout
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
@ -75,7 +73,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
|||||||
glide = GlideApp.with(this)
|
glide = GlideApp.with(this)
|
||||||
// Set up toolbar buttons
|
// Set up toolbar buttons
|
||||||
profileButton.glide = glide
|
profileButton.glide = glide
|
||||||
updateProfileButton()
|
|
||||||
profileButton.setOnClickListener { openSettings() }
|
profileButton.setOnClickListener { openSettings() }
|
||||||
pathStatusViewContainer.disableClipping()
|
pathStatusViewContainer.disableClipping()
|
||||||
pathStatusViewContainer.setOnClickListener { showPath() }
|
pathStatusViewContainer.setOnClickListener { showPath() }
|
||||||
@ -117,12 +114,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
|||||||
homeAdapter.changeCursor(null)
|
homeAdapter.changeCursor(null)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Set up gradient view
|
|
||||||
val gradientViewLayoutParams = gradientView.layoutParams as RelativeLayout.LayoutParams
|
|
||||||
val displayMetrics = DisplayMetrics()
|
|
||||||
windowManager.defaultDisplay.getMetrics(displayMetrics)
|
|
||||||
val height = displayMetrics.heightPixels
|
|
||||||
gradientViewLayoutParams.topMargin = (0.15 * height.toFloat()).toInt()
|
|
||||||
// Set up new conversation button set
|
// Set up new conversation button set
|
||||||
newConversationButtonSet.delegate = this
|
newConversationButtonSet.delegate = this
|
||||||
// Set up typing observer
|
// Set up typing observer
|
||||||
@ -137,7 +128,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
|||||||
OpenGroupManager.startPolling()
|
OpenGroupManager.startPolling()
|
||||||
JobQueue.shared.resumePendingJobs()
|
JobQueue.shared.resumePendingJobs()
|
||||||
}
|
}
|
||||||
IP2Country.configureIfNeeded(this)
|
|
||||||
application.registerForFCMIfNeeded(false)
|
application.registerForFCMIfNeeded(false)
|
||||||
// Observe blocked contacts changed events
|
// Observe blocked contacts changed events
|
||||||
val broadcastReceiver = object : BroadcastReceiver() {
|
val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
@ -150,6 +140,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
|||||||
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter("blockedContactsChanged"))
|
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter("blockedContactsChanged"))
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
// update things based on TextSecurePrefs (profile info etc)
|
// update things based on TextSecurePrefs (profile info etc)
|
||||||
|
updateProfileButton()
|
||||||
|
IP2Country.configureIfNeeded(this@HomeActivity)
|
||||||
TextSecurePreferences.events.filter { it == TextSecurePreferences.PROFILE_NAME_PREF }.collect {
|
TextSecurePreferences.events.filter { it == TextSecurePreferences.PROFILE_NAME_PREF }.collect {
|
||||||
updateProfileButton()
|
updateProfileButton()
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
|
|
||||||
<gradient
|
<gradient
|
||||||
|
android:centerY="0.75"
|
||||||
android:centerColor="?attr/home_gradient_start"
|
android:centerColor="?attr/home_gradient_start"
|
||||||
android:endColor="?attr/home_gradient_end"
|
android:endColor="?attr/home_gradient_end"
|
||||||
android:angle="270" />
|
android:angle="270" />
|
||||||
|
Loading…
Reference in New Issue
Block a user