Skip to content

Commit

Permalink
implement recommendations from code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
CampelloManuel committed Apr 28, 2024
1 parent c0310f0 commit b1bd6ed
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private void assertUriReturnsResult(final Uri uri, final String[] fields, final
final String[] whereArgs, final int count) {
final Cursor c = mResolver
.query(uri, fields, where, whereArgs, null);
assertNotNull(c);
if (count == 6 && c.getCount() == 7) {
// TODO sometimes tests on github (not on a fast PC) crash here. Investigate why
NnnLogger.debug(DBProviderTest.class, "cursor info:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public String getText() {
result += title;
}
if (note != null && !note.isEmpty()) {
if (result.length() > 0) {
if (!result.isEmpty()) {
result += "\n";
}
result += note;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,15 @@ String getShareText() {
return sb.toString();
}

// when sharing many notes from the list view,
// we send a list of their titles as subject
String getShareSubject() {
String result = "";
StringBuilder result = new StringBuilder();
for (Task t : tasks.values()) {
result += ", " + t.title;
result.append(", ").append(t.title);
}
return result.length() > 0 ? result.substring(2) : result;
// if necessary, remove the first ", "
return (result.length() == 0) ? "" : result.substring(2);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public boolean onPreferenceTreeClick(Preference preference) {
.getDefaultSharedPreferences(this.getContext())
.getString(ringtonePrefKey, null);
if (existingValue != null) {
Uri existing = existingValue.length() == 0
Uri existing = existingValue.isEmpty()
? null // Select "Silent"
: Uri.parse(existingValue);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, existing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ protected boolean wasRenamed(final TaskList list, final OrgFile file) {
*/
protected void renameFile(final TaskList list,
final RemoteTaskList dbEntry, final OrgFile file) {
if (list.title != null && list.title.length() > 0) {
if (list.title != null && !list.title.isEmpty()) {
file.setFilename(OrgConverter.getTitleAsFilename(list));
}
dbEntry.remoteId = file.getFilename();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static CharSequence getStyledText(final String title,
final String rest, final float titleRelSize, final int face,
final int font) {
final StringBuilder textBuilder = new StringBuilder(title);
if (rest.length() > 0) {
if (!rest.isEmpty()) {
textBuilder.append("\n").append(rest);
}
return getStyledText(textBuilder.toString(), titleRelSize, face, font);
Expand Down Expand Up @@ -371,7 +371,7 @@ public void setTextRest(final String rest) {
if (rest != null) {
this.mRest = rest;
// Make sure it starts with a new line
if (mRest.length() > 0) {
if (!mRest.isEmpty()) {
mRest = (rest.startsWith("\n") ? "" : "\n") + rest;
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 0 additions & 27 deletions app/src/main/res/drawable/btn_default_selector_dark.xml

This file was deleted.

0 comments on commit b1bd6ed

Please sign in to comment.