Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ImageView _slot1, _slot2, _slot3, _slot4;
- Button _action;
- boolean inAction = true;
- Asynctask _async1, _async2, _async3, _async4;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- _action = findViewById(R.id.action);
- _action.setOnClickListener(this);
- _slot1 = findViewById(R.id.slot1);
- _slot2 = findViewById(R.id.slot2);
- _slot3 = findViewById(R.id.slot3);
- _slot4 = findViewById(R.id.slot4);
- }
- @Override
- public void onClick(View v) {
- if (v.getId() == _action.getId()) {
- if (inAction) {
- new Asynctask(_async1).execute();
- _async1 = new Asynctask();
- _async2 = new Asynctask();
- _async3 = new Asynctask();
- _async4 = new Asynctask();
- // _async1 = new Asynctask();
- // _async1.executeOnExecutor(Asynctask.SERIAL_EXECUTOR, _slot1);
- _async1.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot1);
- //
- // _async2 = new Asynctask();
- _async2.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot2);
- //
- // _async3 = new Asynctask();
- // _async3.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot3);
- // _async4 = (Asynctask) new Asynctask().execute(_slot4);
- // _async4 = new Asynctask();
- _async4.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot4);
- // _async4.execute(_slot4);
- // if (_async1._next == _async2._next && _async2._next == _async3._next) {
- // Toast.makeText(getApplicationContext(), "Menang Banyak", Toast.LENGTH_SHORT).show();
- // } else if (_async1._next == _async2._next || _async2._next == _async3._next || _async1._next == _async3._next) {
- // Toast.makeText(getApplicationContext(), "Menang", Toast.LENGTH_SHORT).show();
- // } else {
- // Toast.makeText(getApplicationContext(), "Kalah", Toast.LENGTH_SHORT).show();
- // }
- // else {
- // Toast.makeText(getApplicationContext(), "Kalah", Toast.LENGTH_SHORT).show();
- // }
- _action.setText("STOP");
- } else {
- _async1._roll = false;
- _async2._roll = false;
- // _async3._roll = false;
- _async4._roll = false;
- if (_async1._next == _async2._next && _async2._next == _async4._next) {
- Toast.makeText(getApplicationContext(), "Menang Banyak", Toast.LENGTH_SHORT).show();
- } else if (_async1._next == _async2._next || _async2._next == _async4._next || _async1._next == _async4._next) {
- Toast.makeText(getApplicationContext(), "Menang", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(getApplicationContext(), "Kalah", Toast.LENGTH_SHORT).show();
- }
- _action.setText("ROLL");
- }
- // if (_async1._next == _async2._next && _async2._next == _async3._next) {
- // Toast.makeText(getBaseContext(), "Menang Banyak", Toast.LENGTH_SHORT).show();
- // } else if (_async1._next == _async2._next || _async2._next == _async3._next || _async1._next == _async3._next) {
- // Toast.makeText(getBaseContext(), "Menang", Toast.LENGTH_SHORT).show();
- // } else {
- // Toast.makeText(getBaseContext(), "Kalah", Toast.LENGTH_SHORT).show();
- // }
- inAction = !inAction;
- }
- }
Add Comment
Please, Sign In to add comment