Skip to content

Commit 3e5e2b8

Browse files
Mattia PRIMAVERATunous
Mattia PRIMAVERA
authored andcommitted
Extract hard-coded bundle params names
1 parent a2d62a0 commit 3e5e2b8

File tree

75 files changed

+929
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+929
-582
lines changed

app/src/main/java/com/gh4a/activities/BlogActivity.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424
import com.gh4a.model.Feed;
2525

2626
public class BlogActivity extends WebViewerActivity {
27+
28+
private static final String EXTRA_TITLE = "title";
29+
private static final String EXTRA_CONTENT = "content";
30+
2731
public static Intent makeIntent(Context context, Feed blog) {
2832
return new Intent(context, BlogActivity.class)
29-
.putExtra("title", blog.getTitle())
30-
.putExtra("content", blog.getContent());
33+
.putExtra(EXTRA_TITLE, blog.getTitle())
34+
.putExtra(EXTRA_CONTENT, blog.getContent());
3135
}
3236

3337
@Override
@@ -58,12 +62,12 @@ protected boolean canSwipeToRefresh() {
5862
@Override
5963
protected String generateHtml(String cssTheme, boolean addTitleHeader) {
6064
String title = addTitleHeader ? getDocumentTitle() : null;
61-
return wrapUnthemedHtml(getIntent().getStringExtra("content"), cssTheme, title);
65+
return wrapUnthemedHtml(getIntent().getStringExtra(EXTRA_CONTENT), cssTheme, title);
6266
}
6367

6468
@Override
6569
protected String getDocumentTitle() {
66-
return getIntent().getStringExtra("title");
70+
return getIntent().getStringExtra(EXTRA_TITLE);
6771
}
6872

6973
@Override

app/src/main/java/com/gh4a/activities/CollaboratorListActivity.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@
2525
import com.gh4a.fragment.CollaboratorListFragment;
2626

2727
public class CollaboratorListActivity extends FragmentContainerActivity {
28+
29+
private static final String EXTRA_OWNER = "owner";
30+
private static final String EXTRA_REPO = "repo";
31+
2832
public static Intent makeIntent(Context context, String repoOwner, String repoName) {
2933
return new Intent(context, CollaboratorListActivity.class)
30-
.putExtra("owner", repoOwner)
31-
.putExtra("repo", repoName);
34+
.putExtra(EXTRA_OWNER, repoOwner)
35+
.putExtra(EXTRA_REPO, repoName);
3236
}
3337

3438
private String mUserLogin;
@@ -48,8 +52,8 @@ protected String getActionBarSubtitle() {
4852

4953
@Override
5054
protected void onInitExtras(Bundle extras) {
51-
mUserLogin = extras.getString("owner");
52-
mRepoName = extras.getString("repo");
55+
mUserLogin = extras.getString(EXTRA_OWNER);
56+
mRepoName = extras.getString(EXTRA_REPO);
5357
}
5458

5559
@Override

app/src/main/java/com/gh4a/activities/CommitActivity.java

+18-11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343

4444
public class CommitActivity extends BaseFragmentPagerActivity implements
4545
CommitFragment.CommentUpdateListener, CommitNoteFragment.CommentUpdateListener {
46+
47+
private static final String EXTRA_OWNER = "owner";
48+
private static final String EXTRA_REPO = "repo";
49+
private static final String EXTRA_PR = "pr";
50+
private static final String EXTRA_SHA = "sha";
51+
private static final String EXTRA_INITIAL_COMMENT = "initial_comment";
52+
4653
public static Intent makeIntent(Context context, String repoOwner, String repoName, String sha) {
4754
return makeIntent(context, repoOwner, repoName, -1, sha, null);
4855
}
@@ -60,11 +67,11 @@ public static Intent makeIntent(Context context, String repoOwner, String repoNa
6067
private static Intent makeIntent(Context context, String repoOwner, String repoName,
6168
int pullRequestNumber, String sha, IntentUtils.InitialCommentMarker initialComment) {
6269
return new Intent(context, CommitActivity.class)
63-
.putExtra("owner", repoOwner)
64-
.putExtra("repo", repoName)
65-
.putExtra("pr", pullRequestNumber)
66-
.putExtra("sha", sha)
67-
.putExtra("initial_comment", initialComment);
70+
.putExtra(EXTRA_OWNER, repoOwner)
71+
.putExtra(EXTRA_REPO, repoName)
72+
.putExtra(EXTRA_PR, pullRequestNumber)
73+
.putExtra(EXTRA_SHA, sha)
74+
.putExtra(EXTRA_INITIAL_COMMENT, initialComment);
6875
}
6976

7077
private static final int ID_LOADER_COMMIT = 0;
@@ -112,12 +119,12 @@ protected AppBarLayout.ScrollingViewBehavior onCreateSwipeLayoutBehavior() {
112119
@Override
113120
protected void onInitExtras(Bundle extras) {
114121
super.onInitExtras(extras);
115-
mRepoOwner = extras.getString("owner");
116-
mRepoName = extras.getString("repo");
117-
mObjectSha = extras.getString("sha");
118-
mPullRequestNumber = extras.getInt("pr", -1);
119-
mInitialComment = extras.getParcelable("initial_comment");
120-
extras.remove("initial_comment");
122+
mRepoOwner = extras.getString(EXTRA_OWNER);
123+
mRepoName = extras.getString(EXTRA_REPO);
124+
mObjectSha = extras.getString(EXTRA_SHA);
125+
mPullRequestNumber = extras.getInt(EXTRA_PR, -1);
126+
mInitialComment = extras.getParcelable(EXTRA_INITIAL_COMMENT);
127+
extras.remove(EXTRA_INITIAL_COMMENT);
121128
}
122129

123130
@Override

app/src/main/java/com/gh4a/activities/CommitHistoryActivity.java

+19-11
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@
1212

1313
public class CommitHistoryActivity extends FragmentContainerActivity implements
1414
CommitListFragment.ContextSelectionCallback {
15+
16+
private static final String EXTRA_OWNER = "owner";
17+
private static final String EXTRA_REPO = "repo";
18+
private static final String EXTRA_REF = "ref";
19+
private static final String EXTRA_PATH = "path";
20+
private static final String EXTRA_BASE_SELECTABLE = "base_selectable";
21+
private static final String EXTRA_COMMIT = "commit";
22+
1523
public static Intent makeIntent(Context context, String repoOwner, String repoName,
1624
String ref, String path, boolean supportBaseSelection) {
1725
return new Intent(context, CommitHistoryActivity.class)
18-
.putExtra("owner", repoOwner)
19-
.putExtra("repo", repoName)
20-
.putExtra("ref", ref)
21-
.putExtra("path", path)
22-
.putExtra("base_selectable", supportBaseSelection);
26+
.putExtra(EXTRA_OWNER, repoOwner)
27+
.putExtra(EXTRA_REPO, repoName)
28+
.putExtra(EXTRA_REF, ref)
29+
.putExtra(EXTRA_PATH, path)
30+
.putExtra(EXTRA_BASE_SELECTABLE, supportBaseSelection);
2331
}
2432

2533
private String mRepoOwner;
@@ -43,11 +51,11 @@ protected String getActionBarSubtitle() {
4351
@Override
4452
protected void onInitExtras(Bundle extras) {
4553
super.onInitExtras(extras);
46-
mRepoOwner = extras.getString("owner");
47-
mRepoName = extras.getString("repo");
48-
mRef = extras.getString("ref");
49-
mFilePath = extras.getString("path");
50-
mSupportBaseSelection = extras.getBoolean("base_selectable");
54+
mRepoOwner = extras.getString(EXTRA_OWNER);
55+
mRepoName = extras.getString(EXTRA_REPO);
56+
mRef = extras.getString(EXTRA_REF);
57+
mFilePath = extras.getString(EXTRA_PATH);
58+
mSupportBaseSelection = extras.getBoolean(EXTRA_BASE_SELECTABLE);
5159
}
5260

5361
@Override
@@ -68,7 +76,7 @@ public boolean baseSelectionAllowed() {
6876
@Override
6977
public void onCommitSelectedAsBase(Commit commit) {
7078
Intent result = new Intent();
71-
result.putExtra("commit", commit);
79+
result.putExtra(EXTRA_COMMIT, commit);
7280
setResult(RESULT_OK, result);
7381
finish();
7482
}

app/src/main/java/com/gh4a/activities/CompareActivity.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@
2525
import com.gh4a.fragment.CommitCompareFragment;
2626

2727
public class CompareActivity extends FragmentContainerActivity {
28+
29+
private static final String EXTRA_OWNER = "owner";
30+
private static final String EXTRA_REPO = "repo";
31+
private static final String EXTRA_BASE = "base";
32+
private static final String EXTRA_HEAD = "head";
33+
2834
public static Intent makeIntent(Context context, String repoOwner, String repoName,
2935
String baseRef, String headRef) {
3036
return new Intent(context, CompareActivity.class)
31-
.putExtra("owner", repoOwner)
32-
.putExtra("repo", repoName)
33-
.putExtra("base", baseRef)
34-
.putExtra("head", headRef);
37+
.putExtra(EXTRA_OWNER, repoOwner)
38+
.putExtra(EXTRA_REPO, repoName)
39+
.putExtra(EXTRA_BASE, baseRef)
40+
.putExtra(EXTRA_HEAD, headRef);
3541
}
3642

3743
private String mRepoOwner;
@@ -52,14 +58,14 @@ protected String getActionBarSubtitle() {
5258
@Override
5359
protected void onInitExtras(Bundle extras) {
5460
super.onInitExtras(extras);
55-
mRepoOwner = extras.getString("owner");
56-
mRepoName = extras.getString("repo");
61+
mRepoOwner = extras.getString(EXTRA_OWNER);
62+
mRepoName = extras.getString(EXTRA_REPO);
5763
}
5864

5965
@Override
6066
protected Fragment onCreateFragment() {
61-
String base = getIntent().getStringExtra("base");
62-
String head = getIntent().getStringExtra("head");
67+
String base = getIntent().getStringExtra(EXTRA_BASE);
68+
String head = getIntent().getStringExtra(EXTRA_HEAD);
6369

6470
return CommitCompareFragment.newInstance(mRepoOwner, mRepoName, base, head);
6571
}

app/src/main/java/com/gh4a/activities/ContributorListActivity.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@
2525
import com.gh4a.fragment.ContributorListFragment;
2626

2727
public class ContributorListActivity extends FragmentContainerActivity {
28+
29+
private static final String EXTRA_OWNER = "owner";
30+
private static final String EXTRA_REPO = "repo";
31+
2832
public static Intent makeIntent(Context context, String repoOwner, String repoName) {
2933
return new Intent(context, ContributorListActivity.class)
30-
.putExtra("owner", repoOwner)
31-
.putExtra("repo", repoName);
34+
.putExtra(EXTRA_OWNER, repoOwner)
35+
.putExtra(EXTRA_REPO, repoName);
3236
}
3337

3438
private String mUserLogin;
@@ -49,8 +53,8 @@ protected String getActionBarSubtitle() {
4953
@Override
5054
protected void onInitExtras(Bundle extras) {
5155
super.onInitExtras(extras);
52-
mUserLogin = extras.getString("owner");
53-
mRepoName = extras.getString("repo");
56+
mUserLogin = extras.getString(EXTRA_OWNER);
57+
mRepoName = extras.getString(EXTRA_REPO);
5458
}
5559

5660
@Override

app/src/main/java/com/gh4a/activities/DiffViewerActivity.java

+37-25
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,33 @@
4949

5050
public abstract class DiffViewerActivity<C extends PositionalCommentBase> extends WebViewerActivity
5151
implements ReactionBar.Callback, ReactionBar.ReactionDetailsCache.Listener {
52+
53+
private static final String EXTRA_OWNER = "owner";
54+
private static final String EXTRA_REPO = "repo";
55+
private static final String EXTRA_SHA = "sha";
56+
private static final String EXTRA_PATH = "path";
57+
private static final String EXTRA_DIFF = "diff";
58+
private static final String EXTRA_COMMENTS = "comments";
59+
private static final String EXTRA_INITIAL_LINE = "initial_line";
60+
private static final String STRING = "highlight_start";
61+
private static final String STRIN = "highlight_end";
62+
private static final String EXTRA_HIGHLIGHT_RIGHT = "highlight_right";
63+
private static final String EXTRA_INITIAL_COMMENT = "initial_comment";
64+
5265
protected static <C extends PositionalCommentBase> Intent fillInIntent(Intent baseIntent,
5366
String repoOwner, String repoName, String commitSha, String path, String diff,
5467
List<C> comments, int initialLine, int highlightStartLine, int highlightEndLine,
5568
boolean highlightisRight, IntentUtils.InitialCommentMarker initialComment) {
56-
return baseIntent.putExtra("owner", repoOwner)
57-
.putExtra("repo", repoName)
58-
.putExtra("sha", commitSha)
59-
.putExtra("path", path)
60-
.putExtra("diff", diff)
61-
.putExtra("comments", comments != null ? new ArrayList<>(comments) : null)
62-
.putExtra("initial_line", initialLine)
63-
.putExtra("highlight_start", highlightStartLine)
64-
.putExtra("highlight_end", highlightEndLine)
65-
.putExtra("highlight_right", highlightisRight)
66-
.putExtra("initial_comment", initialComment);
69+
return baseIntent.putExtra(EXTRA_OWNER, repoOwner)
70+
.putExtra(EXTRA_REPO, repoName)
71+
.putExtra(EXTRA_SHA, commitSha)
72+
.putExtra(EXTRA_PATH, path)
73+
.putExtra(EXTRA_DIFF, diff)
74+
.putExtra(EXTRA_COMMENTS, comments != null ? new ArrayList<>(comments) : null)
75+
.putExtra(EXTRA_INITIAL_LINE, initialLine)
76+
.putExtra(STRING, highlightStartLine)
77+
.putExtra(EXTRA_HIGHLIGHT_RIGHT, highlightisRight)
78+
.putExtra(EXTRA_INITIAL_COMMENT, initialComment);
6779
}
6880

6981
private static final String COMMENT_ADD_URI_FORMAT =
@@ -168,23 +180,23 @@ protected void onDestroy() {
168180
@Override
169181
protected void onInitExtras(Bundle extras) {
170182
super.onInitExtras(extras);
171-
mRepoOwner = extras.getString("owner");
172-
mRepoName = extras.getString("repo");
173-
mPath = extras.getString("path");
174-
mSha = extras.getString("sha");
175-
mDiff = extras.getString("diff");
176-
mInitialLine = extras.getInt("initial_line", -1);
177-
mHighlightStartLine = extras.getInt("highlight_start", -1);
178-
mHighlightEndLine = extras.getInt("highlight_end", -1);
179-
mHighlightIsRight = extras.getBoolean("highlight_right", false);
180-
mInitialComment = extras.getParcelable("initial_comment");
181-
extras.remove("initial_comment");
183+
mRepoOwner = extras.getString(EXTRA_OWNER);
184+
mRepoName = extras.getString(EXTRA_REPO);
185+
mPath = extras.getString(EXTRA_PATH);
186+
mSha = extras.getString(EXTRA_SHA);
187+
mDiff = extras.getString(EXTRA_DIFF);
188+
mInitialLine = extras.getInt(EXTRA_INITIAL_LINE, -1);
189+
mHighlightStartLine = extras.getInt(STRING, -1);
190+
mHighlightEndLine = extras.getInt(STRIN, -1);
191+
mHighlightIsRight = extras.getBoolean(EXTRA_HIGHLIGHT_RIGHT, false);
192+
mInitialComment = extras.getParcelable(EXTRA_INITIAL_COMMENT);
193+
extras.remove(EXTRA_INITIAL_COMMENT);
182194
}
183195

184196
@Override
185197
protected boolean canSwipeToRefresh() {
186198
// no need for pull-to-refresh if everything was passed in the intent extras
187-
return !getIntent().hasExtra("comments");
199+
return !getIntent().hasExtra(EXTRA_COMMENTS);
188200
}
189201

190202
@Override
@@ -420,7 +432,7 @@ protected void handleUrlLoad(Uri uri) {
420432

421433
private void refresh() {
422434
// Make sure we load the comments from remote, as we now know they've changed
423-
getIntent().removeExtra("comments");
435+
getIntent().removeExtra(EXTRA_COMMENTS);
424436

425437
// Make sure our callers are aware of the change
426438
setResult(RESULT_OK);
@@ -454,7 +466,7 @@ private void deleteComment(long id) {
454466

455467
private void loadComments(boolean useIntentExtraIfPresent, boolean force) {
456468
List<C> intentComments = useIntentExtraIfPresent
457-
? getIntent().getParcelableArrayListExtra("comments") : null;
469+
? getIntent().getParcelableArrayListExtra(EXTRA_COMMENTS) : null;
458470
Single<List<C>> commentSingle = intentComments != null
459471
? Single.just(intentComments)
460472
: createCommentSingle(force).compose(makeLoaderSingle(ID_LOADER_COMMENTS, force));

0 commit comments

Comments
 (0)