Reset spinner selection

This makes sure that when you go back to the spinner screen, the
selection is the one corresponding to the current profile.

Bug: 17378446
Change-Id: I536cc2701f9481986a63df1b01a38151edf2fa83
This commit is contained in:
Alexandra Gherghina
2014-09-18 10:59:43 +01:00
parent 628d83e736
commit 06cd50177a
3 changed files with 23 additions and 12 deletions

View File

@@ -252,10 +252,10 @@ public class ManageApplications extends Fragment implements
: R.layout.manage_applications_apps, null);
mPinnedHeader = (ViewGroup) mRootView.findViewById(R.id.pinned_header);
if (mOwner.mProfileSpinnerAdapter != null) {
Spinner spinner = (Spinner) inflater.inflate(R.layout.spinner_view, null);
spinner.setAdapter(mOwner.mProfileSpinnerAdapter);
spinner.setOnItemSelectedListener(mOwner);
mPinnedHeader.addView(spinner);
mOwner.mSpinner = (Spinner) inflater.inflate(R.layout.spinner_view, null);
mOwner.mSpinner.setAdapter(mOwner.mProfileSpinnerAdapter);
mOwner.mSpinner.setOnItemSelectedListener(mOwner);
mPinnedHeader.addView(mOwner.mSpinner);
mPinnedHeader.setVisibility(View.VISIBLE);
}
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
@@ -483,6 +483,7 @@ public class ManageApplications extends Fragment implements
private View mRootView;
private ViewPager mViewPager;
private UserSpinnerAdapter mProfileSpinnerAdapter;
private Spinner mSpinner;
private Context mContext;
AlertDialog mResetDialog;
@@ -1045,6 +1046,9 @@ public class ManageApplications extends Fragment implements
int currentTab = mViewPager.getCurrentItem();
intent.putExtra(EXTRA_LIST_TYPE, mTabs.get(currentTab).mListType);
mContext.startActivityAsUser(intent, selectedUser);
// Go back to default selection, which is the first one; this makes sure that pressing
// the back button takes you into a consistent state
mSpinner.setSelection(0);
}
}