fix a relative-layout placement issue by using invible and not gone in some cases

This commit is contained in:
ligi 2014-10-26 11:28:34 +01:00
parent 0e28da0803
commit c1fdc7164f

View file

@ -29,17 +29,6 @@ public class PassVisualizer {
final CategoryIndicatorView categoryIndicator = findById(container, R.id.categoryView); final CategoryIndicatorView categoryIndicator = findById(container, R.id.categoryView);
if (pass.getLocations().size() > 0) {
findById(container, R.id.navigateTo).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavigateToLocationsDialog.perform(activity, App.getPassStore().getPassbookForId(pass.getId()), false);
}
});
} else {
findById(container, R.id.navigateTo).setVisibility(View.GONE);
}
final DateTime dateForIntent; final DateTime dateForIntent;
if (pass.getRelevantDate().isPresent()) { if (pass.getRelevantDate().isPresent()) {
@ -51,6 +40,28 @@ public class PassVisualizer {
dateForIntent = null; dateForIntent = null;
} }
final boolean noButtons = dateForIntent == null && !(pass.getLocations().size() > 0);
if (noButtons) {
findById(container, R.id.actions_separator).setVisibility(View.GONE);
}
if (pass.getLocations().size() > 0) {
findById(container, R.id.navigateTo).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavigateToLocationsDialog.perform(activity, App.getPassStore().getPassbookForId(pass.getId()), false);
}
});
} else {
if (noButtons) {
findById(container, R.id.navigateTo).setVisibility(View.GONE);
} else {
findById(container, R.id.navigateTo).setVisibility(View.INVISIBLE);
}
}
if (dateForIntent != null) { if (dateForIntent != null) {
findById(container, R.id.addCalendar).setOnClickListener(new View.OnClickListener() { findById(container, R.id.addCalendar).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -68,9 +79,6 @@ public class PassVisualizer {
} }
if (dateForIntent == null && !(pass.getLocations().size() > 0)) {
findById(container, R.id.actions_separator).setVisibility(View.GONE);
}
final ImageView icon_img = findById(container, R.id.icon); final ImageView icon_img = findById(container, R.id.icon);