1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-17 04:00:48 +01:00
This commit is contained in:
Mariotaku Lee 2016-02-08 11:32:49 +08:00
parent a3aed721c6
commit fa45dcc977
4 changed files with 7 additions and 18 deletions

View File

@ -57,10 +57,6 @@ public abstract class BugReporter {
error(null, throwable);
}
public static void logIfFalse(boolean expression, String message) {
if (!expression) error(message);
}
protected abstract void logImpl(@Nullable String message, @Nullable Throwable throwable);
protected abstract void errorImpl(@Nullable String message, @Nullable Throwable throwable);

View File

@ -117,7 +117,8 @@ public class UploadLogsTask implements Runnable {
}
}
if (succeeded) {
BugReporter.logIfFalse(dayLogsDir.delete(), "Unable to delete log dir");
//noinspection ResultOfMethodCallIgnored
dayLogsDir.delete();
}
}
return hasErrors;

View File

@ -366,11 +366,13 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
@Override
protected long[][] doInBackground(final Object... params) {
final FragmentActivity activity = getActivity();
if (activity == null) return null;
final long[][] result = new long[3][];
result[0] = getAccountIds();
result[1] = DataStoreUtils.getOldestMessageIds(getActivity(),
result[1] = DataStoreUtils.getOldestMessageIds(activity,
DirectMessages.Inbox.CONTENT_URI, result[0]);
result[2] = DataStoreUtils.getOldestMessageIds(getActivity(),
result[2] = DataStoreUtils.getOldestMessageIds(activity,
DirectMessages.Outbox.CONTENT_URI, result[0]);
return result;
}
@ -378,7 +380,7 @@ public class DirectMessagesFragment extends AbsContentListRecyclerViewFragment<M
@Override
protected void onPostExecute(final long[][] result) {
final AsyncTwitterWrapper twitter = mTwitterWrapper;
if (twitter == null) return;
if (twitter == null || result == null) return;
twitter.getReceivedDirectMessagesAsync(result[0], result[1], null);
twitter.getSentDirectMessagesAsync(result[0], result[2], null);
}

View File

@ -43,7 +43,6 @@ import java.util.List;
* Created by mariotaku on 15/8/6.
*/
public class JsonSerializer {
public static final String JSON_CACHE_DIR = "json_cache";
@Nullable
public static <T> String serialize(@Nullable final List<T> list, final Class<T> cls) {
@ -146,13 +145,4 @@ public class JsonSerializer {
return buf.toString();
}
public static File getSerializationFile(final Context context, final Object... args) throws IOException {
if (context == null || args == null || args.length == 0) return null;
final File cacheDir = Utils.getBestCacheDir(context, JSON_CACHE_DIR);
if (!cacheDir.exists()) {
BugReporter.logIfFalse(cacheDir.mkdirs(), "Unable to create cache dir " + cacheDir);
}
final String filename = Utils.encodeQueryParams(TwidereArrayUtils.toString(args, '.', false));
return new File(cacheDir, filename + ".json");
}
}