var list: List<DateMy>? = null
private val presenter by lazy { PagePresenter(this) }
private lateinit var adapter: RecyclerView.Adapter<*>
private lateinit var recycle: RecyclerView
private lateinit var recycleManeger: RecyclerView.LayoutManager
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
var root = inflater.inflate(R.layout.fragment_page, container, false)
recycle = root.findViewById<RecyclerView>(R.id.recyclelistview)
recycleManeger = LinearLayoutManager(activity!!)
adapter = RecycleAdapters(presenter.getAllList(position))
recycle.adapter = adapter
recycle.layoutManager = recycleManeger
return root
}
override fun onResume() {
init()
overuse()
super.onResume()
}
override fun onPause() {
list = null
super.onPause()
}
private fun init() {
DownloadTask ()
}
private fun overuse() {
if (position == 0 && presenter.getAllSiagret(position).get(0) >
getLimit()!!.toInt()) {
var string = presenter.getAllSiagret(position).get(0).toString() + "→" + getLimit()
all_sigaret.setTextColor(resources.getColor(R.color.red))
all_sigaret.text = string
}
} private inner class DownloadTask : AsyncTask<String, Void, Array<Int>>() {
/** The system calls this to perform work in a worker thread and
* delivers it the parameters given to AsyncTask.execute() */
override fun doInBackground(vararg urls: String): Array<Int>{
return presenter.getAllSiagret(position)
}
/** The system calls this to perform work in the UI thread and delivers
* the result from doInBackground() */
override fun onPostExecute(result: Array<Int>) {
all_sigaret.text = result.get(0).toString()
similar_sigaret.text = result.get(1).toString()
electronic_sigaret.text = result.get(2).toString()
}
}
}
Оушит скинь на gist, ну емае😅
Обсуждают сегодня