added quick return for user profile timelines
This commit is contained in:
parent
97a8df5f99
commit
539f141d86
|
@ -139,6 +139,35 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
|
||||||
return mainTabs.height - mainTabs.stripHeight
|
return mainTabs.height - mainTabs.stripHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var controlBarOffset: Float
|
||||||
|
get() {
|
||||||
|
if (mainTabs.columns > 1) {
|
||||||
|
val lp = actionsButton.layoutParams
|
||||||
|
val total: Float
|
||||||
|
total = if (lp is MarginLayoutParams) {
|
||||||
|
(lp.bottomMargin + actionsButton.height).toFloat()
|
||||||
|
} else {
|
||||||
|
actionsButton.height.toFloat()
|
||||||
|
}
|
||||||
|
return 1 - actionsButton.translationY / total
|
||||||
|
}
|
||||||
|
val totalHeight = controlBarHeight.toFloat()
|
||||||
|
return 1 + toolbar.translationY / totalHeight
|
||||||
|
}
|
||||||
|
set(offset) {
|
||||||
|
if (mainTabsContainer.visibility != View.VISIBLE) return
|
||||||
|
val translationY = if (mainTabs.columns > 1) 0 else (controlBarHeight * (offset - 1)).toInt()
|
||||||
|
toolbar.translationY = translationY.toFloat()
|
||||||
|
windowOverlay.translationY = translationY.toFloat()
|
||||||
|
val lp = actionsButton.layoutParams
|
||||||
|
if (lp is MarginLayoutParams) {
|
||||||
|
actionsButton.translationY = (lp.bottomMargin + actionsButton.height) * (1 - offset)
|
||||||
|
} else {
|
||||||
|
actionsButton.translationY = actionsButton.height * (1 - offset)
|
||||||
|
}
|
||||||
|
notifyControlBarOffsetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
override val currentVisibleFragment: Fragment?
|
override val currentVisibleFragment: Fragment?
|
||||||
get() {
|
get() {
|
||||||
val currentItem = mainPager.currentItem
|
val currentItem = mainPager.currentItem
|
||||||
|
@ -603,35 +632,6 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
|
||||||
val tabs: List<SupportTabSpec>
|
val tabs: List<SupportTabSpec>
|
||||||
get() = pagerAdapter.tabs
|
get() = pagerAdapter.tabs
|
||||||
|
|
||||||
override var controlBarOffset: Float
|
|
||||||
get() {
|
|
||||||
if (mainTabs.columns > 1) {
|
|
||||||
val lp = actionsButton.layoutParams
|
|
||||||
val total: Float
|
|
||||||
total = if (lp is MarginLayoutParams) {
|
|
||||||
(lp.bottomMargin + actionsButton.height).toFloat()
|
|
||||||
} else {
|
|
||||||
actionsButton.height.toFloat()
|
|
||||||
}
|
|
||||||
return 1 - actionsButton.translationY / total
|
|
||||||
}
|
|
||||||
val totalHeight = controlBarHeight.toFloat()
|
|
||||||
return 1 + toolbar.translationY / totalHeight
|
|
||||||
}
|
|
||||||
set(offset) {
|
|
||||||
if (mainTabsContainer.visibility != View.VISIBLE) return
|
|
||||||
val translationY = if (mainTabs.columns > 1) 0 else (controlBarHeight * (offset - 1)).toInt()
|
|
||||||
toolbar.translationY = translationY.toFloat()
|
|
||||||
windowOverlay.translationY = translationY.toFloat()
|
|
||||||
val lp = actionsButton.layoutParams
|
|
||||||
if (lp is MarginLayoutParams) {
|
|
||||||
actionsButton.translationY = (lp.bottomMargin + actionsButton.height) * (1 - offset)
|
|
||||||
} else {
|
|
||||||
actionsButton.translationY = actionsButton.height * (1 - offset)
|
|
||||||
}
|
|
||||||
notifyControlBarOffsetChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,6 @@ import org.mariotaku.twidere.util.TwidereColorUtils
|
||||||
import org.mariotaku.twidere.view.ExtendedSwipeRefreshLayout
|
import org.mariotaku.twidere.view.ExtendedSwipeRefreshLayout
|
||||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mariotaku on 15/10/26.
|
|
||||||
*/
|
|
||||||
abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<RecyclerView.ViewHolder>,
|
abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<RecyclerView.ViewHolder>,
|
||||||
L : RecyclerView.LayoutManager> : BaseFragment(), SwipeRefreshLayout.OnRefreshListener,
|
L : RecyclerView.LayoutManager> : BaseFragment(), SwipeRefreshLayout.OnRefreshListener,
|
||||||
RefreshScrollTopInterface, IControlBarActivity.ControlBarOffsetListener,
|
RefreshScrollTopInterface, IControlBarActivity.ControlBarOffsetListener,
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.view.ViewGroup
|
||||||
import kotlinx.android.synthetic.main.fragment_toolbar_tab_pages.*
|
import kotlinx.android.synthetic.main.fragment_toolbar_tab_pages.*
|
||||||
import kotlinx.android.synthetic.main.fragment_toolbar_tab_pages.view.*
|
import kotlinx.android.synthetic.main.fragment_toolbar_tab_pages.view.*
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.activity.LinkHandlerActivity
|
|
||||||
import org.mariotaku.twidere.activity.LinkHandlerActivity.HideUiOnScroll
|
import org.mariotaku.twidere.activity.LinkHandlerActivity.HideUiOnScroll
|
||||||
import org.mariotaku.twidere.activity.iface.IControlBarActivity
|
import org.mariotaku.twidere.activity.iface.IControlBarActivity
|
||||||
import org.mariotaku.twidere.activity.iface.IControlBarActivity.ControlBarOffsetListener
|
import org.mariotaku.twidere.activity.iface.IControlBarActivity.ControlBarOffsetListener
|
||||||
|
@ -166,10 +165,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageScrollStateChanged(state: Int) {
|
override fun onPageScrollStateChanged(state: Int) {
|
||||||
val activity = activity
|
(activity as? IControlBarActivity)?.setControlBarVisibleAnimate(true)
|
||||||
if (activity is LinkHandlerActivity) {
|
|
||||||
activity.setControlBarVisibleAnimate(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override var controlBarOffset: Float
|
override var controlBarOffset: Float
|
||||||
|
@ -181,11 +177,11 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||||
if (toolbarContainer == null) return
|
if (toolbarContainer == null) return
|
||||||
val translationY = (offset - 1) * controlBarHeight
|
val translationY = (offset - 1) * controlBarHeight
|
||||||
toolbarContainer.translationY = translationY
|
toolbarContainer.translationY = translationY
|
||||||
windowOverlay!!.translationY = translationY
|
windowOverlay.translationY = translationY
|
||||||
}
|
}
|
||||||
|
|
||||||
override val controlBarHeight: Int
|
override val controlBarHeight: Int
|
||||||
get() = fragmentToolbar.measuredHeight
|
get() = toolbar.height
|
||||||
|
|
||||||
override fun setupWindow(activity: FragmentActivity): Boolean {
|
override fun setupWindow(activity: FragmentActivity): Boolean {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -92,6 +92,7 @@ import org.mariotaku.twidere.activity.BaseActivity
|
||||||
import org.mariotaku.twidere.activity.ColorPickerDialogActivity
|
import org.mariotaku.twidere.activity.ColorPickerDialogActivity
|
||||||
import org.mariotaku.twidere.activity.LinkHandlerActivity
|
import org.mariotaku.twidere.activity.LinkHandlerActivity
|
||||||
import org.mariotaku.twidere.activity.iface.IBaseActivity
|
import org.mariotaku.twidere.activity.iface.IBaseActivity
|
||||||
|
import org.mariotaku.twidere.activity.iface.IControlBarActivity
|
||||||
import org.mariotaku.twidere.adapter.SupportTabsAdapter
|
import org.mariotaku.twidere.adapter.SupportTabsAdapter
|
||||||
import org.mariotaku.twidere.annotation.AccountType
|
import org.mariotaku.twidere.annotation.AccountType
|
||||||
import org.mariotaku.twidere.annotation.TimelineStyle
|
import org.mariotaku.twidere.annotation.TimelineStyle
|
||||||
|
@ -139,7 +140,7 @@ import org.mariotaku.twidere.view.TabPagerIndicator
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
OnTouchListener, SupportFragmentCallback,
|
OnTouchListener, SupportFragmentCallback, LinkHandlerActivity.HideUiOnScroll,
|
||||||
SystemWindowInsetsCallback, RefreshScrollTopInterface, OnPageChangeListener,
|
SystemWindowInsetsCallback, RefreshScrollTopInterface, OnPageChangeListener,
|
||||||
KeyboardShortcutCallback, UserColorChangedListener, UserNicknameChangedListener,
|
KeyboardShortcutCallback, UserColorChangedListener, UserNicknameChangedListener,
|
||||||
IToolBarSupportFragment, AbsContentRecyclerViewFragment.RefreshCompleteListener {
|
IToolBarSupportFragment, AbsContentRecyclerViewFragment.RefreshCompleteListener {
|
||||||
|
@ -147,18 +148,30 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
override val fragmentToolbar: Toolbar
|
override val fragmentToolbar: Toolbar
|
||||||
get() = toolbar
|
get() = toolbar
|
||||||
|
|
||||||
|
override var controlBarOffset: Float
|
||||||
|
get() {
|
||||||
|
return 1 + toolbar.translationY / 0.98f / controlBarHeight
|
||||||
|
}
|
||||||
|
set(offset) {
|
||||||
|
val translationY = (offset - 1) * controlBarHeight
|
||||||
|
toolbar.translationY = translationY * 0.98f
|
||||||
|
profileHeader.translationY = translationY
|
||||||
|
tabsShadow.translationY = translationY
|
||||||
|
}
|
||||||
|
|
||||||
|
override val controlBarHeight: Int
|
||||||
|
get() = toolbar.height
|
||||||
|
|
||||||
private lateinit var profileBirthdayBanner: View
|
private lateinit var profileBirthdayBanner: View
|
||||||
private lateinit var pagerAdapter: SupportTabsAdapter
|
private lateinit var pagerAdapter: SupportTabsAdapter
|
||||||
|
|
||||||
// Data fields
|
// Data fields
|
||||||
var user: ParcelableUser? = null
|
private var user: ParcelableUser? = null
|
||||||
private set
|
|
||||||
private var account: AccountDetails? = null
|
private var account: AccountDetails? = null
|
||||||
private var relationship: ParcelableRelationship? = null
|
private var relationship: ParcelableRelationship? = null
|
||||||
|
|
||||||
private var userInfoLoaderInitialized: Boolean = false
|
private var userInfoLoaderInitialized: Boolean = false
|
||||||
private var friendShipLoaderInitialized: Boolean = false
|
private var friendShipLoaderInitialized: Boolean = false
|
||||||
private var bannerWidth: Int = 0
|
|
||||||
private var cardBackgroundColor: Int = 0
|
private var cardBackgroundColor: Int = 0
|
||||||
private var actionBarShadowColor: Int = 0
|
private var actionBarShadowColor: Int = 0
|
||||||
private var uiColor: Int = 0
|
private var uiColor: Int = 0
|
||||||
|
@ -326,7 +339,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageScrollStateChanged(state: Int) {
|
override fun onPageScrollStateChanged(state: Int) {
|
||||||
|
(activity as? IControlBarActivity)?.setControlBarVisibleAnimate(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
@ -432,8 +445,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
setUiColor(theme.colorPrimary)
|
setUiColor(theme.colorPrimary)
|
||||||
}
|
}
|
||||||
val defWidth = resources.displayMetrics.widthPixels
|
val defWidth = resources.displayMetrics.widthPixels
|
||||||
val width = if (bannerWidth > 0) bannerWidth else defWidth
|
requestManager.loadProfileBanner(context, user, defWidth).into(profileBanner)
|
||||||
requestManager.loadProfileBanner(context, user, width).into(profileBanner)
|
|
||||||
requestManager.loadOriginalProfileImage(context, user, profileImage.style,
|
requestManager.loadOriginalProfileImage(context, user, profileImage.style,
|
||||||
profileImage.cornerRadius, profileImage.cornerRadiusRatio)
|
profileImage.cornerRadius, profileImage.cornerRadiusRatio)
|
||||||
.thumbnail(requestManager.loadProfileImage(context, user, profileImage.style,
|
.thumbnail(requestManager.loadProfileImage(context, user, profileImage.style,
|
||||||
|
@ -1345,14 +1357,6 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override var controlBarOffset: Float
|
|
||||||
get() = 0f
|
|
||||||
set(value) = Unit //Ignore
|
|
||||||
|
|
||||||
override val controlBarHeight: Int
|
|
||||||
get() = 0
|
|
||||||
|
|
||||||
|
|
||||||
private fun ParcelableRelationship.check(user: ParcelableUser): Boolean {
|
private fun ParcelableRelationship.check(user: ParcelableUser): Boolean {
|
||||||
if (account_key != user.account_key) {
|
if (account_key != user.account_key) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/pagerWindowOverlay"
|
android:id="@+id/tabsShadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/element_spacing_msmall"
|
android:layout_height="@dimen/element_spacing_msmall"
|
||||||
android:background="@drawable/shadow_bottom"
|
android:background="@drawable/shadow_bottom"
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
tools:listitem="@layout/layout_tab_item"/>
|
tools:listitem="@layout/layout_tab_item"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/pagerWindowOverlay"
|
android:id="@+id/tabsShadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@+id/viewPager"
|
android:layout_alignBottom="@+id/viewPager"
|
||||||
|
|
Loading…
Reference in New Issue