Search in sources :

Example 61 with FragmentManager

use of android.app.FragmentManager in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    setContentView(R.layout.media_browser_activity);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.media);
    }
    FragmentManager fm = getFragmentManager();
    fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
    mMediaGridFragment = (MediaGridFragment) fm.findFragmentById(R.id.mediaGridFragment);
    mMediaItemFragment = (MediaItemFragment) fm.findFragmentByTag(MediaItemFragment.TAG);
    mMediaEditFragment = (MediaEditFragment) fm.findFragmentByTag(MediaEditFragment.TAG);
    FragmentTransaction ft = fm.beginTransaction();
    if (mMediaItemFragment != null) {
        ft.hide(mMediaGridFragment);
    }
    if (mMediaEditFragment != null && !mMediaEditFragment.isInLayout()) {
        ft.hide(mMediaItemFragment);
    }
    ft.commitAllowingStateLoss();
    setupAddMenuPopup();
    // if media was shared add it to the library
    handleSharedMedia();
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) ActionBar(android.support.v7.app.ActionBar)

Example 62 with FragmentManager

use of android.app.FragmentManager in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity method onMediaItemSelected.

@Override
public void onMediaItemSelected(int localMediaId) {
    final String tempQuery = mQuery;
    if (mSearchView != null) {
        mSearchView.clearFocus();
    }
    if (mSearchMenuItem != null) {
        MenuItemCompat.collapseActionView(mSearchMenuItem);
    }
    FragmentManager fm = getFragmentManager();
    if (fm.getBackStackEntryCount() == 0) {
        mMediaGridFragment.clearSelectedItems();
        mMediaItemFragment = MediaItemFragment.newInstance(mSite, localMediaId);
        FragmentTransaction ft = fm.beginTransaction();
        ft.hide(mMediaGridFragment);
        ft.add(R.id.media_browser_container, mMediaItemFragment, MediaItemFragment.TAG);
        ft.addToBackStack(null);
        ft.commitAllowingStateLoss();
        mQuery = tempQuery;
    }
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction)

Example 63 with FragmentManager

use of android.app.FragmentManager 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);
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment)

Example 64 with FragmentManager

use of android.app.FragmentManager in project WordPress-Android by wordpress-mobile.

the class PeopleManagementActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    setContentView(R.layout.people_management_activity);
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setElevation(0);
    }
    FragmentManager fragmentManager = getFragmentManager();
    if (savedInstanceState == null) {
        // only delete cached people if there is a connection
        if (NetworkUtils.isNetworkAvailable(this)) {
            PeopleTable.deletePeopleExceptForFirstPage(mSite.getId());
        }
        if (actionBar != null) {
            actionBar.setTitle(R.string.people);
        }
        PeopleListFragment peopleListFragment = PeopleListFragment.newInstance(mSite);
        peopleListFragment.setOnPersonSelectedListener(this);
        peopleListFragment.setOnFetchPeopleListener(this);
        mUsersEndOfListReached = false;
        mFollowersEndOfListReached = false;
        mEmailFollowersEndOfListReached = false;
        mViewersEndOfListReached = false;
        mHasRefreshedUsers = false;
        mHasRefreshedFollowers = false;
        mHasRefreshedEmailFollowers = false;
        mHasRefreshedViewers = false;
        mUsersFetchRequestInProgress = false;
        mFollowersFetchRequestInProgress = false;
        mEmailFollowersFetchRequestInProgress = false;
        mViewersFetchRequestInProgress = false;
        mFollowersLastFetchedPage = 0;
        mEmailFollowersLastFetchedPage = 0;
        fragmentManager.beginTransaction().add(R.id.fragment_container, peopleListFragment, KEY_PEOPLE_LIST_FRAGMENT).commit();
    } else {
        mUsersEndOfListReached = savedInstanceState.getBoolean(KEY_USERS_END_OF_LIST_REACHED);
        mFollowersEndOfListReached = savedInstanceState.getBoolean(KEY_FOLLOWERS_END_OF_LIST_REACHED);
        mEmailFollowersEndOfListReached = savedInstanceState.getBoolean(KEY_EMAIL_FOLLOWERS_END_OF_LIST_REACHED);
        mViewersEndOfListReached = savedInstanceState.getBoolean(KEY_VIEWERS_END_OF_LIST_REACHED);
        mHasRefreshedUsers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_USERS);
        mHasRefreshedFollowers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_FOLLOWERS);
        mHasRefreshedEmailFollowers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_EMAIL_FOLLOWERS);
        mHasRefreshedViewers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_VIEWERS);
        mUsersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_USERS_FETCH_REQUEST_IN_PROGRESS);
        mFollowersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_FOLLOWERS_FETCH_REQUEST_IN_PROGRESS);
        mEmailFollowersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_EMAIL_FOLLOWERS_FETCH_REQUEST_IN_PROGRESS);
        mViewersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_VIEWERS_FETCH_REQUEST_IN_PROGRESS);
        mFollowersLastFetchedPage = savedInstanceState.getInt(KEY_FOLLOWERS_LAST_FETCHED_PAGE);
        mEmailFollowersLastFetchedPage = savedInstanceState.getInt(KEY_EMAIL_FOLLOWERS_LAST_FETCHED_PAGE);
        CharSequence title = savedInstanceState.getCharSequence(KEY_TITLE);
        if (actionBar != null && title != null) {
            actionBar.setTitle(title);
        }
        PeopleListFragment peopleListFragment = getListFragment();
        if (peopleListFragment != null) {
            peopleListFragment.setOnPersonSelectedListener(this);
            peopleListFragment.setOnFetchPeopleListener(this);
        }
    }
}
Also used : FragmentManager(android.app.FragmentManager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 65 with FragmentManager

use of android.app.FragmentManager in project WordPress-Android by wordpress-mobile.

the class PostsListActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    setContentView(R.layout.post_list_activity);
    mIsPage = getIntent().getBooleanExtra(EXTRA_VIEW_PAGES, false);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(getString(mIsPage ? R.string.pages : R.string.posts));
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    FragmentManager fm = getFragmentManager();
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    mPostList = (PostsListFragment) fm.findFragmentById(R.id.postList);
    showErrorDialogIfNeeded(getIntent().getExtras());
}
Also used : FragmentManager(android.app.FragmentManager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

FragmentManager (android.app.FragmentManager)177 FragmentTransaction (android.app.FragmentTransaction)84 Fragment (android.app.Fragment)51 Bundle (android.os.Bundle)22 DocumentInfo (com.android.documentsui.model.DocumentInfo)20 DialogFragment (android.app.DialogFragment)15 RootInfo (com.android.documentsui.model.RootInfo)15 ActionBar (android.support.v7.app.ActionBar)12 Intent (android.content.Intent)11 File (java.io.File)6 MediaRouter (android.media.MediaRouter)5 Uri (android.net.Uri)5 StorageManager (android.os.storage.StorageManager)5 VolumeInfo (android.os.storage.VolumeInfo)5 MenuItem (android.view.MenuItem)5 IOException (java.io.IOException)5 Toolbar (android.support.v7.widget.Toolbar)4 View (android.view.View)4 DialogInterface (android.content.DialogInterface)3 ViewGroup (android.view.ViewGroup)3