package com.github.libretube import android.content.Context import android.os.Bundle import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.PlaylistsAdapter import java.io.IOException import retrofit2.HttpException class Library : Fragment() { private val TAG = "LibraryFragment" lateinit var token: String private lateinit var playlistRecyclerView: RecyclerView private lateinit var refreshLayout: SwipeRefreshLayout override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) arguments?.let { } } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_library, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) playlistRecyclerView = view.findViewById(R.id.playlist_recView) playlistRecyclerView.layoutManager = LinearLayoutManager(view.context) val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) token = sharedPref?.getString("token", "")!! refreshLayout = view.findViewById(R.id.playlist_refresh) if (token != "") { view.findViewById(R.id.boogh2).visibility = View.GONE view.findViewById(R.id.textLike2).visibility = View.GONE fetchPlaylists(view) refreshLayout.isEnabled = true refreshLayout.setOnRefreshListener { Log.d(TAG, "hmm") fetchPlaylists(view) } view.findViewById