Android Open Source - WhatsUp Comment Create From Project Back to project page WhatsUp .
License The source code is released under:
GNU General Public License
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.network;
/ * w w w . j a v a 2 s . c o m * /
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import nu.placebo.whatsup.constants.Constants;
import nu.placebo.whatsup.model.Comment;
import nu.placebo.whatsup.model.SessionInfo;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.message.BasicNameValuePair;
import android.util.Log;
public class CommentCreate extends AbstractNetworkOperation<Comment> {
private String body, title;
private boolean hasErrors;
private SessionInfo sessionInfo;
private String author;
private int id;
public CommentCreate(String title, String body,
int id, String author, SessionInfo sessionInfo){
this.id = id;
this.author = author;
this.title = title;
this.body = body;
this.sessionInfo = sessionInfo;
}
public OperationResult<Comment> execute() {
Comment comment = null;
HttpResponse response = null;
this.hasErrors = true;
try {
List<NameValuePair> body = new ArrayList<NameValuePair>(2);
body.add(new BasicNameValuePair("comment_subject" , this.title));
body.add(new BasicNameValuePair("comment_body[und][0][value]" ,
this.body));
body.add(new BasicNameValuePair("nid" , Integer.toString(this.id)));
response = NetworkCalls.performPostRequest(Constants.API_URL
+ "comment.json" , body, this.sessionInfo);
ResponseHandler<String> handler = new BasicResponseHandler();
comment = this.parseResult(handler.handleResponse(response));
hasErrors = false;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return new OperationResult<Comment>(hasErrors,
response.getStatusLine().getStatusCode(), response
.getStatusLine().getReasonPhrase(), comment);
}
private Comment parseResult(String handleResponse) {
Log.d("whatsup" , handleResponse);
return new Comment(this.author, this.body, this.title, new Date());
}
}
Java Source Code List nu.placebo.whatsup.activity.AnnotationActivity.java nu.placebo.whatsup.activity.CreateAnnotationActivity.java nu.placebo.whatsup.activity.CreateCommentActivity.java nu.placebo.whatsup.activity.ListViewActivity.java nu.placebo.whatsup.activity.LogInActivity.java nu.placebo.whatsup.activity.LoginRegTabActivity.java nu.placebo.whatsup.activity.MapViewActivity.java nu.placebo.whatsup.activity.Marker.java nu.placebo.whatsup.activity.MenuHelper.java nu.placebo.whatsup.activity.PositionPickerActivity.java nu.placebo.whatsup.activity.RefPointActivity.java nu.placebo.whatsup.activity.RegisterActivity.java nu.placebo.whatsup.android.os.AsyncTask.java nu.placebo.whatsup.balloon.BalloonItemizedOverlay.java nu.placebo.whatsup.balloon.BalloonOverlayView.java nu.placebo.whatsup.constants.Constants.java nu.placebo.whatsup.ctrl.SessionHandler.java nu.placebo.whatsup.datahandling.DataProvider.java nu.placebo.whatsup.datahandling.DataReturnListener.java nu.placebo.whatsup.datahandling.DataReturn.java nu.placebo.whatsup.datahandling.DatabaseConnectionLayer.java nu.placebo.whatsup.datahandling.DatabaseHelper.java nu.placebo.whatsup.model.Annotation.java nu.placebo.whatsup.model.Comment.java nu.placebo.whatsup.model.ExtendedOverlayItem.java nu.placebo.whatsup.model.GeoLocation.java nu.placebo.whatsup.model.ListMarker.java nu.placebo.whatsup.model.ReferencePoint.java nu.placebo.whatsup.model.SessionInfo.java nu.placebo.whatsup.network.AbstractNetworkOperation.java nu.placebo.whatsup.network.Action.java nu.placebo.whatsup.network.AnnotationCreate.java nu.placebo.whatsup.network.AnnotationRetrieve.java nu.placebo.whatsup.network.CommentCreate.java nu.placebo.whatsup.network.GeoLocationsRetrieve.java nu.placebo.whatsup.network.Login.java nu.placebo.whatsup.network.NetworkCalls.java nu.placebo.whatsup.network.NetworkOperationListener.java nu.placebo.whatsup.network.NetworkOperation.java nu.placebo.whatsup.network.NetworkTask.java nu.placebo.whatsup.network.OperationResult.java nu.placebo.whatsup.network.RegisterOperation.java nu.placebo.whatsup.network.SessionTest.java nu.placebo.whatsup.util.GeoPointUtil.java nu.placebo.whatsup.util.Geodetics.java nu.placebo.whatsup.util.ValidationUtil.java nu.placebo.whatsuptest.TestStarter.java nu.placebo.whatsuptest.activitytest.AnnotationActivityTest.java nu.placebo.whatsuptest.activitytest.ListViewActivityTest.java nu.placebo.whatsuptest.activitytest.MapViewActivityTest.java nu.placebo.whatsuptest.networktest.NetworkTest.java nu.placebo.whatsuptest.utiltest.GeoPointUtilTest.java nu.placebo.whatsuptest.utiltest.GeodeticsTest.java nu.placebo.whatsuptest.utiltest.ValidationTest.java