Guest User

Untitled

a guest
Oct 27th, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 3.37 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"
  7.     android:addStatesFromChildren="true"
  8.     tools:context=".ui.dashboard.DashboardFragment">
  9.  
  10.     <Button
  11.         android:id="@+id/button2"
  12.         android:layout_width="130dp"
  13.         android:layout_height="48dp"
  14.         android:layout_marginBottom="90dp"
  15.         android:background="@drawable/add_modules_button_background"
  16.         android:clickable="true"
  17.         android:paddingStart="15dp"
  18.         android:paddingEnd="15dp"
  19.         android:text="Add modules"
  20.         android:textColor="#F2FFFFFF"
  21.         android:visibility="visible"
  22.         app:layout_constraintBottom_toBottomOf="parent"
  23.         app:layout_constraintEnd_toEndOf="parent"
  24.         app:layout_constraintStart_toStartOf="parent" />
  25.  
  26.     <androidx.recyclerview.widget.RecyclerView
  27.         android:id="@+id/rv_numbers"
  28.         android:layout_width="match_parent"
  29.         android:layout_height="wrap_content"
  30.         app:layout_constraintEnd_toEndOf="parent"
  31.         app:layout_constraintStart_toStartOf="parent" />
  32.  
  33. </androidx.constraintlayout.widget.ConstraintLayout>
  34.  
  35.  
  36.  
  37.  
  38.  
  39. package cum.my.magiskcumception.ui.dashboard
  40.  
  41. import android.os.Bundle
  42. import android.view.LayoutInflater
  43. import android.view.View
  44. import android.view.ViewGroup
  45. import androidx.fragment.app.Fragment
  46. import androidx.lifecycle.ViewModelProviders
  47. import androidx.recyclerview.widget.LinearLayoutManager
  48. import androidx.recyclerview.widget.RecyclerView
  49. import cum.my.magiskcumception.Adapter
  50. import cum.my.magiskcumception.ModuleCard
  51. import cum.my.magiskcumception.R
  52. import kotlinx.android.synthetic.main.a_module_card.*
  53. import kotlinx.android.synthetic.main.fragment_dashboard.*
  54.  
  55.  
  56. class DashboardFragment : Fragment() {
  57.     private val recyclerView: RecyclerView get() = requireView().findViewById<RecyclerView>(R.id.rv_numbers)
  58.     private lateinit var dashboardViewModel: DashboardViewModel
  59.     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  60.         val itemList = generateDummyList(10)
  61.         rv_numbers?.adapter = Adapter(itemList)
  62.         rv_numbers?.layoutManager = LinearLayoutManager(recyclerView.context)
  63.         rv_numbers?.setHasFixedSize(false)
  64.  
  65.         dashboardViewModel =
  66.                 ViewModelProviders.of(this).get(DashboardViewModel::class.java)
  67.         return inflater.inflate(R.layout.fragment_dashboard, container, false)
  68.     }
  69.  
  70.  
  71.     private fun generateDummyList(size: Int): List<ModuleCard> {
  72.         val list = ArrayList<ModuleCard>()
  73.         for (i in 0 until size) {
  74.             val drawable = when (i % 3) {
  75.                 0 -> R.drawable.ic_baseline_adb_24
  76.                 1 -> R.drawable.ic_baseline_adb_24
  77.                 else -> R.drawable.ic_baseline_adb_24
  78.             }
  79.             val item = ModuleCard(
  80.                 logo = drawable,
  81.                 title = "Module $i",
  82.                 description = "6227388383",
  83.                 switch = false,
  84.                 delete = R.drawable.ic_baseline_delete_24
  85.             )
  86.             list + item
  87.         }
  88.         return list
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment