use of android.support.v4.app.Fragment in project AppIntro by apl-devs.
the class AppIntroBase method handleBeforeSlideChanged.
/**
* Called before a slide change happens. By returning false, one can disallow the slide change.
*
* @return true, if the slide change should be allowed, else false
*/
private boolean handleBeforeSlideChanged() {
Fragment currentFragment = mPagerAdapter.getItem(pager.getCurrentItem());
LogHelper.d(TAG, String.format("User wants to move away from slide: %s. Checking if this should be allowed...", currentFragment));
// Check if the current fragment implements ISlidePolicy, else a change is always allowed
if (currentFragment instanceof ISlidePolicy) {
ISlidePolicy slide = (ISlidePolicy) currentFragment;
LogHelper.d(TAG, "Current fragment implements ISlidePolicy.");
// Check if policy is fulfilled
if (!slide.isPolicyRespected()) {
LogHelper.d(TAG, "Slide policy not respected, denying change request.");
return false;
}
}
LogHelper.d(TAG, "Change request will be allowed.");
return true;
}
use of android.support.v4.app.Fragment in project platform_frameworks_base by android.
the class RvCompatListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentById(android.R.id.content) == null) {
RecyclerViewFragment fragment = new RecyclerViewFragment();
fragment.layoutManager = createLayoutManager(this);
fragment.adapter = createAdapter();
fm.beginTransaction().add(android.R.id.content, fragment).commit();
}
}
use of android.support.v4.app.Fragment in project making-apps-beautiful by ankurkotwal.
the class ArticleDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article_detail);
// Show the Up button in the action bar.
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
Bundle arguments = new Bundle();
arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
ArticleDetailFragment fragment = new ArticleDetailFragment();
fragment.setArguments(arguments);
return fragment;
}
@Override
public int getCount() {
return DummyContent.ITEMS.size();
}
});
pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
if (DummyContent.ITEMS.get(i).id.equals(startId)) {
pager.setCurrentItem(i);
return;
}
}
}
use of android.support.v4.app.Fragment in project making-apps-beautiful by ankurkotwal.
the class ArticleDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article_detail);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
Bundle arguments = new Bundle();
arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
ArticleDetailFragment fragment = new ArticleDetailFragment();
fragment.setArguments(arguments);
return fragment;
}
@Override
public int getCount() {
return DummyContent.ITEMS.size();
}
});
pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
if (DummyContent.ITEMS.get(i).id.equals(startId)) {
pager.setCurrentItem(i);
return;
}
}
}
use of android.support.v4.app.Fragment in project making-apps-beautiful by ankurkotwal.
the class ArticleDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article_detail);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
Bundle arguments = new Bundle();
arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
ArticleDetailFragment fragment = new ArticleDetailFragment();
fragment.setArguments(arguments);
return fragment;
}
@Override
public int getCount() {
return DummyContent.ITEMS.size();
}
});
pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
if (DummyContent.ITEMS.get(i).id.equals(startId)) {
pager.setCurrentItem(i);
return;
}
}
}
Aggregations