Fixed weird selection behavior when multiple rows are long-clicked. Fixed rendering artifact issue on 2.x devices when Your Train card is dismissed.

This commit is contained in:
Doug Keen 2012-10-11 11:42:21 -07:00
parent ce71cb6e09
commit c310a00a55
2 changed files with 10 additions and 26 deletions

View File

@ -346,6 +346,9 @@ public class ViewDeparturesActivity extends SActivity implements
@Override @Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, public boolean onItemLongClick(AdapterView<?> adapterView, View view,
int position, long id) { int position, long id) {
if (mSelectedRow != null) {
((Checkable) mSelectedRow).setChecked(false);
}
mWasLongClick = true; mWasLongClick = true;
mSelectedDeparture = (Departure) getListAdapter().getItem(position); mSelectedDeparture = (Departure) getListAdapter().getItem(position);
mSelectedRow = view; mSelectedRow = view;
@ -760,36 +763,11 @@ public class ViewDeparturesActivity extends SActivity implements
refreshBoardedDeparture(true); refreshBoardedDeparture(true);
getListAdapter().notifyDataSetChanged(); getListAdapter().notifyDataSetChanged();
refreshListSelection();
} }
} }
}); });
} }
private void refreshListSelection() {
getListView().clearChoices();
final Departure targetDeparture;
if (isDepartureActionModeActive() && mSelectedDeparture != null) {
targetDeparture = mSelectedDeparture;
} else {
targetDeparture = getBoardedDeparture();
}
for (int i = getListAdapter().getCount() - 1; i >= 0; i--) {
if (getListAdapter().getItem(i).equals(targetDeparture)) {
final int selectedIndex = i;
getListView().post(new Runnable() {
@Override
public void run() {
getListView().setSelection(selectedIndex);
}
});
break;
}
}
getListView().requestLayout();
}
@Override @Override
public void onError(final String errorMessage) { public void onError(final String errorMessage) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {

View File

@ -247,7 +247,13 @@ public class SwipeHelper implements View.OnTouchListener {
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mCallback.onDismiss(mView, mToken); mCallback.onDismiss(mView, mToken);
// Reset view presentation // Reset view presentation
setAlpha(mView, 1f);
/*
* Alpha stays at 0, otherwise Android 2.x leaves weird
* artifacts
*/
// setAlpha(mView, 1f);
setTranslationX(mView, 0); setTranslationX(mView, 0);
lp.height = originalHeight; lp.height = originalHeight;
mView.setLayoutParams(lp); mView.setLayoutParams(lp);