Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

month view getting invisible on expanding #64

Open
MihirLakhia opened this issue Sep 26, 2020 · 6 comments
Open

month view getting invisible on expanding #64

MihirLakhia opened this issue Sep 26, 2020 · 6 comments

Comments

@MihirLakhia
Copy link

on expanding Calendar month view getting disable.
please comment, if anyone have solution.
thanks

ezgif com-video-to-gif

@Zeeshan-The-Dev
Copy link

Zeeshan-The-Dev commented Oct 14, 2020

@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)

@Gajendra479
Copy link

Gajendra479 commented Mar 31, 2021

@Zeeshan-The-Dev not working out still facing same issue while expanding.

@MihirLakhia
Copy link
Author

I was trying fixing this issue, but i reintegrate the library, and it works, try again.

@forceporquillo
Copy link

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!

@Gajendra479
Copy link

Gajendra479 commented Sep 23, 2021

@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()

}

@developer-sunshine
Copy link

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
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants