Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void displayColors(final int quantity) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- delta=0;
- final ImageView[] displayingColors = new ImageView[quantity];
- final RelativeLayout.LayoutParams displayingColorsLayoutParams[] = new RelativeLayout.LayoutParams[k];
- for (int count = 0; count < quantity; count++) {
- displayingColors[count] = new ImageView(getApplicationContext());
- displayingColorsLayoutParams[count] = new RelativeLayout.LayoutParams(height, width);
- displayingColorsLayoutParams[count].setMargins(marginLeft, marginTop, 0, 0);
- }
- for (int count = 0; count < quantity; count++) {
- final int index = count;
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- displayingColors[index].setImageResource(a random image);
- gameBoard.addView(displayingColors[index], displayingColorsLayoutParams[index]); //colors appearing
- if (index >= 1)
- colorsGameBoard.removeView(displayingColors[index - 1]); //colors disappearing
- }
- }, 1000 * (index + 1));
- }
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- colorsGameBoard.removeView(displayingColors[colorsNumber - 1]);
- chooseColorsFromList(colorsNumber);
- delta=100;
- }
- }, 1000 * (k + 1));
- }
- });
- }
- private class CheckTime implements Runnable {
- @Override
- public void run() {
- while (timeAmount > 0) {
- try {
- Thread.sleep(100);
- timeAmount = timeAmount - delta;
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (timeAmount <= 0)
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- //Game Over UI process
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement