mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-31 02:44:57 +01:00
implement the arrows at Day screen
This commit is contained in:
parent
cbd5036e1b
commit
7520656d2c
@ -252,11 +252,11 @@ class DayActivity : SimpleActivity(), NavigationListener, DBHelper.DBOperationsL
|
||||
}
|
||||
|
||||
override fun goLeft() {
|
||||
|
||||
view_pager.currentItem = view_pager.currentItem - 1
|
||||
}
|
||||
|
||||
override fun goRight() {
|
||||
|
||||
view_pager.currentItem = view_pager.currentItem + 1
|
||||
}
|
||||
|
||||
override fun goToDateTime(dateTime: DateTime) {
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.simplemobiletools.calendar.fragments
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.view.*
|
||||
@ -16,25 +19,61 @@ import java.util.*
|
||||
|
||||
class DayFragment : Fragment(), DBHelper.DBOperationsListener, AdapterView.OnItemClickListener,
|
||||
AbsListView.MultiChoiceModeListener {
|
||||
private var mTextColor: Int = 0
|
||||
private var mWeakTextColor: Int = 0
|
||||
private var mTextColorWithEvent: Int = 0
|
||||
private var mWeakTextColorWithEvent: Int = 0
|
||||
private var mDayCode: String = ""
|
||||
private var mEvents: MutableList<Event>? = null
|
||||
private var mListener: NavigationListener? = null
|
||||
|
||||
lateinit var mRes: Resources
|
||||
lateinit var mHolder: RelativeLayout
|
||||
lateinit var mConfig: Config
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val view = inflater!!.inflate(R.layout.day_fragment, container, false)
|
||||
mRes = resources
|
||||
mHolder = view.day_holder
|
||||
|
||||
mConfig = Config.newInstance(context)
|
||||
mDayCode = arguments.getString(Constants.DAY_CODE)
|
||||
|
||||
val day = Formatter.getEventDate(activity.applicationContext, mDayCode)
|
||||
view.month_value.text = day
|
||||
|
||||
checkEvents()
|
||||
mHolder.month_value.text = day
|
||||
|
||||
setupButtons()
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
checkEvents()
|
||||
}
|
||||
|
||||
private fun setupButtons() {
|
||||
val baseColor = if (mConfig.isDarkTheme) Color.WHITE else Color.BLACK
|
||||
mTextColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA)
|
||||
mTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA)
|
||||
mWeakTextColor = Utils.adjustAlpha(baseColor, Constants.LOW_ALPHA)
|
||||
mWeakTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.LOW_ALPHA)
|
||||
|
||||
mHolder.apply {
|
||||
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
||||
top_right_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
||||
top_left_arrow.background = null
|
||||
top_right_arrow.background = null
|
||||
|
||||
top_left_arrow.setOnClickListener {
|
||||
mListener?.goLeft()
|
||||
}
|
||||
|
||||
top_right_arrow.setOnClickListener {
|
||||
mListener?.goRight()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setListener(listener: NavigationListener) {
|
||||
mListener = listener
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class MonthFragment : Fragment(), Calendar {
|
||||
mConfig = Config.newInstance(context)
|
||||
mSundayFirst = mConfig.isSundayFirst
|
||||
|
||||
setupColors()
|
||||
setupButtons()
|
||||
|
||||
mPackageName = activity.packageName
|
||||
mDayTextSize = mRes.getDimension(R.dimen.day_text_size) / mRes.displayMetrics.density
|
||||
@ -78,7 +78,7 @@ class MonthFragment : Fragment(), Calendar {
|
||||
mListener = listener
|
||||
}
|
||||
|
||||
private fun setupColors() {
|
||||
private fun setupButtons() {
|
||||
val baseColor = if (mConfig.isDarkTheme) Color.WHITE else Color.BLACK
|
||||
mTextColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA)
|
||||
mTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA)
|
||||
@ -92,13 +92,11 @@ class MonthFragment : Fragment(), Calendar {
|
||||
top_right_arrow.background = null
|
||||
|
||||
top_left_arrow.setOnClickListener {
|
||||
if (mListener != null)
|
||||
mListener!!.goLeft()
|
||||
mListener?.goLeft()
|
||||
}
|
||||
|
||||
top_right_arrow.setOnClickListener {
|
||||
if (mListener != null)
|
||||
mListener!!.goRight()
|
||||
mListener?.goRight()
|
||||
}
|
||||
|
||||
month_value.setOnClickListener { showMonthDialog() }
|
||||
@ -120,8 +118,7 @@ class MonthFragment : Fragment(), Calendar {
|
||||
alertDialog.setPositiveButton(R.string.ok) { dialog, id ->
|
||||
val month = datePicker.month + 1
|
||||
val year = datePicker.year
|
||||
if (mListener != null)
|
||||
mListener!!.goToDateTime(DateTime().withMonthOfYear(month).withYear(year))
|
||||
mListener?.goToDateTime(DateTime().withMonthOfYear(month).withYear(year))
|
||||
}
|
||||
|
||||
alertDialog.show()
|
||||
|
Loading…
x
Reference in New Issue
Block a user