Collapsible-Calendar-View-Android
Collapsible-Calendar-View-Android copied to clipboard
month view getting invisible on expanding
on expanding Calendar month view getting disable. please comment, if anyone have solution. thanks
@MihirLakhia
Change 301 line in CollapsibleCalendar.kt from
view.layoutParams = TableRow.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
to
view.layoutParams = TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT)
@Zeeshan-The-Dev not working out still facing same issue while expanding.
I was trying fixing this issue, but i reintegrate the library, and it works, try again.
I was trying fixing this issue, but i reintegrate the library, and it works, try again.
I'm also facing the same issue. May I know how you come up with a solution or workaround on this? Thanks!
@MihirLakhia @Zeeshan-The-Dev @forceporquillo @tobiasschuerg
I debug the whole working of it and came up with the solution.
Solution:-
just write ( reload() method ) inside this condition in expand method
if (interpolatedTime == 1f) { state = STATE_EXPANDED
mBtnPrevMonth.isClickable = true
mBtnNextMonth.isClickable = true
reload()
}
Expand Method :-
fun expand(duration: Int) { if (state == STATE_COLLAPSED) { state = STATE_PROCESSING mLayoutBtnGroupMonth.visibility = View.VISIBLE mLayoutBtnGroupWeek.visibility = View.GONE mBtnPrevMonth.isClickable = false mBtnNextMonth.isClickable = false
val currentHeight = mScrollViewBody.measuredHeight
val targetHeight = mInitHeight
val anim = object : Animation() {
override fun applyTransformation(interpolatedTime: Float, t: Transformation) {
mScrollViewBody.layoutParams.height = if (interpolatedTime == 1f)
LinearLayout.LayoutParams.WRAP_CONTENT
else
currentHeight - ((currentHeight - targetHeight) * interpolatedTime).toInt()
mScrollViewBody.requestLayout()
if (interpolatedTime == 1f) {
state = STATE_EXPANDED
mBtnPrevMonth.isClickable = true
mBtnNextMonth.isClickable = true
}
}
}
anim.duration = duration.toLong()
startAnimation(anim)
}
expandIconView.setState(ExpandIconView.LESS, true)
reload()
}
Try this solution:
Change view.layoutParams = TableRow.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
to
view.layoutParams = TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT,1f)
in reload()
method of CollapsibleCalendar.kt
class
Full reload() method
override fun reload() {
mAdapter?.let { mAdapter ->
mAdapter.refresh()
val calendar = Calendar.getInstance()
val tempDatePattern: String
if (calendar.get(Calendar.YEAR) != mAdapter.calendar.get(Calendar.YEAR)) {
tempDatePattern = "MMMM yyyy"
} else {
tempDatePattern = datePattern
}
// reset UI
val dateFormat = SimpleDateFormat(tempDatePattern, getCurrentLocale(context))
dateFormat.timeZone = mAdapter.calendar.timeZone
mTxtTitle.text = dateFormat.format(mAdapter.calendar.time)
mTableHead.removeAllViews()
mTableBody.removeAllViews()
var rowCurrent: TableRow
rowCurrent = TableRow(context)
rowCurrent.layoutParams = TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
for (i in 0..6) {
val view = mInflater.inflate(R.layout.layout_day_of_week, null)
val txtDayOfWeek = view.findViewById<View>(R.id.txt_day_of_week) as TextView
txtDayOfWeek.setText(DateFormatSymbols().getShortWeekdays()[(i + firstDayOfWeek) % 7 + 1])
view.layoutParams = TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT,1f)
rowCurrent.addView(view)
}
mTableHead.addView(rowCurrent)
// set day view
for (i in 0 until mAdapter.count) {
if (i % 7 == 0) {
rowCurrent = TableRow(context)
rowCurrent.layoutParams = TableLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 1f)
mTableBody.addView(rowCurrent)
}
val view = mAdapter.getView(i)
view.layoutParams = TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 1f)
params.let { params ->
if (params != null && (mAdapter.getItem(i).diff < params.prevDays || mAdapter.getItem(i).diff > params.nextDaysBlocked)) {
view.isClickable = false
view.alpha = 0.3f
} else {
view.setOnClickListener { v -> onItemClicked(v, mAdapter.getItem(i)) }
}
}
rowCurrent.addView(view)
}
redraw()
mIsWaitingForUpdate = true
}
}