SHARE
TWEET

Untitled

safall Feb 22nd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import android.content.Context
  2. import android.support.v4.view.PagerAdapter
  3. import android.view.LayoutInflater
  4. import android.view.View
  5. import android.view.ViewGroup
  6. import no.getspiff.spiff.R
  7. import no.getspiff.spiff.adapters.viewHolders.SavingsPlanNewViewHolder
  8. import no.getspiff.spiff.model.AuthorizedUser
  9. import no.getspiff.spiff.model.SavingsPlanPresentation
  10.  
  11. class MoveMoneyFromSavingPlansPagerAdapter(private val context: Context,
  12.                                            private val user: AuthorizedUser?) : PagerAdapter() {
  13.  
  14.  
  15.     var savingsPlansMoveMoney: List<SavingsPlanPresentation>? = null
  16.         set(value) {
  17.             field = value
  18.             notifyDataSetChanged()
  19.         }
  20.  
  21.  
  22.     override fun getCount(): Int {
  23.         return savingsPlansMoveMoney?.size ?: 0
  24.     }
  25.  
  26.     override fun instantiateItem(container: ViewGroup, position: Int): Any {
  27.         val viewHolder = SavingsPlanNewViewHolder(LayoutInflater.from(context).inflate(R.layout.row_savings_plan_new, container, false), context)
  28.         viewHolder.set(position, savingsPlansMoveMoney?.getOrNull(position))
  29.         container.addView(viewHolder.view)
  30.         return viewHolder.view
  31.     }
  32.  
  33.     override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
  34.         if (`object` is View) {
  35.             container.removeView(`object`)
  36.         }
  37.     }
  38.  
  39.     override fun isViewFromObject(view: View, `object`: Any): Boolean {
  40.         return view == `object`
  41.     }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top