diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 69739514..54d2b226 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -149,7 +149,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo }); boardTask = new BoardTask(); - boardTask.execute(boardUrl); + boardTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, boardUrl); } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 0d9cfd26..addccf35 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -118,7 +118,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. // uploadFAB.hide(); parseDownloadPageTask = new ParseDownloadPageTask(); - parseDownloadPageTask.execute(downloadsUrl); + parseDownloadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadsUrl); } // @Override @@ -154,9 +154,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. //Load data parseDownloadPageTask = new ParseDownloadPageTask(); if (downloadsUrl.contains("tpstart")) - parseDownloadPageTask.execute(downloadsUrl.substring(0 + parseDownloadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadsUrl.substring(0 , downloadsUrl.lastIndexOf(";tpstart=")) + ";tpstart=" + pagesLoaded * 10); - else parseDownloadPageTask.execute(downloadsUrl + ";tpstart=" + pagesLoaded * 10); + else parseDownloadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadsUrl + ";tpstart=" + pagesLoaded * 10); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java index d2ddcfb5..70e78af5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java @@ -90,7 +90,7 @@ public class ForumFragment extends BaseFragment { super.onActivityCreated(savedInstanceState); if (categories.isEmpty()) { forumTask = new ForumTask(this::onForumTaskStarted, this::onForumTaskFinished); - forumTask.execute(); + forumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } Timber.d("onActivityCreated"); @@ -114,7 +114,7 @@ public class ForumFragment extends BaseFragment { forumTask.cancel(true); forumTask = new ForumTask(ForumFragment.this::onForumTaskStarted, ForumFragment.this::onForumTaskFinished); forumTask.setUrl(categories.get(parentPosition).getCategoryURL()); - forumTask.execute(); + forumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -125,7 +125,7 @@ public class ForumFragment extends BaseFragment { forumTask.cancel(true); forumTask = new ForumTask(ForumFragment.this::onForumTaskStarted, ForumFragment.this::onForumTaskFinished); forumTask.setUrl(categories.get(parentPosition).getCategoryURL()); - forumTask.execute(); + forumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } }); @@ -145,7 +145,7 @@ public class ForumFragment extends BaseFragment { if (forumTask != null && forumTask.getStatus() != AsyncTask.Status.RUNNING) { forumTask = new ForumTask(ForumFragment.this::onForumTaskStarted, ForumFragment.this::onForumTaskFinished); //forumTask.execute(SessionManager.indexUrl.toString()); - forumTask.execute(); + forumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } ); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index 70a0eed9..6c194c0e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -1,5 +1,6 @@ package gr.thmmy.mthmmy.activities.main.recent; +import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -81,7 +82,7 @@ public class RecentFragment extends BaseFragment { super.onActivityCreated(savedInstanceState); if (topicSummaries.isEmpty()) { recentTask = new RecentTask(this::onRecentTaskStarted, this::onRecentTaskFinished); - recentTask.execute(SessionManager.indexUrl.toString()); + recentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.indexUrl.toString()); } Timber.d("onActivityCreated"); @@ -113,7 +114,7 @@ public class RecentFragment extends BaseFragment { swipeRefreshLayout.setOnRefreshListener(() -> { if (!recentTask.isRunning()) { recentTask = new RecentTask(this::onRecentTaskStarted, this::onRecentTaskFinished); - recentTask.execute(SessionManager.indexUrl.toString()); + recentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.indexUrl.toString()); } } ); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index 79b21b03..0c47bac5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -88,7 +88,7 @@ public class UnreadFragment extends BaseFragment { if (topicSummaries.isEmpty()) { unreadTask = new UnreadTask(this::onUnreadTaskStarted, this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; - unreadTask.execute(SessionManager.unreadUrl.toString()); + unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); } markReadTask = new MarkReadTask(); Timber.d("onActivityCreated"); @@ -108,7 +108,7 @@ public class UnreadFragment extends BaseFragment { fragmentInteractionListener, markReadLinkUrl -> { if (!markReadTask.isRunning() && !unreadTask.isRunning()) { markReadTask = new MarkReadTask(); - markReadTask.execute(markReadLinkUrl); + markReadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, markReadLinkUrl); } }); @@ -130,7 +130,7 @@ public class UnreadFragment extends BaseFragment { loadedPages = 0; unreadTask = new UnreadTask(this::onUnreadTaskStarted, this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; - unreadTask.execute(SessionManager.unreadUrl.toString()); + unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); } } ); @@ -171,7 +171,7 @@ public class UnreadFragment extends BaseFragment { if (loadedPages < numberOfPages) { unreadTask = new UnreadTask(this::onUnreadTaskStarted, this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; - unreadTask.execute(SessionManager.unreadUrl.toString() + ";start=" + loadedPages * 20); + unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString() + ";start=" + loadedPages * 20); } else { progressBar.setVisibility(ProgressBar.INVISIBLE); @@ -306,7 +306,7 @@ public class UnreadFragment extends BaseFragment { loadedPages = 0; unreadTask = new UnreadTask(UnreadFragment.this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; - unreadTask.execute(SessionManager.unreadUrl.toString()); + unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index db6d9238..247365c8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -187,7 +187,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment } profileTask = new ProfileTask(); - profileTask.execute(profileUrl + ";wap"); //Attempts data parsing + profileTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";wap"); //Attempts data parsing } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index 04f20b60..f2c17ff2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -122,7 +122,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap //Load data profileLatestPostsTask = new LatestPostsTask(); - profileLatestPostsTask.execute(profileUrl + ";sa=showPosts;start=" + pagesLoaded * 15); + profileLatestPostsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";sa=showPosts;start=" + pagesLoaded * 15); ++pagesLoaded; } } @@ -132,7 +132,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap super.onActivityCreated(savedInstanceState); if (parsedTopicSummaries.isEmpty() && userHasPosts) { profileLatestPostsTask = new LatestPostsTask(); - profileLatestPostsTask.execute(profileUrl + ";sa=showPosts"); + profileLatestPostsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";sa=showPosts"); pagesLoaded = 1; } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 70e82fba..fbf498c5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -105,7 +105,7 @@ public class StatsFragment extends Fragment { super.onActivityCreated(savedInstanceState); if (!haveParsed) { profileStatsTask = new ProfileStatsTask(); - profileStatsTask.execute(profileUrl + ";sa=statPanel"); + profileStatsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";sa=statPanel"); } Timber.d("onActivityCreated"); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index 264f7842..12e93a60 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -90,7 +90,7 @@ public class SummaryFragment extends Fragment { super.onActivityCreated(savedInstanceState); if (parsedProfileSummaryData.isEmpty()) { summaryTask = new SummaryTask(); - summaryTask.execute(profileSummaryDocument); + summaryTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileSummaryDocument); } Timber.d("onActivityCreated"); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java index 0bcf9a75..4c2590b5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java @@ -1,6 +1,7 @@ package gr.thmmy.mthmmy.activities.shoutbox; import android.app.Activity; +import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -137,7 +138,7 @@ public class ShoutboxFragment extends Fragment { Timber.i("Shout was sent successfully"); editorView.getEditText().getText().clear(); shoutboxTask = new ShoutboxTask(ShoutboxFragment.this::onShoutboxTaskSarted, ShoutboxFragment.this::onShoutboxTaskFinished); - shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); + shoutboxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.shoutboxUrl.toString()); } else if (resultCode == NetworkResultCodes.NETWORK_ERROR) { Timber.w("Failed to send shout"); Toast.makeText(getContext(), "NetworkError", Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java index 44988402..974b8b20 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java @@ -332,7 +332,7 @@ public class UploadActivity extends BaseActivity { if (uploadRootCategories.isEmpty()) { //Parses the uploads page parseUploadPageTask = new ParseUploadPageTask(); - parseUploadPageTask.execute(uploadIndexUrl); + parseUploadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, uploadIndexUrl); } else { //Renders the already parsed data updateUIElements(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java index 5aa92f65..88e34386 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java @@ -21,7 +21,7 @@ public class ShoutboxViewModel extends ViewModel { if (shoutboxTask != null && shoutboxTask.getStatus() == AsyncTask.Status.RUNNING) shoutboxTask.cancel(true); shoutboxTask = new ShoutboxTask(onShoutboxTaskStarted, onShoutboxTaskFinished); - shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); + shoutboxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.shoutboxUrl.toString()); } public void sendShout(String shout) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index 1bbfa9c8..4c6310d6 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -95,7 +95,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa stopLoading(); topicUrl = pageUrl; currentTopicTask = new TopicTask(topicTaskObserver, this); - currentTopicTask.execute(pageUrl); + currentTopicTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageUrl); } public void reloadPage() { @@ -122,7 +122,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa TopicViewModel.this.onTopicTaskCompleted(result); runnable.run(); }); - currentTopicTask.execute(ParseHelpers.getBaseURL(topicUrl) + "." + String.valueOf(currentPageIndex * 15)); + currentTopicTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ParseHelpers.getBaseURL(topicUrl) + "." + String.valueOf(currentPageIndex * 15)); } public void loadPageIndicated() { @@ -158,7 +158,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa SubmitVoteTask submitVoteTask = new SubmitVoteTask(votesArray); submitVoteTask.setOnTaskStartedListener(voteTaskStartedListener); submitVoteTask.setOnNetworkTaskFinishedListener(voteTaskFinishedListener); - submitVoteTask.execute(poll.getPollFormUrl(), poll.getSc()); + submitVoteTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, poll.getPollFormUrl(), poll.getSc()); return true; } @@ -167,7 +167,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa RemoveVoteTask removeVoteTask = new RemoveVoteTask(); removeVoteTask.setOnTaskStartedListener(removeVoteTaskStartedListener); removeVoteTask.setOnNetworkTaskFinishedListener(removeVoteTaskFinishedListener); - removeVoteTask.execute(((Poll) topicItems.getValue().get(0)).getRemoveVoteUrl()); + removeVoteTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Poll) topicItems.getValue().get(0)).getRemoveVoteUrl()); } public void prepareForReply() { @@ -194,13 +194,13 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa } toQuoteList.clear(); Timber.i("Posting reply"); - new ReplyTask(replyFinishListener, includeAppSignature).execute(subject, reply, + new ReplyTask(replyFinishListener, includeAppSignature).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, subject, reply, replyForm.getNumReplies(), replyForm.getSeqnum(), replyForm.getSc(), replyForm.getTopic()); } public void deletePost(String postDeleteUrl) { Timber.i("Deleting post"); - new DeleteTask(deleteTaskStartedListener, deleteTaskFinishedListener).execute(postDeleteUrl); + new DeleteTask(deleteTaskStartedListener, deleteTaskFinishedListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, postDeleteUrl); } public void prepareForEdit(int position, String postEditURL) { @@ -210,7 +210,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa Timber.i("Preparing for edit"); currentPrepareForEditTask = new PrepareForEditTask(prepareForEditCallbacks, this, position, replyPageUrl.getValue()); - currentPrepareForEditTask.execute(postEditURL); + currentPrepareForEditTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, postEditURL); } public void editPost(int position, String subject, String message) { @@ -218,7 +218,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa throw new NullPointerException("Edit preparation was not found!"); PrepareForEditResult editResult = prepareForEditResult.getValue(); Timber.i("Editing post"); - new EditTask(editTaskCallbacks, position).execute(editResult.getCommitEditUrl(), message, + new EditTask(editTaskCallbacks, position).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, editResult.getCommitEditUrl(), message, editResult.getNumReplies(), editResult.getSeqnum(), editResult.getSc(), subject, editResult.getTopic()); }