android-times-square icon indicating copy to clipboard operation
android-times-square copied to clipboard

Logcat errors on cell selection in CalendarPickerView inside AlertDialog

Open nathanielwolf opened this issue 11 years ago • 5 comments

The AlertDialog is created with:

    calendarPickerView = new CalendarPickerView(context,null);

    calendarPickerView.init(new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + DateUtils.YEAR_IN_MILLIS))
        .inMode(CalendarPickerView.SelectionMode.RANGE);

    builder.setView(calendarPickerView);
    builder.show();

Note: Inflating xml containing a CalendarPickerView results in the same situation):

The logcat shows the following whenever a cell is selected/deselected:

01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420dcd88 V..D..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42123f30 V..D..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421aa1d8 V..D..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4212b930 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421b0220 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42268df8 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42278438 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42124d50 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42262e40 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42193c78 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.912  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4219bf30 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421abc28 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421e80d0 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4225b298 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420e1dc0 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420c6548 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42100110 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42191080 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420e17a8 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420fc390 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42104828 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42165540 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421f0250 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4226be78 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421eec68 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420fa2d8 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421ad2a0 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42273e90 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420fd908 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42104428 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421a3d38 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421a4b28 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420ff978 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421636b0 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42191c50 V..D..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4230e778 V..D..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42310010 V..D..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42310868 V..D..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{423110c0 V..D..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42311918 V..D..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42312170 V..D..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{423129c8 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42313ac0 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42315358 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42315bb0 V.ED..C. ..S...ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42316408 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42316c60 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{423174b8 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42317d10 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42318e08 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.922  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231a6a0 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231aef8 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231b750 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231bfa8 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231c800 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231d058 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231e150 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4231f9e8 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42320240 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42320a98 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{423212f0 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42321b48 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{423223a0 V.ED..C. ......ID 570,0-665,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{42323498 V.ED..C. ......ID 0,0-95,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421089e8 V.ED..C. ......ID 95,0-190,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421aab28 V.ED..C. ......ID 190,0-285,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{420c6970 V.ED..C. ......ID 285,0-380,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421abfa8 V.ED..C. ......ID 380,0-475,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{4219ddd8 V.ED..C. ......ID 475,0-570,95} during layout: running second layout pass
01-22 14:38:46.932  25390-25390/com.test.mobile.debug W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{421a4358 V..D..C. ......ID 570,0-665,95} during layout: running second layout pass

nathanielwolf avatar Jan 22 '14 22:01 nathanielwolf

This links to #107 and #107 links back to here. Both are closed with no resolution. Any update on this?

rspenc29 avatar Mar 24 '14 02:03 rspenc29

No update, haven't had a chance to look at it. PRs welcome!

edenman avatar Mar 24 '14 22:03 edenman

Both are closed with no resolution.

This issue is open.

JakeWharton avatar Mar 24 '14 22:03 JakeWharton

I've been digging this issue because performance of the calendar when the layout is being refreshed several times is horrible...

This has to do (at least that is what i've found) with setText() of the text view used as the cell. Once you remove it - all problems are gone!

So - instead of using the textview's text property i am simply drawing it myself - and this solved it all!

Can't commit the changes right now as my code is highly customized but it comes down to modifying this in CalendarCellView:

  • Define vars:

    private String mCellText; private int mCellTextXPadding = 0; private int mCellTextYPadding = 5;

  • Create a base paint for the text:

public CalendarCellView(Context context, AttributeSet attrs) { super(context, attrs);

    this.context = context;

    mTextPaint = new Paint();
    mTextPaint.setTextAlign(Align.CENTER);
    mTextPaint.setTextScaleX(this.getTextScaleX());
}
  • Copy props from the text view itself upon inflating:

protected void onFinishInflate() { super.onFinishInflate();

    mTextPaint.setColor(getTextColors().getDefaultColor());
    mTextPaint.setTextSize(getTextSize());
    mTextPaint.setTypeface(getTypeface());
}
  • Create a setter to set the text:

public void setCellText(String text) { if (mCellText != text) { mCellText = text; invalidate(); } }

  • In OnDraw of the cell draw the text:

// draw the text canvas.drawText((mCellText == null ? "" : mCellText), (this.getWidth() / 2) + mCellTextXPadding, (this.getHeight() / 2) + mCellTextYPadding, mTextPaint);

That's pretty much it.

Sorry for the unformatted text - i am not using gitHub that much :-)

Hope it helps out!

miraclebg avatar Dec 14 '14 10:12 miraclebg

This is again a cyclic reference. Please provide a proper solution. My code is at production level. @JakeWharton @edenman Please look at this. How to reopen this cyclic referenced issues. This is a lot of pain.

RushiMThakker avatar Oct 06 '17 06:10 RushiMThakker