Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated message controller

  • Loading branch information...
commit d9841ab31185a5947f9917bce27c9cab855dfa9e 1 parent 46bc951
Andres Camarena andrescamarena authored
BIN  bin/Messagee.apk
View
Binary file not shown
BIN  bin/classes.dex
View
Binary file not shown
BIN  bin/classes/com/project/controller/MessageController.class
View
Binary file not shown
BIN  bin/classes/com/project/messagee/AddAccount$AddAcctTask.class
View
Binary file not shown
BIN  bin/classes/com/project/messagee/Splash$WaitSplashTask.class
View
Binary file not shown
BIN  bin/res/drawable-hdpi/messagee_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/res/drawable-ldpi/add_people.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/res/drawable-ldpi/add_people_clicked.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/res/drawable-ldpi/messagee_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/res/drawable-mdpi/add_people.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/res/drawable-mdpi/add_people_clicked.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/res/drawable-mdpi/messagee_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  bin/resources.ap_
View
Binary file not shown
BIN  res/drawable-hdpi/messagee_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-ldpi/add_people.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-ldpi/add_people_clicked.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-ldpi/messagee_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-mdpi/add_people.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-mdpi/add_people_clicked.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-mdpi/messagee_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 src/com/project/controller/MessageController.java
View
@@ -2,6 +2,8 @@
package com.project.controller;
+import android.util.Log;
+
import com.project.model.PostImages;
import com.project.model.Posts;
@@ -21,9 +23,11 @@
private String USERGRID_API_URL = "http://apigee-test.usergrid.com";
//Application name
- public static final String USERGRID_APP = "twid";
-
+ public static final String USERGRID_APP = "messagee2";
+ public static final String USERGRID_KEY = "YXA6eL1fDFdnEeG_tyIAChxaZw";
+ public static final String USERGRID_SECRET = "YXA6EZLMqNonMTVk2_b5eymv6deBIzs";
+
//user info
private String email;
private String username;
@@ -50,7 +54,8 @@ public MessageController(){
//function to call client login
public ApiResponse login(String usernameArg, String passwordArg) {
-
+
+
//store password
this.password = passwordArg;
@@ -73,7 +78,9 @@ public ApiResponse login(String usernameArg, String passwordArg) {
imageURL = user.getPicture();
}
-
+
+ Log.d("twid","response: " + username);
+
//return login response
return response;
}
@@ -82,12 +89,21 @@ public ApiResponse login(String usernameArg, String passwordArg) {
//Grab posts using client
public void getPostsFromClient(){
+
+
//client call to get message board feed
- ApiResponse resp = client.apiRequest(HttpMethod.GET,null , null, USERGRID_APP, "users",username,"feed");
+
+ ApiResponse resp = null;
+ try{
+ resp = client.apiRequest(HttpMethod.GET,null , null, USERGRID_APP, "users",username,"feed");
+ } catch (Exception e) {
+ resp = null;
+ }
+
//if response has posts add them to the Posts and PostImages objects
- if(resp.getFirstEntity()!=null){
+ if(resp!=null && resp.getFirstEntity()!=null){
//clear all posts
posts.clearAll();
@@ -129,7 +145,12 @@ public void getPostsFromClient(){
public ApiResponse addFollow(String followName){
//client call to add user to follow
- ApiResponse resp = client.apiRequest(HttpMethod.POST,null , "{}", USERGRID_APP, "users",username,"following","user",followName);
+ ApiResponse resp = null;
+ try{
+ resp = client.apiRequest(HttpMethod.POST,null , "{}", USERGRID_APP, "users",username,"following","user",followName);
+ } catch (Exception e) {
+ resp = null;
+ }
//return client response
return resp;
@@ -160,7 +181,12 @@ public ApiResponse post(String postMess){
data.put("content",postMess);
//client call to post message
- ApiResponse resp = client.apiRequest(HttpMethod.POST,null , data, USERGRID_APP, "users",username,"activities");
+ ApiResponse resp = null;
+ try{
+ resp = client.apiRequest(HttpMethod.POST,null , data, USERGRID_APP, "users",username,"activities");
+ } catch (Exception e) {
+ resp = null;
+ }
//return client response
return resp;
@@ -170,6 +196,7 @@ public ApiResponse post(String postMess){
//client attempt to add account
public ApiResponse addAccount(String username, String password, String email){
+
//attempt to create account
Map<String, Object> data = new HashMap<String,Object>();
@@ -179,11 +206,33 @@ public ApiResponse addAccount(String username, String password, String email){
data.put("email", email);
data.put("password", password);
- //client call to add account
- ApiResponse resp = client.apiRequest(HttpMethod.POST, null, data, USERGRID_APP, "users");
+ //client call to add account
+ ApiResponse resp = null;
+ //attempt to add account
+ try {
+ resp = client.apiRequest(HttpMethod.POST, null, data, USERGRID_APP, "users");
+ } catch (Exception e) {
+ resp = null;
+ }
+
//return client response
return resp;
+
+ }
+
+ //authorize client
+ public ApiResponse authorizeClient(){
+
+ ApiResponse resp = null;
+
+ try{
+ resp = client.authorizeAppClient(USERGRID_KEY, USERGRID_SECRET);
+ } catch (Exception e) {
+ resp = null;
+ }
+
+ return resp;
}
@@ -191,7 +240,10 @@ public ApiResponse addAccount(String username, String password, String email){
public String getAPIURL(){return USERGRID_API_URL;}
//set api url
- public void setAPIURL(String newURL){this.USERGRID_API_URL = newURL;}
+ public void setAPIURL(String newURL){
+ this.USERGRID_API_URL = newURL;
+ client.setApiUrl(USERGRID_API_URL);
+ }
//return posts object
public Posts getPosts(){return posts;}
5 src/com/project/messagee/AddAccount.java
View
@@ -265,7 +265,10 @@ public AddAcctTask(Application app, String username, String password, String ema
//main function, attempts to add account
protected ApiResponse doInBackground(Void... v) {
-
+
+ //authorize client
+ ((Messagee) app).messController.authorizeClient();
+
//attempt to post message
return ((Messagee) app).messController.addAccount(username, password, email);
4 src/com/project/messagee/Splash.java
View
@@ -41,8 +41,8 @@ public WaitSplashTask() {
@Override
protected Void doInBackground(Void... v) {
- //wait for one second
- android.os.SystemClock.sleep(1000);
+ //wait
+ android.os.SystemClock.sleep(3000);
//kill splash activity
finish();
Please sign in to comment.
Something went wrong with that request. Please try again.