Remove extraneous braces

pull/493/head
Alex Baker 8 years ago
parent 0072bb1c77
commit ca8b3ca872

@ -1,7 +1,9 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="Convert2streamapi" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="DoubleBraceInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="Guava" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
@ -13,6 +15,7 @@
<option name="processComments" value="true" />
</inspection_tool>
<inspection_tool class="StaticPseudoFunctionalStyleMethod" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SuspiciousIndentAfterControlStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TryFinallyCanBeTryWithResources" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TryWithIdenticalCatches" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>

@ -278,18 +278,17 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
Task task = viewHolder.task;
// name
final TextView nameView = viewHolder.nameView; {
String nameValue = task.getTitle();
final TextView nameView = viewHolder.nameView;
String nameValue = task.getTitle();
long hiddenUntil = task.getHideUntil();
if(task.getDeletionDate() > 0) {
nameValue = resources.getString(R.string.TAd_deletedFormat, nameValue);
}
if(hiddenUntil > DateUtilities.now()) {
nameValue = resources.getString(R.string.TAd_hiddenFormat, nameValue);
}
nameView.setText(nameValue);
long hiddenUntil = task.getHideUntil();
if(task.getDeletionDate() > 0) {
nameValue = resources.getString(R.string.TAd_deletedFormat, nameValue);
}
if(hiddenUntil > DateUtilities.now()) {
nameValue = resources.getString(R.string.TAd_hiddenFormat, nameValue);
}
nameView.setText(nameValue);
setupDueDateAndTags(viewHolder, task);
@ -507,64 +506,62 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
};
}
// Returns due date text width
private void setupDueDateAndTags(ViewHolder viewHolder, Task task) {
// due date / completion date
final TextView dueDateView = viewHolder.dueDate; {
if(!task.isCompleted() && task.hasDueDate()) {
long dueDate = task.getDueDate();
if(task.isOverdue()) {
dueDateView.setTextColor(textColorOverdue);
} else {
dueDateView.setTextColor(textColorSecondary);
}
String dateValue = DateUtilities.getRelativeDateStringWithTime(context, dueDate);
dueDateView.setText(dateValue);
dueDateView.setVisibility(View.VISIBLE);
} else if(task.isCompleted()) {
String dateValue = DateUtilities.getRelativeDateStringWithTime(context, task.getCompletionDate());
dueDateView.setText(resources.getString(R.string.TAd_completed, dateValue));
dueDateView.setTextColor(textColorHint);
dueDateView.setVisibility(View.VISIBLE);
final TextView dueDateView = viewHolder.dueDate;
if(!task.isCompleted() && task.hasDueDate()) {
long dueDate = task.getDueDate();
if(task.isOverdue()) {
dueDateView.setTextColor(textColorOverdue);
} else {
dueDateView.setVisibility(View.GONE);
dueDateView.setTextColor(textColorSecondary);
}
String dateValue = DateUtilities.getRelativeDateStringWithTime(context, dueDate);
dueDateView.setText(dateValue);
dueDateView.setVisibility(View.VISIBLE);
} else if(task.isCompleted()) {
String dateValue = DateUtilities.getRelativeDateStringWithTime(context, task.getCompletionDate());
dueDateView.setText(resources.getString(R.string.TAd_completed, dateValue));
dueDateView.setTextColor(textColorHint);
dueDateView.setVisibility(View.VISIBLE);
} else {
dueDateView.setVisibility(View.GONE);
}
if (task.isCompleted()) {
viewHolder.tagBlock.setVisibility(View.GONE);
} else {
String tags = viewHolder.tagsString;
List<String> tagUuids = tags != null ? newArrayList(tags.split(",")) : Lists.newArrayList();
Iterable<TagData> t = filter(transform(tagUuids, uuidToTag), Predicates.notNull());
List<TagData> firstFourByName = orderByName.leastOf(t, 4);
int numTags = firstFourByName.size();
if (numTags > 0) {
List<TagData> firstFourByNameLength = orderByLength.sortedCopy(firstFourByName);
float maxLength = tagCharacters / numTags;
for (int i = 0; i < numTags - 1; i++) {
TagData tagData = firstFourByNameLength.get(i);
String name = tagData.getName();
if (name.length() >= maxLength) {
break;
}
float excess = maxLength - name.length();
int beneficiaries = numTags - i - 1;
float additional = excess / beneficiaries;
maxLength += additional;
if (task.isCompleted()) {
viewHolder.tagBlock.setVisibility(View.GONE);
} else {
String tags = viewHolder.tagsString;
List<String> tagUuids = tags != null ? newArrayList(tags.split(",")) : Lists.newArrayList();
Iterable<TagData> t = filter(transform(tagUuids, uuidToTag), Predicates.notNull());
List<TagData> firstFourByName = orderByName.leastOf(t, 4);
int numTags = firstFourByName.size();
if (numTags > 0) {
List<TagData> firstFourByNameLength = orderByLength.sortedCopy(firstFourByName);
float maxLength = tagCharacters / numTags;
for (int i = 0; i < numTags - 1; i++) {
TagData tagData = firstFourByNameLength.get(i);
String name = tagData.getName();
if (name.length() >= maxLength) {
break;
}
List<SpannableString> tagStrings = transform(firstFourByName, tagToString(maxLength));
SpannableStringBuilder builder = new SpannableStringBuilder();
for (SpannableString tagString : tagStrings) {
if (builder.length() > 0) {
builder.append(HAIR_SPACE);
}
builder.append(tagString);
float excess = maxLength - name.length();
int beneficiaries = numTags - i - 1;
float additional = excess / beneficiaries;
maxLength += additional;
}
List<SpannableString> tagStrings = transform(firstFourByName, tagToString(maxLength));
SpannableStringBuilder builder = new SpannableStringBuilder();
for (SpannableString tagString : tagStrings) {
if (builder.length() > 0) {
builder.append(HAIR_SPACE);
}
viewHolder.tagBlock.setText(builder);
viewHolder.tagBlock.setVisibility(View.VISIBLE);
} else {
viewHolder.tagBlock.setVisibility(View.GONE);
builder.append(tagString);
}
viewHolder.tagBlock.setText(builder);
viewHolder.tagBlock.setVisibility(View.VISIBLE);
} else {
viewHolder.tagBlock.setVisibility(View.GONE);
}
}
}

Loading…
Cancel
Save