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;
}
});
}
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");
}
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");
}
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();
}
}
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();
}
}
}
Aggregations