Removed collections from profile tabs

This commit is contained in:
mjaillot 2020-05-21 21:11:15 +02:00
parent 9553b00b37
commit 8789c3f09c
5 changed files with 20 additions and 16 deletions

View File

@ -19,6 +19,7 @@ import com.google.android.material.tabs.TabLayoutMediator
import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.fragments.ProfileBookmarkFragment
import com.h.pixeldroid.fragments.ProfilePostFragment
import com.h.pixeldroid.fragments.ProfileTabsFragment
import com.h.pixeldroid.objects.Account
import com.h.pixeldroid.objects.Account.Companion.ACCOUNT_TAG
import com.h.pixeldroid.objects.Relationship
@ -59,7 +60,7 @@ class ProfileActivity : AppCompatActivity() {
setViews()
activateFollow()
val tabs = arrayOf(ProfilePostFragment(), Fragment())
val tabs : Array<ProfileTabsFragment> = arrayOf(ProfilePostFragment())
setTabs(tabs)
} ?: run {
pixelfedAPI.verifyCredentials("Bearer $accessToken")
@ -69,7 +70,7 @@ class ProfileActivity : AppCompatActivity() {
account = response.body()!!
setViews()
val tabs = arrayOf(ProfilePostFragment(), Fragment(), ProfileBookmarkFragment())
val tabs = arrayOf(ProfilePostFragment(), ProfileBookmarkFragment())
setTabs(tabs)
}
}
@ -120,7 +121,7 @@ class ProfileActivity : AppCompatActivity() {
nbFollowing.setOnClickListener{ onClickFollowing() }
}
private fun setTabs(tabs: Array<Fragment>) {
private fun setTabs(tabs: Array<ProfileTabsFragment>) {
val viewPager = findViewById<ViewPager2>(R.id.profile_view_pager)
viewPager.adapter = object : FragmentStateAdapter(this) {
override fun createFragment(position: Int): Fragment {

View File

@ -15,10 +15,10 @@ import com.h.pixeldroid.R
import com.h.pixeldroid.adapters.ProfilePostsRecyclerViewAdapter
import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.objects.Status
import com.h.pixeldroid.utils.DBUtils
import retrofit2.Response
abstract class ProfileTabsFragment : Fragment() {
private lateinit var preferences: SharedPreferences
internal lateinit var pixelfedAPI: PixelfedAPI
internal lateinit var adapter : ProfilePostsRecyclerViewAdapter
private lateinit var recycler : RecyclerView
@ -29,11 +29,14 @@ abstract class ProfileTabsFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_profile_post, container, false)
preferences = requireActivity().getSharedPreferences(
"${BuildConfig.APPLICATION_ID}.pref", Context.MODE_PRIVATE
)
pixelfedAPI = PixelfedAPI.create("${preferences.getString("domain", "")}")
accessToken = preferences.getString("accessToken", "")
val db = DBUtils.initDB(requireContext())
val user = db.userDao().getActiveUser()
val domain = user?.instance_uri.orEmpty()
pixelfedAPI = PixelfedAPI.create(domain)
accessToken = user?.accessToken.orEmpty()
// Set posts RecyclerView as a grid with 3 columns
recycler = view.findViewById(R.id.profilePostsRecyclerView)

View File

@ -338,11 +338,11 @@ data class Status(
// Activate bookmarker
setEventListener { _, buttonState ->
if (buttonState) {
// Button is active
bookmarkPostCall(holder, api, credential, this@Status)
} else {
// Button is inactive
// Button is active, unbookmark
unBookmarkPostCall(holder, api, credential, this@Status)
} else {
// Button is inactive, bookmark
bookmarkPostCall(holder, api, credential, this@Status)
}
//show animation or not?
true

View File

@ -134,7 +134,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabBackground="@color/colorPrimary" />
app:tabBackground="@color/colorPrimaryTab" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/profile_view_pager"

View File

@ -62,8 +62,8 @@
sparkbutton:activeImage="@drawable/ic_bookmark_black_24dp"
sparkbutton:iconSize="28dp"
sparkbutton:inactiveImage="@drawable/ic_bookmark_border_black_24dp"
sparkbutton:primaryColor="@color/black"
sparkbutton:secondaryColor="@color/share_blue"
sparkbutton:primaryColor="@color/share_blue"
sparkbutton:secondaryColor="@color/black"
app:layout_constraintBottom_toBottomOf="@+id/profilePic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/profilePic" />