mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 19:59:00 +00:00
minor fixes
This commit is contained in:
parent
203b701140
commit
dbea9ce516
12 changed files with 135 additions and 99 deletions
|
|
@ -32,7 +32,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -42,7 +41,6 @@
|
|||
android:text="@string/avatar_size"
|
||||
android:gravity="center_vertical"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -62,6 +60,45 @@
|
|||
android:id="@+id/avatarSkinView"
|
||||
app:equipmentTitle="@string/avatar_skin"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/avatar_hair"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
style="@style/SectionTitle"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:divider="?android:listDivider"
|
||||
android:showDividers="middle"
|
||||
android:background="@drawable/layout_rounded_bg_window">
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairColorView"
|
||||
app:equipmentTitle="@string/avatar_color" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairBaseView"
|
||||
app:equipmentTitle="@string/avatar_style" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairBangsView"
|
||||
app:equipmentTitle="@string/avatar_bangs" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairBeardView"
|
||||
app:equipmentTitle="@string/avatar_beard" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairMustacheView"
|
||||
app:equipmentTitle="@string/avatar_mustache" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -108,46 +145,6 @@
|
|||
android:id="@+id/avatar_headband_view"
|
||||
app:equipmentTitle="@string/avatar_headband"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/avatar_hair"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
style="@style/SectionTitle"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:divider="?android:listDivider"
|
||||
android:showDividers="middle"
|
||||
android:background="@drawable/layout_rounded_bg_window">
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairColorView"
|
||||
app:equipmentTitle="@string/avatar_color" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairBaseView"
|
||||
app:equipmentTitle="@string/avatar_base" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairBangsView"
|
||||
app:equipmentTitle="@string/avatar_bangs" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairBeardView"
|
||||
app:equipmentTitle="@string/avatar_beard" />
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarHairMustacheView"
|
||||
app:equipmentTitle="@string/avatar_mustache" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -1158,4 +1158,5 @@
|
|||
<string name="survey_menu_description">Fill out this 5 minute survey to help us grow and receive an achievement!</string>
|
||||
<string name="locked_equipment_shop_dialog">You must purchase the previous items in this sequence to unlock</string>
|
||||
<string name="caused_damage">You caused damage to the boss</string>
|
||||
<string name="avatar_style">Style</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.CustomizationRepository
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.extensions.subscribeWithErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
|
|
@ -17,15 +18,15 @@ import com.habitrpg.android.habitica.ui.adapter.CustomizationRecyclerViewAdapter
|
|||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarginDecoration
|
||||
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class AvatarCustomizationFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
||||
class AvatarCustomizationFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
override var binding: FragmentRecyclerviewBinding? = null
|
||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecyclerviewBinding {
|
||||
return FragmentRecyclerviewBinding.inflate(inflater, container, false)
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
|
@ -82,7 +83,7 @@ class AvatarCustomizationFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
}
|
||||
}
|
||||
adapter.customizationType = type
|
||||
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
val layoutManager = GridLayoutManager(activity, 4)
|
||||
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
|
|
@ -175,5 +176,11 @@ class AvatarCustomizationFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
this.adapter.activeCustomization = activeCustomization
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe({
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.extensions.subscribeWithErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.responses.UnlockResponse
|
||||
|
|
@ -20,15 +21,16 @@ import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
|||
import io.reactivex.rxjava3.core.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class AvatarEquipmentFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
||||
class AvatarEquipmentFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@Inject
|
||||
lateinit var inventoryRepository: InventoryRepository
|
||||
|
||||
override var binding: FragmentRecyclerviewBinding? = null
|
||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecyclerviewBinding {
|
||||
return FragmentRecyclerviewBinding.inflate(inflater, container, false)
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
var type: String? = null
|
||||
|
|
@ -70,7 +72,7 @@ class AvatarEquipmentFragment : BaseMainFragment<FragmentRecyclerviewBinding>()
|
|||
category = args.category
|
||||
}
|
||||
}
|
||||
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
setGridSpanCount(view.width)
|
||||
val layoutManager = GridLayoutManager(activity, 4)
|
||||
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
|
|
@ -136,4 +138,10 @@ class AvatarEquipmentFragment : BaseMainFragment<FragmentRecyclerviewBinding>()
|
|||
this.adapter.activeEquipment = activeEquipment
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe({
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
|
@ -6,24 +6,26 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.ui.adapter.inventory.EquipmentRecyclerViewAdapter
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
||||
import javax.inject.Inject
|
||||
|
||||
class EquipmentDetailFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
||||
class EquipmentDetailFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@Inject
|
||||
lateinit var inventoryRepository: InventoryRepository
|
||||
|
||||
override var binding: FragmentRecyclerviewBinding? = null
|
||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecyclerviewBinding {
|
||||
return FragmentRecyclerviewBinding.inflate(inflater, container, false)
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
var type: String? = null
|
||||
|
|
@ -49,6 +51,7 @@ class EquipmentDetailFragment : BaseMainFragment<FragmentRecyclerviewBinding>()
|
|||
isCostume = args.isCostume
|
||||
equippedGear = args.equippedGear
|
||||
}
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
|
||||
this.adapter.equippedGear = this.equippedGear
|
||||
this.adapter.isCostume = this.isCostume
|
||||
|
|
@ -70,4 +73,10 @@ class EquipmentDetailFragment : BaseMainFragment<FragmentRecyclerviewBinding>()
|
|||
override fun injectFragment(component: UserComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe({
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.extensions.getTranslatedType
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.inventory.Mount
|
||||
|
|
@ -19,7 +20,8 @@ import com.habitrpg.android.habitica.ui.helpers.MarginDecoration
|
|||
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
||||
import javax.inject.Inject
|
||||
|
||||
class MountDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
||||
class MountDetailRecyclerFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@Inject
|
||||
internal lateinit var inventoryRepository: InventoryRepository
|
||||
|
|
@ -30,10 +32,10 @@ class MountDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
var animalColor: String? = null
|
||||
internal var layoutManager: androidx.recyclerview.widget.GridLayoutManager? = null
|
||||
|
||||
override var binding: FragmentRecyclerviewBinding? = null
|
||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecyclerviewBinding {
|
||||
return FragmentRecyclerviewBinding.inflate(inflater, container, false)
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
|
@ -62,6 +64,7 @@ class MountDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
animalType = args.type
|
||||
animalColor = args.color
|
||||
}
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
|
||||
layoutManager = androidx.recyclerview.widget.GridLayoutManager(activity, 2)
|
||||
layoutManager?.spanSizeLookup = object : androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup() {
|
||||
|
|
@ -155,4 +158,10 @@ class MountDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
companion object {
|
||||
private const val ANIMAL_TYPE_KEY = "ANIMAL_TYPE_KEY"
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe({
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.events.commands.FeedCommand
|
||||
import com.habitrpg.android.habitica.extensions.getTranslatedType
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
|
|
@ -20,7 +21,6 @@ import com.habitrpg.android.habitica.models.user.OwnedPet
|
|||
import com.habitrpg.android.habitica.ui.adapter.inventory.PetDetailRecyclerAdapter
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemDialogFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemRecyclerFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarginDecoration
|
||||
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
|
|
@ -28,7 +28,8 @@ import io.reactivex.rxjava3.kotlin.Flowables
|
|||
import org.greenrobot.eventbus.Subscribe
|
||||
import javax.inject.Inject
|
||||
|
||||
class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
||||
class PetDetailRecyclerFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@Inject
|
||||
lateinit var inventoryRepository: InventoryRepository
|
||||
|
|
@ -40,10 +41,10 @@ class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>(
|
|||
private var animalColor: String? = null
|
||||
internal var layoutManager: androidx.recyclerview.widget.GridLayoutManager? = null
|
||||
|
||||
override var binding: FragmentRecyclerviewBinding? = null
|
||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecyclerviewBinding {
|
||||
return FragmentRecyclerviewBinding.inflate(inflater, container, false)
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
|
@ -75,6 +76,7 @@ class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>(
|
|||
animalType = args.type
|
||||
animalColor = args.color
|
||||
}
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
|
||||
layoutManager = androidx.recyclerview.widget.GridLayoutManager(getActivity(), 2)
|
||||
layoutManager?.spanSizeLookup = object : androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup() {
|
||||
|
|
@ -196,4 +198,10 @@ class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>(
|
|||
companion object {
|
||||
private const val ANIMAL_TYPE_KEY = "ANIMAL_TYPE_KEY"
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe({
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.extensions.getTranslatedType
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
|
|
@ -26,11 +28,14 @@ import io.reactivex.rxjava3.kotlin.combineLatest
|
|||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class StableRecyclerFragment : BaseFragment<FragmentRecyclerviewBinding>() {
|
||||
class StableRecyclerFragment : BaseFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@Inject
|
||||
lateinit var inventoryRepository: InventoryRepository
|
||||
@Inject
|
||||
lateinit var userRepository: UserRepository
|
||||
@Inject
|
||||
lateinit var configManager: AppConfigManager
|
||||
|
||||
var adapter: StableRecyclerAdapter? = null
|
||||
|
|
@ -39,10 +44,10 @@ class StableRecyclerFragment : BaseFragment<FragmentRecyclerviewBinding>() {
|
|||
var user: User? = null
|
||||
internal var layoutManager: androidx.recyclerview.widget.GridLayoutManager? = null
|
||||
|
||||
override var binding: FragmentRecyclerviewBinding? = null
|
||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRecyclerviewBinding {
|
||||
return FragmentRecyclerviewBinding.inflate(inflater, container, false)
|
||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
|
@ -66,7 +71,8 @@ class StableRecyclerFragment : BaseFragment<FragmentRecyclerviewBinding>() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding?.recyclerView?.setEmptyView(binding?.emptyView)
|
||||
binding?.emptyView?.text = getString(R.string.empty_items, itemTypeText)
|
||||
binding?.emptyViewTitle?.text = getString(R.string.empty_items, itemTypeText)
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
|
||||
layoutManager = androidx.recyclerview.widget.GridLayoutManager(activity, 2)
|
||||
layoutManager?.spanSizeLookup = object : androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup() {
|
||||
|
|
@ -243,4 +249,10 @@ class StableRecyclerFragment : BaseFragment<FragmentRecyclerviewBinding>() {
|
|||
private const val ITEM_TYPE_KEY = "CLASS_TYPE_KEY"
|
||||
private const val HEADER_VIEW_TYPE = 0
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe({
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentGuildListBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.extensions.subscribeWithErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.ui.adapter.social.GuildListAdapter
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.habitrpg.android.habitica.ui.AvatarView
|
|||
import com.habitrpg.android.habitica.ui.activities.FullProfileActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemDialogFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemRecyclerFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.dismissKeyboard
|
||||
|
|
@ -73,8 +74,6 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
||||
binding?.refreshLayout?.setOnRefreshListener { this.refreshParty() }
|
||||
|
||||
binding?.questAcceptButton?.setOnClickListener { onQuestAccept() }
|
||||
|
|
@ -320,14 +319,15 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
|
|||
dialog?.addButton(android.R.string.cancel, false) { _, _ -> activity?.dismissKeyboard() }
|
||||
dialog?.setTitle(context?.getString(R.string.remove_member_confirm, displayName))
|
||||
dialog?.show()
|
||||
dialog?.show()
|
||||
}
|
||||
|
||||
private fun inviteNewQuest() {
|
||||
val fragment = ItemRecyclerFragment()
|
||||
val fragment = ItemDialogFragment()
|
||||
fragment.itemType = "quests"
|
||||
fragment.itemTypeText = getString(R.string.quest)
|
||||
fragment.isModal = true
|
||||
//fragment.show(parentFragmentManager, "questDialog")
|
||||
fragment.show(parentFragmentManager, "questDialog")
|
||||
}
|
||||
|
||||
internal fun leaveParty() {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
context?.let { binding?.recyclerView?.setBackgroundColor(ContextCompat.getColor(it, R.color.content_background)) }
|
||||
savedInstanceState?.let { this.taskType = savedInstanceState.getString(CLASS_TYPE_KEY, "") }
|
||||
|
||||
this.setInnerAdapter()
|
||||
|
|
@ -239,29 +238,17 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
}
|
||||
}
|
||||
|
||||
binding?.recyclerView?.setScaledPadding(context, 0, 0, 0, 48)
|
||||
binding?.recyclerView?.setScaledPadding(context, 0, 0, 0, 108)
|
||||
|
||||
layoutManager = getLayoutManager(context)
|
||||
layoutManager?.isItemPrefetchEnabled = false
|
||||
binding?.recyclerView?.layoutManager = layoutManager
|
||||
|
||||
allowReordering()
|
||||
|
||||
val bottomPadding = ((binding?.recyclerView?.paddingBottom ?: 0) + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60f, resources.displayMetrics)).toInt()
|
||||
binding?.recyclerView?.setPadding(0, 0, 0, bottomPadding)
|
||||
binding?.recyclerView?.itemAnimator = itemAnimator
|
||||
|
||||
binding?.refreshLayout?.setOnRefreshListener(this)
|
||||
|
||||
binding?.recyclerView?.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
super.onScrollStateChanged(recyclerView, newState)
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
binding?.refreshLayout?.isEnabled = (activity as? MainActivity)?.isAppBarExpanded ?: false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
setEmptyLabels()
|
||||
|
||||
if (Task.TYPE_REWARD == className) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.habitrpg.android.habitica.models.tasks.Task
|
|||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import com.habitrpg.android.habitica.ui.activities.TaskFormActivity
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemRecyclerFragment
|
||||
import com.habitrpg.android.habitica.ui.views.navigation.HabiticaBottomNavigationViewListener
|
||||
import com.habitrpg.android.habitica.ui.views.tasks.TaskFilterDialog
|
||||
import io.reactivex.rxjava3.disposables.Disposable
|
||||
|
|
@ -216,7 +217,7 @@ class TasksFragment : BaseMainFragment<FragmentViewpagerBinding>(), SearchView.O
|
|||
|
||||
binding?.viewPager?.adapter = object : FragmentStateAdapter(fragmentManager, lifecycle) {
|
||||
|
||||
override fun createFragment(position: Int): androidx.fragment.app.Fragment {
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
val fragment: TaskRecyclerViewFragment = when (position) {
|
||||
0 -> TaskRecyclerViewFragment.newInstance(context, Task.TYPE_HABIT)
|
||||
1 -> TaskRecyclerViewFragment.newInstance(context, Task.TYPE_DAILY)
|
||||
|
|
|
|||
Loading…
Reference in a new issue