extended: init tabs with loader info
This commit is contained in:
committed by
Dominik Schürmann
parent
6f74ba2f2d
commit
50248bd570
@@ -78,9 +78,6 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
|
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, TAB_SHARE);
|
|
||||||
|
|
||||||
mDataUri = getIntent().getData();
|
mDataUri = getIntent().getData();
|
||||||
if (mDataUri == null) {
|
if (mDataUri == null) {
|
||||||
Log.e(Constants.TAG, "Data missing. Should be uri of key!");
|
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.
|
// or start new ones.
|
||||||
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
|
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
|
||||||
|
|
||||||
initTabs(mDataUri);
|
|
||||||
|
|
||||||
// switch to tab selected by extra
|
|
||||||
mViewPager.setCurrentItem(switchToTab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -112,17 +105,18 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
setContentView(R.layout.view_key_adv_activity);
|
setContentView(R.layout.view_key_adv_activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTabs(Uri dataUri) {
|
private void initTabs(Uri dataUri, boolean hasSecret) {
|
||||||
PagerTabStripAdapter adapter = new PagerTabStripAdapter(this);
|
PagerTabStripAdapter adapter = new PagerTabStripAdapter(this);
|
||||||
mViewPager.setAdapter(adapter);
|
mViewPager.setAdapter(adapter);
|
||||||
|
|
||||||
Bundle shareBundle = new Bundle();
|
Bundle shareBundle = new Bundle();
|
||||||
shareBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri);
|
shareBundle.putParcelable(ViewKeyAdvShareFragment.ARG_DATA_URI, dataUri);
|
||||||
adapter.addTab(ViewKeyAdvShareFragment.class,
|
adapter.addTab(ViewKeyAdvShareFragment.class,
|
||||||
shareBundle, getString(R.string.key_view_tab_share));
|
shareBundle, getString(R.string.key_view_tab_share));
|
||||||
|
|
||||||
Bundle userIdsBundle = new Bundle();
|
Bundle userIdsBundle = new Bundle();
|
||||||
userIdsBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri);
|
userIdsBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri);
|
||||||
|
userIdsBundle.putBoolean(ViewKeyAdvUserIdsFragment.ARG_HAS_SECRET, hasSecret);
|
||||||
adapter.addTab(ViewKeyAdvUserIdsFragment.class,
|
adapter.addTab(ViewKeyAdvUserIdsFragment.class,
|
||||||
userIdsBundle, getString(R.string.section_user_ids));
|
userIdsBundle, getString(R.string.section_user_ids));
|
||||||
|
|
||||||
@@ -138,6 +132,12 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
|
|
||||||
// update layout after operations
|
// update layout after operations
|
||||||
mSlidingTabLayout.setViewPager(mViewPager);
|
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.
|
// These are the rows that we will retrieve.
|
||||||
@@ -216,6 +216,8 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
|
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
|
||||||
mSlidingTabLayout.setBackgroundColor(color);
|
mSlidingTabLayout.setBackgroundColor(color);
|
||||||
|
|
||||||
|
initTabs(mDataUri, isSecret);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,15 +43,16 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
|||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
|
public static final String ARG_HAS_SECRET = "has_secret";
|
||||||
|
|
||||||
private ListView mUserIds;
|
private ListView mUserIds;
|
||||||
|
|
||||||
private static final int LOADER_ID_UNIFIED = 0;
|
private static final int LOADER_ID_USER_IDS = 0;
|
||||||
private static final int LOADER_ID_USER_IDS = 1;
|
|
||||||
|
|
||||||
private UserIdsAdapter mUserIdsAdapter;
|
private UserIdsAdapter mUserIdsAdapter;
|
||||||
|
|
||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
|
private boolean mHasSecret;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user