-
Notifications
You must be signed in to change notification settings - Fork 31
/
StudentParcelerActivity.java
executable file
·60 lines (50 loc) · 1.94 KB
/
StudentParcelerActivity.java
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
package com.example.activitystarter.parceler;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Switch;
import com.example.activitystarter.BaseActivity;
import com.example.activitystarter.R;
import activitystarter.Arg;
import activitystarter.MakeActivityStarter;
import butterknife.BindView;
import butterknife.ButterKnife;
@MakeActivityStarter
public class StudentParcelerActivity extends BaseActivity {
@Arg(parceler = true) StudentParceler student;
@BindView(R.id.student_name) EditText studentNameView;
@BindView(R.id.student_id) EditText studentIdView;
@BindView(R.id.student_grade) EditText studentGradeView;
@BindView(R.id.student_is_passing) Switch studentIsPassingView;
@BindView(R.id.save_button) Button saveButton;
@BindView(R.id.restore_button) Button restoreButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data);
ButterKnife.bind(this);
fill();
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = studentNameView.getText().toString();
int id = Integer.parseInt(studentIdView.getText().toString());
char grade = studentGradeView.getText().charAt(0);
student = new StudentParceler(id, name, grade);
}
});
restoreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fill();
}
});
}
private void fill() {
studentNameView.setText(student.getName());
studentIdView.setText(""+student.getId());
studentGradeView.setText(""+student.getGrade());
studentIsPassingView.setVisibility(View.GONE);
}
}