Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view)
- {
- fun bind(position: Int) {
- val card = cardList[position]
- callback?.onClickCallback(card, itemView, position)
- }
- }
- interface AdapterCallback {
- fun onClickCallback(itemModel: Card, itemView: View, position: Int)
- }
- class CardDetailFragment : Fragment(), CardStackListener, CardStackAdapter.AdapterCallback {
- override fun onClickCallback(itemModel: Card, itemView: View, position: Int) {
- stringTest = itemModel.cardQuestion
- this.itemModel = itemModel
- this.itemView = itemView
- this.position = position
- }
- override fun onCardDisappeared(view: View?, position: Int) {}
- override fun onCardDragging(direction: Direction?, ratio: Float) {}
- override fun onCardSwiped(direction: Direction?) {}
- override fun onCardCanceled() {}
- override fun onCardAppeared(view: View?, position: Int) {}
- override fun onCardRewound() {}
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- setString = arguments?.getString("setString")
- val collectionType = object : TypeToken<List<Card>>() {}.type
- cardList = Gson().fromJson(setString, collectionType) as List<Card>
- for (i in cardList!!) {
- adapter.addItem(i, this)
- }
- setUpCardStackView()
- }
- }
- myButton -> {
- activity?.toast(stringTest ?: "") // Always given the third card instead of first one which is what is showing on the screen
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement