diff --git a/app/src/main/java/com/gh4a/fragment/CollaboratorListFragment.java b/app/src/main/java/com/gh4a/fragment/CollaboratorListFragment.java index c8c664e05..7d3ed916b 100644 --- a/app/src/main/java/com/gh4a/fragment/CollaboratorListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/CollaboratorListFragment.java @@ -18,19 +18,22 @@ public class CollaboratorListFragment extends PagedDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + public static CollaboratorListFragment newInstance(String owner, String repo) { CollaboratorListFragment f = new CollaboratorListFragment(); Bundle args = new Bundle(); - args.putString("owner", owner); - args.putString("repo", repo); + args.putString(EXTRA_OWNER, owner); + args.putString(EXTRA_REPO, repo); f.setArguments(args); return f; } @Override protected Single>> loadPage(int page, boolean bypassCache) { - String owner = getArguments().getString("owner"); - String repo = getArguments().getString("repo"); + String owner = getArguments().getString(EXTRA_OWNER); + String repo = getArguments().getString(EXTRA_REPO); final RepositoryCollaboratorService service = ServiceFactory.get(RepositoryCollaboratorService.class, bypassCache); return service.getCollaborators(owner, repo, page); diff --git a/app/src/main/java/com/gh4a/fragment/CommitCompareFragment.java b/app/src/main/java/com/gh4a/fragment/CommitCompareFragment.java index d478f5a5c..3cfd9836a 100644 --- a/app/src/main/java/com/gh4a/fragment/CommitCompareFragment.java +++ b/app/src/main/java/com/gh4a/fragment/CommitCompareFragment.java @@ -15,10 +15,6 @@ */ package com.gh4a.fragment; -import java.net.HttpURLConnection; -import java.util.ArrayList; -import java.util.List; - import android.app.Activity; import android.content.Intent; import android.os.Bundle; @@ -36,10 +32,23 @@ import com.meisolsson.githubsdk.model.CommitCompare; import com.meisolsson.githubsdk.service.repositories.RepositoryCommitService; +import java.net.HttpURLConnection; +import java.util.ArrayList; +import java.util.List; + import io.reactivex.Single; public class CommitCompareFragment extends ListDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_BASE = "base"; + private static final String EXTRA_BASE_LABEL = "base_label"; + private static final String EXTRA_HEAD = "head"; + private static final String EXTRA_HEAD_LABEL = "head_label"; + private static final String EXTRA_PR = "pr"; + private static final int REQUEST_COMMIT = 2000; + public static CommitCompareFragment newInstance(String repoOwner, String repoName, String baseRef, String headRef) { return newInstance(repoOwner, repoName, -1, null, baseRef, null, headRef); @@ -49,21 +58,19 @@ public static CommitCompareFragment newInstance(String repoOwner, String repoNam int pullRequestNumber, String baseRefLabel, String baseRef, String headRefLabel, String headRef) { Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); - args.putString("base", baseRef); - args.putString("base_label", baseRefLabel); - args.putString("head", headRef); - args.putString("head_label", headRefLabel); - args.putInt("pr", pullRequestNumber); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); + args.putString(EXTRA_BASE, baseRef); + args.putString(EXTRA_BASE_LABEL, baseRefLabel); + args.putString(EXTRA_HEAD, headRef); + args.putString(EXTRA_HEAD_LABEL, headRefLabel); + args.putInt(EXTRA_PR, pullRequestNumber); CommitCompareFragment f = new CommitCompareFragment(); f.setArguments(args); return f; } - private static final int REQUEST_COMMIT = 2000; - private String mRepoOwner; private String mRepoName; private String mBase; @@ -77,13 +84,13 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mRepoOwner = args.getString("owner"); - mRepoName = args.getString("repo"); - mBase = args.getString("base"); - mBaseLabel = args.getString("base_label"); - mHead = args.getString("head"); - mHeadLabel = args.getString("head_label"); - mPullRequestNumber = args.getInt("pr", -1); + mRepoOwner = args.getString(EXTRA_OWNER); + mRepoName = args.getString(EXTRA_REPO); + mBase = args.getString(EXTRA_BASE); + mBaseLabel = args.getString(EXTRA_BASE_LABEL); + mHead = args.getString(EXTRA_HEAD); + mHeadLabel = args.getString(EXTRA_HEAD_LABEL); + mPullRequestNumber = args.getInt(EXTRA_PR, -1); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/CommitFragment.java b/app/src/main/java/com/gh4a/fragment/CommitFragment.java index 8411cf392..eaf46e8e5 100644 --- a/app/src/main/java/com/gh4a/fragment/CommitFragment.java +++ b/app/src/main/java/com/gh4a/fragment/CommitFragment.java @@ -39,19 +39,30 @@ import java.util.List; public class CommitFragment extends LoadingFragmentBase implements OnClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_SHA = "sha"; + private static final String EXTRA_COMMIT = "commit"; + private static final String EXTRA_COMMENTS = "comments"; + private static final String STATUS_ADDED = "added"; + private static final String STATUS_MODIFIED = "modified"; + private static final String STATUS_RENAMED = "renamed"; + private static final String STATUS_REMOVED = "removed"; + private static final int REQUEST_DIFF_VIEWER = 1000; + public static CommitFragment newInstance(String repoOwner, String repoName, String commitSha, Commit commit, List comments) { CommitFragment f = new CommitFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); - args.putString("sha", commitSha); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); + args.putString(EXTRA_SHA, commitSha); // Commit objects can be huge, depending on the number of patches attached to it. // In order to avoid TransactionTooLargeExceptions being thrown when the activity we're // attached to is recreated, store the data in compressed form - IntentUtils.putParcelableToBundleCompressed(args, "commit", commit, 100000); - args.putParcelableArrayList("comments", new ArrayList<>(comments)); + IntentUtils.putParcelableToBundleCompressed(args, EXTRA_COMMIT, commit, 100000); + args.putParcelableArrayList(EXTRA_COMMENTS, new ArrayList<>(comments)); f.setArguments(args); return f; } @@ -60,8 +71,6 @@ public interface CommentUpdateListener { void onCommentsUpdated(); } - private static final int REQUEST_DIFF_VIEWER = 1000; - private String mRepoOwner; private String mRepoName; private String mObjectSha; @@ -73,11 +82,11 @@ public interface CommentUpdateListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mRepoOwner = args.getString("owner"); - mRepoName = args.getString("repo"); - mObjectSha = args.getString("sha"); - mCommit = IntentUtils.readCompressedParcelableFromBundle(args, "commit"); - mComments = args.getParcelableArrayList("comments"); + mRepoOwner = args.getString(EXTRA_OWNER); + mRepoName = args.getString(EXTRA_REPO); + mObjectSha = args.getString(EXTRA_SHA); + mCommit = IntentUtils.readCompressedParcelableFromBundle(args, EXTRA_COMMIT); + mComments = args.getParcelableArrayList(EXTRA_COMMENTS); } @Override @@ -197,19 +206,19 @@ protected void fillStats(List files, List impleme CommitNoteAdapter.OnCommentAction, EditorBottomSheet.Callback, EditorBottomSheet.Listener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_SHA = "sha"; + private static final String EXTRA_COMMIT_AUTHOR = "commit_author"; + private static final String EXTRA_COMMITTER = "committer"; + private static final String EXTRA_COMMENTS = "comments"; + private static final String EXTRA_INITIAL_COMMENT = "initial_comment"; + public static CommitNoteFragment newInstance(String repoOwner, String repoName, String commitSha, Commit commit, List allComments, IntentUtils.InitialCommentMarker initialComment) { @@ -53,13 +61,13 @@ public static CommitNoteFragment newInstance(String repoOwner, String repoName, } Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); - args.putString("sha", commitSha); - args.putParcelable("commit_author", commit.author()); - args.putParcelable("committer", commit.committer()); - args.putParcelableArrayList("comments", comments); - args.putParcelable("initial_comment", initialComment); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); + args.putString(EXTRA_SHA, commitSha); + args.putParcelable(EXTRA_COMMIT_AUTHOR, commit.author()); + args.putParcelable(EXTRA_COMMITTER, commit.committer()); + args.putParcelableArrayList(EXTRA_COMMENTS, comments); + args.putParcelable(EXTRA_INITIAL_COMMENT, initialComment); f.setArguments(args); return f; @@ -85,13 +93,13 @@ public interface CommentUpdateListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mRepoOwner = args.getString("owner"); - mRepoName = args.getString("repo"); - mObjectSha = args.getString("sha"); - mCommitAuthor = args.getParcelable("commit_author"); - mCommitter = args.getParcelable("committer"); - mInitialComment = args.getParcelable("initial_comment"); - args.remove("initial_comment"); + mRepoOwner = args.getString(EXTRA_OWNER); + mRepoName = args.getString(EXTRA_REPO); + mObjectSha = args.getString(EXTRA_SHA); + mCommitAuthor = args.getParcelable(EXTRA_COMMIT_AUTHOR); + mCommitter = args.getParcelable(EXTRA_COMMITTER); + mInitialComment = args.getParcelable(EXTRA_INITIAL_COMMENT); + args.remove(EXTRA_INITIAL_COMMENT); } @Override @@ -227,7 +235,7 @@ protected int getEmptyTextResId() { @Override protected Single> onCreateDataSingle(boolean bypassCache) { - List comments = getArguments().getParcelableArrayList("comments"); + List comments = getArguments().getParcelableArrayList(EXTRA_COMMENTS); if (comments != null && !comments.isEmpty()) { return Single.just(comments); } diff --git a/app/src/main/java/com/gh4a/fragment/ContentListContainerFragment.java b/app/src/main/java/com/gh4a/fragment/ContentListContainerFragment.java index 4db39befb..9ac0696fa 100644 --- a/app/src/main/java/com/gh4a/fragment/ContentListContainerFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ContentListContainerFragment.java @@ -54,6 +54,10 @@ public interface CommitSelectionCallback { private static final String STATE_KEY_DIR_STACK = "dir_stack"; private static final String STATE_KEY_CONTENT_CACHE_PREFIX = "content_cache_"; private static final String STATE_KEY_INITIAL_PATH = "initial_path"; + private static final String EXTRA_REPOSITORY = "repository"; + private static final String EXTRA_REF = "ref"; + private static final String EXTRA_INITIAL_PATH = "initialpath"; + private static final int LOADER_MODULEMAP = 100; private RxLoader mRxLoader; private PathBreadcrumbs mBreadcrumbs; @@ -81,9 +85,9 @@ public static ContentListContainerFragment newInstance(Repository repository, ContentListContainerFragment f = new ContentListContainerFragment(); Bundle args = new Bundle(); - args.putParcelable("repository", repository); - args.putString("ref", ref); - args.putString("initialpath", initialPath); + args.putParcelable(EXTRA_REPOSITORY, repository); + args.putString(EXTRA_REF, ref); + args.putString(EXTRA_INITIAL_PATH, initialPath); f.setArguments(args); return f; } @@ -93,8 +97,8 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRxLoader = new RxLoader(getActivity(), getLoaderManager()); - mRepository = getArguments().getParcelable("repository"); - mSelectedRef = getArguments().getString("ref"); + mRepository = getArguments().getParcelable(EXTRA_REPOSITORY); + mSelectedRef = getArguments().getString(EXTRA_REF); mStateSaved = false; if (savedInstanceState != null) { @@ -115,7 +119,7 @@ public void onCreate(Bundle savedInstanceState) { } else { mDirStack.push(""); - String initialPath = getArguments().getString("initialpath"); + String initialPath = getArguments().getString(EXTRA_INITIAL_PATH); if (initialPath != null) { mInitialPathToLoad = new ArrayList<>(); int pos = initialPath.indexOf("/"); @@ -152,7 +156,7 @@ public void onRefresh() { } public void setRef(String ref) { - getArguments().putString("ref", ref); + getArguments().putString(EXTRA_REF, ref); mSelectedRef = ref; mGitModuleMap = null; diff --git a/app/src/main/java/com/gh4a/fragment/ContentListFragment.java b/app/src/main/java/com/gh4a/fragment/ContentListFragment.java index 7ed2c47d4..0db8b0279 100644 --- a/app/src/main/java/com/gh4a/fragment/ContentListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ContentListFragment.java @@ -53,6 +53,10 @@ public class ContentListFragment extends ListDataBaseFragment implement RootAdapter.OnItemClickListener { private static final int MENU_HISTORY = Menu.FIRST + 1; private static final int REQUEST_FILE_HISTORY = 1000; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_PATH = "path"; + private static final String EXTRA_REF = "ref"; + private static final String EXTRA_CONTENTS = "contents"; private static final Comparator COMPARATOR = (lhs, rhs) -> { boolean lhsIsDir = lhs.type() == ContentType.Directory; @@ -89,10 +93,10 @@ public static ContentListFragment newInstance(Repository repository, ContentListFragment f = new ContentListFragment(); Bundle args = new Bundle(); - args.putString("path", path != null ? path : ""); - args.putString("ref", ref); - args.putParcelable("repo", repository); - args.putParcelableArrayList("contents", contents); + args.putString(EXTRA_PATH, path != null ? path : ""); + args.putString(EXTRA_REF, ref); + args.putParcelable(EXTRA_REPO, repository); + args.putParcelableArrayList(EXTRA_CONTENTS, contents); f.setArguments(args); return f; @@ -101,9 +105,9 @@ public static ContentListFragment newInstance(Repository repository, @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mRepository = getArguments().getParcelable("repo"); - mPath = getArguments().getString("path"); - mRef = getArguments().getString("ref"); + mRepository = getArguments().getParcelable(EXTRA_REPO); + mPath = getArguments().getString(EXTRA_PATH); + mRef = getArguments().getString(EXTRA_REF); if (StringUtils.isBlank(mRef)) { mRef = mRepository.defaultBranch(); } diff --git a/app/src/main/java/com/gh4a/fragment/ContributorListFragment.java b/app/src/main/java/com/gh4a/fragment/ContributorListFragment.java index 431789151..3e9a8237f 100644 --- a/app/src/main/java/com/gh4a/fragment/ContributorListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ContributorListFragment.java @@ -18,12 +18,15 @@ public class ContributorListFragment extends PagedDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + public static ContributorListFragment newInstance(String repoOwner, String repoName) { ContributorListFragment f = new ContributorListFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); f.setArguments(args); return f; @@ -31,8 +34,8 @@ public static ContributorListFragment newInstance(String repoOwner, String repoN @Override protected Single>> loadPage(int page, boolean bypassCache) { - String repoOwner = getArguments().getString("owner"); - String repoName = getArguments().getString("repo"); + String repoOwner = getArguments().getString(EXTRA_OWNER); + String repoName = getArguments().getString(EXTRA_REPO); RepositoryService service = ServiceFactory.get(RepositoryService.class, bypassCache); return service.getContributors(repoOwner, repoName, page); } diff --git a/app/src/main/java/com/gh4a/fragment/EventListFragment.java b/app/src/main/java/com/gh4a/fragment/EventListFragment.java index b78161341..24bd49da4 100644 --- a/app/src/main/java/com/gh4a/fragment/EventListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/EventListFragment.java @@ -86,8 +86,6 @@ public abstract class EventListFragment extends PagedDataBaseFragment { + private static final String EXTRA_USER = "user"; + private static final String EXTRA_SHOW_FOLLOWERS = "show_followers"; + public static FollowersFollowingListFragment newInstance(String login, boolean showFollowers) { FollowersFollowingListFragment f = new FollowersFollowingListFragment(); Bundle args = new Bundle(); - args.putString("user", login); - args.putBoolean("show_followers", showFollowers); + args.putString(EXTRA_USER, login); + args.putBoolean(EXTRA_SHOW_FOLLOWERS, showFollowers); f.setArguments(args); return f; @@ -49,8 +52,8 @@ public static FollowersFollowingListFragment newInstance(String login, boolean s @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mLogin = getArguments().getString("user"); - mShowFollowers = getArguments().getBoolean("show_followers"); + mLogin = getArguments().getString(EXTRA_USER); + mShowFollowers = getArguments().getBoolean(EXTRA_SHOW_FOLLOWERS); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/ForkListFragment.java b/app/src/main/java/com/gh4a/fragment/ForkListFragment.java index fb465076e..b359b74a1 100644 --- a/app/src/main/java/com/gh4a/fragment/ForkListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ForkListFragment.java @@ -31,6 +31,9 @@ import retrofit2.Response; public class ForkListFragment extends PagedDataBaseFragment { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private String mRepoOwner; private String mRepoName; @@ -38,8 +41,8 @@ public static ForkListFragment newInstance(String repoOwner, String repoName) { ForkListFragment f = new ForkListFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); f.setArguments(args); return f; @@ -48,8 +51,8 @@ public static ForkListFragment newInstance(String repoOwner, String repoName) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mRepoOwner = getArguments().getString("owner"); - mRepoName = getArguments().getString("repo"); + mRepoOwner = getArguments().getString(EXTRA_OWNER); + mRepoName = getArguments().getString(EXTRA_REPO); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/GistListFragment.java b/app/src/main/java/com/gh4a/fragment/GistListFragment.java index 36256f73f..04d5b149c 100644 --- a/app/src/main/java/com/gh4a/fragment/GistListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/GistListFragment.java @@ -17,10 +17,13 @@ public class GistListFragment extends PagedDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_USER = "user"; + private static final String EXTRA_STARRED = "starred"; + public static GistListFragment newInstance(String userLogin, boolean starred) { Bundle args = new Bundle(); - args.putString("user", userLogin); - args.putBoolean("starred", starred); + args.putString(EXTRA_USER, userLogin); + args.putBoolean(EXTRA_STARRED, starred); GistListFragment f = new GistListFragment(); f.setArguments(args); @@ -34,8 +37,8 @@ public static GistListFragment newInstance(String userLogin, boolean starred) { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mUserLogin = getArguments().getString("user"); - mShowStarred = getArguments().getBoolean("starred"); + mUserLogin = getArguments().getString(EXTRA_USER); + mShowStarred = getArguments().getBoolean(EXTRA_STARRED); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/IssueFragmentBase.java b/app/src/main/java/com/gh4a/fragment/IssueFragmentBase.java index 66e144b24..2d17377cf 100644 --- a/app/src/main/java/com/gh4a/fragment/IssueFragmentBase.java +++ b/app/src/main/java/com/gh4a/fragment/IssueFragmentBase.java @@ -74,6 +74,11 @@ public abstract class IssueFragmentBase extends ListDataBaseFragment INTERESTING_EVENTS = Arrays.asList( IssueEventType.Closed, IssueEventType.Reopened, IssueEventType.Merged, @@ -101,11 +106,11 @@ public abstract class IssueFragmentBase extends ListDataBaseFragment { private static final int REQUEST_ISSUE = 1000; + private static final String EXTRA_QUERY = "query"; + private static final String EXTRA_SORT_MODE = "sortmode"; + private static final String EXTRA_ORDER = "order"; + private static final String EXTRA_EMPTY_TEXT = "emptytext"; + private static final String EXTRA_STATE = "state"; + private static final String EXTRA_WITH_REPO = "withrepo"; private String mQuery; private String mSortMode; @@ -53,12 +59,12 @@ public static IssueListFragment newInstance(String query, String sortMode, Strin IssueListFragment f = new IssueListFragment(); Bundle args = new Bundle(); - args.putString("query", query); - args.putString("sortmode", sortMode); - args.putString("order", order); - args.putInt("emptytext", emptyTextResId); - args.putString("state", state); - args.putBoolean("withrepo", showRepository); + args.putString(EXTRA_QUERY, query); + args.putString(EXTRA_SORT_MODE, sortMode); + args.putString(EXTRA_ORDER, order); + args.putInt(EXTRA_EMPTY_TEXT, emptyTextResId); + args.putString(EXTRA_STATE, state); + args.putBoolean(EXTRA_WITH_REPO, showRepository); f.setArguments(args); return f; @@ -69,12 +75,12 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mQuery = args.getString("query"); - mSortMode = args.getString("sortmode"); - mOrder = args.getString("order"); - mEmptyTextResId = args.getInt("emptytext"); - mIssueState = args.getString("state"); - mShowRepository = args.getBoolean("withrepo"); + mQuery = args.getString(EXTRA_QUERY); + mSortMode = args.getString(EXTRA_SORT_MODE); + mOrder = args.getString(EXTRA_ORDER); + mEmptyTextResId = args.getInt(EXTRA_EMPTY_TEXT); + mIssueState = args.getString(EXTRA_STATE); + mShowRepository = args.getBoolean(EXTRA_WITH_REPO); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/IssueMilestoneListFragment.java b/app/src/main/java/com/gh4a/fragment/IssueMilestoneListFragment.java index a53f2bd77..0ef57facd 100644 --- a/app/src/main/java/com/gh4a/fragment/IssueMilestoneListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/IssueMilestoneListFragment.java @@ -37,6 +37,11 @@ public class IssueMilestoneListFragment extends ListDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_CLOSED = "closed"; + private static final String EXTRA_FROM_PR = "from_pr"; + private String mRepoOwner; private String mRepoName; private boolean mShowClosed; @@ -47,10 +52,10 @@ public static IssueMilestoneListFragment newInstance(String repoOwner, String re IssueMilestoneListFragment f = new IssueMilestoneListFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); - args.putBoolean("closed", showClosed); - args.putBoolean("from_pr", fromPullRequest); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); + args.putBoolean(EXTRA_CLOSED, showClosed); + args.putBoolean(EXTRA_FROM_PR, fromPullRequest); f.setArguments(args); return f; @@ -62,10 +67,10 @@ public static IssueMilestoneListFragment newInstance(String repoOwner, String re public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mRepoOwner = args.getString("owner"); - mRepoName = args.getString("repo"); - mShowClosed = args.getBoolean("closed"); - mFromPullRequest = args.getBoolean("from_pr", false); + mRepoOwner = args.getString(EXTRA_OWNER); + mRepoName = args.getString(EXTRA_REPO); + mShowClosed = args.getBoolean(EXTRA_CLOSED); + mFromPullRequest = args.getBoolean(EXTRA_FROM_PR, false); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/OrganizationMemberListFragment.java b/app/src/main/java/com/gh4a/fragment/OrganizationMemberListFragment.java index 3d67b3a06..ec1e2ad84 100644 --- a/app/src/main/java/com/gh4a/fragment/OrganizationMemberListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/OrganizationMemberListFragment.java @@ -17,17 +17,19 @@ public class OrganizationMemberListFragment extends PagedDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_ORG = "org"; + public static OrganizationMemberListFragment newInstance(String organization) { OrganizationMemberListFragment f = new OrganizationMemberListFragment(); Bundle args = new Bundle(); - args.putString("org", organization); + args.putString(EXTRA_ORG, organization); f.setArguments(args); return f; } @Override protected Single>> loadPage(int page, boolean bypassCache) { - String organization = getArguments().getString("org"); + String organization = getArguments().getString(EXTRA_ORG); final OrganizationMemberService service = ServiceFactory.get(OrganizationMemberService.class, bypassCache); return service.getMembers(organization, page); diff --git a/app/src/main/java/com/gh4a/fragment/PrivateEventListFragment.java b/app/src/main/java/com/gh4a/fragment/PrivateEventListFragment.java index 528135bab..8fca2770c 100644 --- a/app/src/main/java/com/gh4a/fragment/PrivateEventListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/PrivateEventListFragment.java @@ -11,14 +11,17 @@ import retrofit2.Response; public class PrivateEventListFragment extends EventListFragment { + private static final String EXTRA_LOGIN = "login"; + private static final String EXTRA_ORG = "org"; + private String mLogin; private String mOrganization; public static PrivateEventListFragment newInstance(String login, String organization) { PrivateEventListFragment f = new PrivateEventListFragment(); Bundle args = new Bundle(); - args.putString("login", login); - args.putString("org", organization); + args.putString(EXTRA_LOGIN, login); + args.putString(EXTRA_ORG, organization); f.setArguments(args); return f; } @@ -26,8 +29,8 @@ public static PrivateEventListFragment newInstance(String login, String organiza @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mLogin = getArguments().getString("login"); - mOrganization = getArguments().getString("org"); + mLogin = getArguments().getString(EXTRA_LOGIN); + mOrganization = getArguments().getString(EXTRA_ORG); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/PullRequestFilesFragment.java b/app/src/main/java/com/gh4a/fragment/PullRequestFilesFragment.java index 47b706f89..802090d53 100644 --- a/app/src/main/java/com/gh4a/fragment/PullRequestFilesFragment.java +++ b/app/src/main/java/com/gh4a/fragment/PullRequestFilesFragment.java @@ -21,23 +21,27 @@ import java.util.List; public class PullRequestFilesFragment extends CommitFragment { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_NUMBER = "number"; + private static final String EXTRA_HEAD = "head"; + private static final int REQUEST_DIFF_VIEWER = 1000; + private static final int ID_LOADER_FILES = 0; + private static final int ID_LOADER_COMMENTS = 1; + public static PullRequestFilesFragment newInstance(String repoOwner, String repoName, int pullRequestNumber, String headSha) { PullRequestFilesFragment f = new PullRequestFilesFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); - args.putInt("number", pullRequestNumber); - args.putString("head", headSha); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); + args.putInt(EXTRA_NUMBER, pullRequestNumber); + args.putString(EXTRA_HEAD, headSha); f.setArguments(args); return f; } - private static final int ID_LOADER_FILES = 0; - private static final int ID_LOADER_COMMENTS = 1; - private static final int REQUEST_DIFF_VIEWER = 1000; - public interface CommentUpdateListener { void onCommentsUpdated(); } @@ -53,10 +57,10 @@ public interface CommentUpdateListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); - mRepoOwner = args.getString("owner"); - mRepoName = args.getString("repo"); - mPullRequestNumber = args.getInt("number"); - mHeadSha = args.getString("head"); + mRepoOwner = args.getString(EXTRA_OWNER); + mRepoName = args.getString(EXTRA_REPO); + mPullRequestNumber = args.getInt(EXTRA_NUMBER); + mHeadSha = args.getString(EXTRA_HEAD); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java b/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java index 71559dd4f..1e1a7e3c6 100644 --- a/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java +++ b/app/src/main/java/com/gh4a/fragment/PullRequestFragment.java @@ -36,9 +36,8 @@ import com.gh4a.utils.IntentUtils; import com.gh4a.utils.Optional; import com.gh4a.utils.RxUtils; -import com.gh4a.widget.PullRequestBranchInfoView; import com.gh4a.widget.CommitStatusBox; - +import com.gh4a.widget.PullRequestBranchInfoView; import com.meisolsson.githubsdk.model.GitHubCommentBase; import com.meisolsson.githubsdk.model.GitHubFile; import com.meisolsson.githubsdk.model.Issue; @@ -78,6 +77,7 @@ public class PullRequestFragment extends IssueFragmentBase { private static final int ID_LOADER_STATUS = 1; private static final int ID_LOADER_HEAD_REF = 2; + private static final String EXTRA_PR = "pr"; private PullRequest mPullRequest; private GitReference mHeadReference; @@ -90,7 +90,7 @@ public static PullRequestFragment newInstance(PullRequest pr, Issue issue, Repository repo = pr.base().repo(); Bundle args = buildArgs(repo.owner().login(), repo.name(), issue, isCollaborator, initialComment); - args.putParcelable("pr", pr); + args.putParcelable(EXTRA_PR, pr); f.setArguments(args); return f; @@ -110,7 +110,7 @@ public void updateState(PullRequest pr) { @Override public void onCreate(Bundle savedInstanceState) { - mPullRequest = getArguments().getParcelable("pr"); + mPullRequest = getArguments().getParcelable(EXTRA_PR); super.onCreate(savedInstanceState); setHasOptionsMenu(true); } diff --git a/app/src/main/java/com/gh4a/fragment/ReleaseListFragment.java b/app/src/main/java/com/gh4a/fragment/ReleaseListFragment.java index b98838d29..7030ba4a3 100644 --- a/app/src/main/java/com/gh4a/fragment/ReleaseListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ReleaseListFragment.java @@ -18,14 +18,17 @@ public class ReleaseListFragment extends PagedDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private String mUserLogin; private String mRepoName; public static ReleaseListFragment newInstance(String owner, String repo) { ReleaseListFragment f = new ReleaseListFragment(); Bundle args = new Bundle(); - args.putString("owner", owner); - args.putString("repo", repo); + args.putString(EXTRA_OWNER, owner); + args.putString(EXTRA_REPO, repo); f.setArguments(args); return f; } @@ -33,8 +36,8 @@ public static ReleaseListFragment newInstance(String owner, String repo) { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mUserLogin = getArguments().getString("owner"); - mRepoName = getArguments().getString("repo"); + mUserLogin = getArguments().getString(EXTRA_OWNER); + mRepoName = getArguments().getString(EXTRA_REPO); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/RepositoryEventListFragment.java b/app/src/main/java/com/gh4a/fragment/RepositoryEventListFragment.java index f8a30437a..656922d31 100644 --- a/app/src/main/java/com/gh4a/fragment/RepositoryEventListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/RepositoryEventListFragment.java @@ -12,12 +12,14 @@ import retrofit2.Response; public class RepositoryEventListFragment extends EventListFragment { + private static final String EXTRA_REPOSITORY = "repository"; + private Repository mRepository; public static RepositoryEventListFragment newInstance(Repository repository) { RepositoryEventListFragment f = new RepositoryEventListFragment(); Bundle args = new Bundle(); - args.putParcelable("repository", repository); + args.putParcelable(EXTRA_REPOSITORY, repository); f.setArguments(args); return f; } @@ -25,7 +27,7 @@ public static RepositoryEventListFragment newInstance(Repository repository) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mRepository = getArguments().getParcelable("repository"); + mRepository = getArguments().getParcelable(EXTRA_REPOSITORY); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/RepositoryFragment.java b/app/src/main/java/com/gh4a/fragment/RepositoryFragment.java index 99ec9556e..7353bfec9 100644 --- a/app/src/main/java/com/gh4a/fragment/RepositoryFragment.java +++ b/app/src/main/java/com/gh4a/fragment/RepositoryFragment.java @@ -57,12 +57,15 @@ import java.util.Locale; public class RepositoryFragment extends LoadingFragmentBase implements OnClickListener { + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_REF = "ref"; + public static RepositoryFragment newInstance(Repository repository, String ref) { RepositoryFragment f = new RepositoryFragment(); Bundle args = new Bundle(); - args.putParcelable("repo", repository); - args.putString("ref", ref); + args.putParcelable(EXTRA_REPO, repository); + args.putString(EXTRA_REF, ref); f.setArguments(args); return f; @@ -87,8 +90,8 @@ public static RepositoryFragment newInstance(Repository repository, String ref) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mRepository = getArguments().getParcelable("repo"); - mRef = getArguments().getString("ref"); + mRepository = getArguments().getParcelable(EXTRA_REPO); + mRef = getArguments().getString(EXTRA_REF); } @Override @@ -168,7 +171,7 @@ public void onSaveInstanceState(Bundle outState) { public void setRef(String ref) { mRef = ref; - getArguments().putString("ref", ref); + getArguments().putString(EXTRA_REF, ref); // Reload readme if (mIsReadmeLoaded) { diff --git a/app/src/main/java/com/gh4a/fragment/RepositoryListContainerFragment.java b/app/src/main/java/com/gh4a/fragment/RepositoryListContainerFragment.java index b71cbdbfe..972fb2d8b 100644 --- a/app/src/main/java/com/gh4a/fragment/RepositoryListContainerFragment.java +++ b/app/src/main/java/com/gh4a/fragment/RepositoryListContainerFragment.java @@ -26,6 +26,33 @@ public class RepositoryListContainerFragment extends Fragment implements BaseActivity.RefreshableChild, SearchView.OnCloseListener, SearchView.OnQueryTextListener, MenuItem.OnActionExpandListener, SwipeRefreshLayout.ChildScrollDelegate { + private static final String EXTRA_USER = "user"; + private static final String EXTRA_IS_ORG = "is_org"; + private static final String EXTRA_FILTER_TYPE = "filter_type"; + private static final String STATE_KEY_FILTER_TYPE = "filter_type"; + private static final String STATE_KEY_SORT_ORDER = "sort_order"; + private static final String STATE_KEY_SORT_DIRECTION = "sort_direction"; + private static final String STATE_KEY_SEARCH_VISIBLE = "search_visible"; + private static final String STATE_KEY_QUERY = "search_query"; + private static final String STATE_KEY_SEARCH_IS_EXPANDED = "search_is_expanded"; + private static final String SORT_DIRECTION_ASC = "asc"; + private static final String SORT_DIRECTION_DESC = "desc"; + private static final String SORT_ORDER_FULL_NAME = "full_name"; + private static final String SORT_ORDER_UPDATED = "updated"; + private static final String SORT_ORDER_CREATED = "created"; + private static final String SORT_ORDER_PUSHED = "pushed"; + private static final String TAG_MAIN = "main"; + private static final String TAG_SEARCH = "search"; + private static final String FILTER_TYPE_ALL = "all"; + private static final String FILTER_TYPE_OWNER = "owner"; + private static final String FILTER_TYPE_MEMBER = "member"; + private static final String FILTER_TYPE_PUBLIC = "public"; + private static final String FILTER_TYPE_PRIVATE = "private"; + private static final String FILTER_TYPE_SOURCES = "sources"; + private static final String FILTER_TYPE_FORKS = "forks"; + private static final String FILTER_TYPE_WATCHED = "watched"; + public static final String FILTER_TYPE_STARRED = "starred"; + public static RepositoryListContainerFragment newInstance(String userLogin, boolean isOrg) { return newInstance(userLogin, isOrg, null); } @@ -35,21 +62,19 @@ public static RepositoryListContainerFragment newInstance(String userLogin, bool RepositoryListContainerFragment f = new RepositoryListContainerFragment(); Bundle args = new Bundle(); - args.putString("user", userLogin); - args.putBoolean("is_org", isOrg); - args.putString("filter_type", defaultFilter); + args.putString(EXTRA_USER, userLogin); + args.putBoolean(EXTRA_IS_ORG, isOrg); + args.putString(EXTRA_FILTER_TYPE, defaultFilter); f.setArguments(args); return f; } - public static final String FILTER_TYPE_STARRED = "starred"; - private String mUserLogin; private boolean mIsOrg; private String mFilterType; - private String mSortOrder = "full_name"; - private String mSortDirection = "asc"; + private String mSortOrder = SORT_ORDER_FULL_NAME; + private String mSortDirection = SORT_DIRECTION_ASC; private boolean mSearchVisible; private PagedDataBaseFragment mMainFragment; @@ -62,22 +87,15 @@ public interface Callback { void initiateFilter(); } - private static final String STATE_KEY_FILTER_TYPE = "filter_type"; - private static final String STATE_KEY_SORT_ORDER = "sort_order"; - private static final String STATE_KEY_SORT_DIRECTION = "sort_direction"; - private static final String STATE_KEY_SEARCH_VISIBLE = "search_visible"; - private static final String STATE_KEY_QUERY = "search_query"; - private static final String STATE_KEY_SEARCH_IS_EXPANDED = "search_is_expanded"; - @Override public void onCreate(Bundle savedInstanceState) { Bundle data = getArguments(); - mUserLogin = data.getString("user"); - mIsOrg = data.getBoolean("is_org"); + mUserLogin = data.getString(EXTRA_USER); + mIsOrg = data.getBoolean(EXTRA_IS_ORG); // Only read filter type from arguments if it wasn't overridden already by our parent if (mFilterType == null) { - mFilterType = data.getString("filter_type", "all"); + mFilterType = data.getString(EXTRA_FILTER_TYPE, FILTER_TYPE_ALL); } if (savedInstanceState != null && savedInstanceState.containsKey(STATE_KEY_FILTER_TYPE)) { @@ -117,8 +135,8 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); FragmentManager fm = getChildFragmentManager(); - mMainFragment = (PagedDataBaseFragment) fm.findFragmentByTag("main"); - mSearchFragment = (RepositorySearchFragment) fm.findFragmentByTag("search"); + mMainFragment = (PagedDataBaseFragment) fm.findFragmentByTag(TAG_MAIN); + mSearchFragment = (RepositorySearchFragment) fm.findFragmentByTag(TAG_SEARCH); if (mMainFragment == null) { applyFilterTypeAndSortOrder(); @@ -165,18 +183,18 @@ public void setSortOrder(String sortOrder, String direction) { } private void validateSortOrder() { - if (TextUtils.equals(mFilterType, "starred")) { - if (!TextUtils.equals(mSortOrder, "updated") - && !TextUtils.equals(mSortOrder, "created")) { - mSortOrder = "created"; - mSortDirection = "desc"; + if (TextUtils.equals(mFilterType, FILTER_TYPE_STARRED)) { + if (!TextUtils.equals(mSortOrder, SORT_ORDER_UPDATED) + && !TextUtils.equals(mSortOrder, SORT_ORDER_CREATED)) { + mSortOrder = SORT_ORDER_CREATED; + mSortDirection = SORT_DIRECTION_DESC; } } else { - if (!TextUtils.equals(mSortOrder, "full_name") - && !TextUtils.equals(mSortOrder, "created") - && !TextUtils.equals(mSortOrder, "pushed")) { - mSortOrder = "full_name"; - mSortDirection = "asc"; + if (!TextUtils.equals(mSortOrder, SORT_ORDER_FULL_NAME) + && !TextUtils.equals(mSortOrder, SORT_ORDER_CREATED) + && !TextUtils.equals(mSortOrder, SORT_ORDER_PUSHED)) { + mSortOrder = SORT_ORDER_FULL_NAME; + mSortDirection = SORT_DIRECTION_ASC; } } } @@ -188,7 +206,7 @@ private void applyFilterTypeAndSortOrder() { } switch (mFilterType) { - case "watched": + case FILTER_TYPE_WATCHED: mMainFragment = WatchedRepositoryListFragment.newInstance(mUserLogin); break; default: @@ -199,12 +217,12 @@ private void applyFilterTypeAndSortOrder() { FragmentManager fm = getChildFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); - Fragment old = fm.findFragmentByTag("main"); + Fragment old = fm.findFragmentByTag(TAG_MAIN); if (old != null) { ft.remove(old); } - ft.add(R.id.details, mMainFragment, "main"); + ft.add(R.id.details, mMainFragment, TAG_MAIN); ft.commitAllowingStateLoss(); } @@ -226,7 +244,7 @@ private void addSearchFragment() { mSearchFragment = RepositorySearchFragment.newInstance(mUserLogin); mSearchFragment.setUserVisibleHint(false); - ft.add(R.id.details, mSearchFragment, "search"); + ft.add(R.id.details, mSearchFragment, TAG_SEARCH); ft.hide(mSearchFragment); ft.commit(); } @@ -236,7 +254,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { getActivity().getMenuInflater().inflate(R.menu.repo_list_menu, menu); // We can only properly search the 'all repos' list - if ("all".equals(mFilterType)) { + if (FILTER_TYPE_ALL.equals(mFilterType)) { MenuItem searchItem = menu.findItem(R.id.search); searchItem.setOnActionExpandListener(this); @@ -274,8 +292,8 @@ public boolean onOptionsItemSelected(MenuItem item) { } private void setSearchVisibility(boolean visible) { - String hiddenTag = visible ? "main" : "search"; - String visibleTag = visible ? "search" : "main"; + String hiddenTag = visible ? TAG_MAIN : TAG_SEARCH; + String visibleTag = visible ? TAG_SEARCH : TAG_MAIN; FragmentManager fm = getChildFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); @@ -352,14 +370,14 @@ public static class FilterDrawerHelper { private static final SparseArray FILTER_LOOKUP = new SparseArray<>(); static { - FILTER_LOOKUP.put(R.id.filter_type_all, "all"); - FILTER_LOOKUP.put(R.id.filter_type_owner, "owner"); - FILTER_LOOKUP.put(R.id.filter_type_member, "member"); - FILTER_LOOKUP.put(R.id.filter_type_public, "public"); - FILTER_LOOKUP.put(R.id.filter_type_private, "private"); - FILTER_LOOKUP.put(R.id.filter_type_sources, "sources"); - FILTER_LOOKUP.put(R.id.filter_type_forks, "forks"); - FILTER_LOOKUP.put(R.id.filter_type_watched, "watched"); + FILTER_LOOKUP.put(R.id.filter_type_all, FILTER_TYPE_ALL); + FILTER_LOOKUP.put(R.id.filter_type_owner, FILTER_TYPE_OWNER); + FILTER_LOOKUP.put(R.id.filter_type_member, FILTER_TYPE_MEMBER); + FILTER_LOOKUP.put(R.id.filter_type_public, FILTER_TYPE_PUBLIC); + FILTER_LOOKUP.put(R.id.filter_type_private, FILTER_TYPE_PRIVATE); + FILTER_LOOKUP.put(R.id.filter_type_sources, FILTER_TYPE_SOURCES); + FILTER_LOOKUP.put(R.id.filter_type_forks, FILTER_TYPE_FORKS); + FILTER_LOOKUP.put(R.id.filter_type_watched, FILTER_TYPE_WATCHED); } public static FilterDrawerHelper create(String userLogin, boolean isOrg) { @@ -400,18 +418,18 @@ public String handleSelectionAndGetFilterType(MenuItem item) { } public static class SortDrawerHelper { - private String mFilterType = "all"; + private String mFilterType = FILTER_TYPE_ALL; private static final SparseArray SORT_LOOKUP = new SparseArray<>(); static { - SORT_LOOKUP.put(R.id.sort_name_asc, new String[] { "full_name", "asc" }); - SORT_LOOKUP.put(R.id.sort_name_desc, new String[] { "full_name", "desc" }); - SORT_LOOKUP.put(R.id.sort_created_asc, new String[] { "created", "asc" }); - SORT_LOOKUP.put(R.id.sort_created_desc, new String[] { "created", "desc" }); - SORT_LOOKUP.put(R.id.sort_pushed_asc, new String[] { "pushed", "asc" }); - SORT_LOOKUP.put(R.id.sort_pushed_desc, new String[] { "pushed", "desc" }); - SORT_LOOKUP.put(R.id.sort_updated_asc, new String[] { "updated", "asc" }); - SORT_LOOKUP.put(R.id.sort_updated_desc, new String[] { "updated", "desc" }); + SORT_LOOKUP.put(R.id.sort_name_asc, new String[] { SORT_ORDER_FULL_NAME, SORT_DIRECTION_ASC }); + SORT_LOOKUP.put(R.id.sort_name_desc, new String[] { SORT_ORDER_FULL_NAME, SORT_DIRECTION_DESC }); + SORT_LOOKUP.put(R.id.sort_created_asc, new String[] { SORT_ORDER_CREATED, SORT_DIRECTION_ASC }); + SORT_LOOKUP.put(R.id.sort_created_desc, new String[] { SORT_ORDER_CREATED, SORT_DIRECTION_DESC }); + SORT_LOOKUP.put(R.id.sort_pushed_asc, new String[] { SORT_ORDER_PUSHED, SORT_DIRECTION_ASC }); + SORT_LOOKUP.put(R.id.sort_pushed_desc, new String[] { SORT_ORDER_PUSHED, SORT_DIRECTION_DESC }); + SORT_LOOKUP.put(R.id.sort_updated_asc, new String[] { SORT_ORDER_UPDATED, SORT_DIRECTION_ASC }); + SORT_LOOKUP.put(R.id.sort_updated_desc, new String[] { SORT_ORDER_UPDATED, SORT_DIRECTION_DESC }); } public SortDrawerHelper() { @@ -422,7 +440,7 @@ public void setFilterType(String type) { } public int getMenuResId() { - return TextUtils.equals(mFilterType, "watched") ? 0 : R.menu.repo_sort; + return TextUtils.equals(mFilterType, FILTER_TYPE_WATCHED) ? 0 : R.menu.repo_sort; } public void selectSortType(Menu menu, String order, String direction, diff --git a/app/src/main/java/com/gh4a/fragment/RepositoryListFragment.java b/app/src/main/java/com/gh4a/fragment/RepositoryListFragment.java index cc709815c..b901e7e80 100644 --- a/app/src/main/java/com/gh4a/fragment/RepositoryListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/RepositoryListFragment.java @@ -38,33 +38,47 @@ import retrofit2.Response; public class RepositoryListFragment extends PagedDataBaseFragment { - private String mLogin; - private String mRepoType; - private final Map mFilterData = new HashMap<>(); + private static final String EXTRA_USER = "user"; + private static final String EXTRA_IS_ORG = "is_org"; + private static final String EXTRA_REPO_TYPE = "repo_type"; + private static final String EXTRA_SORT_ORDER = "sort_order"; + private static final String EXTRA_SORT_DIRECTION = "sort_direction"; + private static final String REPO_TYPE_SOURCES = "sources"; + private static final String REPO_TYPE_FORKS = "forks"; + private static final String REPO_TYPE_ALL = "all"; + private static final String FILTER_DATA_AFFILIATION = "affiliation"; + private static final String FILTER_DATA_TYPE = "type"; + private static final String FILTER_DATA_SORT = "sort"; + private static final String FILTER_DATA_DIRECTION = "direction"; public static RepositoryListFragment newInstance(String login, boolean isOrg, String repoType, String sortOrder, String sortDirection) { RepositoryListFragment f = new RepositoryListFragment(); Bundle args = new Bundle(); - args.putString("user", login); - args.putBoolean("is_org", isOrg); - args.putString("repo_type", repoType); - args.putString("sort_order", sortOrder); - args.putString("sort_direction", sortDirection); + args.putString(EXTRA_USER, login); + args.putBoolean(EXTRA_IS_ORG, isOrg); + args.putString(EXTRA_REPO_TYPE, repoType); + args.putString(EXTRA_SORT_ORDER, sortOrder); + args.putString(EXTRA_SORT_DIRECTION, sortDirection); f.setArguments(args); return f; } + private final Map mFilterData = new HashMap<>(); + + private String mLogin; + private String mRepoType; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); - mLogin = args.getString("user"); - mRepoType = args.getString("repo_type"); + mLogin = args.getString(EXTRA_USER); + mRepoType = args.getString(EXTRA_REPO_TYPE); final boolean isSelf = ApiHelpers.loginEquals(mLogin, Gh4Application.get().getAuthLogin()); @@ -79,19 +93,19 @@ public void onCreate(Bundle savedInstanceState) { // Additionally, using affiliation together with type is not supported, so omit // type when adding affiliation. - String actualFilterType = "sources".equals(mRepoType) || "forks".equals(mRepoType) - ? "all" : mRepoType; + String actualFilterType = REPO_TYPE_SOURCES.equals(mRepoType) || REPO_TYPE_FORKS.equals(mRepoType) + ? REPO_TYPE_ALL : mRepoType; - if (isSelf && TextUtils.equals(actualFilterType, "all")) { - mFilterData.put("affiliation", "owner,collaborator"); - } else if (!TextUtils.equals(actualFilterType, "all") || !args.getBoolean("is_org")) { - mFilterData.put("type", actualFilterType); + if (isSelf && TextUtils.equals(actualFilterType, REPO_TYPE_ALL)) { + mFilterData.put(FILTER_DATA_AFFILIATION, "owner,collaborator"); + } else if (!TextUtils.equals(actualFilterType, REPO_TYPE_ALL) || !args.getBoolean(EXTRA_IS_ORG)) { + mFilterData.put(FILTER_DATA_TYPE, actualFilterType); } - final String sortOrder = args.getString("sort_order"); + final String sortOrder = args.getString(EXTRA_SORT_ORDER); if (sortOrder != null) { - mFilterData.put("sort", sortOrder); - mFilterData.put("direction", args.getString("sort_direction")); + mFilterData.put(FILTER_DATA_SORT, sortOrder); + mFilterData.put(FILTER_DATA_DIRECTION, args.getString(EXTRA_SORT_DIRECTION)); } } @@ -108,11 +122,11 @@ protected int getEmptyTextResId() { @Override protected void onAddData(RootAdapter adapter, Collection repositories) { - if ("sources".equals(mRepoType) || "forks".equals(mRepoType)) { + if (REPO_TYPE_SOURCES.equals(mRepoType) || REPO_TYPE_FORKS.equals(mRepoType)) { for (Repository repository : repositories) { - if ("sources".equals(mRepoType) && !repository.isFork()) { + if (REPO_TYPE_SOURCES.equals(mRepoType) && !repository.isFork()) { adapter.add(repository); - } else if ("forks".equals(mRepoType) && repository.isFork()) { + } else if (REPO_TYPE_FORKS.equals(mRepoType) && repository.isFork()) { adapter.add(repository); } } diff --git a/app/src/main/java/com/gh4a/fragment/RepositorySearchFragment.java b/app/src/main/java/com/gh4a/fragment/RepositorySearchFragment.java index 285b0c6f7..a64d4832c 100644 --- a/app/src/main/java/com/gh4a/fragment/RepositorySearchFragment.java +++ b/app/src/main/java/com/gh4a/fragment/RepositorySearchFragment.java @@ -22,18 +22,21 @@ import retrofit2.Response; public class RepositorySearchFragment extends PagedDataBaseFragment { + private static final String EXTRA_USER = "user"; + private static final String EXTRA_QUERY = "query"; + public static RepositorySearchFragment newInstance(String userLogin) { RepositorySearchFragment f = new RepositorySearchFragment(); Bundle args = new Bundle(); - args.putString("user", userLogin); + args.putString(EXTRA_USER, userLogin); f.setArguments(args); return f; } public void setQuery(String query) { - getArguments().putString("query", query); + getArguments().putString(EXTRA_QUERY, query); if (isAdded()) { onRefresh(); } @@ -41,8 +44,8 @@ public void setQuery(String query) { @Override protected Single>> loadPage(int page, boolean bypassCache) { - String login = getArguments().getString("user"); - String query = getArguments().getString("query"); + String login = getArguments().getString(EXTRA_USER); + String query = getArguments().getString(EXTRA_QUERY); if (TextUtils.isEmpty(query)) { return Single.just(Response.success(new ApiHelpers.DummyPage<>())); diff --git a/app/src/main/java/com/gh4a/fragment/ReviewFragment.java b/app/src/main/java/com/gh4a/fragment/ReviewFragment.java index 2b3f4c534..df9b38084 100644 --- a/app/src/main/java/com/gh4a/fragment/ReviewFragment.java +++ b/app/src/main/java/com/gh4a/fragment/ReviewFragment.java @@ -25,7 +25,6 @@ import com.gh4a.utils.Optional; import com.gh4a.utils.RxUtils; import com.gh4a.widget.EditorBottomSheet; - import com.meisolsson.githubsdk.model.GitHubCommentBase; import com.meisolsson.githubsdk.model.GitHubFile; import com.meisolsson.githubsdk.model.Reaction; @@ -33,11 +32,11 @@ import com.meisolsson.githubsdk.model.ReviewComment; import com.meisolsson.githubsdk.model.request.ReactionRequest; import com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment; +import com.meisolsson.githubsdk.service.issues.IssueCommentService; +import com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService; import com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService; import com.meisolsson.githubsdk.service.pull_request.PullRequestService; import com.meisolsson.githubsdk.service.reactions.ReactionService; -import com.meisolsson.githubsdk.service.issues.IssueCommentService; -import com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService; import java.util.ArrayList; import java.util.Collections; @@ -48,25 +47,25 @@ import retrofit2.Response; public class ReviewFragment extends ListDataBaseFragment - implements TimelineItemAdapter.OnCommentAction, + implements TimelineItemAdapter.OnCommentAction , EditorBottomSheet.Callback, EditorBottomSheet.Listener { private static final int REQUEST_EDIT = 1000; private static final String EXTRA_SELECTED_REPLY_COMMENT_ID = "selected_reply_comment_id"; - - @Nullable - private TimelineItemAdapter mAdapter; - private EditorBottomSheet mBottomSheet; + private static final String EXTRA_REPO_OWNER = "repo_owner"; + private static final String EXTRA_REPO_NAME = "repo_name"; + private static final String EXTRA_ISSUE_NUMBER = "issue_number"; + private static final String EXTRA_INITIAL_COMMENT = "initial_comment"; public static ReviewFragment newInstance(String repoOwner, String repoName, int issueNumber, Review review, IntentUtils.InitialCommentMarker mInitialComment) { ReviewFragment f = new ReviewFragment(); Bundle args = new Bundle(); - args.putString("repo_owner", repoOwner); - args.putString("repo_name", repoName); - args.putInt("issue_number", issueNumber); - args.putParcelable("review", review); - args.putParcelable("initial_comment", mInitialComment); + args.putString(EXTRA_REPO_OWNER, repoOwner); + args.putString(EXTRA_REPO_NAME, repoName); + args.putInt(EXTRA_ISSUE_NUMBER, issueNumber); + args.putParcelable(EXTRA_REPO_NAME, review); + args.putParcelable(EXTRA_INITIAL_COMMENT, mInitialComment); f.setArguments(args); return f; } @@ -77,18 +76,22 @@ public static ReviewFragment newInstance(String repoOwner, String repoName, int private Review mReview; private IntentUtils.InitialCommentMarker mInitialComment; private long mSelectedReplyCommentId; - private @StringRes int mCommentEditorHintResId = R.string.review_reply_hint; + @StringRes + private int mCommentEditorHintResId = R.string.review_reply_hint; + @Nullable + private TimelineItemAdapter mAdapter; + private EditorBottomSheet mBottomSheet; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mRepoOwner = args.getString("repo_owner"); - mRepoName = args.getString("repo_name"); - mIssueNumber = args.getInt("issue_number"); - mReview = args.getParcelable("review"); - mInitialComment = args.getParcelable("initial_comment"); - args.remove("initial_comment"); + mRepoOwner = args.getString(EXTRA_REPO_OWNER); + mRepoName = args.getString(EXTRA_REPO_NAME); + mIssueNumber = args.getInt(EXTRA_ISSUE_NUMBER); + mReview = args.getParcelable(EXTRA_REPO_NAME); + mInitialComment = args.getParcelable(EXTRA_INITIAL_COMMENT); + args.remove(EXTRA_INITIAL_COMMENT); if (savedInstanceState != null) { mSelectedReplyCommentId = savedInstanceState.getLong(EXTRA_SELECTED_REPLY_COMMENT_ID); diff --git a/app/src/main/java/com/gh4a/fragment/SearchFragment.java b/app/src/main/java/com/gh4a/fragment/SearchFragment.java index f4664ea9e..df6e17b2e 100644 --- a/app/src/main/java/com/gh4a/fragment/SearchFragment.java +++ b/app/src/main/java/com/gh4a/fragment/SearchFragment.java @@ -54,15 +54,8 @@ public class SearchFragment extends PagedDataBaseFragment implements SearchView.OnQueryTextListener, SearchView.OnCloseListener, SearchView.OnSuggestionListener, FilterQueryProvider, AdapterView.OnItemSelectedListener, SearchAdapter.Callback { - public static SearchFragment newInstance(int initialType, String initialQuery) { - SearchFragment f = new SearchFragment(); - Bundle args = new Bundle(); - args.putInt("search_type", initialType); - args.putString("initial_search", initialQuery); - f.setArguments(args); - return f; - } - + private static final String EXTRA_SEARCH_TYPE = "search_type"; + private static final String EXTRA_INITIAL_SEARCH = "initial_search"; public static final int SEARCH_TYPE_REPO = 0; public static final int SEARCH_TYPE_USER = 1; public static final int SEARCH_TYPE_CODE = 2; @@ -84,6 +77,15 @@ public static SearchFragment newInstance(int initialType, String initialQuery) { private static final String STATE_KEY_QUERY = "query"; private static final String STATE_KEY_SEARCH_TYPE = "search_type"; + public static SearchFragment newInstance(int initialType, String initialQuery) { + SearchFragment f = new SearchFragment(); + Bundle args = new Bundle(); + args.putInt(EXTRA_SEARCH_TYPE, initialType); + args.putString(EXTRA_INITIAL_SEARCH, initialQuery); + f.setArguments(args); + return f; + } + private SearchAdapter mAdapter; private Spinner mSearchType; @@ -100,8 +102,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { mSelectedSearchType = savedInstanceState.getInt(STATE_KEY_SEARCH_TYPE, SEARCH_TYPE_REPO); } else { Bundle args = getArguments(); - mSelectedSearchType = args.getInt("search_type", SEARCH_TYPE_REPO); - mQuery = args.getString("initial_search"); + mSelectedSearchType = args.getInt(EXTRA_SEARCH_TYPE, SEARCH_TYPE_REPO); + mQuery = args.getString(EXTRA_INITIAL_SEARCH); } } diff --git a/app/src/main/java/com/gh4a/fragment/StargazerListFragment.java b/app/src/main/java/com/gh4a/fragment/StargazerListFragment.java index e5c8a3cf1..06c5fc1d3 100644 --- a/app/src/main/java/com/gh4a/fragment/StargazerListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/StargazerListFragment.java @@ -32,12 +32,15 @@ import retrofit2.Response; public class StargazerListFragment extends PagedDataBaseFragment { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + public static StargazerListFragment newInstance(String repoOwner, String repoName) { StargazerListFragment f = new StargazerListFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); f.setArguments(args); return f; @@ -49,8 +52,8 @@ public static StargazerListFragment newInstance(String repoOwner, String repoNam @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mRepoOwner = getArguments().getString("owner"); - mRepoName = getArguments().getString("repo"); + mRepoOwner = getArguments().getString(EXTRA_OWNER); + mRepoName = getArguments().getString(EXTRA_REPO); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/StarredRepositoryListFragment.java b/app/src/main/java/com/gh4a/fragment/StarredRepositoryListFragment.java index 523bb2c7c..05d699f7a 100644 --- a/app/src/main/java/com/gh4a/fragment/StarredRepositoryListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/StarredRepositoryListFragment.java @@ -38,12 +38,15 @@ public class StarredRepositoryListFragment extends PagedDataBaseFragment { private static final String STATE_KEY_SORT_ORDER = "sort_order"; private static final String STATE_KEY_SORT_DIRECTION = "sort_direction"; + private static final String EXTRA_USER = "user"; + private static final String FILTER_DATA_SORT = "sort"; + private static final String FILTER_DATA_DIRECTION = "direction"; public static StarredRepositoryListFragment newInstance(String login) { StarredRepositoryListFragment f = new StarredRepositoryListFragment(); Bundle args = new Bundle(); - args.putString("user", login); + args.putString(EXTRA_USER, login); f.setArguments(args); return f; @@ -57,7 +60,7 @@ public static StarredRepositoryListFragment newInstance(String login) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mLogin = getArguments().getString("user"); + mLogin = getArguments().getString(EXTRA_USER); mSortHelper = new RepositoryListContainerFragment.SortDrawerHelper(); @@ -114,8 +117,8 @@ public void onItemClick(Repository repository) { protected Single>> loadPage(int page, boolean bypassCache) { final StarringService service = ServiceFactory.get(StarringService.class, bypassCache); final HashMap filterData = new HashMap<>(); - filterData.put("sort", mSortOrder); - filterData.put("direction", mSortDirection); + filterData.put(FILTER_DATA_SORT, mSortOrder); + filterData.put(FILTER_DATA_DIRECTION, mSortDirection); return service.getStarredRepositories(mLogin, filterData, page); } diff --git a/app/src/main/java/com/gh4a/fragment/TrendingFragment.java b/app/src/main/java/com/gh4a/fragment/TrendingFragment.java index 93767e42a..df9a83174 100644 --- a/app/src/main/java/com/gh4a/fragment/TrendingFragment.java +++ b/app/src/main/java/com/gh4a/fragment/TrendingFragment.java @@ -32,6 +32,8 @@ public class TrendingFragment extends ListDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_TYPE = "type"; + private static final String EXTRA_STARS_TEMPLATE = "stars_template"; public static final String TYPE_DAILY = "daily"; public static final String TYPE_WEEKLY = "weekly"; public static final String TYPE_MONTHLY = "monthly"; @@ -46,11 +48,11 @@ public static TrendingFragment newInstance(String type) { TrendingFragment f = new TrendingFragment(); Bundle args = new Bundle(); - args.putString("type", type); + args.putString(EXTRA_TYPE, type); switch (type) { - case TYPE_DAILY: args.putInt("stars_template", R.string.trend_stars_today); break; - case TYPE_WEEKLY: args.putInt("stars_template", R.string.trend_stars_week); break; - case TYPE_MONTHLY: args.putInt("stars_template", R.string.trend_stars_month); break; + case TYPE_DAILY: args.putInt(EXTRA_STARS_TEMPLATE, R.string.trend_stars_today); break; + case TYPE_WEEKLY: args.putInt(EXTRA_STARS_TEMPLATE, R.string.trend_stars_week); break; + case TYPE_MONTHLY: args.putInt(EXTRA_STARS_TEMPLATE, R.string.trend_stars_month); break; default: throw new IllegalArgumentException(); } f.setArguments(args); @@ -61,8 +63,8 @@ public static TrendingFragment newInstance(String type) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mType = getArguments().getString("type"); - mStarsTemplate = getArguments().getInt("stars_template", 0); + mType = getArguments().getString(EXTRA_TYPE); + mStarsTemplate = getArguments().getInt(EXTRA_STARS_TEMPLATE, 0); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/UserFragment.java b/app/src/main/java/com/gh4a/fragment/UserFragment.java index 0e9481330..500ca14ca 100644 --- a/app/src/main/java/com/gh4a/fragment/UserFragment.java +++ b/app/src/main/java/com/gh4a/fragment/UserFragment.java @@ -61,11 +61,13 @@ import retrofit2.Response; public class UserFragment extends LoadingFragmentBase implements View.OnClickListener { + public static final String EXTRA_LOGIN = "login"; + public static UserFragment newInstance(String login) { UserFragment f = new UserFragment(); Bundle args = new Bundle(); - args.putString("login", login); + args.putString(EXTRA_LOGIN, login); f.setArguments(args); return f; @@ -89,7 +91,7 @@ public static UserFragment newInstance(String login) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mUserLogin = getArguments().getString("login"); + mUserLogin = getArguments().getString(EXTRA_LOGIN); mIsSelf = ApiHelpers.loginEquals(mUserLogin, Gh4Application.get().getAuthLogin()); setHasOptionsMenu(true); } diff --git a/app/src/main/java/com/gh4a/fragment/WatchedRepositoryListFragment.java b/app/src/main/java/com/gh4a/fragment/WatchedRepositoryListFragment.java index 3091e76f9..1bb54792e 100644 --- a/app/src/main/java/com/gh4a/fragment/WatchedRepositoryListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/WatchedRepositoryListFragment.java @@ -31,11 +31,13 @@ import retrofit2.Response; public class WatchedRepositoryListFragment extends PagedDataBaseFragment { + private static final String EXTRA_USER = "user"; + public static WatchedRepositoryListFragment newInstance(String login) { WatchedRepositoryListFragment f = new WatchedRepositoryListFragment(); Bundle args = new Bundle(); - args.putString("user", login); + args.putString(EXTRA_USER, login); f.setArguments(args); return f; @@ -46,7 +48,7 @@ public static WatchedRepositoryListFragment newInstance(String login) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mLogin = getArguments().getString("user"); + mLogin = getArguments().getString(EXTRA_USER); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/WatcherListFragment.java b/app/src/main/java/com/gh4a/fragment/WatcherListFragment.java index 65fd10109..3dea32f9e 100644 --- a/app/src/main/java/com/gh4a/fragment/WatcherListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/WatcherListFragment.java @@ -32,12 +32,15 @@ import retrofit2.Response; public class WatcherListFragment extends PagedDataBaseFragment { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + public static WatcherListFragment newInstance(String repoOwner, String repoName) { WatcherListFragment f = new WatcherListFragment(); Bundle args = new Bundle(); - args.putString("owner", repoOwner); - args.putString("repo", repoName); + args.putString(EXTRA_OWNER, repoOwner); + args.putString(EXTRA_REPO, repoName); f.setArguments(args); return f; @@ -49,8 +52,8 @@ public static WatcherListFragment newInstance(String repoOwner, String repoName) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mRepoOwner = getArguments().getString("owner"); - mRepoName = getArguments().getString("repo"); + mRepoOwner = getArguments().getString(EXTRA_OWNER); + mRepoName = getArguments().getString(EXTRA_REPO); } @Override diff --git a/app/src/main/java/com/gh4a/fragment/WikiListFragment.java b/app/src/main/java/com/gh4a/fragment/WikiListFragment.java index 5c242bb95..0ffe0e9c6 100644 --- a/app/src/main/java/com/gh4a/fragment/WikiListFragment.java +++ b/app/src/main/java/com/gh4a/fragment/WikiListFragment.java @@ -20,6 +20,10 @@ public class WikiListFragment extends ListDataBaseFragment implements RootAdapter.OnItemClickListener { + private static final String EXTRA_OWNER = "owner"; + private static final String EXTRA_REPO = "repo"; + private static final String EXTRA_INITIAL_PAGE = "initial_page"; + private String mUserLogin; private String mRepoName; private String mInitialPage; @@ -27,9 +31,9 @@ public class WikiListFragment extends ListDataBaseFragment implements public static WikiListFragment newInstance(String owner, String repo, String initialPage) { WikiListFragment f = new WikiListFragment(); Bundle args = new Bundle(); - args.putString("owner", owner); - args.putString("repo", repo); - args.putString("initial_page", initialPage); + args.putString(EXTRA_OWNER, owner); + args.putString(EXTRA_REPO, repo); + args.putString(EXTRA_INITIAL_PAGE, initialPage); f.setArguments(args); return f; } @@ -37,10 +41,10 @@ public static WikiListFragment newInstance(String owner, String repo, String ini @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mUserLogin = getArguments().getString("owner"); - mRepoName = getArguments().getString("repo"); - mInitialPage = getArguments().getString("initial_page"); - getArguments().remove("initial_page"); + mUserLogin = getArguments().getString(EXTRA_OWNER); + mRepoName = getArguments().getString(EXTRA_REPO); + mInitialPage = getArguments().getString(EXTRA_INITIAL_PAGE); + getArguments().remove(EXTRA_INITIAL_PAGE); } @Override