Example #1
0
  private void setFragemnt(final Fragment fragment, CharSequence title) {
    if (fragment == null) return;

    toolbarTitle = title.toString();
    getSupportActionBar().setTitle(toolbarTitle);

    // 如果是TabsFragment,显示TabLayout
    if (fragment instanceof ATabsFragment) {
      tabLayout.setVisibility(View.VISIBLE);
    } else {
      tabLayout.setVisibility(View.GONE);
    }
    // 显示AppBarLayout
    appBarLayout.setExpanded(true, true);

    // .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
    View view = findViewById(R.id.content_frame);
    view.setAlpha(0.0f);
    ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 1.0f);
    anim.setDuration(600);
    anim.start();
    getFragmentManager()
        .beginTransaction()
        .replace(R.id.content_frame, fragment, "MainFragment")
        .commit();
  }
Example #2
0
 private void setupAppBarLayout(Bundle savedInstanceState) {
   // 随着ToolBar的移动,来控制Fab的显示和隐藏
   //        appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
   //
   //            @Override
   //            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
   //                float percent = Math.abs(verticalOffset) * 1.0f /
   // SystemUtils.getActionBarHeight(MainActivity.this);
   //
   //                int translationY = fabBtn.getHeight() +
   // getResources().getDimensionPixelSize(R.dimen.fab_spacing);
   //                fabBtn.setTranslationY(translationY * (percent));
   //            }
   //
   //        });
   if (savedInstanceState != null) {
     Fragment fragment = getFragmentManager().findFragmentByTag("MainFragment");
     // 如果是TabsFragment,显示TabLayout
     if (fragment != null) {
       if (fragment instanceof ATabsFragment) {
         tabLayout.setVisibility(View.VISIBLE);
       } else {
         tabLayout.setVisibility(View.GONE);
       }
       // 显示AppBarLayout
       appBarLayout.setExpanded(true, true);
     }
   }
 }
 private void getVisibility() {
   TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tabLayout);
   tabLayout.setVisibility(View.GONE);
   ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.viewPager);
   viewPager.setVisibility(View.GONE);
   FrameLayout outTabContent = (FrameLayout) getActivity().findViewById(R.id.outTabContent);
   outTabContent.setVisibility(View.VISIBLE);
 }
Example #4
0
  private void setOneFragmentInScreen(FermatFragmentFactory walletFragmentFactory) {

    try {
      WalletNavigationStructure walletRuntime = getWalletRuntimeManager().getLastWallet();
      String walletPublicKey = walletRuntime.getPublicKey();
      String walletCategory = walletRuntime.getWalletCategory();
      String walletType = walletRuntime.getWalletType();

      FermatSession walletSession = getWalletSessionManager().getWalletSession(walletPublicKey);
      String fragment = walletRuntime.getLastActivity().getLastFragment().getType();

      if (walletFragmentFactory != null) {

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.GONE);

        ViewPager pagertabs = (ViewPager) findViewById(R.id.pager);
        pagertabs.setVisibility(View.VISIBLE);

        adapter =
            new TabsPagerAdapter(
                getFragmentManager(),
                getApplicationContext(),
                walletFragmentFactory,
                fragment,
                walletSession,
                getWalletResourcesProviderManager());
        pagertabs.setAdapter(adapter);

        // pagertabs.setCurrentItem();
        final int pageMargin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        pagertabs.setPageMargin(pageMargin);
        // pagertabs.setCurrentItem(tabStrip.getStartItem(), true);

        // tabLayout.setupWithViewPager(pagertabs);
        // pagertabs.setOffscreenPageLimit(tabStrip.getTabs().size());
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #5
0
  private void setOneFragmentInScreen() throws InvalidParameterException {

    SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware();
    SubApps subAppType = subAppRuntimeManager.getLastSubApp().getType();

    com.bitdubai.fermat_android_api.layer.definition.wallet.interfaces.SubAppFragmentFactory
        subAppFragmentFactory = SubAppFragmentFactory.getFragmentFactoryBySubAppType(subAppType);
    String fragment =
        subAppRuntimeManager.getLastSubApp().getLastActivity().getLastFragment().getType();
    SubAppsSession subAppsSession = getSubAppSessionManager().getSubAppsSession(subAppType);

    try {
      if (subAppFragmentFactory != null) {

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.GONE);

        ViewPager pagertabs = (ViewPager) findViewById(R.id.pager);
        pagertabs.setVisibility(View.VISIBLE);

        adapter =
            new TabsPagerAdapter(
                getFragmentManager(),
                getApplicationContext(),
                subAppFragmentFactory,
                fragment,
                subAppsSession,
                getSubAppResourcesProviderManager(),
                getResources());
        pagertabs.setAdapter(adapter);

        final int pageMargin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        pagertabs.setPageMargin(pageMargin);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #6
0
 private void setCategories(List<Category> categories) {
   adapter.setCategories(categories);
   tabs.setTabsFromPagerAdapter(adapter);
   tabs.setVisibility(categories.size() <= 1 ? View.GONE : View.VISIBLE);
 }