Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ImageView _slotgambar;
- Random _acak = new Random();
- boolean _roll = true;
- int[] _slotimg = {R.drawable.slot1, R.drawable.slot2, R.drawable.slot3,
- R.drawable.slot4, R.drawable.slot5, R.drawable.slotbar};
- int _next;
- // public Asynctask() {
- // this._roll = true;
- // }
- public Asynctask(Asynctask tv) {
- _acak = tv;
- }
- // interface tester {
- // void newImage(int img);
- // }
- // public void nextimg() {
- // _next++;
- //
- // if (_next == _slotimg.length) {
- // _next = 0;
- // }
- // int j = _acak.nextInt(3);
- // publishProgress(j);
- // _acak.nextInt(3);
- // }
- @Override
- protected Boolean doInBackground(ImageView... slotimg) {
- _slotgambar = slotimg[0];
- // int i = 0;
- while (_roll) {
- // int j = _acak.nextInt(3);
- // publishProgress(j);
- // _next++;
- //
- // if (_next == _slotimg.length) {
- // _next = 1;
- // }
- _next = _acak.nextInt(6);
- publishProgress(_next);
- // nextimg();
- try {
- Thread.sleep(_acak.nextInt(3000));
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- return !_roll;
- }
- @Override
- protected void onProgressUpdate(Integer... values) {
- super.onProgressUpdate(values);
- // int k = _acak.nextInt(3);
- // tester.newImage(_slotimg[_next]);
- // _slotgambar.setImageResource(_slotimg[values[0]]);
- _slotgambar.setImageResource(_slotimg[_next]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement