Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Ignore metadata from IDEA (Android Studio)
*.iml
.idea/
out/
bin/
gen/
*~
24 changes: 15 additions & 9 deletions src/com/BreakingBytes/SifterReader/SifterReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public void onCreate(Bundle savedInstanceState) {
mAccessKey = mSifterHelper.mAccessKey;
} else {
mLoginError = mSifterHelper.mLoginError;
loginKeys();
loginKeys(null);
return;
}
String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
if (sifterConnection == null) {
loginKeys();
loginKeys(null);
return;
}
mDialog = ProgressDialog.show(this, "", "Loading ...",true);
Expand All @@ -139,7 +139,7 @@ protected void onPostExecute(JSONObject sifterJSONObject) {
if (sifterJSONObject == null)
return;
if (getSifterError(sifterJSONObject)) {
loginKeys();
loginKeys(null);
return;
}
try {
Expand Down Expand Up @@ -188,7 +188,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case LOGIN_ID:
loginKeys();
loginKeys(null);
return true;
case DELETE_ID:
deleteKeys();
Expand All @@ -198,8 +198,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

/** start LoginActivity to get domain and access key. */
private void loginKeys() {
private void loginKeys(Integer flags) {
Intent intent = new Intent(this, LoginActivity.class);
if (flags != null) {
intent.addFlags(flags);
}
intent.putExtra(DOMAIN, mDomain);
intent.putExtra(ACCESS_KEY, mAccessKey);
intent.putExtra(LOGIN_ERROR, mLoginError.toString());
Expand All @@ -209,7 +212,8 @@ private void loginKeys() {
private void deleteKeys() {
File keyFile = getFileStreamPath(KEY_FILE);
if (keyFile.exists()) {
keyFile.delete();
//noinspection ResultOfMethodCallIgnored
keyFile.delete();
mAllProjects = null;
mDomain = null;
mAccessKey = null;
Expand All @@ -223,6 +227,8 @@ private void deleteKeys() {
setListAdapter(null);
onContentChanged();
}
// launch the login activity
loginKeys(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}

/** start ProjectDetail activity for clicked project in list. */
Expand Down Expand Up @@ -315,7 +321,7 @@ protected void onPostExecute(JSONObject sifterJSONObject) {
if (sifterJSONObject == null)
return;
if (getSifterError(sifterJSONObject)) {
loginKeys();
loginKeys(null);
return;
}
if (PROJ_DETAIL.equals(ISSUES)) {
Expand Down Expand Up @@ -432,7 +438,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
if (mDomain.length()==0 || mAccessKey.length()==0) {
try {
mLoginError = mSifterHelper.onMissingToken();
loginKeys();
loginKeys(null);
} catch (Exception e) {
e.printStackTrace();
mSifterHelper.onException(e.toString());
Expand All @@ -443,7 +449,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
if (sifterConnection == null) {
loginKeys();
loginKeys(null);
break;
} // if URL misformatted return to LoginActivity
mDialog = ProgressDialog.show(this, "", "Loading ...",true);
Expand Down