Я пытаюсь удалить имя из списка, но ничего, оно выходит со всем внутри, и я просто хочу, чтобы вы сказали мне только matematicas и другие предметы, которые я добавлю
{
"id": 419704,
"page": 1,
"total_results": 0,
"total_pages": 0,
"results": [
{
"id": 1,
"nom_prof": "nombre profesor",
"asignaturas": [
{
"matematicas": {
"lunes": {
"hora1": "x",
"hora2": "x",continue....
и это то, что я могу вспомнить
clasigicacion.asignaturas.forEach {
itemView.tv_asignaturas.text = it.toString()
}
clasificacion - это список
Это адаптер для улучшения внешнего вида
class TeachAdapter (val profesores: ArrayList<Results.Profesores>): androidx.recyclerview.widget.RecyclerView.Adapter<TeachAdapter.ClasiViewHolder>() {
private var context: Context? = null
override fun onBindViewHolder(holder: ClasiViewHolder, position: Int) {
val itemClasi = profesores[position]
holder.bindClasificacion(itemClasi)
holder.itemView.setOnClickListener{
//Toast.makeText(context, "settings", Toast.LENGTH_SHORT).show()
val bundle = Bundle()
bundle.putString("nom_prof", itemClasi?.nom_prof)
bundle.putString("img_profe", itemClasi?.img_profe)
bundle.putString("img_fondo", itemClasi?.img_fondo)
bundle.putString("asignatura", itemClasi.asignaturas[0].nom_asignatura)
bundle.putString("lunes_1", itemClasi.asignaturas[0].lunes?.hora1)
bundle.putString("lunes_2", itemClasi.asignaturas[0].lunes?.hora2)
bundle.putString("lunes_3", itemClasi.asignaturas[0].lunes?.hora3)
bundle.putString("lunes_4", itemClasi.asignaturas[0].lunes?.hora4)
bundle.putString("lunes_5", itemClasi.asignaturas[0].lunes?.hora5)
bundle.putString("lunes_6", itemClasi.asignaturas[0].lunes?.hora6)
context!!.startActivity(Intent(context, DetProfesor::class.java).putExtras(bundle))
}
}
override fun getItemCount(): Int {
return profesores.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ClasiViewHolder {
val layoutInflate = LayoutInflater.from(parent.context)
.inflate(R.layout.teach_row, parent, false)
context = parent.context
return ClasiViewHolder(layoutInflate)
}
class ClasiViewHolder(itemView: View): androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView){
@SuppressLint("SetTextI18n", "LogNotTimber")
fun bindClasificacion(profesores: Results.Profesores){
Picasso.get()
.load(Constants.URL_IMAGES + profesores.img_profe)
.resize(50, 50)
.centerCrop()
.into(itemView.civ_imageProf)
//Log.d("Tag xxx: ", clasigicacion.nom_prof)
itemView.tv_namProf.text = profesores.nom_prof
itemView.tv_asignaturas.text = profesores.asignaturas[0].nom_asignatura
for ((k, v) in profesores.asignaturas) {
println("key: $k values - $v")
}
}
}
}
Фрагмент отсюда парсера
class FragProfesores : androidx.fragment.app.Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.teach_list, container, false)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerView.layoutManager = GridLayoutManager(context, 1)
recyclerView.adapter = null
val progressBar: ProgressBar = this.progressBar
Thread(Runnable {
activity!!.runOnUiThread(java.lang.Runnable {
progressBar.visibility = View.VISIBLE
})
try {
var i = 0
while(i<Int.MAX_VALUE){
i++
}
} catch (e: InterruptedException) {
e.printStackTrace()
}
activity!!.runOnUiThread(java.lang.Runnable {
progressBar.visibility = View.GONE
})
}).start()
val apiClasi = Api000.getClient.getClasificacion()
apiClasi.enqueue(object : Callback<Results> {
override fun onFailure(call: Call<Results>, t: Throwable?) {
// Log.e("TAG Fallo: ", t.toString())
}
override fun onResponse(call: Call<Results>, response: Response<Results>) {
for(res in response.body()!!.results){
//Log.d("TAG Respuesta: ", res.asignaturas!!.asig_1)
}
recyclerView.adapter = TeachAdapter(response.body()!!.results)
}
})
}
}
и ModelBeen
data class Results (val results: ArrayList<Profesores>){
data class Profesores (
val id: String,
val nom_prof: String,
val asignaturas: ArrayList<Asignaturas>,
val img_profe: String,
val img_fondo: String){
data class Asignaturas(val matematicas: Matematicas?){
data class Matematicas(val lunes: Lunes?,val martes: Martes?){
data class Lunes(
val hora1: String,val hora2: String,val hora3: String,val hora4: String,val hora5: String,val hora6: String)
data class Martes(
val hora1: String,val hora2: String,val hora3: String,val hora4: String,val hora5: String,val hora6: String)
}
}
}
}