-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hard-Coded bundle params + few extra strings removed #714 #719
base: master
Are you sure you want to change the base?
Hard-Coded bundle params + few extra strings removed #714 #719
Conversation
I'd prefer if the string constants had an |
@@ -26,9 +26,32 @@ | |||
|
|||
import org.eclipse.egit.github.core.Repository; | |||
|
|||
import java.io.CharArrayReader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the second newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eagle eyed :P
@@ -91,7 +94,7 @@ public static SearchFragment newInstance(int initialType, String initialQuery) { | |||
private static final String SUGGESTION_ORDER = SuggestionsProvider.Columns.DATE + " DESC"; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
Also, the filter strings should live in the Github API bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you meant "AFFILIATINO" spelling error right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the filter strings should live in the Github API bindings.
I created a Constants file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ... |
@@ -83,6 +83,7 @@ | |||
|
|||
protected String mLogin; | |||
private EventAdapter mAdapter; | |||
private static final String LOGIN = "login"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there. Remaining questions should be answered by @maniac103.
@@ -191,19 +198,19 @@ protected void fillStats(List<CommitFile> files, List<CommitComment> comments) { | |||
final LinearLayout parent; | |||
|
|||
switch (file.getStatus()) { | |||
case "added": | |||
case Constants.STATUS_ADDED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should go to CommitFile.java instead.
return new CommitStatusLoader(getActivity(), mRepoOwner, mRepoName, | ||
mPullRequest.getHead().getSha()); | ||
} | ||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will probably need some prefix or be moved to another file.
@maniac103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FilterConstants file is good ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -56,7 +57,7 @@ public static UserFragment newInstance(String login) { | |||
UserFragment f = new UserFragment(); | |||
|
|||
Bundle args = new Bundle(); | |||
args.putString("login", login); | |||
args.putString(Constants.EXTRA_LOGIN, login); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep extra in this file.
@@ -85,8 +86,8 @@ protected void onResultReady(User result) { | |||
@Override | |||
protected Loader<LoaderResult<Collection<Repository>>> onCreateLoader() { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably move to Repository.java?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated, please remove.
private RootAdapter<T, ? extends RecyclerView.ViewHolder> mAdapter; | ||
private PageIteratorWithSaveableState<T> mIterator; | ||
private boolean mIsLoadCompleted; | ||
private View mLoadingView; | ||
|
||
private static final String STATE_KEY_ITERATOR_STATE = "iterator_state"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change, please remove.
|
||
private void fillStatus(List<CommitStatus> statuses) { | ||
private void fillStatus(List<CommitStatus> statuses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace errors.
public class UserFragment extends LoadingFragmentBase implements View.OnClickListener { | ||
public static final String EXTRA_LOGIN = "login"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public -> private
import org.xml.sax.SAXException; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ;)