-
Notifications
You must be signed in to change notification settings - Fork 133
Use wrapper methods to remove duplicated code #116
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
Changes from 1 commit
3c08017
fd0542b
b3fb608
f5b64b9
ec300a4
2147c52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
-Fix some File.equals(someString) that always returned false.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,7 +215,7 @@ public String[] getMenuItemNames(String menuLabel, String boardName) { | |
| * | ||
| */ | ||
| public String[] GetArduinoBoards() { | ||
| if (mLastLoadedBoardsFile.equals("")) { | ||
| if (mLastLoadedBoardsFile == null || mLastLoadedBoardsFile.toString().isEmpty()) { | ||
| String[] sBoards = new String[0]; | ||
| return sBoards; | ||
| } | ||
|
|
@@ -247,11 +247,11 @@ public String[] GetArduinoBoards() { | |
| * @author jan | ||
| */ | ||
| public boolean LoadBoardsFile(String boardsFile) { | ||
|
|
||
| if ((mLastLoadedBoardsFile != null) && (mLastLoadedBoardsFile.equals(boardsFile))) | ||
| return true; // do nothing when value didn't change | ||
| mLastLoadedBoardsFile = new File(boardsFile); | ||
| return LoadBoardsFile(); | ||
| File newFile = new File(boardsFile); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. funny: now I read (mLastLoadedBoardsFile != null) so there is definitely room for more consistency
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The (mLastLoadedBoardsFile != null) condition is already done in newFile.equals(...). So maybe this fixes a bug that forced always calling to LoadBoardsFile().
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think debugging is the only way to find out for sure. |
||
| if (newFile.equals(mLastLoadedBoardsFile)) | ||
| return true; // do nothing when value didn't change | ||
| mLastLoadedBoardsFile = newFile; | ||
| return LoadBoardsFile(); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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'm not sure this is an improvement because (as far as I recall) mLastLoadedBoardsFile is initialized as "" and never set to null.
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.
Is initialized with null at the beginning of class. Seems that some time ago was initialized with "" since there is a line of code commented.
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 personally hate these double tests (first not null and then test)
I guess it is a style thing.
I do agre that isempty is far better than equals("")