java - Handle expired links while parsing JSON from within the android application -
i designing application in kotlin parses json-array. have completed application stuck on 1 minor(in case major) glitch.i have successfully parsed array , displayed required array of objects in cardview
, opened link in browser when card item clicked.
problem
the json contains links expired or no longer in use. how i handle such(expired) links within app when user clicks on particular card(with flowery message or `imageview)? comfortable in android basics , still learning devise kotlin in android application , searched on internet best of knowledge efforts went in vein.
any warmly , benignly welcomed....
below code fragment(feedviewholder.kt):
class feedviewholder(itemview: view):recyclerview.viewholder(itemview), view.onclicklistener,view.onlongclicklistener { var txttitle: textview var txtpubdate: textview var txtcontent: textview private var itemclicklistener: itemclicklistener? = null init { txttitle = itemview.findviewbyid(r.id.txttitle) textview txtpubdate = itemview.findviewbyid(r.id.txtpubdate) textview txtcontent = itemview.findviewbyid(r.id.txtcontent) textview itemview.setonclicklistener(this) itemview.setonlongclicklistener(this) } fun setitemclicklistener(itemclicklistener: itemclicklistener) { this.itemclicklistener = itemclicklistener } override fun onclick(v: view?) { itemclicklistener!!.onclick(v, adapterposition, false) } override fun onlongclick(v: view?): boolean { itemclicklistener!!.onclick(v, adapterposition, true) return true } }
adapter class
class feedadapter(private val rssobject: rssobject, private val mcontext:context): recyclerview.adapter<feedviewholder>() { private val inflater:layoutinflater init { inflater = layoutinflater.from(mcontext) } override fun getitemcount(): int { return rssobject.items.size } override fun onbindviewholder(holder: feedviewholder, position: int) { holder.txttitle.text = rssobject.items[position].title holder.txtcontent.text = rssobject.items[position].content holder.txtpubdate.text = rssobject.items[position].pubdate holder.setitemclicklistener(itemclicklistener { view, position, islongclick -> if(!islongclick){ val browserintent = intent(intent.action_view, uri.parse(rssobject.items[position].link)) browserintent.addflags(intent.flag_activity_new_task) mcontext.startactivity(browserintent) } }) } override fun oncreateviewholder(parent: viewgroup?, viewtype: int): feedviewholder { val itemview = inflater.inflate(r.layout.row,parent,false) return feedviewholder(itemview) }
Comments
Post a Comment