final Tour tour new Tour tour setName tourNameInput getText toString t

 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
final Tour tour = new Tour();
tour.setName(tourNameInput.getText().toString());
tour.setTravelAgency(travelAgencyInput.getText().toString());
tour.setBeginDate(startDateInput.getText().toString());
tour.setDuration(duration);
tour.setMemberCount(20);
tour.setTourguide((User) ParseUser.getCurrentUser());
tour.setTourCode(CodeGenerator.generate());
tour.setTouristCode(CodeGenerator.generate());
tour.setSnapshotVersion(1);
final ProgressDialogFragment progressDialogFragment = ProgressDialogFragment.newInstance();
progressDialogFragment.show(getFragmentManager(), ProgressDialogFragment.class.getSimpleName());
tour.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException exception) {
if (exception == null) {
Snapshot snapshot = new Snapshot(tour);
final String snapshotJson = BaseSnapshotModel.getGson().toJson(snapshot);
byte[] snapshotBytes = snapshotJson.getBytes();
tour.setSnapshot(new ParseFile(snapshotBytes));
tour.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
progressDialogFragment.dismiss();
SnapshotUtil.getInstance(getActivity()).setSnapshot(snapshotJson);
startActivity(MainActivity.createIntent(getActivity(), true));
getActivity().finish();
}
});
} else {
progressDialogFragment.dismiss();
exception.printStackTrace();
}
}
});