If you think the Android project WhatsUp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package nu.placebo.whatsup.activity;
//fromwww.java2s.comimport nu.placebo.whatsup.R;
import nu.placebo.whatsup.constants.Constants;
import nu.placebo.whatsup.ctrl.SessionHandler;
import nu.placebo.whatsup.datahandling.DataProvider;
import nu.placebo.whatsup.model.Comment;
import nu.placebo.whatsup.network.NetworkOperationListener;
import nu.placebo.whatsup.network.OperationResult;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
publicclass CreateCommentActivity extends Activity implements OnClickListener,
NetworkOperationListener<Comment> {
privateint id = 0;
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.create_comment);
Bundle extras = this.getIntent().getExtras();
this.id = extras.getInt("id");
Button submitButton = (Button) this
.findViewById(R.id.create_comment_submit);
submitButton.setOnClickListener(this);
}
publicvoid onClick(View v) {
if (v.getId() == R.id.create_comment_submit) {
TextView text = (TextView) this
.findViewById(R.id.create_commit_desc);
TextView title = (TextView) this
.findViewById(R.id.create_comment_title);
if (!text.toString().equals("") && !title.toString().equals("")) {
DataProvider.getDataProvider(getApplicationContext()).
createComment( id,
SessionHandler.getInstance(this).getUserName(),
text.getText().toString(), title.getText().toString(), this);
} else {
Toast.makeText(this, "Please enter text in both fields",
Toast.LENGTH_LONG);
}
}
}
publicvoid operationExcecuted(OperationResult<Comment> result) {
// TODO Error handling
if (!result.hasErrors()) {
setResult(Constants.ACTIVITY_FINISHED_OK);
Toast.makeText(this, "Comment added", Toast.LENGTH_SHORT);
this.finish();
}
}
}