fix playlists not showing

This commit is contained in:
Bnyro 2022-07-02 16:30:47 +02:00
parent ff77c69eb1
commit ebaa7374cb
5 changed files with 69 additions and 72 deletions

View File

@ -9,6 +9,7 @@ import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.databinding.DialogLoginBinding import com.github.libretube.databinding.DialogLoginBinding
import com.github.libretube.obj.Login import com.github.libretube.obj.Login
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
@ -89,6 +90,7 @@ class LoginDialog : DialogFragment() {
Toast.makeText(context, R.string.loggedIn, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.loggedIn, Toast.LENGTH_SHORT).show()
PreferenceHelper.setToken(requireContext(), response.token!!) PreferenceHelper.setToken(requireContext(), response.token!!)
PreferenceHelper.setUsername(requireContext(), login.username!!) PreferenceHelper.setUsername(requireContext(), login.username!!)
requireMainActivityRestart = true
dialog?.dismiss() dialog?.dismiss()
} }
} }

View File

@ -7,6 +7,7 @@ import android.widget.Toast
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.databinding.DialogLogoutBinding import com.github.libretube.databinding.DialogLogoutBinding
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -25,6 +26,7 @@ class LogoutDialog : DialogFragment() {
binding.user.text = binding.user.text =
binding.user.text.toString() + " (" + user + ")" binding.user.text.toString() + " (" + user + ")"
binding.logout.setOnClickListener { binding.logout.setOnClickListener {
requireMainActivityRestart = true
Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()
PreferenceHelper.setToken(requireContext(), "") PreferenceHelper.setToken(requireContext(), "")
dialog?.dismiss() dialog?.dismiss()

View File

@ -2,7 +2,6 @@ package com.github.libretube.preferences
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.navigation.fragment.findNavController
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R import com.github.libretube.R

View File

@ -2,7 +2,6 @@ package com.github.libretube.preferences
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat

View File

@ -6,95 +6,90 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".fragments.LibraryFragment"> tools:context=".fragments.LibraryFragment">
<LinearLayout <RelativeLayout
android:id="@+id/loginOrRegister2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<LinearLayout <ImageView
android:id="@+id/showWatchHistory" android:id="@+id/boogh"
android:layout_width="match_parent" android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_login" />
<TextView
android:id="@+id/text_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:layout_below="@id/boogh"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:src="@drawable/ic_time_outlined" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/watch_history"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="@+id/loginOrRegister2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_centerVertical="true"> android:gravity="center"
android:text="@string/please_login"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<ImageView <com.github.libretube.util.CustomSwipeToRefresh
android:id="@+id/boogh" android:id="@+id/playlist_refresh"
android:layout_width="100dp" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="match_parent">
android:layout_centerInParent="true"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_login" />
<TextView <ScrollView
android:id="@+id/text_like" android:id="@+id/scrollview_playlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/boogh"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="@string/please_login"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<com.github.libretube.util.CustomSwipeToRefresh
android:id="@+id/playlist_refresh"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ScrollView <LinearLayout
android:id="@+id/scrollview_playlist"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/showWatchHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:src="@drawable/ic_time_outlined" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/watch_history"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:descendantFocusability="blocksDescendants">
<RelativeLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/playlist_recView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"> android:nestedScrollingEnabled="false" />
<androidx.recyclerview.widget.RecyclerView </RelativeLayout>
android:id="@+id/playlist_recView" </LinearLayout>
android:layout_width="match_parent" </ScrollView>
android:layout_height="match_parent" </com.github.libretube.util.CustomSwipeToRefresh>
android:nestedScrollingEnabled="false" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</com.github.libretube.util.CustomSwipeToRefresh>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/create_playlist" android:id="@+id/create_playlist"