extended: init tabs with loader info

This commit is contained in:
Vincent Breitmoser
2015-11-02 21:29:53 +01:00
committed by Dominik Schürmann
parent 6f74ba2f2d
commit 50248bd570
2 changed files with 14 additions and 11 deletions

View File

@@ -78,9 +78,6 @@ public class ViewKeyAdvActivity extends BaseActivity implements
mViewPager = (ViewPager) findViewById(R.id.pager);
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
Intent intent = getIntent();
int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, TAB_SHARE);
mDataUri = getIntent().getData();
if (mDataUri == null) {
Log.e(Constants.TAG, "Data missing. Should be uri of key!");
@@ -101,10 +98,6 @@ public class ViewKeyAdvActivity extends BaseActivity implements
// or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
initTabs(mDataUri);
// switch to tab selected by extra
mViewPager.setCurrentItem(switchToTab);
}
@Override
@@ -112,17 +105,18 @@ public class ViewKeyAdvActivity extends BaseActivity implements
setContentView(R.layout.view_key_adv_activity);
}
private void initTabs(Uri dataUri) {
private void initTabs(Uri dataUri, boolean hasSecret) {
PagerTabStripAdapter adapter = new PagerTabStripAdapter(this);
mViewPager.setAdapter(adapter);
Bundle shareBundle = new Bundle();
shareBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri);
shareBundle.putParcelable(ViewKeyAdvShareFragment.ARG_DATA_URI, dataUri);
adapter.addTab(ViewKeyAdvShareFragment.class,
shareBundle, getString(R.string.key_view_tab_share));
Bundle userIdsBundle = new Bundle();
userIdsBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri);
userIdsBundle.putBoolean(ViewKeyAdvUserIdsFragment.ARG_HAS_SECRET, hasSecret);
adapter.addTab(ViewKeyAdvUserIdsFragment.class,
userIdsBundle, getString(R.string.section_user_ids));
@@ -138,6 +132,12 @@ public class ViewKeyAdvActivity extends BaseActivity implements
// update layout after operations
mSlidingTabLayout.setViewPager(mViewPager);
// switch to tab selected by extra
Intent intent = getIntent();
int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, TAB_SHARE);
mViewPager.setCurrentItem(switchToTab);
}
// These are the rows that we will retrieve.
@@ -216,6 +216,8 @@ public class ViewKeyAdvActivity extends BaseActivity implements
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
mSlidingTabLayout.setBackgroundColor(color);
initTabs(mDataUri, isSecret);
break;
}
}

View File

@@ -43,15 +43,16 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
LoaderManager.LoaderCallbacks<Cursor> {
public static final String ARG_DATA_URI = "uri";
public static final String ARG_HAS_SECRET = "has_secret";
private ListView mUserIds;
private static final int LOADER_ID_UNIFIED = 0;
private static final int LOADER_ID_USER_IDS = 1;
private static final int LOADER_ID_USER_IDS = 0;
private UserIdsAdapter mUserIdsAdapter;
private Uri mDataUri;
private boolean mHasSecret;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {