Back to project page Mamytas.
The source code is released under:
GNU General Public License
If you think the Android project Mamytas listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package mn.aug.restfulandroid.rest; /* ww w. j av a 2 s . c om*/ import java.io.IOException; import java.net.URI; import java.util.List; import java.util.Map; import mn.aug.restfulandroid.rest.RestMethodFactory.Method; import mn.aug.restfulandroid.rest.resource.Login; import org.json.JSONArray; import org.json.JSONObject; import android.content.Context; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; public class LoginRestMethod extends AbstractRestMethod<Login>{ private Context mContext; private static final URI LOGIN_URI = URI.create("http://paultpt-wunderlist.rhcloud.com/login"); private Map<String, List<String>> headers; private byte[] body; public LoginRestMethod(Context context, Map<String, List<String>> headers,byte[] body){ mContext = context.getApplicationContext(); this.headers = headers; this.body=body; } @Override protected Request buildRequest() { Request request = new Request(Method.POST, LOGIN_URI, headers, body); return request; } @Override protected Login parseResponseBody(String responseBody) throws Exception { Login login=null; if (responseBody!= null && responseBody.length()>0) { try { final ObjectMapper mapper = new ObjectMapper(); login = mapper.readValue(responseBody, Login.class); } catch (JsonParseException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return login; } @Override protected Context getContext() { return mContext; } }