Advertisement
Leedwon

Untitled

Feb 1st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. public class MainMenuActivity extends AppCompatActivity {
  2.  
  3.     int width;
  4.     int height;
  5.     MainView mainView;
  6.  
  7.     @Override
  8.     protected void onCreate(Bundle savedInstanceState) {
  9.         super.onCreate(savedInstanceState);
  10.         DisplayMetrics displayMetrics = new DisplayMetrics();
  11.         getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
  12.         height = displayMetrics.heightPixels;
  13.         width = displayMetrics.widthPixels;
  14.         mainView = new MainView(this, height, width);
  15.         setContentView(mainView);
  16.  
  17.         Thread thread = new Thread(){
  18.  
  19.             @Override
  20.             public void run() {
  21.                 try {
  22.                     while (!isInterrupted()) {
  23.                         Thread.sleep(1000);
  24.                         runOnUiThread(new Runnable() {
  25.                             @Override
  26.                             public void run() {
  27.                                 mainView.updateBird(new Canvas());
  28.                             }
  29.                         });
  30.                     }
  31.                 } catch (InterruptedException e) {
  32.                     Log.e("MainActivity", "Thread Run Exception");
  33.                 }
  34.             }
  35.         };
  36.         thread.start();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement