mirror of
https://github.com/etesync/android
synced 2024-11-17 05:19:12 +00:00
Fix adding members on some devices.
Networking is not allowed on the main thread, and on some devices with strict mode on, even the creation of the http handler is enough to trigger an exception (i.e even if not used from the thread). This moves even the creation to a thread which fixes the issue.
This commit is contained in:
parent
2b17b56c8c
commit
5a64bd90cc
@ -3,6 +3,7 @@ package com.etesync.syncadapter.ui;
|
||||
import android.accounts.Account;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@ -30,7 +31,7 @@ public class AddMemberFragment extends DialogFragment {
|
||||
final static private String KEY_MEMBER = "memberEmail";
|
||||
private Account account;
|
||||
private AccountSettings settings;
|
||||
private OkHttpClient httpClient;
|
||||
private Context ctx;
|
||||
private HttpUrl remote;
|
||||
private CollectionInfo info;
|
||||
private String memberEmail;
|
||||
@ -52,9 +53,9 @@ public class AddMemberFragment extends DialogFragment {
|
||||
account = getArguments().getParcelable(Constants.KEY_ACCOUNT);
|
||||
info = (CollectionInfo) getArguments().getSerializable(Constants.KEY_COLLECTION_INFO);
|
||||
memberEmail = getArguments().getString(KEY_MEMBER);
|
||||
ctx = getContext();
|
||||
try {
|
||||
settings = new AccountSettings(getContext(), account);
|
||||
httpClient = HttpClient.create(getContext(), settings);
|
||||
settings = new AccountSettings(ctx, account);
|
||||
} catch (InvalidAccountException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -79,6 +80,7 @@ public class AddMemberFragment extends DialogFragment {
|
||||
@Override
|
||||
protected AddResult doInBackground(Void... voids) {
|
||||
try {
|
||||
OkHttpClient httpClient = HttpClient.create(ctx, settings);
|
||||
UserInfoManager userInfoManager = new UserInfoManager(httpClient, remote);
|
||||
|
||||
UserInfoManager.UserInfo userInfo = userInfoManager.get(memberEmail);
|
||||
@ -143,6 +145,7 @@ public class AddMemberFragment extends DialogFragment {
|
||||
@Override
|
||||
protected AddResultSecond doInBackground(Void... voids) {
|
||||
try {
|
||||
OkHttpClient httpClient = HttpClient.create(ctx, settings);
|
||||
JournalManager journalsManager = new JournalManager(httpClient, remote);
|
||||
|
||||
JournalManager.Journal journal = JournalManager.Journal.fakeWithUid(info.uid);
|
||||
|
Loading…
Reference in New Issue
Block a user