Fixed array index errors in google auth activities, fixed possible JSON issue in pushtaskonsave

pull/14/head
Sam Bosley 14 years ago
parent 9a84a36f56
commit 1864b0e395

@ -100,11 +100,14 @@ public class ActFmGoogleAuthActivity extends ListActivity {
@Override @Override
protected void onListItemClick(ListView l, View v, int position, long id) { protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id); super.onListItemClick(l, v, position, id);
final ProgressDialog pd = DialogUtilities.progressDialog(this, this.getString(R.string.gtasks_GLA_authenticating)); int offsetPosition = position - 1; // Subtract 1 because apparently android counts the header view as part of the adapter.
pd.show(); if (offsetPosition >= 0 && offsetPosition < nameArray.length) {
final Account a = accountManager.getAccountByName(nameArray[position - 1]); // Subtract 1 because apparently android counts the header view as part of the adapter. final ProgressDialog pd = DialogUtilities.progressDialog(this, this.getString(R.string.gtasks_GLA_authenticating));
accountName = a.name; pd.show();
getAuthToken(a, pd); final Account a = accountManager.getAccountByName(nameArray[position - 1]);
accountName = a.name;
getAuthToken(a, pd);
}
} }
private void getAuthToken(Account a, final ProgressDialog pd) { private void getAuthToken(Account a, final ProgressDialog pd) {

@ -346,8 +346,11 @@ public final class ActFmSyncService {
if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) { if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) {
try { try {
JSONObject user = new JSONObject(task.getValue(Task.USER)); JSONObject user = new JSONObject(task.getValue(Task.USER));
params.add("user_email"); String userEmail = user.optString("email");
params.add(user.get("email")); if (!TextUtils.isEmpty(userEmail)) {
params.add("user_email");
params.add(userEmail);
}
} catch (JSONException e) { } catch (JSONException e) {
Log.e("Error parsing user", task.getValue(Task.USER), e); Log.e("Error parsing user", task.getValue(Task.USER), e);
} }

@ -120,11 +120,14 @@ public class GtasksLoginActivity extends ListActivity {
@Override @Override
protected void onListItemClick(ListView l, View v, int position, long id) { protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id); super.onListItemClick(l, v, position, id);
final ProgressDialog pd = DialogUtilities.progressDialog(this, this.getString(R.string.gtasks_GLA_authenticating)); int offsetPosition = position - 1; // Subtract 1 because apparently android counts the header view as part of the adapter.
pd.show(); if (offsetPosition >= 0 && offsetPosition < nameArray.length) {
final Account a = accountManager.getAccountByName(nameArray[position - 1]); // Subtract 1 because apparently android counts the header view as part of the adapter. final ProgressDialog pd = DialogUtilities.progressDialog(this, this.getString(R.string.gtasks_GLA_authenticating));
accountName = a.name; pd.show();
getAuthToken(a, pd); final Account a = accountManager.getAccountByName(nameArray[offsetPosition]);
accountName = a.name;
getAuthToken(a, pd);
}
} }
private void getAuthToken(Account a, final ProgressDialog pd) { private void getAuthToken(Account a, final ProgressDialog pd) {

Loading…
Cancel
Save