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

Using large amount (50+) of head items with listener and static background. #27

Open
JaisonBrooks opened this issue Apr 6, 2015 · 7 comments

Comments

@JaisonBrooks
Copy link

Hey madcyph3r,

First off great lib! its freaking awesome!!!

I'd like to use this lib in a project where i have an array of custom objects and am using this array to build the head items. Sometimes i may have up to 50+ custom objects in the array and need a head item for each one. I'd like to have a static background between them. Or a way to load the background initially for the first item then only on head item change. (I ran into memory issues when setting the same background (~12kb jpg) to 50+ header items).

I need to be able to load the custom object from the array based on the position of the head item that was clicked (either by avatar clicked or from extra menu).

I'd attempted to use bits and pieces from the header item types 5 item with extra menu and i can successfully build 50+ header items with a transparent xml background and a onheaditemchange listener. However this listener seems to only be being called when i click the avatars and not when clicking from the extra menu (not sure why).

Any advise or explanation on how to go about this would be greatly appreciated. Also do you have in the pipeline a demo with large amounts of head items or something similar to my query? thanks for your time.

@JaisonBrooks JaisonBrooks reopened this Apr 6, 2015
@JaisonBrooks JaisonBrooks changed the title Add example of large (50+) head items / custom configuration? Using large amount (50+) of head items with listener and static background. Apr 6, 2015
@madcyph3r
Copy link
Owner

I will add a method, to set a static background and test the result.

@madcyph3r
Copy link
Owner

See the latest git version. I have add an option, to set a static background. I will release the next version, if i have found the sliding tab bug.

@JaisonBrooks
Copy link
Author

Thanks for adding a static method!! I downloaded the latest apk from the github link and your 100+ static background seems to be failing on my end.

04-19 21:28:10.726 E/AndroidRuntime(32054): java.lang.OutOfMemoryError: Failed to allocate a 3111708 byte allocation with 2044872 free bytes and 1996KB until OOM

Any ideas?

@JaisonBrooks
Copy link
Author

Here is the full logs

04-19 21:30:44.496 E/AndroidRuntime(833): Process: de.madcyph3r.MaterialDrawer, PID: 833
04-19 21:30:44.496 E/AndroidRuntime(833): java.lang.OutOfMemoryError: Failed to allocate a 3111708 byte allocation with 2034696 free bytes and 1987KB until OOM
04-19 21:30:44.496 E/AndroidRuntime(833): at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:467)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:497)
04-19 21:30:44.496 E/AndroidRuntime(833): at de.madcyph3r.example.example.headItemTypes.HeadItem100StaticBackgroundActivity.getHeadItem(HeadItem100StaticBackgroundActivity.java:66)
04-19 21:30:44.496 E/AndroidRuntime(833): at de.madcyph3r.example.example.headItemTypes.HeadItem100StaticBackgroundActivity.init(HeadItem100StaticBackgroundActivity.java:46)
04-19 21:30:44.496 E/AndroidRuntime(833): at de.madcyph3r.materialnavigationdrawer.MaterialNavigationDrawer.onCreate(MaterialNavigationDrawer.java:218)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.Activity.performCreate(Activity.java:5938)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.ActivityThread.access$900(ActivityThread.java:147)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.os.Handler.dispatchMessage(Handler.java:102)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.os.Looper.loop(Looper.java:135)
04-19 21:30:44.496 E/AndroidRuntime(833): at android.app.ActivityThread.main(ActivityThread.java:5254)
04-19 21:30:44.496 E/AndroidRuntime(833): at java.lang.reflect.Method.invoke(Native Method)
04-19 21:30:44.496 E/AndroidRuntime(833): at java.lang.reflect.Method.invoke(Method.java:372)
04-19 21:30:44.496 E/AndroidRuntime(833): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
04-19 21:30:44.496 E/AndroidRuntime(833): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)

@madcyph3r
Copy link
Owner

Do you use images for the headItem avatar?

@JaisonBrooks
Copy link
Author

I've been using TextDrawable's as the avatar heads, and this stack trace is from the sample app.

@madcyph3r
Copy link
Owner

Ok, then i must implement lazy load for the icons.

@madcyph3r madcyph3r reopened this Apr 26, 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

No branches or pull requests

2 participants