use of android.app.Fragment in project react-native-navigation by wix.
the class FragmentScreen method addFragment.
private void addFragment() {
try {
Fragment fragment = tryGetFragment();
if (fragment != null) {
addFragment(fragment);
return;
}
android.support.v4.app.Fragment supportFragment = tryGetSupportFragment();
if (supportFragment != null) {
addSupportFragment(supportFragment);
return;
}
throw new RuntimeException("must provide public static method " + CONTRACT_GET_FRAGMENT + " or " + CONTRACT_GET_SUPPORT_FRAGMENT);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of android.app.Fragment in project WordPress-Android by wordpress-mobile.
the class WPMainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
ProfilingUtils.split("WPMainActivity.onCreate");
((WordPress) getApplication()).component().inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mViewPager = (WPViewPager) findViewById(R.id.viewpager_main);
mViewPager.setOffscreenPageLimit(WPMainTabAdapter.NUM_TABS - 1);
mTabAdapter = new WPMainTabAdapter(getFragmentManager());
mViewPager.setAdapter(mTabAdapter);
mConnectionBar = (TextView) findViewById(R.id.connection_bar);
mConnectionBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// slide out the bar on click, then re-check connection after a brief delay
AniUtils.animateBottomBar(mConnectionBar, false);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!isFinishing()) {
checkConnection();
}
}
}, 2000);
}
});
mTabLayout = (WPMainTabLayout) findViewById(R.id.tab_layout);
mTabLayout.createTabs();
mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
// nop
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
//scroll the active fragment's contents to the top when user taps the current tab
Fragment fragment = mTabAdapter.getFragment(tab.getPosition());
if (fragment instanceof OnScrollToTopListener) {
((OnScrollToTopListener) fragment).onScrollToTop();
}
}
});
mAppBarElevation = getResources().getDimensionPixelSize(R.dimen.appbar_elevation);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
AppPrefs.setMainTabIndex(position);
switch(position) {
case WPMainTabAdapter.TAB_MY_SITE:
setTabLayoutElevation(mAppBarElevation);
break;
case WPMainTabAdapter.TAB_READER:
setTabLayoutElevation(0);
break;
case WPMainTabAdapter.TAB_ME:
setTabLayoutElevation(mAppBarElevation);
break;
case WPMainTabAdapter.TAB_NOTIFS:
setTabLayoutElevation(mAppBarElevation);
Fragment fragment = mTabAdapter.getFragment(position);
if (fragment instanceof OnScrollToTopListener) {
((OnScrollToTopListener) fragment).onScrollToTop();
}
break;
}
trackLastVisibleTab(position, true);
}
@Override
public void onPageScrollStateChanged(int state) {
// noop
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// animate its fab to match
if (position == WPMainTabAdapter.TAB_MY_SITE) {
EventBus.getDefault().post(new MainViewPagerScrolled(positionOffset));
}
}
});
if (savedInstanceState == null) {
if (FluxCUtils.isSignedInWPComOrHasWPOrgSite(mAccountStore, mSiteStore)) {
// open note detail if activity called from a push, otherwise return to the tab
// that was showing last time
boolean openedFromPush = (getIntent() != null && getIntent().getBooleanExtra(ARG_OPENED_FROM_PUSH, false));
if (openedFromPush) {
getIntent().putExtra(ARG_OPENED_FROM_PUSH, false);
if (getIntent().hasExtra(NotificationsPendingDraftsReceiver.POST_ID_EXTRA)) {
launchWithPostId(getIntent().getIntExtra(NotificationsPendingDraftsReceiver.POST_ID_EXTRA, 0), getIntent().getBooleanExtra(NotificationsPendingDraftsReceiver.IS_PAGE_EXTRA, false));
} else {
launchWithNoteId();
}
} else {
int position = AppPrefs.getMainTabIndex();
if (mTabAdapter.isValidPosition(position) && position != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(position);
}
checkMagicLinkSignIn();
}
} else {
ActivityLauncher.showSignInForResult(this);
}
}
startService(new Intent(this, NotificationsScreenLockWatchService.class));
// ensure the deep linking activity is enabled. It may have been disabled elsewhere and failed to get re-enabled
WPActivityUtils.enableComponent(this, ReaderPostPagerActivity.class);
// monitor whether we're not the default app
trackDefaultApp();
}
use of android.app.Fragment in project WordPress-Android by wordpress-mobile.
the class PeopleManagementActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
} else if (item.getItemId() == R.id.remove_person) {
confirmRemovePerson();
return true;
} else if (item.getItemId() == R.id.invite) {
FragmentManager fragmentManager = getFragmentManager();
Fragment peopleInviteFragment = fragmentManager.findFragmentByTag(KEY_PERSON_DETAIL_FRAGMENT);
if (peopleInviteFragment == null) {
peopleInviteFragment = PeopleInviteFragment.newInstance(mSite);
}
if (peopleInviteFragment != null && !peopleInviteFragment.isAdded()) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, peopleInviteFragment, KEY_PEOPLE_INVITE_FRAGMENT);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
} else if (item.getItemId() == R.id.send_invitation) {
FragmentManager fragmentManager = getFragmentManager();
Fragment peopleInviteFragment = fragmentManager.findFragmentByTag(KEY_PEOPLE_INVITE_FRAGMENT);
if (peopleInviteFragment != null) {
((InvitationSender) peopleInviteFragment).send();
}
}
return super.onOptionsItemSelected(item);
}
use of android.app.Fragment in project WordPress-Android by wordpress-mobile.
the class EditPostActivity method onBackPressed.
@Override
public void onBackPressed() {
if (isPhotoChooserShowing()) {
hidePhotoChooser();
return;
}
Fragment imageSettingsFragment = getFragmentManager().findFragmentByTag(ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_TAG);
if (imageSettingsFragment != null && imageSettingsFragment.isVisible()) {
((ImageSettingsDialogFragment) imageSettingsFragment).dismissFragment();
return;
}
if (mViewPager.getCurrentItem() > PAGE_CONTENT) {
if (mViewPager.getCurrentItem() == PAGE_SETTINGS) {
mPost.setFeaturedImageId(mEditPostSettingsFragment.getFeaturedImageId());
mEditorFragment.setFeaturedImageId(mPost.getFeaturedImageId());
}
mViewPager.setCurrentItem(PAGE_CONTENT);
invalidateOptionsMenu();
return;
}
if (mEditorFragment != null && !mEditorFragment.onBackPressed()) {
saveAndFinish();
}
}
use of android.app.Fragment in project WordPress-Android by wordpress-mobile.
the class ReaderPostListActivity method showListFragmentForFeed.
private void showListFragmentForFeed(long feedId) {
if (isFinishing()) {
return;
}
Fragment fragment = ReaderPostListFragment.newInstanceForFeed(feedId);
getFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, getString(R.string.fragment_tag_reader_post_list)).commit();
String title = ReaderBlogTable.getFeedName(feedId);
if (title.isEmpty()) {
title = getString(R.string.reader_title_blog_preview);
}
setTitle(title);
}
Aggregations