-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathTicTacToeActivity.java
More file actions
61 lines (51 loc) · 1.6 KB
/
Copy pathTicTacToeActivity.java
File metadata and controls
61 lines (51 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.acme.tictactoe.view;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.acme.tictactoe.R;
import com.acme.tictactoe.databinding.TictactoeBinding;
import com.acme.tictactoe.viewmodel.TicTacToeViewModel;
public class TicTacToeActivity extends AppCompatActivity {
TicTacToeViewModel viewModel = new TicTacToeViewModel();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TictactoeBinding binding = DataBindingUtil.setContentView(this, R.layout.tictactoe);
binding.setViewModel(viewModel);
viewModel.onCreate();
}
@Override
protected void onPause() {
super.onPause();
viewModel.onPause();
}
@Override
protected void onResume() {
super.onResume();
viewModel.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
viewModel.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_tictactoe, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_reset:
viewModel.onResetSelected();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}