ITeye博客

raging_sweet的博客

raging_sweet · 共 46 篇文章

经济学十大原理

经济学研究社会如何管理自己的稀缺(scarcity)资源 原理一:人们面临权衡取舍 效率与平等,当政府想要把经济蛋糕切为更均等的小块时,这块蛋糕本身也就变小了。 原理二:某种东西的成本是为了得到它所放弃的东西 一种东西的机会成本(opportunity cost)是为了得到这种东西所放弃的东西。 原理三:理性人考虑边际量 边际变动(marginal change):对行动计划微小的增量调整 只有一种行动的边际利益大于边际成本,一个理性决策者才会采取这项行动。 原理四:人们会对激励做出反应 原理五:贸易能使每个人状况更好 原理六:市场通常是组织经济活动的一种好方法 看不见的手,当政府组织价格根…

2012-05-22 09:41 · 经济学原理 · 评论(0)

Attacking memory problems on Android

Attacking memory problems on Android Yay, my first post on Android :) Immediately attacking a difficult one: memory problems. You might not run into them that quickly, but when you do, with a bit of bad luck, you've got a lot of work to do. I've split the memory problems in two parts: out of memory…

2012-04-23 22:38 · Android · 转贴 · 评论(0)

ViewPager and Fragments

Android: ViewPager and Fragments Part II What are the different ways to get a reference to the currently visible fragment page in a ViewPager? First Solution You can set a unique tag on each fragment page: getSupportFragmentManager().beginTransaction().add(myFragment, "Some Tag").commit(); ... and …

2012-03-25 20:11 · Android · 转贴 · 评论(0)

Genie Effect AS

package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.geom.Point; import flash…

2012-03-21 23:13 · 转贴 · 评论(0)

How to avoid OutOfMemory Error / OOM (The Ugly Truth Revealed)

ERROR/dalvikvm-heap(4204): 691456-byte external allocation too large for this process. 01-25 22:13:18.694: ERROR/(4204): VM won't let us allocate 691456 bytes 01-25 22:13:18.694 If you have ever got the message above, you are at the right place. First of all the reason: Heap size != External Memory…

2012-03-13 23:38 · Android · 转贴 · 评论(0)

Reduce Bitmap size using BitmapFactory.Options.inSampleSize

In the post " Load ImageView with JPG file in SD Card ", the ImageView is loaded with bitmap in full-size. It cost too much resources for a mobile device, and easy to make the app closed unexpectly. We can generate a shrinked bitmap using BitmapFactory.Options with inSampleSize; such that to reduce…

2012-03-13 23:32 · Android · 转贴 · 评论(0)

解決在 Android 中使用 Bitmap 造成 Out of memory 的方法~

因為Android本身的限制,在2.x版中使用 Bitmap 只要遇到稍大一點的圖,很容易就會遇到 out of memory 的狀況,在經過一陣搜尋之後,一直沒有很好的方法,有很多網站介紹的方法是把原圖 subsample,但對於圖片quality有要求的程式來說,這可是不被接受的解法,搞了半天,最後只好直接把 Android 的 source code 拿出來瞧瞧看看是否有什麼機會解決這個問題,突然發現原來這個問題竟然有個投機取巧的解決方法。 目前在網站上找到的結果,效果最有效的是使用 BitmapFactory.Options 將裏面的 inPurgeable 設定為 true,這樣可…

2012-03-13 23:30 · Android · 转贴 · 评论(0)

android BitmapFactory的OutOfMemoryError: bitmap size exceeds VM budget解决方案

使用android提供的BitmapFactory解码一张图片时,有时会遇到该错误,即:java.lang.OutOfMemoryError: bitmap size exceeds VM budget。这往往是由于图片过大造成的。要想正常使用,一种方式是分配更少的内存空间来存储,即在载入图片的时候以牺牲图片质量为代价,将图片进行放缩,这也是不少人现在为避免以上的OOM所采用的解决方法。但是,这种方法是得不偿失的,当我们使用图片作为缩略图查看时候倒是没有说什么,但是,当需要提供图片质量的时候,该怎么办呢?java.lang.OutOfMemoryError: bitmap size exce…

2012-03-13 23:28 · Android · 转贴 · 评论(0)

About Bitmap allocated

Bitmap data is not allocated in the VM heap. There is a reference to it in the VM heap (which is small), but the actual data is allocated in the Native heap by the underlying Skia graphics library. Unfortunately, while the definition of BitmapFactory.decode...() says that it returns null if the ima…

2012-03-13 23:08 · Android · 转贴 · 评论(0)

The Java Thread Pool

A thread pool helps to constrain the number of threads that may be running in an application at any one time. As threads require system resources, having too many threads executing simultaneously will negatively impact on a system’s performance. Threads can be represented as objects. To define what…

2012-03-03 00:55 · Java · Android · 评论(0)

Android Animations 3D flip

In this post we are going to look at how to create a 3D flip animation, with a FrameLayout. In the first few posts I've written on Android and animations we have only looked at the predefined animations supplied in the android.view.animations package. In fact we've only used the translate animation…

2012-03-02 23:24 · 转贴 · 评论(0)

Multithreading For Performance

A good practice in creating responsive applications is to make sure your main UI thread does the minimum amount of work. Any potentially long task that may hang your application should be handled in a different thread. Typical examples of such tasks are network operations, which involve unpredictab…

2012-03-02 23:23 · 转贴 · 评论(0)

SQLITE Best practice

Recently I’ve been doing quite a bit of work with the Android Sqlite database. Mostly with the android piece of ormlite . The Android examples cover some basic Sqlite usage, but they really don’t go into depth with regards to proper usage patters, and more importantly, improper usage patters. Most …

2012-02-15 23:02 · Android · 转贴 · 评论(0)

Correct use of ConcurrentHashMap

ConcurrentHashMap has been pitched as a simple alternative for HashMap , eliminating the need for a synchronized blocks. I had some simple event counting code that created count records on the fly. Although I could have used synchronized blocks for safety I used ConcurrentHashMap for this situation…

2012-02-12 22:13 · Java · 转贴 · 评论(0)

NDK Findclass

I’m a big fan of the new native activity functionality available for Android NDK users. While it does limit your target audience to Android 2.3 and above (currently comprising less than 10% of the Android smartphone market, albeit covering 100% of the Android tablet market), it can represent a sign…

2012-02-09 23:24 · 转贴 · 评论(0)