qr-basic-admin-scrollview(tak sebe ploho) stable version
This commit is contained in:
parent
68ce2f9520
commit
cc1628c733
@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.toRoute
|
||||
import com.gfg.example_recyclerview.adapterScrollView
|
||||
import com.squareup.picasso.Picasso
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import ru.myitschool.work.R
|
||||
@ -16,6 +17,10 @@ import ru.myitschool.work.ui.qr.result.QrResultDestination
|
||||
import ru.myitschool.work.ui.qr.scan.QrScanDestination
|
||||
import ru.myitschool.work.utils.collectWhenStarted
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ru.myitschool.work.utils.HistoryItem
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainFragment: Fragment(R.layout.fragment_main) {
|
||||
private var _binding: FragmentMainBinding? = null
|
||||
@ -27,6 +32,51 @@ class MainFragment: Fragment(R.layout.fragment_main) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentMainBinding.bind(view)
|
||||
|
||||
val recyclerView = binding.recyclerView
|
||||
|
||||
val examList: MutableList<HistoryItem> = ArrayList()
|
||||
examList.add(
|
||||
HistoryItem(
|
||||
"Math Exam",
|
||||
"May 23, 2015",
|
||||
"Best of Luck",
|
||||
R.drawable.clock,
|
||||
R.drawable.card
|
||||
)
|
||||
)
|
||||
examList.add(
|
||||
HistoryItem(
|
||||
"Science Exam",
|
||||
"June 10, 2015",
|
||||
"Do Well",
|
||||
R.drawable.clock,
|
||||
R.drawable.card
|
||||
)
|
||||
)
|
||||
examList.add(
|
||||
HistoryItem(
|
||||
"History Exam",
|
||||
"July 15, 2015",
|
||||
"All the Best",
|
||||
R.drawable.clock,
|
||||
R.drawable.card
|
||||
)
|
||||
)
|
||||
examList.add(
|
||||
HistoryItem(
|
||||
"English Exam",
|
||||
"August 1, 2015",
|
||||
"Stay Confident",
|
||||
R.drawable.clock,
|
||||
R.drawable.card
|
||||
)
|
||||
)
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(requireActivity())
|
||||
|
||||
val adapter = adapterScrollView(examList)
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
val username = findNavController().currentBackStackEntry?.toRoute<MainDestination>()?.username
|
||||
username?.let { user ->
|
||||
val password = findNavController().currentBackStackEntry?.toRoute<MainDestination>()?.password
|
||||
|
@ -0,0 +1,46 @@
|
||||
package com.gfg.example_recyclerview
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ru.myitschool.work.R
|
||||
import ru.myitschool.work.utils.HistoryItem
|
||||
|
||||
class adapterScrollView(private val entryList: List<HistoryItem>) :
|
||||
RecyclerView.Adapter<adapterScrollView.MyViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.person_card, parent, false)
|
||||
return MyViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
|
||||
val examItem = entryList[position]
|
||||
|
||||
holder.entryName.text = examItem.entryName
|
||||
holder.entryDate.text = examItem.entryDate
|
||||
holder.entryMessage.text = examItem.entryMessage
|
||||
|
||||
if(examItem.entryPicTime != null)
|
||||
holder.entryPicTime.setImageResource(examItem.entryPicTime!!)
|
||||
|
||||
if(examItem.entryPicCard != null)
|
||||
holder.entryPicCard.setImageResource(examItem.entryPicCard!!)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return entryList.size
|
||||
}
|
||||
|
||||
// ViewHolder class
|
||||
class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val entryName: TextView = itemView.findViewById(R.id.EntryName)
|
||||
val entryDate: TextView = itemView.findViewById(R.id.EntryDate)
|
||||
val entryMessage: TextView = itemView.findViewById(R.id.EntryMessage)
|
||||
val entryPicTime: ImageView = itemView.findViewById(R.id.entryPicTime)
|
||||
val entryPicCard: ImageView = itemView.findViewById(R.id.entryPicCard)
|
||||
}
|
||||
}
|
18
app/src/main/java/ru/myitschool/work/utils/recyclerview.kt
Normal file
18
app/src/main/java/ru/myitschool/work/utils/recyclerview.kt
Normal file
@ -0,0 +1,18 @@
|
||||
package ru.myitschool.work.utils
|
||||
|
||||
class HistoryItem {
|
||||
var entryName: String? = null
|
||||
var entryDate: String? = null
|
||||
var entryMessage: String? = null
|
||||
var entryPicTime: Int? = null
|
||||
var entryPicCard: Int? = null
|
||||
|
||||
constructor(entryName:String, entryDate:String, entryMessage:String, entryPicTime:Int, entryPicCard:Int){
|
||||
this.entryName = entryName
|
||||
this.entryDate = entryDate
|
||||
this.entryMessage = entryMessage
|
||||
this.entryPicTime = entryPicTime
|
||||
this.entryPicCard = entryPicCard
|
||||
}
|
||||
|
||||
}
|
@ -130,9 +130,11 @@
|
||||
android:textColorLink="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="normal"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/error" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/error"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/photo"
|
||||
@ -148,6 +150,8 @@
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="0sp"
|
||||
android:layout_height="0sp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@color/app_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@ -155,7 +159,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
tools:context=".MainActivity" android:layout_height="0sp" android:layout_width="0sp">
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -163,10 +167,27 @@
|
||||
android:layout_marginTop="10sp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="185dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/entry"
|
||||
android:paddingTop="15sp"
|
||||
android:paddingBottom="15sp"
|
||||
android:text="Ваши проходы"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textColorLink="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/error" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="240dp"
|
||||
android:layout_height="110dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:overScrollMode="never" />
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
android:textSize="16sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/examPic"
|
||||
android:id="@+id/entryPicTime"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_below="@+id/EntryName"
|
||||
@ -27,36 +27,36 @@
|
||||
app:srcCompat="@drawable/clock"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/examDate"
|
||||
android:id="@+id/EntryDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/EntryName"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_toEndOf="@+id/examPic"
|
||||
android:layout_toEndOf="@+id/entryPicTime"
|
||||
android:gravity="center"
|
||||
android:text="2024"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/examPic2"
|
||||
android:id="@+id/entryPicCard"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_below="@+id/examDate"
|
||||
android:layout_below="@+id/EntryDate"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="7dp"
|
||||
app:srcCompat="@drawable/card"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/examMessage"
|
||||
android:id="@+id/EntryMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/examDate"
|
||||
android:layout_below="@+id/EntryDate"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_toEndOf="@+id/examPic2"
|
||||
android:layout_toEndOf="@+id/entryPicCard"
|
||||
android:gravity="center"
|
||||
android:text="карта"
|
||||
android:textSize="16sp" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user