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

Add isInEditMode checks for preview rendering.

Open cs-victor-nascimento opened this issue 10 years ago • 11 comments
trafficstars

Hey people!

I am trying to use TimesSquare but am getting a NullPointerException in a simple preview from Android Studio like:

npe_timessquare Looking through the code it seems a bit strange that it should be working...

This code seems like will always throw a null pointer exception but I may be mistaken...

The layout file I am trying to preview is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.squareup.timessquare.CalendarPickerView
        android:id="@+id/calendar_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

When I run it the app crashes just the same.

Am I missing something? Thanks in advance

cs-victor-nascimento avatar Jan 28 '15 18:01 cs-victor-nascimento

Are you initializing the calendar? See the README for an example of calling init

edenman avatar Jan 28 '15 18:01 edenman

Yeah... I missed it... Sorry for the inconvenience! But that means it won't be able to preview in Studio right?

cs-victor-nascimento avatar Jan 28 '15 18:01 cs-victor-nascimento

We can add some isInEdit checks for reasonable preview rendering. On Jan 28, 2015 10:30 AM, "Victor Oliveira Nascimento" < [email protected]> wrote:

Yeah... I missed it... Sorry for the inconvenience! But that means it won't be able to preview in Studio right?

— Reply to this email directly or view it on GitHub https://github.com/square/android-times-square/issues/176#issuecomment-71888395 .

JakeWharton avatar Jan 28 '15 18:01 JakeWharton

That would help :+1:

cs-victor-nascimento avatar Jan 28 '15 18:01 cs-victor-nascimento

Re-purposed the issue for that task.

JakeWharton avatar Jan 28 '15 18:01 JakeWharton

Hi :) So, any progress with that? I have problems with previewing layout in AS (did not check eclipse), if there is CalendarPickerView dropped onto layout.

glebsts avatar Aug 30 '15 02:08 glebsts

Hello again. Few months ago I just threw away this component. Now took that again, and still problems with rendering. AS, API17 rendered, gradle imported 1.6.4 version. java.lang.IllegalArgumentException: Illegal pattern character 'L' at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845) at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659) at java.text.SimpleDateFormat.(SimpleDateFormat.java:585) at com.squareup.timessquare.CalendarPickerView.(CalendarPickerView.java:140) ......

Found that in google: https://code.google.com/p/android/issues/detail?id=75940

So how are you guys using this component?

glebsts avatar Nov 16 '15 13:11 glebsts

@glebsts you're just talking about issues with previewing a CalendarPickerView in Android Studio, right?

edenman avatar Nov 16 '15 17:11 edenman

I am just trying to figure out if something was fixed or is going to be fixed :) Yes, issue with preview in AS.

glebsts avatar Nov 16 '15 17:11 glebsts

No changes have been made on this issue. PRs welcome if you really need AS preview (most of us at Square don't use it).

edenman avatar Nov 16 '15 17:11 edenman

Well, I thought idea is to provide a component that works in any conditions :) You could at least make a note in readme if you put it into public.... or at least make some statements here in github discussions :) Your component is considered the best across the internets, I was hoping you might be interested in keeping perfect reputation :) So far I work-arounded that by hiding component and setting visibility in run-time, but you know, sometimes it is nice to see how your layout will look like :D Thank you for your answer anyway! Are you using Eclipse?

glebsts avatar Nov 16 '15 18:11 glebsts