List of usage examples for android.widget RelativeLayout postDelayed
public boolean postDelayed(Runnable action, long delayMillis)
Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Fill the moneybox with all the movements dropping coins randomly *//*from ww w .j a v a2 s .co m*/ public void fillMoneybox() { RelativeLayout layout; int maxWidth; ArrayList<Movement> lstMoney; Random rndLeft; double total; int i; MainActivity parent; parent = (MainActivity) getActivity(); layout = findLayout(); maxWidth = layout.getWidth(); if (maxWidth == 0) { // The layout is not initialized return; } total = 0.0; i = 0; rndLeft = new Random(); lstMoney = MovementsManager.getActiveMovements(parent.getCurrentMoneybox()); for (Movement m : lstMoney) { Rect r; CurrencyValueDef curr; int left; curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount())); if (curr != null) { r = curr.getDrawable().getBounds(); left = rndLeft.nextInt(maxWidth - r.width()); total += m.getAmount(); MoneyTimerTask task; task = new MoneyTimerTask(this, m, left, r.width(), total); layout.postDelayed(task, 400 * i); } i++; } }