public void onCancel(DialogInterface dialog) { TrytonCall.cancel(this.callId); this.callId = 0; this.loadingDialog = null; this.kill = true; this.finish(); }
@Override public void onCreate(Bundle state) { super.onCreate(state); boolean loadData = false; boolean loadView = false; AlertBuilder.updateRelogHandler(new Handler(this), this); // Init data if (state != null) { this.view = (ModelView) state.getSerializable("view"); this.viewId = state.getInt("viewId"); this.callId = state.getInt("callId"); this.currentLoadingMsg = state.getInt("currentLoadingMsg"); if (this.callId != 0) { TrytonCall.update(this.callId, new Handler(this)); this.showLoadingDialog(this.currentLoadingMsg); } this.command = (DelayedRequester.Command) state.getSerializable("command"); } else { this.view = viewInitializer; viewInitializer = null; this.viewId = viewIdInitializer; viewIdInitializer = 0; this.command = commandInitializer; if (this.command != null) { this.view = this.command.getView(); } // This is the first call, need to update data for new fields loadView = (this.view == null); loadData = true; } // Init view this.setContentView(R.layout.form); this.table = (LinearLayout) this.findViewById(R.id.form_table); if (!loadView && !loadData) { this.initView(); } else { if (loadView) { this.loadViewAndData(); } else { this.loadDataAndMeta(); } } }
/** Show dialog and send save call to the server. Callback is in handler. */ private void sendSave() { if (DelayedRequester.current.getQueueSize() > 0) { // There is a queue waiting, don't mess command order by sending // a new command before the other Toast t = Toast.makeText(this, R.string.data_send_queued, Toast.LENGTH_SHORT); t.show(); if (!Session.current.isCreatingModel()) { this.queueUpdate(); } else { this.queueCreate(); } } else { // Standard connected behaviour: send to server this.showLoadingDialog(LOADING_SEND); Session s = Session.current; this.callId = TrytonCall.saveData( s.userId, s.cookie, s.prefs, s.tempModel, s.editedModel, this, new Handler(this)); } }
private void sendDelete() { if (DelayedRequester.current.getQueueSize() > 0) { // There is a queue waiting, don't mess command order by sending // a new command before the other Toast t = Toast.makeText(this, R.string.data_send_queued, Toast.LENGTH_SHORT); t.show(); this.queueDelete(); } else { // Standard connected behaviour: send to server this.showLoadingDialog(LOADING_SEND); Session s = Session.current; this.callId = TrytonCall.deleteData( s.userId, s.cookie, s.prefs, (Integer) s.editedModel.get("id"), s.editedModel.getClassName(), new Handler(this)); } }