Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
erisee92 committed Jan 15, 2016
1 parent a287667 commit 8be13bc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 43 deletions.
7 changes: 7 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ private void getContent() {
public void onSuccess(JSONArray result) {
Log.i("List",result.toString());
try {
if(result.getJSONObject(0).getString("name")!= null && !result.getJSONObject(0).getString("name").isEmpty()){
ArrayList<Session> arrayOfSessions = new ArrayList<Session>();
if(!result.getJSONObject(0).getString("response").equals("No Groups Created")){
if(result.getJSONObject(0).getString("name")!= null && !result.getJSONObject(0).getString("name").isEmpty()) {
ArrayList<Session> arrayOfSessions = new ArrayList<Session>();

SessionAdapter adapter = new SessionAdapter(getApplicationContext(), arrayOfSessions);
gl.setAdapter(adapter);
SessionAdapter adapter = new SessionAdapter(getApplicationContext(), arrayOfSessions);
gl.setAdapter(adapter);

ArrayList<Session> newSessions = Session.fromJson(result);
adapter.addAll(newSessions);
mSwipeRefreshLayout.setRefreshing(false);
ArrayList<Session> newSessions = Session.fromJson(result);
adapter.addAll(newSessions);
mSwipeRefreshLayout.setRefreshing(false);
}
}
} catch (JSONException e) {
e.printStackTrace();
Expand Down Expand Up @@ -165,47 +167,53 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void Logout() {
String user_id = prefs.getString("LOG_ID", "");
JSONObject logout = User.logout(user_id, getApplicationContext(), new User.VolleyCallback() {
@Override
public void onSuccess(JSONObject result) {
Log.i("Logout", result.toString());
try {
String response = result.getString("response");
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
SharedPreferences.Editor edit = prefs.edit();
edit.remove("LOG_ID");
edit.apply();
edit.remove("LOG_NAME");
edit.apply();
edit.remove("LOG_USERNAME");
edit.apply();
edit.remove("SESSION_ID");
edit.apply();
edit.putBoolean("ADMIN",false);
edit.commit();
if(prefs.getBoolean("ADMIN",false)){
Toast.makeText(getApplicationContext(), R.string.adminLogout, Toast.LENGTH_SHORT).show();

}else {

String user_id = prefs.getString("LOG_ID", "");
JSONObject logout = User.logout(user_id, getApplicationContext(), new User.VolleyCallback() {
@Override
public void onSuccess(JSONObject result) {
Log.i("Logout", result.toString());
try {
String response = result.getString("response");
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
SharedPreferences.Editor edit = prefs.edit();
edit.remove("LOG_ID");
edit.apply();
edit.remove("LOG_NAME");
edit.apply();
edit.remove("LOG_USERNAME");
edit.apply();
edit.remove("SESSION_ID");
edit.apply();
edit.putBoolean("ADMIN", false);
edit.commit();

Intent intent = new Intent();
intent.setClass(ListActivity.this, LoginActivity.class);
startActivity(intent);
Intent intent = new Intent();
intent.setClass(ListActivity.this, LoginActivity.class);
startActivity(intent);

finish();
} catch (JSONException e) {
e.printStackTrace();
finish();
} catch (JSONException e) {
e.printStackTrace();
}
}
}

@Override
public void onError(JSONObject result) {
Log.i("Logout", result.toString());
try {
String response = result.getString("response");
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
@Override
public void onError(JSONObject result) {
Log.i("Logout", result.toString());
try {
String response = result.getString("response");
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
});
}
}

@Override
Expand Down

0 comments on commit 8be13bc

Please sign in to comment.