create a gridview viewholder
This commit is contained in:
parent
ab4964db5f
commit
952df754a4
|
@ -10,7 +10,7 @@ import com.simplemobiletools.calendar.fragments.WeekFragment
|
|||
class MyWeekPagerAdapter(fm: FragmentManager, private val mListener: WeekFragment.WeekScrollListener) : FragmentStatePagerAdapter(fm) {
|
||||
private val mFragments = SparseArray<WeekFragment>()
|
||||
|
||||
override fun getCount() = 3
|
||||
override fun getCount() = 1
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
val bundle = Bundle()
|
||||
|
|
|
@ -6,17 +6,31 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.BaseAdapter
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
||||
class WeekEventsAdapter(val context: Context) : BaseAdapter() {
|
||||
class WeekEventsAdapter(val context: Context, val mEvents: List<Event>) : BaseAdapter() {
|
||||
private val mInflater: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||
return mInflater.inflate(R.layout.week_grid_item, parent, false)
|
||||
var view = convertView
|
||||
val viewHolder: ViewHolder
|
||||
|
||||
if (view == null) {
|
||||
view = mInflater.inflate(R.layout.week_grid_item, parent, false)
|
||||
viewHolder = ViewHolder(view)
|
||||
view!!.tag = viewHolder
|
||||
} else {
|
||||
viewHolder = view.tag as ViewHolder
|
||||
}
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
override fun getItem(position: Int) = null
|
||||
override fun getItem(position: Int) = mEvents[position]
|
||||
|
||||
override fun getItemId(position: Int) = 0L
|
||||
|
||||
override fun getCount() = 24 * 7
|
||||
|
||||
internal class ViewHolder(view: View)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.simplemobiletools.calendar.models.Event
|
|||
import com.simplemobiletools.calendar.views.MyScrollView
|
||||
import kotlinx.android.synthetic.main.fragment_week.view.*
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
class WeekFragment : Fragment(), WeeklyCalendar {
|
||||
private var mListener: WeekScrollListener? = null
|
||||
|
@ -37,7 +38,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
}
|
||||
})
|
||||
|
||||
mView.week_events_grid.adapter = WeekEventsAdapter(context)
|
||||
mView.week_events_grid.adapter = WeekEventsAdapter(context, ArrayList<Event>())
|
||||
|
||||
mCalendar = WeeklyCalendarImpl(this, context)
|
||||
return mView
|
||||
|
|
Loading…
Reference in New Issue