Skip to content

Commit

Permalink
Account Data Management
Browse files Browse the repository at this point in the history
  • Loading branch information
aarya123 committed Jan 12, 2013
1 parent 2ceb7ce commit ecb9173
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 32 deletions.
45 changes: 38 additions & 7 deletions src/com/example/campusfeed/Accounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,59 @@
public class Accounts
{
// TODO Fix this
public Accounts(){

static String s;
static String username, password,email;
static String[] starredEvents, createdEvents;

public static void setUsername(String user)
{
username = user;
}

public static void starEvent(String uniqueId, String email)
public static void setPassword(String pass)
{
new AccountOnline().execute(uniqueId, email);
password = pass;
}
public static void setEmail(String addy){
email=addy;
}

public static void ReadAccountInfo()
public static void setStarredEvents(String[] events)
{
starredEvents = events;
}

public static void setCreatedEvents(String[] events)
{
createdEvents = events;
}

public static void MyEvents()
public static String getUsername()
{
return username;
}
public static String getEmail(){
return email;
}

public static String getPassword()
{
return password;
}

public static String[] getStarredEvents()
{
return starredEvents;
}

public static void starredEvents()
public static String[] setCreatedEvents()
{
return createdEvents;
}

public static void starEvent(String uniqueId, String email)
{
new AccountOnline().execute(uniqueId, email);
}
}

Expand Down
67 changes: 42 additions & 25 deletions src/com/example/campusfeed/CreateAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
Expand All @@ -19,7 +22,7 @@
public class CreateAccount extends Activity
{
EditText userName, passWord, email;
static TextView error;
TextView error;

protected void onCreate(Bundle savedInstanceState)
{
Expand Down Expand Up @@ -52,34 +55,48 @@ public void onClick(View v)
}
});
}
}

class createAcc extends AsyncTask<String, Void, String>
{

protected String doInBackground(String... params)
class createAcc extends AsyncTask<String, Void, String>
{
String url = "http://ezevents.6te.net/createaccount.php" + "?email="
+ params[0] + "&username=" + params[1] + "&password="
+ params[2];
HttpGet httpGet = new HttpGet(url);
HttpClient h = new DefaultHttpClient();
HttpResponse r = null;
try
{
// execute request
r = h.execute(httpGet);
} catch (ClientProtocolException e1)

protected String doInBackground(String... params)
{
Log.d("APP", e1.getMessage());
} catch (IOException e1)
String url = "http://ezevents.6te.net/createaccount.php"
+ "?email=" + params[0] + "&username=" + params[1]
+ "&password=" + params[2];
HttpGet httpGet = new HttpGet(url);
HttpClient h = new DefaultHttpClient();
HttpResponse r = null;
try
{
// execute request
r = h.execute(httpGet);
} catch (ClientProtocolException e1)
{
Log.d("APP", e1.getMessage());
} catch (IOException e1)
{
Log.d("APP", e1.getMessage());
}
try
{
return EntityUtils.toString(r.getEntity());
} catch (ParseException e)
{
Log.d("ERROR", e.getMessage());
} catch (IOException e)
{
Log.d("ERROR", e.getMessage());
}
return null;
}

protected void onPostExecute(String response)
{
Log.d("APP", e1.getMessage());
if (response.equals("fail") || response == null)
error.setVisibility(View.VISIBLE);
else
CreateAccount.this.finish();
}
if (r.getEntity().equals("fail"))
CreateAccount.error.setVisibility(View.VISIBLE);
else
CreateAccount.error.setVisibility(View.GONE);
return null;
}
}
4 changes: 4 additions & 0 deletions src/com/example/campusfeed/SignIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ protected void onPostExecute(String result)
error.setVisibility(View.VISIBLE);
} else
{
Accounts.setUsername(userName.getText().toString());
Accounts.setPassword(passWord.getText().toString());
String[] array=result.split("|");
Accounts.setEmail(array[0]);
error.setVisibility(View.GONE);
p.dismiss();
SignIn.this.finish();
Expand Down

0 comments on commit ecb9173

Please sign in to comment.