Source:
<code>protected void onCollectionLoaded(Collection col) { super.onCollectionLoaded(col); mTemplateAdapter = new TemplatePagerAdapter(getSupportFragmentManager()); mTemplateAdapter.setModel(col.getModels().get(mModelId)); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mTemplateAdapter); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(final int position, final float v, final int i2) { } @Override public void onPageSelected(final int position) { CardTemplateFragment fragment = (CardTemplateFragment) mTemplateAdapter.instantiateItem(mViewPager, position); if (fragment != null) { fragment.updateCss(); } } @Override public void onPageScrollStateChanged(final int position) { } }); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); mSlidingTabLayout.setViewPager(mViewPager); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(R.string.title_activity_template_editor); getSupportActionBar().setSubtitle(col.getModels().get(mModelId).optString("name")); } try { if (mModelBackup == null) { mModelBackup = new JSONObject(col.getModels().get(mModelId).toString()); } } catch (JSONException e) { throw new RuntimeException(e); } Timber.i("CardTemplateEditor:: Card template editor successfully started for model id %d", mModelId); <START> if (mCardId != -1L) { <END> try { Card currentCard = getCol().getCard(mCardId); JSONArray tmpls = mTemplateAdapter.mModel.getJSONArray("tmpls"); for (int tabIndex = 0; tabIndex < tmpls.length(); tabIndex++) { if (currentCard.template().optString("name").equals(tmpls.getJSONObject(tabIndex).optString("name"))) { mViewPager.setCurrentItem(tabIndex); } } } catch (JSONException e) { throw new RuntimeException(e); } } }</code><technical_language>get card ord tab index? I necessary iterate is it? In fact need pass card id, pass ord this code simpler</technical_language>

Target:
protected void onCollectionLoaded(Collection col) { super.onCollectionLoaded(col); mTemplateAdapter = new TemplatePagerAdapter(getSupportFragmentManager()); mTemplateAdapter.setModel(col.getModels().get(mModelId)); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mTemplateAdapter); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(final int position, final float v, final int i2) { } @Override public void onPageSelected(final int position) { CardTemplateFragment fragment = (CardTemplateFragment) mTemplateAdapter.instantiateItem(mViewPager, position); if (fragment != null) { fragment.updateCss(); } } @Override public void onPageScrollStateChanged(final int position) { } }); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); mSlidingTabLayout.setViewPager(mViewPager); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(R.string.title_activity_template_editor); getSupportActionBar().setSubtitle(col.getModels().get(mModelId).optString("name")); } try { if (mModelBackup == null) { mModelBackup = new JSONObject(col.getModels().get(mModelId).toString()); } } catch (JSONException e) { throw new RuntimeException(e); } Timber.i("CardTemplateEditor:: Card template editor successfully started for model id %d", mModelId); if (mOrdId != -1) { mViewPager.setCurrentItem(mOrdId); } }