Hard-Coded bundle params + few extra strings removed #714#719
Hard-Coded bundle params + few extra strings removed #714#719MattiaPrimavera wants to merge 1 commit intoslapperwan:masterfrom
Conversation
|
I'd prefer if the string constants had an |
|
|
||
| import org.eclipse.egit.github.core.Repository; | ||
|
|
||
| import java.io.CharArrayReader; |
There was a problem hiding this comment.
typing error (ALT+ENTER) :P
| 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"; |
There was a problem hiding this comment.
Please move to Github API.
| private static final String HEAD_LABEL = "head_label"; | ||
| private static final String PR = "pr"; | ||
|
|
||
|
|
There was a problem hiding this comment.
Please remove the second newline.
| private static final String STATE_KEY_QUERY = "query"; | ||
| private static final String STATE_KEY_SEARCH_TYPE = "search_type"; | ||
| private static final String STATE_KEY_SEARCH_TYPE = SEARCH_TYPE; | ||
|
|
There was a problem hiding this comment.
Extra key and state key are unrelated, please restore the string literal to not give the impression they are related.
| private static final String LOGIN = "login"; | ||
| private static final String SORT = "sort"; | ||
| private static final String PUSHED = "pushed"; | ||
| private static final String AFFILIATINO = "affiliation"; |
There was a problem hiding this comment.
Typo.
Also, the filter strings should live in the Github API bindings.
There was a problem hiding this comment.
you meant "AFFILIATINO" spelling error right ?
There was a problem hiding this comment.
the filter strings should live in the Github API bindings.
I created a Constants file
There was a problem hiding this comment.
you meant "AFFILIATINO" spelling error right ?
Yes.
I created a Constants file
Plesse change that to either use the existing IGithubConstants class or put the constants to the respective service classes. If the constants only apply to one service, I'd prefer the latter.
|
Argh I though about the prefix, was not sure on your conventions ... |
|
|
||
| protected String mLogin; | ||
| private EventAdapter mAdapter; | ||
| private static final String LOGIN = "login"; |
There was a problem hiding this comment.
I'd say to move it up to the rest of statics.
|
Not sure if we follow this rule elsewhere but I think it's a good idea to keep static fields above instance fields. I saw that you placed them together in some files. |
👍 If we don't do it in all places yet, we definitely should do that. |
Tunous
left a comment
There was a problem hiding this comment.
Nearly there. Remaining questions should be answered by @maniac103.
|
|
||
| switch (file.getStatus()) { | ||
| case "added": | ||
| case Constants.STATUS_ADDED: |
| return new CommitStatusLoader(getActivity(), mRepoOwner, mRepoName, | ||
| mPullRequest.getHead().getSha()); | ||
| } | ||
| @Override |
There was a problem hiding this comment.
Revert. This was indented like this on purpose.
| 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 FILTER_ALL = "all"; | ||
| private static final String OWNER = "owner"; |
There was a problem hiding this comment.
These will probably need some prefix or be moved to another file.
@maniac103
There was a problem hiding this comment.
FilterConstants file is good ?
There was a problem hiding this comment.
I have found that RepositoryService already contains some of these so the rest should be moved here too.
There was a problem hiding this comment.
For the naming. Filter constants should start with TYPE_ as these already present in RepositoryService. Sort constants should be prefixed with SORT_. And the main, search tag are specific to this fragment so these 2 leave here.
|
|
||
| Bundle args = new Bundle(); | ||
| args.putString("login", login); | ||
| args.putString(Constants.EXTRA_LOGIN, login); |
| Map<String, String> filterData = new HashMap<>(); | ||
| filterData.put("sort", "pushed"); | ||
| filterData.put("affiliation", "owner,collaborator"); | ||
| filterData.put(Constants.EXTRA_SORT, Constants.PUSHED); |
There was a problem hiding this comment.
I moved it to IGithubConstants
| @@ -0,0 +1,12 @@ | |||
| package org.eclipse.egit.github.core.util; | |||
|
|
|||
| public class Constants { | |||
There was a problem hiding this comment.
This file shouldn't be needed.
| import static org.eclipse.egit.github.core.CommitFile.STATUS_ADDED; | ||
| import static org.eclipse.egit.github.core.CommitFile.STATUS_MODIFIED; | ||
| import static org.eclipse.egit.github.core.CommitFile.STATUS_REMOVED; | ||
| import static org.eclipse.egit.github.core.CommitFile.STATUS_RENAMED; |
There was a problem hiding this comment.
Please avoid static imports and use CommitFile.STATUS_* below instead.
|
|
||
| public static CommitFragment newInstance(String repoOwner, String repoName, String commitSha, | ||
| RepositoryCommit commit, List<CommitComment> comments) { | ||
|
|
There was a problem hiding this comment.
Please remove that newline.
| Event.TYPE_PUSH, Event.TYPE_ISSUES, Event.TYPE_WATCH, Event.TYPE_CREATE, | ||
| Event.TYPE_PULL_REQUEST, Event.TYPE_COMMIT_COMMENT, Event.TYPE_DELETE, | ||
| Event.TYPE_DOWNLOAD, Event.TYPE_FORK_APPLY, Event.TYPE_PUBLIC, | ||
| Event.TYPE_MEMBER, Event.TYPE_ISSUE_COMMENT |
There was a problem hiding this comment.
This change is unrelated, please remove.
| private boolean mIsLoadCompleted; | ||
| private View mLoadingView; | ||
|
|
||
| private static final String STATE_KEY_ITERATOR_STATE = "iterator_state"; |
There was a problem hiding this comment.
Unrelated change, please remove.
| } | ||
|
|
||
| private void fillStatus(List<CommitStatus> statuses) { | ||
| private void fillStatus(List<CommitStatus> statuses) { |
| import static org.eclipse.egit.github.core.client.IGitHubConstants.PUSHED; | ||
|
|
||
| public class UserFragment extends LoadingFragmentBase implements View.OnClickListener { | ||
| public static final String EXTRA_LOGIN = "login"; |
| import com.gh4a.loader.LoaderResult; | ||
|
|
||
| import org.xml.sax.SAXException; | ||
|
|
There was a problem hiding this comment.
No unrelated whitespace changes please.
| filterData.put("sort", "pushed"); | ||
| filterData.put("affiliation", "owner,collaborator"); | ||
| filterData.put(EXTRA_SORT, PUSHED); | ||
| filterData.put(EXTRA_AFFILIATION, "owner,collaborator"); |
There was a problem hiding this comment.
Those aren't extras, but filter fields. Please move those to RepositoryService (see IssueService for example on variable naming).
|
|
||
| String EXTRA_SORT = "sort"; | ||
| String EXTRA_AFFILIATION = "affiliation"; | ||
| String PUSHED = "pushed"; |
There was a problem hiding this comment.
Please remove as per above.
| public static final String STARRED = "starred"; | ||
| public static final String FULL_NAME = "full_name"; | ||
| public static final String MAIN_TAG = "main"; | ||
| public static final String SEARCH_TAG = "search"; |
There was a problem hiding this comment.
Fragment tags don't belong into the Github API, but to their respective activity.
All other items are filter fields (right?) and thus should be moved to the respective service (RepositoryService, I guess) with appropriate naming.
d9247f1 to
397eea9
Compare
397eea9 to
3e5e2b8
Compare
|
I've rebased this onto master, fixed mentioned issues and added similar constants to activity files. |
Done for fragments package bundle parameters + some other hard-coded strings ;)