Don't start new activity when selecting a category
Instead of starting a new activity we use the event bus to scroll the currently displayed list.
This commit is contained in:
parent
eb009db03c
commit
3eb5cfd622
3 changed files with 20 additions and 12 deletions
|
@ -0,0 +1,9 @@
|
|||
package org.ligi.passandroid.events;
|
||||
|
||||
public class TypeFocusEvent {
|
||||
public final String type;
|
||||
|
||||
public TypeFocusEvent(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import org.ligi.passandroid.App;
|
|||
import org.ligi.passandroid.R;
|
||||
import org.ligi.passandroid.events.NavigationOpenedEvent;
|
||||
import org.ligi.passandroid.events.SortOrderChangeEvent;
|
||||
import org.ligi.passandroid.events.TypeFocusEvent;
|
||||
import org.ligi.passandroid.helper.CategoryHelper;
|
||||
import org.ligi.passandroid.model.PassStore;
|
||||
import org.ligi.passandroid.ui.views.CategoryIndicatorView;
|
||||
|
@ -181,9 +182,7 @@ public class NavigationFragment extends Fragment {
|
|||
item.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(getActivity(), TicketListActivity.class);
|
||||
i.putExtra("typeFocus", type);
|
||||
startActivity(i);
|
||||
App.getBus().post(new TypeFocusEvent(type));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.ligi.passandroid.R;
|
|||
import org.ligi.passandroid.Tracker;
|
||||
import org.ligi.passandroid.events.NavigationOpenedEvent;
|
||||
import org.ligi.passandroid.events.SortOrderChangeEvent;
|
||||
import org.ligi.passandroid.events.TypeFocusEvent;
|
||||
import org.ligi.passandroid.helper.PassVisualizer;
|
||||
import org.ligi.tracedroid.TraceDroid;
|
||||
import org.ligi.tracedroid.logging.Log;
|
||||
|
@ -77,6 +78,12 @@ public class TicketListActivity extends ActionBarActivity {
|
|||
refreshPasses();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void typeFocus(TypeFocusEvent typeFocusEvent) {
|
||||
scrollToType(typeFocusEvent.type);
|
||||
drawer.closeDrawers();
|
||||
}
|
||||
|
||||
@OnItemClick(R.id.content_list)
|
||||
void lisItemCick(int position) {
|
||||
Intent intent = new Intent(TicketListActivity.this, TicketViewActivity.class);
|
||||
|
@ -179,18 +186,11 @@ public class TicketListActivity extends ActionBarActivity {
|
|||
})
|
||||
|
||||
.setup(mPullToRefreshLayout);
|
||||
|
||||
scrollToTypeIfWanted();
|
||||
}
|
||||
|
||||
private void scrollToTypeIfWanted() {
|
||||
if (!getIntent().hasExtra("typeFocus")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String typeFocus = getIntent().getStringExtra("typeFocus");
|
||||
private void scrollToType(String type) {
|
||||
for (int i = 0; i < passadapter.getCount(); i++) {
|
||||
if (App.getPassStore().getReducedPassbookAt(i).getTypeNotNull().equals(typeFocus)) {
|
||||
if (App.getPassStore().getReducedPassbookAt(i).getTypeNotNull().equals(type)) {
|
||||
listView.setSelection(i);
|
||||
return; // we are done
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue