StaticLayout OutOfMemoryError with large text - android

I get error when I use StaticLayout for create pagination of large text (~6mb).
This is my log:
java.lang.OutOfMemoryError
at android.text.MeasuredText.addStyleRun(MeasuredText.java:193)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:269)
at android.text.StaticLayout.generate(StaticLayout.java:291)
at android.text.StaticLayout.<init>(StaticLayout.java:143)
at android.text.StaticLayout.<init>(StaticLayout.java:93)
at android.text.StaticLayout.<init>(StaticLayout.java:71)
at android.text.StaticLayout.<init>(StaticLayout.java:51)
at com.ex.test.pagenation.Pagination.layout(Pagination.java:38)
at com.ex.test.pagenation.Pagination.<init>(Pagination.java:34)
at com.ex.test.pagenation.MainActivity$1.onGlobalLayout(MainActivity.java:51)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2006)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Is there any suggestion for fix this error? Or Is there any alternative solution?

You should rewrite or extend Pagination class.
You should not put all the text into StaticLayout at once.
Instead, you should split text into parts. Parts should not be too lage.
I guess 10k-100k will be ok.
take first part, split it into pages, count pages, multiply it by amount of parts - that will be approximate quantity of pages in you book.
When a user want to see the past page of a first part, you should start second part just where the last page of first part begins. And so on.
Do not load all the text into StaticLayout - it is too much.

Related

IndexOutOfBoundsException, No specific logs

In my application, I am facing a weird issue. And this happens only on Android 6. It doesn't crash on version higher than 6.0
I cannot add code because I have no idea where exactly is the crash.
Is there any way to find out what can be an issue. All I have is a full stack trace.
I think this due change in behaviour of ListView in Android 6, but cannot exactly sure about it.
Fatal Exception: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
at android.widget.ListView.dispatchDraw(ListView.java:3327)
at android.view.View.draw(View.java:16276)
at android.widget.AbsListView.draw(AbsListView.java:4316)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1379)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.draw(View.java:16276)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.draw(View.java:16276)
at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2740)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:295)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:301)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:336)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2760)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2564)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2164)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1174)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6241)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873)
at android.view.Choreographer.doCallbacks(Choreographer.java:676)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
I found a scenario which solved my issue.
I had a list which had its own data.
One option was to refresh list. So here, cleared ArrayList >> get new data from API (2-3 secs delay) >> added to ArrayList >> Notify dataset changed.
The problem was I didn't notify dataset immediately after clearing the ArrayList. (Because it would flicker)
Solution: I managed to clear data, add new data and notify at the same time (After API call).
Still wondering why did it only crashed on Android 6.0

Android ViewPager fakeDragBy

I'm attempting to make my ViewPager bounce a few times on first load to indicate to the user that what they are looking at is a horizontally scrollable view. I've tried to use fakeDragBy but my app will crash when I attempt to do this. What is the recommended way to use fakeDragBy properly to achieve what I am seeking?
Here is the code I am running inside my Activity:
#Override
public void onStart(){
super.onStart();
mViewPager.setCurrentItem(0);
mViewPager.beginFakeDrag();
mViewPager.fakeDragBy(25);
mViewPager.endFakeDrag();
}
Here is the stack trace:
09-24 12:21:49.702 28243-28243/com.company E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.company, PID: 28243
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company/com.company.onboarding.OnboardingActivity}: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.support.v4.view.ViewPager.fakeDragBy(ViewPager.java:2431)
at com.company.onboarding.OnboardingActivity.onStart(OnboardingActivity.java:100)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:5949)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
If you pay close attention to the error log:
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.support.v4.view.ViewPager.fakeDragBy(ViewPager.java:2431)
Your view pager has zero items at the time of the fakeDragBy. That means that the Adapter is not giving your view pager any data, so the ViewPager is not ready to do anything.
We'd need to see how/when you are initializing your ViewPager. Without those bits of information, it's impossible to tell why you're getting an Out of Bounds exception.
Please add more code.
The issue could be else where, it's hard to tell, since you seem to be able to setCurrentItem(0) without problems.
As a side note, the Google's recommendation of wiggling the view pager upon startup to help discovery, mentions that this should only be done once. Since you're adding code to onStart() I guess you intend to do it every time you start the Activity, careful with that ;)

Out of Memory Picasso Lib

I'm developing an app that loads a lot of images through lib Picasso. When I'm navigating through the app, suddenly the app crashes, giving out of memory.
I already tried to do somethings to avoid this kind of problem, but with no success.
If someone could help me, i would be glad.
Below the code:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.codal.whatsee/com.codal.whatsee.fragmentactivity.ItemPostFragmentActivity}: android.view.InflateException: Binary
XML file line #55: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2217)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2266)
at android.app.ActivityThread.access$800(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5141)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #55: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:343)
at android.app.Activity.setContentView(Activity.java:1929)
at com.codal.whatsee.fragmentactivity.ItemPostFragmentActivity.onCreate(ItemPostFragmentActivity.java:150)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2171)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
... 23 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:594)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:429)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2208)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.<init>(ImageView.java:129)
at android.widget.ImageView.<init>(ImageView.java:119)
at com.codal.whatsee.utils.SquareImageView.<init>(SquareImageView.java:13)
... 26 more
OBS: This problem happens not just in this class, but in any other class happens too.
This sounds a lot like your application is leaking memory and the image decoding is just the last operation that fills the heap. You should use the android DDMS tools and create a heap dump of your app after short use. If you see many Activities or Fragments in the dump, you should try to figure out which objects are still holding references to them.
Here is the related page from the developer site:
https://developer.android.com/tools/debugging/debugging-memory.html
You can expect such exception when dealing with images and bitmap. In present case it appears that out of memory is due to loading of a large/big image which consume the available memory and creating issue.
Luckily picasso lib offers an option to scale down your image so that it may not consumed much memory and thus lower down the chances for getting out of memory exception.
See if this below code is helpful to you or not.
Picasso.with(context).load(file).resize(sizeToScaleDown, sizeToSacleDown).onlyScaleDown().into(imageView);
Note: onlyScaleDown() function only works if you have also used resize() function. Using onlyScaleDown() function without resize() function will cause you exception.
Android 4.2 and 4.3 do not free the memory for a bitmap unless you finish the activity using the bitmap or recycle it (Bitmap.recycle()). See Android Bitmap Memory Analysis - Part 3. API Version Comparison for a detailed analysis. In Android 4.3 you need to additionally remove the image view from the view hierarchy.
So if you have an app where you can build up a deep navigation history and are using Picasso, you will run out of memory sooner or later because Picasso does not track references to bitmaps and therefore cannot call Bitmap.recycle() for them.
We had a similar issue and finally switched to Facebook's Fresco library, which goes at great length to track references. It is therefore more complex too use but it pays off.
You may be getting OOM because of the following:
You are doing some operation that continuously demands a lot of memory. Like Picasso Lib fetching large images/bitmaps which plays with bitmap operations
Picasso uses fit() or resize() methods while fetching the images. ReferenceLink
Memory leaks: You didn’t made the previous objects you allocated eligible for Garbage Collection (GC)
Use memory analyzer tool for taking Dump check where object are getting leak.
Dealing with large bitmaps. Scaling and bitmap operation take the memory from the heap.
I came across this link. It may help you : Link

In Android, how can I overcome my "Out of Memory" error? [duplicate]

This question already has answers here:
Strange OutOfMemory issue while loading an image to a Bitmap object
(44 answers)
Closed 8 years ago.
I have an activity that uses tabs. The content of the tab is pulled is pulled from the SQLite database. Everytime the user taps on a tab a call is made to the database and the content in the viewing area is displayed.
The content is list of ImageViews that, when clicked, interact with other areas of the activity. Since this can vary between 1 -> n number of items I'm not loading all the images at once and hiding views. Doing this could really cause some issue with loading the activity.
The tabs work but as I go through switching between tabs I end up getting an out of memory error:
E/AndroidRuntime(10469): FATAL EXCEPTION: main
E/AndroidRuntime(10469): java.lang.OutOfMemoryError
E/AndroidRuntime(10469): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
E/AndroidRuntime(10469): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:613)
E/AndroidRuntime(10469): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
E/AndroidRuntime(10469): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
E/AndroidRuntime(10469): at android.graphics.drawable.Drawable.createFromStream(Drawable.java:776)
E/AndroidRuntime(10469): at com.testapplication.testapplicationconfigurator.Configurator$2.createTabContent(Configurator.java:405)
E/AndroidRuntime(10469): at android.widget.TabHost$FactoryContentStrategy.getContentView(TabHost.java:735)
E/AndroidRuntime(10469): at android.widget.TabHost.setCurrentTab(TabHost.java:430)
E/AndroidRuntime(10469): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:161)
E/AndroidRuntime(10469): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:563)
E/AndroidRuntime(10469): at android.view.View.performClick(View.java:4383)
E/AndroidRuntime(10469): at android.view.View$PerformClick.run(View.java:18097)
E/AndroidRuntime(10469): at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime(10469): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(10469): at android.os.Looper.loop(Looper.java:176)
E/AndroidRuntime(10469): at android.app.ActivityThread.main(ActivityThread.java:5279)
E/AndroidRuntime(10469): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(10469): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(10469): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
E/AndroidRuntime(10469): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
E/AndroidRuntime(10469): at dalvik.system.NativeStart.main(Native Method)
The image being used is a stored location on the devices such as
/storage/emulated/0/TestApplicaiton/2/maUdwcbaLU.jpg
I use the location to make it into a drawable object and place the drawable as the background to an ImageView:
ImageView iv = new ImageView(Configurator.this);
int ivHT = (int) (getResources().getDimension(
R.dimen.iv_height) / getResources()
.getDisplayMetrics().density);
LayoutParams params = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT);
// set margins (left,top,right,bottom)
params.setMargins(0, 0, 40, 0);
iv.setLayoutParams(params);
iv.getLayoutParams().height = ivHT;
iv.getLayoutParams().width = ivHT;
final String imageLoc = partData.get("productIndexImageLoc");
Log.d("imageLoc",imageLoc);
InputStream imageStream;
try {
imageStream = new FileInputStream(imageLoc);
Drawable x = Drawable.createFromStream(imageStream, null);
iv.setImageDrawable(x);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
partData is just a LinkedHashMap to store content and values for each part such as price, name, etc.
It seems pretty obvious that it has something to do with the Bitmap/Drawable I'm creating being left in memory. Is there a way to clear that used memory when someone taps a new tab or clear the item from memory once it's used in the view?
Yes when the bitmap is not more usefull you can call:
bitmap.recycle()
If you not have this possibility you can add more heap in manifest(Onli > API 2.3):
android:largeHeap="true"
I suggest to read this documentation to find the good way to work with bitmap in android:
Android bitmap memory management

Application works on emulator, but not on real device - float type

My application works great while using the emulator, but it crashes while working on real device. I code it for Android 2.2. Real device is 2.3.6.
Problem is here:
When I use something like that:
tvPlayerOneScores.setText("-" + numberFormat.format(level));
it works great both on emulator and real device.
But when I try this:
tvPlayerOneScores.setText("-" + numberFormat.format(level * 0.5f));
it works on emulator, but crashes on real device.
Stack Trace:
java.lang.NumberFormatException
at org.apache.harmony.luni.util.FloatingPointParser.parseFltImpl(Native Method)
at org.apache.harmony.luni.util.FloatingPointParser.parseFloat(FloatingPointParser.java:321)
at java.lang.Float.parseFloat(Float.java:323)
at java.lang.Float.valueOf(Float.java:362)
at com.amrotek.truthordare.GameActivity$4.onClick(GameActivity.java:287)
at android.view.View.performClick(View.java:2552)
at android.view.View$PerformClick.run(View.java:9229)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
at dalvik.system.NativeStart.main(Native Method)
EDIT:
I multiplied all values by 10, so I only work with integer numbers when I do arithmetic operations. At the end I just divide end value by 10. It works :)
you should have included faulty line in the question not in the comments:
playerOnePoints = Float.valueOf(numberFormat.format(playerOnePoints - level * 0.5f));
since it's not enough to make a conclusion, here's a short list of things for you to check:
why do you need to format a number with numberFormat just to convert it back with valueOf?
what's the numberFormat, does it really produce valid float strings?
is playerOnePoints float or Float? should not you use parseFloat() instead of valueOf()?
Finally, if you still are unable to solve your problem, I'd suggest to replace the aforementioned line with simple:
playerOnePoints = playerOnePoints - level * 0.5f;
That should do the trick =)
ps. also you migth want to get acquainted with Math.floor()/ceil(), if I understood your intentions with parseFloat()/numberFormat() correctly.

Categories

Resources