cleanup and renaming things around
This commit is contained in:
parent
8231a7080a
commit
4ff8e82271
|
@ -56,7 +56,7 @@ dependencies {
|
|||
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
implementation "androidx.room:room-ktx:$room_version"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
|
|
|
@ -47,7 +47,7 @@ class HistoryFragment : Fragment(), HistoryItemAdapterListener {
|
|||
|
||||
override fun onItemClick(url: String) {
|
||||
val bundle = bundleOf("url" to url)
|
||||
findNavController().navigate(R.id.action_global_pageViewFragment, bundle)
|
||||
findNavController().navigate(R.id.action_global_pageFragment, bundle)
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
|
|
|
@ -6,7 +6,6 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.core.os.bundleOf
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import dev.lowrespalmtree.comet.databinding.ActivityMainBinding
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
|
||||
|
@ -27,10 +26,10 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
/** Navigate to the PageViewFragment; this will automatically use the home URL if any. */
|
||||
fun goHome(item: MenuItem) {
|
||||
fun goHome(@Suppress("unused_parameter") item: MenuItem) {
|
||||
val bundle = bundleOf()
|
||||
Preferences.getHomeUrl(this)?.let { bundle.putString("url", it) }
|
||||
nhf?.navController?.navigate(R.id.action_global_pageViewFragment, bundle)
|
||||
nhf?.navController?.navigate(R.id.action_global_pageFragment, bundle)
|
||||
binding.drawerLayout.closeDrawers()
|
||||
}
|
||||
}
|
|
@ -19,8 +19,8 @@ import dev.lowrespalmtree.comet.databinding.*
|
|||
* it could be a n-to-1 relation: many lines belong to the same block. This of course changes a bit
|
||||
* the way we have to render things.
|
||||
*/
|
||||
class ContentAdapter(private val listener: ContentAdapterListener) :
|
||||
RecyclerView.Adapter<ContentAdapter.ContentViewHolder>() {
|
||||
class PageAdapter(private val listener: ContentAdapterListener) :
|
||||
RecyclerView.Adapter<PageAdapter.ContentViewHolder>() {
|
||||
|
||||
private var lines = listOf<Line>()
|
||||
private var currentLine = 0
|
||||
|
@ -161,7 +161,7 @@ class ContentAdapter(private val listener: ContentAdapterListener) :
|
|||
override fun getItemCount(): Int = blocks.size
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ContentRecycler"
|
||||
private const val TAG = "PageAdapter"
|
||||
private const val TYPE_EMPTY = 0
|
||||
private const val TYPE_TITLE_1 = 1
|
||||
private const val TYPE_TITLE_2 = 2
|
|
@ -22,15 +22,15 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import dev.lowrespalmtree.comet.ContentAdapter.ContentAdapterListener
|
||||
import dev.lowrespalmtree.comet.PageAdapter.ContentAdapterListener
|
||||
import dev.lowrespalmtree.comet.databinding.FragmentPageViewBinding
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
class PageViewFragment : Fragment(), ContentAdapterListener {
|
||||
class PageFragment : Fragment(), ContentAdapterListener {
|
||||
private lateinit var binding: FragmentPageViewBinding
|
||||
private lateinit var pageViewModel: PageViewModel
|
||||
private lateinit var adapter: ContentAdapter
|
||||
private lateinit var adapter: PageAdapter
|
||||
|
||||
/** Property to access and set the current address bar URL value. */
|
||||
private var currentUrl
|
||||
|
@ -51,7 +51,7 @@ class PageViewFragment : Fragment(), ContentAdapterListener {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
pageViewModel = ViewModelProvider(this)[PageViewModel::class.java]
|
||||
adapter = ContentAdapter(this)
|
||||
adapter = PageAdapter(this)
|
||||
binding.contentRecycler.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.contentRecycler.adapter = adapter
|
||||
|
||||
|
@ -223,6 +223,6 @@ class PageViewFragment : Fragment(), ContentAdapterListener {
|
|||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "PageViewFragment"
|
||||
private const val TAG = "PageFragment"
|
||||
}
|
||||
}
|
|
@ -2,15 +2,15 @@
|
|||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main"
|
||||
app:startDestination="@id/pageViewFragment">
|
||||
app:startDestination="@id/pageFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/pageViewFragment"
|
||||
android:name="dev.lowrespalmtree.comet.PageViewFragment"
|
||||
android:id="@+id/pageFragment"
|
||||
android:name="dev.lowrespalmtree.comet.PageFragment"
|
||||
android:label="PageViewFragment" />
|
||||
<action
|
||||
android:id="@+id/action_global_pageViewFragment"
|
||||
app:destination="@id/pageViewFragment"
|
||||
android:id="@+id/action_global_pageFragment"
|
||||
app:destination="@id/pageFragment"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
|
|
Reference in a new issue