Search in sources :

Example 31 with Fragment

use of androidx.fragment.app.Fragment in project Android-skin-support by ximsfei.

the class MainActivity method initViews.

private void initViews() {
    mFragments = new ArrayList<>();
    mFragments.add(new HomeFragment());
    mFragments.add(new DiscoveryFragment());
    mFragments.add(new MineFragment());
    mContainerVp.setAdapter(new FragmentStateAdapter(this) {

        @NonNull
        @Override
        public Fragment createFragment(int position) {
            return mFragments.get(position);
        }

        @Override
        public int getItemCount() {
            return mFragments.size();
        }
    });
    mContainerVp.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {

        @Override
        public void onPageSelected(int position) {
            mMenuBnv.getMenu().getItem(position).setChecked(true);
            setTitle(mMenuBnv.getMenu().getItem(position).getTitle());
        }
    });
    mMenuBnv.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch(item.getItemId()) {
                case R.id.bnv_home:
                    mContainerVp.setCurrentItem(0);
                    return true;
                case R.id.bnv_discovery:
                    mContainerVp.setCurrentItem(1);
                    return true;
                case R.id.bnv_mine:
                    mContainerVp.setCurrentItem(2);
                    return true;
            }
            return false;
        }
    });
}
Also used : MineFragment(skin.support.mobile.demo.fragment.MineFragment) MenuItem(android.view.MenuItem) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) HomeFragment(skin.support.mobile.demo.fragment.HomeFragment) Fragment(androidx.fragment.app.Fragment) HomeFragment(skin.support.mobile.demo.fragment.HomeFragment) DiscoveryFragment(skin.support.mobile.demo.fragment.DiscoveryFragment) MineFragment(skin.support.mobile.demo.fragment.MineFragment) ViewPager2(androidx.viewpager2.widget.ViewPager2) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) NonNull(androidx.annotation.NonNull) DiscoveryFragment(skin.support.mobile.demo.fragment.DiscoveryFragment)

Example 32 with Fragment

use of androidx.fragment.app.Fragment in project Conversations by siacs.

the class BlocklistActivity method showEnterJidDialog.

protected void showEnterJidDialog() {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    EnterJidDialog dialog = EnterJidDialog.newInstance(null, getString(R.string.block_jabber_id), getString(R.string.block), null, account.getJid().asBareJid().toEscapedString(), true, false);
    dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
        Blockable blockable = new RawBlockable(account, contactJid);
        if (xmppConnectionService.sendBlockRequest(blockable, false)) {
            Toast.makeText(BlocklistActivity.this, R.string.corresponding_conversations_closed, Toast.LENGTH_SHORT).show();
        }
        return true;
    });
    dialog.show(ft, "dialog");
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) RawBlockable(eu.siacs.conversations.entities.RawBlockable) Fragment(androidx.fragment.app.Fragment) RawBlockable(eu.siacs.conversations.entities.RawBlockable) Blockable(eu.siacs.conversations.entities.Blockable)

Example 33 with Fragment

use of androidx.fragment.app.Fragment in project Conversations by siacs.

the class ChooseContactActivity method showEnterJidDialog.

protected void showEnterJidDialog(XmppUri uri) {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    Jid jid = uri == null ? null : uri.getJid();
    EnterJidDialog dialog = EnterJidDialog.newInstance(mActivatedAccounts, getString(R.string.enter_contact), getString(R.string.select), jid == null ? null : jid.asBareJid().toString(), getIntent().getStringExtra(EXTRA_ACCOUNT), true, false);
    dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
        final Intent request = getIntent();
        final Intent data = new Intent();
        data.putExtra("contact", contactJid.toString());
        data.putExtra(EXTRA_ACCOUNT, accountJid.toEscapedString());
        data.putExtra(EXTRA_SELECT_MULTIPLE, false);
        copy(request, data);
        setResult(RESULT_OK, data);
        finish();
        return true;
    });
    dialog.show(ft, "dialog");
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) Jid(eu.siacs.conversations.xmpp.Jid) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment)

Example 34 with Fragment

use of androidx.fragment.app.Fragment in project Conversations by siacs.

the class ChooseContactActivity method onBackendConnected.

@Override
void onBackendConnected() {
    filterContacts();
    this.mActivatedAccounts.clear();
    for (Account account : xmppConnectionService.getAccounts()) {
        if (account.getStatus() != Account.State.DISABLED) {
            if (Config.DOMAIN_LOCK != null) {
                this.mActivatedAccounts.add(account.getJid().getEscapedLocal());
            } else {
                this.mActivatedAccounts.add(account.getJid().asBareJid().toEscapedString());
            }
        }
    }
    ActivityResult activityResult = this.postponedActivityResult.pop();
    if (activityResult != null) {
        handleActivityResult(activityResult);
    }
    final Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DIALOG);
    if (fragment instanceof OnBackendConnected) {
        ((OnBackendConnected) fragment).onBackendConnected();
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) OnBackendConnected(eu.siacs.conversations.ui.interfaces.OnBackendConnected) ActivityResult(eu.siacs.conversations.ui.util.ActivityResult) Fragment(androidx.fragment.app.Fragment)

Example 35 with Fragment

use of androidx.fragment.app.Fragment in project MVPArms by JessYanCoding.

the class BaseLazyLoadFragment method dispatchParentVisibleState.

/**
 * ViewPager场景下,当前fragment可见时,如果其子fragment也可见,则让子fragment请求数据
 */
private void dispatchParentVisibleState() {
    FragmentManager fragmentManager = getChildFragmentManager();
    List<Fragment> fragments = fragmentManager.getFragments();
    if (fragments.isEmpty()) {
        return;
    }
    for (Fragment child : fragments) {
        if (child instanceof BaseLazyLoadFragment && ((BaseLazyLoadFragment) child).isVisibleToUser) {
            ((BaseLazyLoadFragment) child).tryLoadData();
        }
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Fragment(androidx.fragment.app.Fragment)

Aggregations

Fragment (androidx.fragment.app.Fragment)262 FragmentTransaction (androidx.fragment.app.FragmentTransaction)57 Bundle (android.os.Bundle)49 FragmentManager (androidx.fragment.app.FragmentManager)42 DialogFragment (androidx.fragment.app.DialogFragment)24 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 Intent (android.content.Intent)22 View (android.view.View)22 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18