|
49 | 49 |
|
50 | 50 | public abstract class DiffViewerActivity<C extends PositionalCommentBase> extends WebViewerActivity
|
51 | 51 | 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 | + |
52 | 65 | protected static <C extends PositionalCommentBase> Intent fillInIntent(Intent baseIntent,
|
53 | 66 | String repoOwner, String repoName, String commitSha, String path, String diff,
|
54 | 67 | List<C> comments, int initialLine, int highlightStartLine, int highlightEndLine,
|
55 | 68 | 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); |
67 | 79 | }
|
68 | 80 |
|
69 | 81 | private static final String COMMENT_ADD_URI_FORMAT =
|
@@ -168,23 +180,23 @@ protected void onDestroy() {
|
168 | 180 | @Override
|
169 | 181 | protected void onInitExtras(Bundle extras) {
|
170 | 182 | 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); |
182 | 194 | }
|
183 | 195 |
|
184 | 196 | @Override
|
185 | 197 | protected boolean canSwipeToRefresh() {
|
186 | 198 | // 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); |
188 | 200 | }
|
189 | 201 |
|
190 | 202 | @Override
|
@@ -420,7 +432,7 @@ protected void handleUrlLoad(Uri uri) {
|
420 | 432 |
|
421 | 433 | private void refresh() {
|
422 | 434 | // Make sure we load the comments from remote, as we now know they've changed
|
423 |
| - getIntent().removeExtra("comments"); |
| 435 | + getIntent().removeExtra(EXTRA_COMMENTS); |
424 | 436 |
|
425 | 437 | // Make sure our callers are aware of the change
|
426 | 438 | setResult(RESULT_OK);
|
@@ -454,7 +466,7 @@ private void deleteComment(long id) {
|
454 | 466 |
|
455 | 467 | private void loadComments(boolean useIntentExtraIfPresent, boolean force) {
|
456 | 468 | List<C> intentComments = useIntentExtraIfPresent
|
457 |
| - ? getIntent().getParcelableArrayListExtra("comments") : null; |
| 469 | + ? getIntent().getParcelableArrayListExtra(EXTRA_COMMENTS) : null; |
458 | 470 | Single<List<C>> commentSingle = intentComments != null
|
459 | 471 | ? Single.just(intentComments)
|
460 | 472 | : createCommentSingle(force).compose(makeLoaderSingle(ID_LOADER_COMMENTS, force));
|
|
0 commit comments