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

[Review] Minor performance tweaks #74

Merged
merged 4 commits into from
Aug 15, 2015
Merged

[Review] Minor performance tweaks #74

merged 4 commits into from
Aug 15, 2015

Conversation

pt2121
Copy link
Contributor

@pt2121 pt2121 commented Aug 13, 2015

Hi guys,

First of all, thanks for this awesome work.
I'd like to propose to use Parcelable instead of Serializable in Emojicon class.
Hopefully, this might improve performance (as mention at http://www.developerphil.com/parcelable-vs-serializable/) and seems to align with Android best practices.

Also, I updated ViewHolder to be static based on Favor static member classes over nonstatic

Changes:

Thanks!

@pt2121 pt2121 changed the title [Review] Change from Serializable to Parcelable [Review] Minor performance tweaks Aug 13, 2015
@rockerhieu
Copy link
Owner

Looks good, I will test it a bit and keep you posted.

rockerhieu added a commit that referenced this pull request Aug 15, 2015
[Review] Minor performance tweaks
@rockerhieu rockerhieu merged commit 7a8b9f4 into rockerhieu:master Aug 15, 2015
@pt2121
Copy link
Contributor Author

pt2121 commented Aug 16, 2015

Thanks for merging!

@@ -66,8 +67,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
mData = People.DATA;
mUseSystemDefault = false;
} else {
Object[] o = (Object[]) getArguments().getSerializable("emojicons");
mData = Arrays.asList(o).toArray(new Emojicon[o.length]);
mData = (Emojicon[]) getArguments().getParcelableArray(EMOJICONS_KEY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this throws an exception

Caused by: java.lang.ClassCastException: android.os.Parcelable[] cannot be cast to com.rockerhieu.emojicon.emoji.Emojicon[]

it can be fixed as described here: http://stackoverflow.com/questions/3647432/how-to-pass-an-array-of-address-objects-to-an-other-acitvity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uwemaurer Interesting. It worked fine when I tested it. Does it crash your app or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we see this exception in our exception reporting. (reported on Android 4.1.2 and 4.4.2 so far)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uwemaurer Maybe I am missing something but I can't reproduce this on emulators API 19 and 23. Anyway, I've sent a pull request (#79). Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can reproduce it on my phone when I enable 'Don't keep activities' in the developer options. I can confirm that your pull request fixes it.

I got this stacktrace (maybe it has to do with the support library):

E/AndroidRuntime(26523): Caused by: java.lang.ClassCastException: android.os.Parcelable[] cannot be cast to com.rockerhieu.emojicon.emoji.Emojicon[]
E/AndroidRuntime(26523): at com.rockerhieu.emojicon.EmojiconGridFragment.onViewCreated(EmojiconGridFragment.java:70)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1197)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1179)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1991)
E/AndroidRuntime(26523): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1976)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1041)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1197)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1179)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1991)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:165)
E/AndroidRuntime(26523): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:507)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uwemaurer Ok Thanks. It's good to learn something new every day!

@pt2121 pt2121 mentioned this pull request Sep 18, 2015
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

Successfully merging this pull request may close these issues.

3 participants