как поместить это ArrayList
в этот метод?
Может кто-нибудь сказать мне, как передать этот ArrayList
в этом методе?
Я добавил весь фрагмент кода, кто-нибудь может направить меня?
Я пытался несколькими способами передать это ArrayList
, но безуспешно всегда остается пустым фрагмент
спасибо
Список массивов
<string-array name="object_types">
метод
private var issues: ArrayList<Issue> = ArrayList()
private fun getIssues() {
val stream = resources.openRawResource(R.raw.markers)
val inputString = stream.bufferedReader().use {
it.readText()
}
val klaxon = Klaxon()
JsonReader(StringReader(inputString)).use { reader -> // requires kotlin > 1.2 !!
reader.beginArray {
while (reader.hasNext()) { // requires "[]" array and not {"something": []}
val issue = klaxon.parse<Issue>(reader)
this.issues!!.add(issue!!)
} }
}
this.issues = Utils.markers
}
GalleryFragment
весь фрагмент кода следует ниже
class GalleryFragment : Fragment(), IssueItemOnClickListener {
private var productsRecyclerView: RecyclerView? = null
private var recyclerAdapter: IssueRecyclerViewAdapter? = null
private var recyclerLayoutManager: RecyclerView.LayoutManager? = null
private var issues: ArrayList<Issue> = ArrayList()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_gallery, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
getIssues()
this.productsRecyclerView = view.findViewById(R.id.issue_list_recycler_view) as RecyclerView
this.productsRecyclerView!!.setHasFixedSize(true)
// use a grid layout manager -> 2 columns
this.recyclerLayoutManager = GridLayoutManager(context, 2) as RecyclerView.LayoutManager?
this.productsRecyclerView!!.layoutManager = this.recyclerLayoutManager
this.recyclerAdapter = IssueRecyclerViewAdapter(this.issues, this)
this.productsRecyclerView!!.adapter = recyclerAdapter
}
override fun onIssueItemClick(pos: Int, issue: Issue) {
val args = Bundle()
val detailsFragment = IssueDetailsFragment()
args.putDouble("lat", issue.lat)
args.putDouble("lng", issue.lng)
args.putString("description", issue.description)
args.putString("name", issue.name)
args.putString("type", issue.type)
args.putString("imgUrl", issue.imgUrl)
detailsFragment.arguments = args
val ft = activity!!.supportFragmentManager.beginTransaction()
ft.replace(R.id.main_fragment_content, detailsFragment)
.setTransition(android.app.FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.addToBackStack(null).commit()
}
private fun getIssues() {
val stream = resources.openRawResource(R.raw.markers)
val inputString = stream.bufferedReader().use {
it.readText()
}
val klaxon = Klaxon()
JsonReader(StringReader(inputString)).use { reader -> // requires kotlin > 1.2 !!
reader.beginArray {
while (reader.hasNext()) { // requires "[]" array and not {"something": []}
val issue = klaxon.parse<Issue>(reader)
this.issues!!.add(issue!!)
}
}
}
this.issues = Utils.markers
}
}