Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android

Respuesta
 
Herramientas
  #1  
Viejo 06/07/19, 10:55:15
Array

[xs_avatar]
Merche300 Merche300 no está en línea
Betatester oficial
 
Fecha de registro: dic 2008
Localización: Valencia
Mensajes: 625
Modelo de smartphone: NEXUS 5 - ONEPLUS 3
Tu operador: Pepephone
Paso de parametros a interface

Como puedo pasar la variable num_jor, dentro del if, a la interface en el metodo getData.getDataApi000.getClient.getActJuvenil? Lo que quiero es pasar el index de la mutableList a la interface, ya que es parte de la url que hay que acceder.


Código:
class FragActual : Fragment() {

    var dataList = ArrayList<ActModel>()
    lateinit var recyclerView: RecyclerView

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?): View? {
        val view = inflater.inflate(R.layout.actual_list, container, false)
        return view
    }


       @SuppressLint("SimpleDateFormat")
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val progressBar: ProgressBar = this.progressBar1

        recyclerView = view.findViewById(R.id.recycler_view)
        recyclerView.adapter= ActAdapter(dataList,activity!!)
        recyclerView.layoutManager = LinearLayoutManager(context!!,LinearLayoutManager.VERTICAL,false)

        Thread(Runnable {
            activity!!.runOnUiThread {
                progressBar.visibility = View.VISIBLE
            }

            try {
                var i = 0
                while(i < Int.MAX_VALUE){
                    i++
                }
            } catch (e: InterruptedException) {
                e.printStackTrace()
            }

            activity!!.runOnUiThread {
                progressBar.visibility = View.GONE
            }
        }).start()

        val mutableList: MutableList<String> = mutableListOf(
            "1/6/2019", "8/6/2019", "16/6/2019", "24/6/2019", "1/7/2019",  "8/7/2019", "15/7/2019",  "30/7/2019", "15/8/2019", "30/8/2019",
            "1/9/2019", "8/9/2019", "16/9/2019", "24/9/2019", "1/10/2019",  "8/10/2019", "15/10/2019",  "30/10/2019", "15/11/2019", "30/11/2019",
            "1/12/2019", "8/12/2019", "16/12/2019", "24/12/2019", "1/7/2020",  "8/7/2020", "15/7/2020",  "30/7/2020", "15/8/2019", "30/6/2019")

        for ((indice, item) in mutableList.withIndex()) {
            val indice = indice+1

            val date = Calendar.getInstance()

            val dateformatter = SimpleDateFormat("d/M/yyyy")
            val fechaInicial = (dateformatter.format(date.time))

            val date2 = Calendar.getInstance()
            date2.add(Calendar.DATE, 7)

            val dateformatter1 = SimpleDateFormat("d/M/yyyy")
            val fechaFinal = (dateformatter1.format(date2.time))

            if (item == fechaInicial){

                val num_jor = indice
            }
        }
        getData()
    }

    private fun getData() {
        val call: Call<List<ActModel>> = Api000.getClient.getActJuvenil(num_jor)
        call.enqueue(object : Callback<List<ActModel>> {

            override fun onResponse(call: Call<List<ActModel>>?, response: Response<List<ActModel>>?) {
                dataList.addAll(response!!.body()!!)
                recyclerView.adapter!!.notifyDataSetChanged()
            }

            override fun onFailure(call: Call<List<ActModel>>?, t: Throwable?) {
            }
        })
    }
}

Última edición por Merche300 Día 21/07/19 a las 12:03:42.
Responder Con Cita


Respuesta

Estás aquí
Regresar   Portal | Indice > Todo sobre Android > Programación y Desarrollo para Android



Hora actual: 18:46:51 (GMT +2)



User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.

Contactar por correo / Contact by mail / 邮件联系 /