on the listview highlight the current day and currently active event

This commit is contained in:
tibbi 2016-11-02 23:04:04 +01:00
parent 252d0e63f2
commit 46a44baa1e
2 changed files with 18 additions and 1 deletions

View File

@ -3,7 +3,6 @@ package com.simplemobiletools.calendar.activities
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import com.simplemobiletools.calendar.Config
import com.simplemobiletools.calendar.R

View File

@ -20,10 +20,17 @@ class EventsListAdapter(context: Context, val mEvents: List<ListItem>) : BaseAda
private val mInflater: LayoutInflater
private var mTopDivider: Drawable? = null
private var mNow = (System.currentTimeMillis() / 1000).toInt()
private var mOrangeColor = 0
private var mGreyColor = 0
private var mTodayDate = ""
init {
mInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
mTopDivider = context.resources.getDrawable(R.drawable.divider)
mOrangeColor = context.resources.getColor(R.color.colorPrimary)
val mTodayCode = Formatter.getDayCodeFromTS(mNow)
mTodayDate = Formatter.getEventDate(context, mTodayCode)
}
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
@ -57,11 +64,22 @@ class EventsListAdapter(context: Context, val mEvents: List<ListItem>) : BaseAda
end?.text = Formatter.getTime(item.endTS)
end?.visibility = View.VISIBLE
}
val currTextColor = if (item.startTS <= mNow) mOrangeColor else mGreyColor
start?.setTextColor(currTextColor)
end?.setTextColor(currTextColor)
title.setTextColor(currTextColor)
description?.setTextColor(currTextColor)
}
} else {
val item = mEvents[position] as ListSection
viewHolder.title.text = item.title
viewHolder.title.setCompoundDrawablesWithIntrinsicBounds(null, if (position == 0) null else mTopDivider, null, null)
if (mGreyColor == 0)
mGreyColor = viewHolder.title.currentTextColor
viewHolder.title.setTextColor(if (item.title == mTodayDate) mOrangeColor else mGreyColor)
}
return view