From bd9c92087624c5c91b44dbf4464017022dbf2d21 Mon Sep 17 00:00:00 2001 From: Kosh Date: Mon, 6 Mar 2017 13:07:48 +0800 Subject: [PATCH] fixed offline mode crash to solve #64 and #63, fixed #62 where i misplaced a menuItem and finally #48 now should fixed for good and released 1.0.6 --- app/build.gradle | 4 +-- .../fastaccess/helper/ParseDateFormat.java | 33 ++++++++----------- .../provider/rest/RestProvider.java | 2 +- .../ui/modules/feeds/FeedsPresenter.java | 3 +- .../ui/modules/gists/GistsPresenter.java | 3 +- .../ui/modules/gists/gist/GistPresenter.java | 2 +- .../gist/comments/GistCommentsPresenter.java | 7 ++-- .../notification/NotificationsPresenter.java | 2 +- .../followers/ProfileFollowersPresenter.java | 3 +- .../following/ProfileFollowingPresenter.java | 3 +- .../profile/gists/ProfileGistsPresenter.java | 3 +- .../profile/repos/ProfileReposPresenter.java | 3 +- .../starred/ProfileStarredPresenter.java | 3 +- .../ui/modules/repos/RepoPagerPresenter.java | 2 +- .../code/commit/RepoCommitsPresenter.java | 3 +- .../commit/details/CommitPagerPresenter.java | 3 +- .../comments/CommitCommentsPresenter.java | 3 +- .../RepoContributorsPresenter.java | 3 +- .../repos/code/files/RepoFilesPresenter.java | 3 +- .../code/prettifier/ViewerPresenter.java | 3 +- .../code/releases/RepoReleasesPresenter.java | 3 +- .../issues/issue/RepoIssuesPresenter.java | 3 +- .../issue/details/IssuePagerPresenter.java | 13 ++++---- .../comments/IssueCommentsPresenter.java | 3 +- .../details/events/IssueDetailsPresenter.java | 4 ++- .../RepoPullRequestPresenter.java | 3 +- .../commits/PullRequestCommitsPresenter.java | 3 +- app/src/main/res/menu/pull_request_menu.xml | 11 ++++--- 28 files changed, 74 insertions(+), 60 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7f327c8e0..58e5a4736 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,8 @@ android { applicationId "com.fastaccess.github" minSdkVersion 21 targetSdkVersion 25 - versionCode 105 - versionName "1.0.5" + versionCode 106 + versionName "1.0.6" signingConfig signingConfigs.signing buildConfigField "String", "GITHUB_CLIENT_ID", "\"${GITHUB_CLIENT_ID}\"" buildConfigField "String", "GITHUB_SECRET", "\"${GITHUB_SECRET}\"" diff --git a/app/src/main/java/com/fastaccess/helper/ParseDateFormat.java b/app/src/main/java/com/fastaccess/helper/ParseDateFormat.java index 206a5ed77..878d4ede9 100644 --- a/app/src/main/java/com/fastaccess/helper/ParseDateFormat.java +++ b/app/src/main/java/com/fastaccess/helper/ParseDateFormat.java @@ -15,44 +15,35 @@ public class ParseDateFormat { private static final ParseDateFormat INSTANCE = new ParseDateFormat(); - private static ParseDateFormat getInstance() { - return INSTANCE; - } - private final Object lock = new Object(); + private final DateFormat dateFormat; - private final TimeZone timeZone; private ParseDateFormat() { - dateFormat = new SimpleDateFormat("HH:mm:ss", Locale.US); + dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH); dateFormat.setTimeZone(TimeZone.getDefault()); - timeZone = TimeZone.getDefault(); } - public String format(Date date) { + @NonNull public String format(Date date) { synchronized (lock) { return dateFormat.format(date); } } - public static CharSequence getTimeAgo(@Nullable Date parsedDate) { + @NonNull public static CharSequence getTimeAgo(@Nullable Date parsedDate) { if (parsedDate != null) { - long toLocalTime = parsedDate.getTime() + getInstance().timeZone.getRawOffset() + getInstance().timeZone.getDSTSavings(); - if (INSTANCE.timeZone.getID().equalsIgnoreCase("UTC")) { - toLocalTime = parsedDate.getTime(); - } - return DateUtils.getRelativeTimeSpanString(toLocalTime, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS); + long now = System.currentTimeMillis(); + return DateUtils.getRelativeTimeSpanString(parsedDate.getTime(), now, DateUtils.SECOND_IN_MILLIS); } return "N/A"; } - public static String toGithubDate(@NonNull Date date) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); - return simpleDateFormat.format(date); + @NonNull public static String toGithubDate(@NonNull Date date) { + return getInstance().format(date); } - public static String prettifyDate(long timestamp) { - return new SimpleDateFormat("dd-MM-yyyy", Locale.US).format(new Date(timestamp)); + @NonNull public static String prettifyDate(long timestamp) { + return new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH).format(new Date(timestamp)); } @Nullable public static Date getDateFromString(@NonNull String date) { @@ -63,4 +54,8 @@ public static String prettifyDate(long timestamp) { } return null; } + + @NonNull private static ParseDateFormat getInstance() { + return INSTANCE; + } } \ No newline at end of file diff --git a/app/src/main/java/com/fastaccess/provider/rest/RestProvider.java b/app/src/main/java/com/fastaccess/provider/rest/RestProvider.java index 9366fd189..063c28caf 100644 --- a/app/src/main/java/com/fastaccess/provider/rest/RestProvider.java +++ b/app/src/main/java/com/fastaccess/provider/rest/RestProvider.java @@ -50,7 +50,7 @@ public class RestProvider { private final static Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC) - .setDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") + .setDateFormat("yyyy-MM-dd HH:mm:ss") .setPrettyPrinting() .create(); diff --git a/app/src/main/java/com/fastaccess/ui/modules/feeds/FeedsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/feeds/FeedsPresenter.java index 034c280a0..5e69a64ef 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/feeds/FeedsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/feeds/FeedsPresenter.java @@ -14,6 +14,7 @@ import com.fastaccess.data.dao.SimpleUrlsModel; import com.fastaccess.data.dao.types.EventsType; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.provider.scheme.SchemeParser; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -90,7 +91,7 @@ class FeedsPresenter extends BasePresenter implements FeedsMvp.Pr @Override public void onWorkOffline() { if (eventsModels.isEmpty()) { - manageSubscription(EventsModel.getEvents().subscribe(modelList -> { + manageSubscription(RxHelper.getObserver(EventsModel.getEvents()).subscribe(modelList -> { if (modelList != null) { eventsModels.addAll(modelList); sendToView(FeedsMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/gists/GistsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/gists/GistsPresenter.java index 81f551145..679eb65f6 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/gists/GistsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/gists/GistsPresenter.java @@ -5,6 +5,7 @@ import android.view.View; import com.fastaccess.data.dao.GistsModel; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; import com.fastaccess.ui.modules.gists.gist.GistView; @@ -72,7 +73,7 @@ class GistsPresenter extends BasePresenter implements GistsMvp.Pr @Override public void onWorkOffline() { if (gistsModels.isEmpty()) { - manageSubscription(GistsModel.getGists().subscribe(gistsModels1 -> { + manageSubscription(RxHelper.getObserver(GistsModel.getGists()).subscribe(gistsModels1 -> { gistsModels.addAll(gistsModels1); sendToView(GistsMvp.View::onNotifyAdapter); })); diff --git a/app/src/main/java/com/fastaccess/ui/modules/gists/gist/GistPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/gists/gist/GistPresenter.java index 2dd280260..a2665914a 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/gists/gist/GistPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/gists/gist/GistPresenter.java @@ -121,7 +121,7 @@ class GistPresenter extends BasePresenter implements GistMvp.Prese @Override public void onWorkOffline(@NonNull String gistId) { if (gist == null) { - manageSubscription(GistsModel.getGist(gistId) + manageSubscription(RxHelper.getObserver(GistsModel.getGist(gistId)) .subscribe(gistsModel -> { this.gist = gistsModel; sendToView(GistMvp.View::onSetupDetails); diff --git a/app/src/main/java/com/fastaccess/ui/modules/gists/gist/comments/GistCommentsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/gists/gist/comments/GistCommentsPresenter.java index 864cd9802..d533424e7 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/gists/gist/comments/GistCommentsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/gists/gist/comments/GistCommentsPresenter.java @@ -1,7 +1,5 @@ package com.fastaccess.ui.modules.gists.gist.comments; -import android.app.Activity; -import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -12,11 +10,10 @@ import com.fastaccess.data.dao.LoginModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.Logger; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; -import com.fastaccess.ui.adapter.CommentsAdapter; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; -import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView; import java.util.ArrayList; @@ -94,7 +91,7 @@ class GistCommentsPresenter extends BasePresenter implemen @Override public void onWorkOffline(@NonNull String gistId) { if (comments.isEmpty()) { - manageSubscription(CommentsModel.getGistComments(gistId).subscribe( + manageSubscription(RxHelper.getObserver(CommentsModel.getGistComments(gistId)).subscribe( localComments -> { if (localComments != null && !localComments.isEmpty()) { Logger.e(localComments.size()); diff --git a/app/src/main/java/com/fastaccess/ui/modules/notification/NotificationsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/notification/NotificationsPresenter.java index 5f46e9dc6..fd5684764 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/notification/NotificationsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/notification/NotificationsPresenter.java @@ -55,7 +55,7 @@ public class NotificationsPresenter extends BasePresenter @Override public void onWorkOffline() { if (notifications.isEmpty()) { - manageSubscription(NotificationThreadModel.getNotifications() + manageSubscription(RxHelper.getObserver(NotificationThreadModel.getNotifications()) .subscribe(models -> { if (models != null) { notifications.addAll(models); diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/followers/ProfileFollowersPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/followers/ProfileFollowersPresenter.java index 89a614380..8832c8d95 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/followers/ProfileFollowersPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/followers/ProfileFollowersPresenter.java @@ -5,6 +5,7 @@ import android.view.View; import com.fastaccess.data.dao.UserModel; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -79,7 +80,7 @@ class ProfileFollowersPresenter extends BasePresenter @Override public void onWorkOffline(@NonNull String login) { if (users.isEmpty()) { - manageSubscription(UserModel.getFollowers(login).subscribe(userModels -> { + manageSubscription(RxHelper.getObserver(UserModel.getFollowers(login)).subscribe(userModels -> { users.addAll(userModels); sendToView(ProfileFollowersMvp.View::onNotifyAdapter); })); diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/following/ProfileFollowingPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/following/ProfileFollowingPresenter.java index d70c7a619..f90cf2997 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/following/ProfileFollowingPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/following/ProfileFollowingPresenter.java @@ -5,6 +5,7 @@ import android.view.View; import com.fastaccess.data.dao.UserModel; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -79,7 +80,7 @@ class ProfileFollowingPresenter extends BasePresenter @Override public void onWorkOffline(@NonNull String login) { if (users.isEmpty()) { - manageSubscription(UserModel.getFollowing(login).subscribe(userModels -> { + manageSubscription(RxHelper.getObserver(UserModel.getFollowing(login)).subscribe(userModels -> { users.addAll(userModels); sendToView(ProfileFollowingMvp.View::onNotifyAdapter); })); diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/gists/ProfileGistsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/gists/ProfileGistsPresenter.java index 3e4455a36..bf56df5bc 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/gists/ProfileGistsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/gists/ProfileGistsPresenter.java @@ -5,6 +5,7 @@ import android.view.View; import com.fastaccess.data.dao.GistsModel; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -78,7 +79,7 @@ class ProfileGistsPresenter extends BasePresenter implemen @Override public void onWorkOffline(@NonNull String login) { if (gistsModels.isEmpty()) { - manageSubscription(GistsModel.getMyGists(login).subscribe(gistsModels1 -> { + manageSubscription(RxHelper.getObserver(GistsModel.getMyGists(login)).subscribe(gistsModels1 -> { gistsModels.addAll(gistsModels1); sendToView(ProfileGistsMvp.View::onNotifyAdapter); })); diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/repos/ProfileReposPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/repos/ProfileReposPresenter.java index 18e4261d9..236db25db 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/repos/ProfileReposPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/repos/ProfileReposPresenter.java @@ -8,6 +8,7 @@ import com.fastaccess.data.dao.LoginModel; import com.fastaccess.data.dao.NameParser; import com.fastaccess.data.dao.RepoModel; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; import com.fastaccess.ui.modules.repos.RepoPagerView; @@ -89,7 +90,7 @@ class ProfileReposPresenter extends BasePresenter implemen @Override public void onWorkOffline(@NonNull String login) { if (repos.isEmpty()) { - manageSubscription(RepoModel.getMyRepos(login).subscribe(repoModels -> { + manageSubscription(RxHelper.getObserver(RepoModel.getMyRepos(login)).subscribe(repoModels -> { repos.addAll(repoModels); sendToView(ProfileReposMvp.View::onNotifyAdapter); })); diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/starred/ProfileStarredPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/starred/ProfileStarredPresenter.java index c9216ffcb..ca7746eca 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/starred/ProfileStarredPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/starred/ProfileStarredPresenter.java @@ -7,6 +7,7 @@ import com.fastaccess.data.dao.NameParser; import com.fastaccess.data.dao.RepoModel; import com.fastaccess.helper.Logger; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; import com.fastaccess.ui.modules.repos.RepoPagerView; @@ -82,7 +83,7 @@ class ProfileStarredPresenter extends BasePresenter impl @Override public void onWorkOffline(@NonNull String login) { if (repos.isEmpty()) { - manageSubscription(RepoModel.getStarred(login).subscribe(repoModels -> { + manageSubscription(RxHelper.getObserver(RepoModel.getStarred(login)).subscribe(repoModels -> { repos.addAll(repoModels); Logger.e(repoModels); sendToView(ProfileStarredMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/RepoPagerPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/RepoPagerPresenter.java index 7e0806a92..efbf70cb9 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/RepoPagerPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/RepoPagerPresenter.java @@ -200,7 +200,7 @@ class RepoPagerPresenter extends BasePresenter implements Rep @Override public void onWorkOffline() { if (!InputHelper.isEmpty(login()) && !InputHelper.isEmpty(repoId())) { - manageSubscription(RepoModel.getRepo(repoId) + manageSubscription(RxHelper.getObserver(RepoModel.getRepo(repoId)) .subscribe(repoModel -> { repo = repoModel; sendToView(view -> { diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/RepoCommitsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/RepoCommitsPresenter.java index 0fed980f2..98dc1e028 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/RepoCommitsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/RepoCommitsPresenter.java @@ -8,6 +8,7 @@ import com.fastaccess.data.dao.CommitModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -88,7 +89,7 @@ class RepoCommitsPresenter extends BasePresenter implements @Override public void onWorkOffline() { if (commits.isEmpty()) { - manageSubscription(CommitModel.getCommits(repoId, login) + manageSubscription(RxHelper.getObserver(CommitModel.getCommits(repoId, login)) .subscribe(models -> { commits.addAll(models); sendToView(RepoCommitsMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerPresenter.java index 74fb512d8..cdc2e8066 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerPresenter.java @@ -7,6 +7,7 @@ import com.fastaccess.data.dao.CommitModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -55,7 +56,7 @@ class CommitPagerPresenter extends BasePresenter implements } @Override public void onWorkOffline(@NonNull String sha, @NonNull String repoId, @NonNull String login) { - manageSubscription(CommitModel.getCommit(sha, repoId, login) + manageSubscription(RxHelper.getObserver(CommitModel.getCommit(sha, repoId, login)) .subscribe(commit -> { commitModel = commit; sendToView(CommitPagerMvp.View::onSetup); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsPresenter.java index f3d06f98c..664023618 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsPresenter.java @@ -9,6 +9,7 @@ import com.fastaccess.data.dao.CommentsModel; import com.fastaccess.data.dao.LoginModel; import com.fastaccess.helper.BundleConstant; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -88,7 +89,7 @@ class CommitCommentsPresenter extends BasePresenter impl @Override public void onWorkOffline() { if (comments.isEmpty()) { - manageSubscription(CommentsModel.getCommitComments(repoId(), login(), sha) + manageSubscription(RxHelper.getObserver(CommentsModel.getCommitComments(repoId(), login(), sha)) .subscribe(models -> { if (models != null) { comments.addAll(models); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/contributors/RepoContributorsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/contributors/RepoContributorsPresenter.java index 72d3578ad..fff3352db 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/contributors/RepoContributorsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/contributors/RepoContributorsPresenter.java @@ -8,6 +8,7 @@ import com.fastaccess.data.dao.UserModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -75,7 +76,7 @@ class RepoContributorsPresenter extends BasePresenter @Override public void onWorkOffline() { if (users.isEmpty()) { - manageSubscription(UserModel.getContributors(repoId) + manageSubscription(RxHelper.getObserver(UserModel.getContributors(repoId)) .subscribe(userModels -> { users.addAll(userModels); sendToView(RepoContributorsMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/files/RepoFilesPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/files/RepoFilesPresenter.java index 5a7179612..75b996ea8 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/files/RepoFilesPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/files/RepoFilesPresenter.java @@ -9,6 +9,7 @@ import com.fastaccess.data.dao.RepoFilesModel; import com.fastaccess.data.dao.RepoPathsManager; import com.fastaccess.data.dao.types.FilesType; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -52,7 +53,7 @@ class RepoFilesPresenter extends BasePresenter implements Rep @Override public void onWorkOffline() { if ((repoId == null || login == null) || !files.isEmpty()) return; - manageSubscription(RepoFilesModel.getFiles(login, repoId).subscribe( + manageSubscription(RxHelper.getObserver(RepoFilesModel.getFiles(login, repoId)).subscribe( models -> { files.addAll(models); sendToView(RepoFilesMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java index 2972e945e..540a2342f 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java @@ -9,6 +9,7 @@ import com.fastaccess.data.dao.MarkdownModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.markdown.MarkDownProvider; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -69,7 +70,7 @@ class ViewerPresenter extends BasePresenter implements ViewerMvp @Override public void onWorkOffline() { if (downloadedStream == null) { - manageSubscription(FileModel.get(url) + manageSubscription(RxHelper.getObserver(FileModel.get(url)) .subscribe(fileModel -> { if (fileModel != null) { isImage = MarkDownProvider.isImage(fileModel.getFullUrl()); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/releases/RepoReleasesPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/releases/RepoReleasesPresenter.java index f6a2623a6..692925a13 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/releases/RepoReleasesPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/releases/RepoReleasesPresenter.java @@ -9,6 +9,7 @@ import com.fastaccess.data.dao.ReleasesModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -84,7 +85,7 @@ class RepoReleasesPresenter extends BasePresenter implemen @Override public void onWorkOffline() { if (releases.isEmpty()) { - manageSubscription(ReleasesModel.get(repoId, login) + manageSubscription(RxHelper.getObserver(ReleasesModel.get(repoId, login)) .subscribe(releasesModels -> { releases.addAll(releasesModels); sendToView(RepoReleasesMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/RepoIssuesPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/RepoIssuesPresenter.java index e0727e61d..c6d916144 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/RepoIssuesPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/RepoIssuesPresenter.java @@ -14,6 +14,7 @@ import com.fastaccess.helper.Bundler; import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.Logger; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -91,7 +92,7 @@ class RepoIssuesPresenter extends BasePresenter implements R @Override public void onWorkOffline() { if (issues.isEmpty()) { - manageSubscription(IssueModel.getIssues(repoId, login, issueState) + manageSubscription(RxHelper.getObserver(IssueModel.getIssues(repoId, login, issueState)) .subscribe(issueModel -> { issues.addAll(issueModel); sendToView(RepoIssuesMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerPresenter.java index 5de3a37eb..207b991f9 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerPresenter.java @@ -85,12 +85,13 @@ class IssuePagerPresenter extends BasePresenter implements I @Override public void onWorkOffline(long issueNumber, @NonNull String repoId, @NonNull String login) { if (issueModel == null) { - manageSubscription(IssueModel.getIssueByNumber((int) issueNumber).subscribe(issueModel1 -> { - if (issueModel1 != null) { - issueModel = issueModel1; - sendToView(IssuePagerMvp.View::onSetupIssue); - } - })); + manageSubscription(RxHelper.getObserver(IssueModel.getIssueByNumber((int) issueNumber)) + .subscribe(issueModel1 -> { + if (issueModel1 != null) { + issueModel = issueModel1; + sendToView(IssuePagerMvp.View::onSetupIssue); + } + })); } else { sendToView(BaseMvp.FAView::hideProgress); } diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/comments/IssueCommentsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/comments/IssueCommentsPresenter.java index 1355200dc..da686252e 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/comments/IssueCommentsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/comments/IssueCommentsPresenter.java @@ -9,6 +9,7 @@ import com.fastaccess.data.dao.CommentsModel; import com.fastaccess.data.dao.LoginModel; import com.fastaccess.helper.BundleConstant; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -88,7 +89,7 @@ class IssueCommentsPresenter extends BasePresenter implem @Override public void onWorkOffline() { if (comments.isEmpty()) { - manageSubscription(CommentsModel.getIssueComments(repoId(), login(), String.valueOf(number)) + manageSubscription(RxHelper.getObserver(CommentsModel.getIssueComments(repoId(), login(), String.valueOf(number))) .subscribe(models -> { if (models != null) { comments.addAll(models); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/events/IssueDetailsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/events/IssueDetailsPresenter.java index 994262a35..e3c013c0e 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/events/IssueDetailsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/events/IssueDetailsPresenter.java @@ -10,6 +10,7 @@ import com.fastaccess.data.dao.IssueEventModel; import com.fastaccess.data.dao.IssueModel; import com.fastaccess.helper.BundleConstant; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.provider.scheme.SchemeParser; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -45,7 +46,8 @@ class IssueDetailsPresenter extends BasePresenter implemen @Override public void onWorkOffline() { if (events.isEmpty() || events.size() == 1) { - manageSubscription(IssueEventModel.get(issueModel.getRepoId(), issueModel.getLogin(), String.valueOf(issueModel.getNumber())) + manageSubscription(RxHelper.getObserver(IssueEventModel.get(issueModel.getRepoId(), + issueModel.getLogin(), String.valueOf(issueModel.getNumber()))) .subscribe( models -> { if (models != null) { diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/RepoPullRequestPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/RepoPullRequestPresenter.java index 0f1e2544f..f8afa9404 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/RepoPullRequestPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/RepoPullRequestPresenter.java @@ -13,6 +13,7 @@ import com.fastaccess.helper.Bundler; import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.Logger; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -91,7 +92,7 @@ class RepoPullRequestPresenter extends BasePresenter im @Override public void onWorkOffline() { if (pullRequests.isEmpty()) { - manageSubscription(PullRequestModel.getPullRequests(repoId, login, issueState) + manageSubscription(RxHelper.getObserver(PullRequestModel.getPullRequests(repoId, login, issueState)) .subscribe(pulls -> { pullRequests.addAll(pulls); sendToView(RepoPullRequestMvp.View::onNotifyAdapter); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/details/commits/PullRequestCommitsPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/details/commits/PullRequestCommitsPresenter.java index bf294c5a0..63a809c45 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/details/commits/PullRequestCommitsPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/pull_requests/pull_request/details/commits/PullRequestCommitsPresenter.java @@ -8,6 +8,7 @@ import com.fastaccess.data.dao.CommitModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.BaseMvp; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; @@ -90,7 +91,7 @@ class PullRequestCommitsPresenter extends BasePresenter { commits.addAll(models); sendToView(PullRequestCommitsMvp.View::onNotifyAdapter); diff --git a/app/src/main/res/menu/pull_request_menu.xml b/app/src/main/res/menu/pull_request_menu.xml index 85504c362..253bb6adf 100644 --- a/app/src/main/res/menu/pull_request_menu.xml +++ b/app/src/main/res/menu/pull_request_menu.xml @@ -40,12 +40,13 @@ android:id="@+id/assignees" android:icon="@drawable/ic_profile" android:title="@string/assignees"/> + - +