|
|
@ -60,36 +60,42 @@ import java.util.zip.GZIPInputStream;
|
|
|
|
import java.util.zip.Inflater;
|
|
|
|
import java.util.zip.Inflater;
|
|
|
|
import java.util.zip.InflaterInputStream;
|
|
|
|
import java.util.zip.InflaterInputStream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 该类用于与 Google 任务服务进行交互,包括登录、创建任务、创建任务列表等操作
|
|
|
|
|
|
|
|
*/
|
|
|
|
public class GTaskClient {
|
|
|
|
public class GTaskClient {
|
|
|
|
|
|
|
|
// 日志标签
|
|
|
|
private static final String TAG = GTaskClient.class.getSimpleName();
|
|
|
|
private static final String TAG = GTaskClient.class.getSimpleName();
|
|
|
|
|
|
|
|
// Google 任务的基本 URL
|
|
|
|
private static final String GTASK_URL = "https://mail.google.com/tasks/";
|
|
|
|
private static final String GTASK_URL = "https://mail.google.com/tasks/";
|
|
|
|
|
|
|
|
// 获取任务列表的 URL
|
|
|
|
private static final String GTASK_GET_URL = "https://mail.google.com/tasks/ig";
|
|
|
|
private static final String GTASK_GET_URL = "https://mail.google.com/tasks/ig";
|
|
|
|
|
|
|
|
// 提交任务操作的 URL
|
|
|
|
private static final String GTASK_POST_URL = "https://mail.google.com/tasks/r/ig";
|
|
|
|
private static final String GTASK_POST_URL = "https://mail.google.com/tasks/r/ig";
|
|
|
|
|
|
|
|
// 单例实例
|
|
|
|
private static GTaskClient mInstance = null;
|
|
|
|
private static GTaskClient mInstance = null;
|
|
|
|
|
|
|
|
// HTTP 客户端
|
|
|
|
private DefaultHttpClient mHttpClient;
|
|
|
|
private DefaultHttpClient mHttpClient;
|
|
|
|
|
|
|
|
// 获取任务列表的实际 URL
|
|
|
|
private String mGetUrl;
|
|
|
|
private String mGetUrl;
|
|
|
|
|
|
|
|
// 提交任务操作的实际 URL
|
|
|
|
private String mPostUrl;
|
|
|
|
private String mPostUrl;
|
|
|
|
|
|
|
|
// 客户端版本号
|
|
|
|
private long mClientVersion;
|
|
|
|
private long mClientVersion;
|
|
|
|
|
|
|
|
// 是否登录标志
|
|
|
|
private boolean mLoggedin;
|
|
|
|
private boolean mLoggedin;
|
|
|
|
|
|
|
|
// 最后登录时间
|
|
|
|
private long mLastLoginTime;
|
|
|
|
private long mLastLoginTime;
|
|
|
|
|
|
|
|
// 操作 ID
|
|
|
|
private int mActionId;
|
|
|
|
private int mActionId;
|
|
|
|
|
|
|
|
// 同步账户
|
|
|
|
private Account mAccount;
|
|
|
|
private Account mAccount;
|
|
|
|
|
|
|
|
// 更新操作数组
|
|
|
|
private JSONArray mUpdateArray;
|
|
|
|
private JSONArray mUpdateArray;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 私有构造函数,初始化客户端参数
|
|
|
|
|
|
|
|
*/
|
|
|
|
private GTaskClient() {
|
|
|
|
private GTaskClient() {
|
|
|
|
mHttpClient = null;
|
|
|
|
mHttpClient = null;
|
|
|
|
mGetUrl = GTASK_GET_URL;
|
|
|
|
mGetUrl = GTASK_GET_URL;
|
|
|
@ -102,6 +108,10 @@ public class GTaskClient {
|
|
|
|
mUpdateArray = null;
|
|
|
|
mUpdateArray = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取单例实例
|
|
|
|
|
|
|
|
* @return GTaskClient 单例实例
|
|
|
|
|
|
|
|
*/
|
|
|
|
public static synchronized GTaskClient getInstance() {
|
|
|
|
public static synchronized GTaskClient getInstance() {
|
|
|
|
if (mInstance == null) {
|
|
|
|
if (mInstance == null) {
|
|
|
|
mInstance = new GTaskClient();
|
|
|
|
mInstance = new GTaskClient();
|
|
|
@ -109,34 +119,35 @@ public class GTaskClient {
|
|
|
|
return mInstance;
|
|
|
|
return mInstance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 登录 Google 任务服务
|
|
|
|
|
|
|
|
* @param activity 当前活动
|
|
|
|
|
|
|
|
* @return 登录成功返回 true,失败返回 false
|
|
|
|
|
|
|
|
*/
|
|
|
|
public boolean login(Activity activity) {
|
|
|
|
public boolean login(Activity activity) {
|
|
|
|
// we suppose that the cookie would expire after 5 minutes
|
|
|
|
// 假设 cookie 有效期为 5 分钟,超过时间需要重新登录
|
|
|
|
// then we need to re-login
|
|
|
|
|
|
|
|
final long interval = 1000 * 60 * 5;
|
|
|
|
final long interval = 1000 * 60 * 5;
|
|
|
|
if (mLastLoginTime + interval < System.currentTimeMillis()) {
|
|
|
|
if (mLastLoginTime + interval < System.currentTimeMillis()) {
|
|
|
|
mLoggedin = false;
|
|
|
|
mLoggedin = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 切换账户后需要重新登录
|
|
|
|
// need to re-login after account switch
|
|
|
|
|
|
|
|
if (mLoggedin
|
|
|
|
if (mLoggedin
|
|
|
|
&& !TextUtils.equals(getSyncAccount().name, NotesPreferenceActivity
|
|
|
|
&& !TextUtils.equals(getSyncAccount().name, NotesPreferenceActivity
|
|
|
|
.getSyncAccountName(activity))) {
|
|
|
|
.getSyncAccountName(activity))) {
|
|
|
|
mLoggedin = false;
|
|
|
|
mLoggedin = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mLoggedin) {
|
|
|
|
if (mLoggedin) {
|
|
|
|
Log.d(TAG, "already logged in");
|
|
|
|
Log.d(TAG, "already logged in");
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mLastLoginTime = System.currentTimeMillis();
|
|
|
|
mLastLoginTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
// 登录 Google 账户获取认证令牌
|
|
|
|
String authToken = loginGoogleAccount(activity, false);
|
|
|
|
String authToken = loginGoogleAccount(activity, false);
|
|
|
|
if (authToken == null) {
|
|
|
|
if (authToken == null) {
|
|
|
|
Log.e(TAG, "login google account failed");
|
|
|
|
Log.e(TAG, "login google account failed");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 非 gmail 或 googlemail 账户需要尝试自定义域名登录
|
|
|
|
// login with custom domain if necessary
|
|
|
|
|
|
|
|
if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase()
|
|
|
|
if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase()
|
|
|
|
.endsWith("googlemail.com"))) {
|
|
|
|
.endsWith("googlemail.com"))) {
|
|
|
|
StringBuilder url = new StringBuilder(GTASK_URL).append("a/");
|
|
|
|
StringBuilder url = new StringBuilder(GTASK_URL).append("a/");
|
|
|
@ -145,13 +156,11 @@ public class GTaskClient {
|
|
|
|
url.append(suffix + "/");
|
|
|
|
url.append(suffix + "/");
|
|
|
|
mGetUrl = url.toString() + "ig";
|
|
|
|
mGetUrl = url.toString() + "ig";
|
|
|
|
mPostUrl = url.toString() + "r/ig";
|
|
|
|
mPostUrl = url.toString() + "r/ig";
|
|
|
|
|
|
|
|
|
|
|
|
if (tryToLoginGtask(activity, authToken)) {
|
|
|
|
if (tryToLoginGtask(activity, authToken)) {
|
|
|
|
mLoggedin = true;
|
|
|
|
mLoggedin = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 尝试使用 Google 官方 URL 登录
|
|
|
|
// try to login with google official url
|
|
|
|
|
|
|
|
if (!mLoggedin) {
|
|
|
|
if (!mLoggedin) {
|
|
|
|
mGetUrl = GTASK_GET_URL;
|
|
|
|
mGetUrl = GTASK_GET_URL;
|
|
|
|
mPostUrl = GTASK_POST_URL;
|
|
|
|
mPostUrl = GTASK_POST_URL;
|
|
|
@ -159,21 +168,24 @@ public class GTaskClient {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mLoggedin = true;
|
|
|
|
mLoggedin = true;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 登录 Google 账户获取认证令牌
|
|
|
|
|
|
|
|
* @param activity 当前活动
|
|
|
|
|
|
|
|
* @param invalidateToken 是否使旧令牌失效
|
|
|
|
|
|
|
|
* @return 认证令牌,失败返回 null
|
|
|
|
|
|
|
|
*/
|
|
|
|
private String loginGoogleAccount(Activity activity, boolean invalidateToken) {
|
|
|
|
private String loginGoogleAccount(Activity activity, boolean invalidateToken) {
|
|
|
|
String authToken;
|
|
|
|
String authToken;
|
|
|
|
AccountManager accountManager = AccountManager.get(activity);
|
|
|
|
AccountManager accountManager = AccountManager.get(activity);
|
|
|
|
Account[] accounts = accountManager.getAccountsByType("com.google");
|
|
|
|
Account[] accounts = accountManager.getAccountsByType("com.google");
|
|
|
|
|
|
|
|
|
|
|
|
if (accounts.length == 0) {
|
|
|
|
if (accounts.length == 0) {
|
|
|
|
Log.e(TAG, "there is no available google account");
|
|
|
|
Log.e(TAG, "there is no available google account");
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String accountName = NotesPreferenceActivity.getSyncAccountName(activity);
|
|
|
|
String accountName = NotesPreferenceActivity.getSyncAccountName(activity);
|
|
|
|
Account account = null;
|
|
|
|
Account account = null;
|
|
|
|
for (Account a : accounts) {
|
|
|
|
for (Account a : accounts) {
|
|
|
@ -188,8 +200,7 @@ public class GTaskClient {
|
|
|
|
Log.e(TAG, "unable to get an account with the same name in the settings");
|
|
|
|
Log.e(TAG, "unable to get an account with the same name in the settings");
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取认证令牌
|
|
|
|
// get the token now
|
|
|
|
|
|
|
|
AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account,
|
|
|
|
AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account,
|
|
|
|
"goanna_mobile", null, activity, null, null);
|
|
|
|
"goanna_mobile", null, activity, null, null);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -203,20 +214,23 @@ public class GTaskClient {
|
|
|
|
Log.e(TAG, "get auth token failed");
|
|
|
|
Log.e(TAG, "get auth token failed");
|
|
|
|
authToken = null;
|
|
|
|
authToken = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return authToken;
|
|
|
|
return authToken;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 尝试登录 Google 任务服务
|
|
|
|
|
|
|
|
* @param activity 当前活动
|
|
|
|
|
|
|
|
* @param authToken 认证令牌
|
|
|
|
|
|
|
|
* @return 登录成功返回 true,失败返回 false
|
|
|
|
|
|
|
|
*/
|
|
|
|
private boolean tryToLoginGtask(Activity activity, String authToken) {
|
|
|
|
private boolean tryToLoginGtask(Activity activity, String authToken) {
|
|
|
|
if (!loginGtask(authToken)) {
|
|
|
|
if (!loginGtask(authToken)) {
|
|
|
|
// maybe the auth token is out of date, now let's invalidate the
|
|
|
|
// 可能认证令牌过期,使旧令牌失效并重新尝试登录
|
|
|
|
// token and try again
|
|
|
|
|
|
|
|
authToken = loginGoogleAccount(activity, true);
|
|
|
|
authToken = loginGoogleAccount(activity, true);
|
|
|
|
if (authToken == null) {
|
|
|
|
if (authToken == null) {
|
|
|
|
Log.e(TAG, "login google account failed");
|
|
|
|
Log.e(TAG, "login google account failed");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!loginGtask(authToken)) {
|
|
|
|
if (!loginGtask(authToken)) {
|
|
|
|
Log.e(TAG, "login gtask failed");
|
|
|
|
Log.e(TAG, "login gtask failed");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -225,6 +239,11 @@ public class GTaskClient {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 使用认证令牌登录 Google 任务服务
|
|
|
|
|
|
|
|
* @param authToken 认证令牌
|
|
|
|
|
|
|
|
* @return 登录成功返回 true,失败返回 false
|
|
|
|
|
|
|
|
*/
|
|
|
|
private boolean loginGtask(String authToken) {
|
|
|
|
private boolean loginGtask(String authToken) {
|
|
|
|
int timeoutConnection = 10000;
|
|
|
|
int timeoutConnection = 10000;
|
|
|
|
int timeoutSocket = 15000;
|
|
|
|
int timeoutSocket = 15000;
|
|
|
@ -235,15 +254,12 @@ public class GTaskClient {
|
|
|
|
BasicCookieStore localBasicCookieStore = new BasicCookieStore();
|
|
|
|
BasicCookieStore localBasicCookieStore = new BasicCookieStore();
|
|
|
|
mHttpClient.setCookieStore(localBasicCookieStore);
|
|
|
|
mHttpClient.setCookieStore(localBasicCookieStore);
|
|
|
|
HttpProtocolParams.setUseExpectContinue(mHttpClient.getParams(), false);
|
|
|
|
HttpProtocolParams.setUseExpectContinue(mHttpClient.getParams(), false);
|
|
|
|
|
|
|
|
|
|
|
|
// login gtask
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String loginUrl = mGetUrl + "?auth=" + authToken;
|
|
|
|
String loginUrl = mGetUrl + "?auth=" + authToken;
|
|
|
|
HttpGet httpGet = new HttpGet(loginUrl);
|
|
|
|
HttpGet httpGet = new HttpGet(loginUrl);
|
|
|
|
HttpResponse response = null;
|
|
|
|
HttpResponse response = null;
|
|
|
|
response = mHttpClient.execute(httpGet);
|
|
|
|
response = mHttpClient.execute(httpGet);
|
|
|
|
|
|
|
|
// 获取认证 cookie
|
|
|
|
// get the cookie now
|
|
|
|
|
|
|
|
List<Cookie> cookies = mHttpClient.getCookieStore().getCookies();
|
|
|
|
List<Cookie> cookies = mHttpClient.getCookieStore().getCookies();
|
|
|
|
boolean hasAuthCookie = false;
|
|
|
|
boolean hasAuthCookie = false;
|
|
|
|
for (Cookie cookie : cookies) {
|
|
|
|
for (Cookie cookie : cookies) {
|
|
|
@ -254,8 +270,7 @@ public class GTaskClient {
|
|
|
|
if (!hasAuthCookie) {
|
|
|
|
if (!hasAuthCookie) {
|
|
|
|
Log.w(TAG, "it seems that there is no auth cookie");
|
|
|
|
Log.w(TAG, "it seems that there is no auth cookie");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取客户端版本号
|
|
|
|
// get the client version
|
|
|
|
|
|
|
|
String resString = getResponseContent(response.getEntity());
|
|
|
|
String resString = getResponseContent(response.getEntity());
|
|
|
|
String jsBegin = "_setup(";
|
|
|
|
String jsBegin = "_setup(";
|
|
|
|
String jsEnd = ")}</script>";
|
|
|
|
String jsEnd = ")}</script>";
|
|
|
@ -272,18 +287,24 @@ public class GTaskClient {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// simply catch all exceptions
|
|
|
|
|
|
|
|
Log.e(TAG, "httpget gtask_url failed");
|
|
|
|
Log.e(TAG, "httpget gtask_url failed");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取操作 ID
|
|
|
|
|
|
|
|
* @return 操作 ID
|
|
|
|
|
|
|
|
*/
|
|
|
|
private int getActionId() {
|
|
|
|
private int getActionId() {
|
|
|
|
return mActionId++;
|
|
|
|
return mActionId++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建 HttpPost 请求
|
|
|
|
|
|
|
|
* @return HttpPost 请求对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
private HttpPost createHttpPost() {
|
|
|
|
private HttpPost createHttpPost() {
|
|
|
|
HttpPost httpPost = new HttpPost(mPostUrl);
|
|
|
|
HttpPost httpPost = new HttpPost(mPostUrl);
|
|
|
|
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
|
|
|
|
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
|
|
|
@ -291,13 +312,18 @@ public class GTaskClient {
|
|
|
|
return httpPost;
|
|
|
|
return httpPost;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取 HTTP 响应内容
|
|
|
|
|
|
|
|
* @param entity HTTP 响应实体
|
|
|
|
|
|
|
|
* @return 响应内容
|
|
|
|
|
|
|
|
* @throws IOException 读取响应内容时可能抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
private String getResponseContent(HttpEntity entity) throws IOException {
|
|
|
|
private String getResponseContent(HttpEntity entity) throws IOException {
|
|
|
|
String contentEncoding = null;
|
|
|
|
String contentEncoding = null;
|
|
|
|
if (entity.getContentEncoding() != null) {
|
|
|
|
if (entity.getContentEncoding() != null) {
|
|
|
|
contentEncoding = entity.getContentEncoding().getValue();
|
|
|
|
contentEncoding = entity.getContentEncoding().getValue();
|
|
|
|
Log.d(TAG, "encoding: " + contentEncoding);
|
|
|
|
Log.d(TAG, "encoding: " + contentEncoding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InputStream input = entity.getContent();
|
|
|
|
InputStream input = entity.getContent();
|
|
|
|
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
|
|
|
|
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
|
|
|
|
input = new GZIPInputStream(entity.getContent());
|
|
|
|
input = new GZIPInputStream(entity.getContent());
|
|
|
@ -305,12 +331,10 @@ public class GTaskClient {
|
|
|
|
Inflater inflater = new Inflater(true);
|
|
|
|
Inflater inflater = new Inflater(true);
|
|
|
|
input = new InflaterInputStream(entity.getContent(), inflater);
|
|
|
|
input = new InflaterInputStream(entity.getContent(), inflater);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
InputStreamReader isr = new InputStreamReader(input);
|
|
|
|
InputStreamReader isr = new InputStreamReader(input);
|
|
|
|
BufferedReader br = new BufferedReader(isr);
|
|
|
|
BufferedReader br = new BufferedReader(isr);
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
String buff = br.readLine();
|
|
|
|
String buff = br.readLine();
|
|
|
|
if (buff == null) {
|
|
|
|
if (buff == null) {
|
|
|
@ -323,24 +347,27 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 提交 JSON 请求
|
|
|
|
|
|
|
|
* @param js JSON 对象
|
|
|
|
|
|
|
|
* @return 响应的 JSON 对象
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
private JSONObject postRequest(JSONObject js) throws NetworkFailureException {
|
|
|
|
private JSONObject postRequest(JSONObject js) throws NetworkFailureException {
|
|
|
|
if (!mLoggedin) {
|
|
|
|
if (!mLoggedin) {
|
|
|
|
Log.e(TAG, "please login first");
|
|
|
|
Log.e(TAG, "please login first");
|
|
|
|
throw new ActionFailureException("not logged in");
|
|
|
|
throw new ActionFailureException("not logged in");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HttpPost httpPost = createHttpPost();
|
|
|
|
HttpPost httpPost = createHttpPost();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>();
|
|
|
|
LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>();
|
|
|
|
list.add(new BasicNameValuePair("r", js.toString()));
|
|
|
|
list.add(new BasicNameValuePair("r", js.toString()));
|
|
|
|
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8");
|
|
|
|
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8");
|
|
|
|
httpPost.setEntity(entity);
|
|
|
|
httpPost.setEntity(entity);
|
|
|
|
|
|
|
|
// 执行 POST 请求
|
|
|
|
// execute the post
|
|
|
|
|
|
|
|
HttpResponse response = mHttpClient.execute(httpPost);
|
|
|
|
HttpResponse response = mHttpClient.execute(httpPost);
|
|
|
|
String jsString = getResponseContent(response.getEntity());
|
|
|
|
String jsString = getResponseContent(response.getEntity());
|
|
|
|
return new JSONObject(jsString);
|
|
|
|
return new JSONObject(jsString);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ClientProtocolException e) {
|
|
|
|
} catch (ClientProtocolException e) {
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
@ -360,25 +387,27 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建任务
|
|
|
|
|
|
|
|
* @param task 任务对象
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void createTask(Task task) throws NetworkFailureException {
|
|
|
|
public void createTask(Task task) throws NetworkFailureException {
|
|
|
|
commitUpdate();
|
|
|
|
commitUpdate();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
|
|
|
|
// 添加创建任务的操作
|
|
|
|
// action_list
|
|
|
|
|
|
|
|
actionList.put(task.getCreateAction(getActionId()));
|
|
|
|
actionList.put(task.getCreateAction(getActionId()));
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
|
|
|
|
// 设置客户端版本号
|
|
|
|
// client_version
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
|
|
|
|
// 提交请求
|
|
|
|
// post
|
|
|
|
|
|
|
|
JSONObject jsResponse = postRequest(jsPost);
|
|
|
|
JSONObject jsResponse = postRequest(jsPost);
|
|
|
|
JSONObject jsResult = (JSONObject) jsResponse.getJSONArray(
|
|
|
|
JSONObject jsResult = (JSONObject) jsResponse.getJSONArray(
|
|
|
|
GTaskStringUtils.GTASK_JSON_RESULTS).get(0);
|
|
|
|
GTaskStringUtils.GTASK_JSON_RESULTS).get(0);
|
|
|
|
|
|
|
|
// 设置任务的 Google ID
|
|
|
|
task.setGid(jsResult.getString(GTaskStringUtils.GTASK_JSON_NEW_ID));
|
|
|
|
task.setGid(jsResult.getString(GTaskStringUtils.GTASK_JSON_NEW_ID));
|
|
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
@ -386,25 +415,27 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建任务列表
|
|
|
|
|
|
|
|
* @param tasklist 任务列表对象
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void createTaskList(TaskList tasklist) throws NetworkFailureException {
|
|
|
|
public void createTaskList(TaskList tasklist) throws NetworkFailureException {
|
|
|
|
commitUpdate();
|
|
|
|
commitUpdate();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
|
|
|
|
// 添加创建任务列表的操作
|
|
|
|
// action_list
|
|
|
|
|
|
|
|
actionList.put(tasklist.getCreateAction(getActionId()));
|
|
|
|
actionList.put(tasklist.getCreateAction(getActionId()));
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
|
|
|
|
// 设置客户端版本号
|
|
|
|
// client version
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
|
|
|
|
// 提交请求
|
|
|
|
// post
|
|
|
|
|
|
|
|
JSONObject jsResponse = postRequest(jsPost);
|
|
|
|
JSONObject jsResponse = postRequest(jsPost);
|
|
|
|
JSONObject jsResult = (JSONObject) jsResponse.getJSONArray(
|
|
|
|
JSONObject jsResult = (JSONObject) jsResponse.getJSONArray(
|
|
|
|
GTaskStringUtils.GTASK_JSON_RESULTS).get(0);
|
|
|
|
GTaskStringUtils.GTASK_JSON_RESULTS).get(0);
|
|
|
|
|
|
|
|
// 设置任务列表的 Google ID
|
|
|
|
tasklist.setGid(jsResult.getString(GTaskStringUtils.GTASK_JSON_NEW_ID));
|
|
|
|
tasklist.setGid(jsResult.getString(GTaskStringUtils.GTASK_JSON_NEW_ID));
|
|
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
@ -412,17 +443,19 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 提交更新操作
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void commitUpdate() throws NetworkFailureException {
|
|
|
|
public void commitUpdate() throws NetworkFailureException {
|
|
|
|
if (mUpdateArray != null) {
|
|
|
|
if (mUpdateArray != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
|
|
|
|
// 添加更新操作数组
|
|
|
|
// action_list
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, mUpdateArray);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, mUpdateArray);
|
|
|
|
|
|
|
|
// 设置客户端版本号
|
|
|
|
// client_version
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
|
|
|
|
// 提交请求
|
|
|
|
postRequest(jsPost);
|
|
|
|
postRequest(jsPost);
|
|
|
|
mUpdateArray = null;
|
|
|
|
mUpdateArray = null;
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
@ -433,20 +466,31 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 添加更新节点操作
|
|
|
|
|
|
|
|
* @param node 节点对象
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void addUpdateNode(Node node) throws NetworkFailureException {
|
|
|
|
public void addUpdateNode(Node node) throws NetworkFailureException {
|
|
|
|
if (node != null) {
|
|
|
|
if (node != null) {
|
|
|
|
// too many update items may result in an error
|
|
|
|
// 更新项过多时先提交更新
|
|
|
|
// set max to 10 items
|
|
|
|
|
|
|
|
if (mUpdateArray != null && mUpdateArray.length() > 10) {
|
|
|
|
if (mUpdateArray != null && mUpdateArray.length() > 10) {
|
|
|
|
commitUpdate();
|
|
|
|
commitUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mUpdateArray == null)
|
|
|
|
if (mUpdateArray == null)
|
|
|
|
mUpdateArray = new JSONArray();
|
|
|
|
mUpdateArray = new JSONArray();
|
|
|
|
|
|
|
|
// 添加更新操作
|
|
|
|
mUpdateArray.put(node.getUpdateAction(getActionId()));
|
|
|
|
mUpdateArray.put(node.getUpdateAction(getActionId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 移动任务
|
|
|
|
|
|
|
|
* @param task 任务对象
|
|
|
|
|
|
|
|
* @param preParent 原父任务列表
|
|
|
|
|
|
|
|
* @param curParent 当前父任务列表
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void moveTask(Task task, TaskList preParent, TaskList curParent)
|
|
|
|
public void moveTask(Task task, TaskList preParent, TaskList curParent)
|
|
|
|
throws NetworkFailureException {
|
|
|
|
throws NetworkFailureException {
|
|
|
|
commitUpdate();
|
|
|
|
commitUpdate();
|
|
|
@ -454,31 +498,25 @@ public class GTaskClient {
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONObject action = new JSONObject();
|
|
|
|
JSONObject action = new JSONObject();
|
|
|
|
|
|
|
|
// 设置移动任务的操作
|
|
|
|
// action_list
|
|
|
|
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
|
|
|
|
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_MOVE);
|
|
|
|
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_MOVE);
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ID, task.getGid());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ID, task.getGid());
|
|
|
|
if (preParent == curParent && task.getPriorSibling() != null) {
|
|
|
|
if (preParent == curParent && task.getPriorSibling() != null) {
|
|
|
|
// put prioring_sibing_id only if moving within the tasklist and
|
|
|
|
|
|
|
|
// it is not the first one
|
|
|
|
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_PRIOR_SIBLING_ID, task.getPriorSibling());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_PRIOR_SIBLING_ID, task.getPriorSibling());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_SOURCE_LIST, preParent.getGid());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_SOURCE_LIST, preParent.getGid());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_DEST_PARENT, curParent.getGid());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_DEST_PARENT, curParent.getGid());
|
|
|
|
if (preParent != curParent) {
|
|
|
|
if (preParent != curParent) {
|
|
|
|
// put the dest_list only if moving between tasklists
|
|
|
|
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_DEST_LIST, curParent.getGid());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_DEST_LIST, curParent.getGid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actionList.put(action);
|
|
|
|
actionList.put(action);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
|
|
|
|
// 设置客户端版本号
|
|
|
|
// client_version
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
|
|
|
|
// 提交请求
|
|
|
|
postRequest(jsPost);
|
|
|
|
postRequest(jsPost);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
Log.e(TAG, e.toString());
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
@ -486,20 +524,24 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 删除节点
|
|
|
|
|
|
|
|
* @param node 节点对象
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void deleteNode(Node node) throws NetworkFailureException {
|
|
|
|
public void deleteNode(Node node) throws NetworkFailureException {
|
|
|
|
commitUpdate();
|
|
|
|
commitUpdate();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
|
|
|
|
// 设置节点为已删除
|
|
|
|
// action_list
|
|
|
|
|
|
|
|
node.setDeleted(true);
|
|
|
|
node.setDeleted(true);
|
|
|
|
|
|
|
|
// 添加删除操作
|
|
|
|
actionList.put(node.getUpdateAction(getActionId()));
|
|
|
|
actionList.put(node.getUpdateAction(getActionId()));
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
|
|
|
|
// 设置客户端版本号
|
|
|
|
// client_version
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
|
|
|
|
// 提交请求
|
|
|
|
postRequest(jsPost);
|
|
|
|
postRequest(jsPost);
|
|
|
|
mUpdateArray = null;
|
|
|
|
mUpdateArray = null;
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
@ -509,18 +551,21 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取任务列表
|
|
|
|
|
|
|
|
* @return 任务列表的 JSON 数组
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public JSONArray getTaskLists() throws NetworkFailureException {
|
|
|
|
public JSONArray getTaskLists() throws NetworkFailureException {
|
|
|
|
if (!mLoggedin) {
|
|
|
|
if (!mLoggedin) {
|
|
|
|
Log.e(TAG, "please login first");
|
|
|
|
Log.e(TAG, "please login first");
|
|
|
|
throw new ActionFailureException("not logged in");
|
|
|
|
throw new ActionFailureException("not logged in");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
HttpGet httpGet = new HttpGet(mGetUrl);
|
|
|
|
HttpGet httpGet = new HttpGet(mGetUrl);
|
|
|
|
HttpResponse response = null;
|
|
|
|
HttpResponse response = null;
|
|
|
|
response = mHttpClient.execute(httpGet);
|
|
|
|
response = mHttpClient.execute(httpGet);
|
|
|
|
|
|
|
|
// 获取任务列表的 JSON 数据
|
|
|
|
// get the task list
|
|
|
|
|
|
|
|
String resString = getResponseContent(response.getEntity());
|
|
|
|
String resString = getResponseContent(response.getEntity());
|
|
|
|
String jsBegin = "_setup(";
|
|
|
|
String jsBegin = "_setup(";
|
|
|
|
String jsEnd = ")}</script>";
|
|
|
|
String jsEnd = ")}</script>";
|
|
|
@ -547,14 +592,19 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取指定任务列表下的任务
|
|
|
|
|
|
|
|
* @param listGid 任务列表的 Google ID
|
|
|
|
|
|
|
|
* @return 任务的 JSON 数组
|
|
|
|
|
|
|
|
* @throws NetworkFailureException 网络请求失败时抛出的异常
|
|
|
|
|
|
|
|
*/
|
|
|
|
public JSONArray getTaskList(String listGid) throws NetworkFailureException {
|
|
|
|
public JSONArray getTaskList(String listGid) throws NetworkFailureException {
|
|
|
|
commitUpdate();
|
|
|
|
commitUpdate();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONObject jsPost = new JSONObject();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONArray actionList = new JSONArray();
|
|
|
|
JSONObject action = new JSONObject();
|
|
|
|
JSONObject action = new JSONObject();
|
|
|
|
|
|
|
|
// 设置获取任务列表的操作
|
|
|
|
// action_list
|
|
|
|
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
|
|
|
|
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_GETALL);
|
|
|
|
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_GETALL);
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId());
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId());
|
|
|
@ -562,10 +612,9 @@ public class GTaskClient {
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_GET_DELETED, false);
|
|
|
|
action.put(GTaskStringUtils.GTASK_JSON_GET_DELETED, false);
|
|
|
|
actionList.put(action);
|
|
|
|
actionList.put(action);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
|
|
|
|
|
|
|
|
// 设置客户端版本号
|
|
|
|
// client_version
|
|
|
|
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
|
|
|
|
|
|
|
|
// 提交请求
|
|
|
|
JSONObject jsResponse = postRequest(jsPost);
|
|
|
|
JSONObject jsResponse = postRequest(jsPost);
|
|
|
|
return jsResponse.getJSONArray(GTaskStringUtils.GTASK_JSON_TASKS);
|
|
|
|
return jsResponse.getJSONArray(GTaskStringUtils.GTASK_JSON_TASKS);
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
@ -575,11 +624,18 @@ public class GTaskClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取同步账户
|
|
|
|
|
|
|
|
* @return 同步账户对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
public Account getSyncAccount() {
|
|
|
|
public Account getSyncAccount() {
|
|
|
|
return mAccount;
|
|
|
|
return mAccount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 重置更新操作数组
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void resetUpdateArray() {
|
|
|
|
public void resetUpdateArray() {
|
|
|
|
mUpdateArray = null;
|
|
|
|
mUpdateArray = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|