Ejemplo n.º 1
1
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setupDrawer();
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    MetricsManager.register(getApplication());

    mContext = this;

    if (mPreferences.useAutoSync()) {
      SyncScheduler.schedule(this, mPreferences.isRequiresCharging());
    }

    Intent i = getIntent();
    if (i != null) {
      mOpenChangelog = i.getBooleanExtra(EXTRA_FROM_NOTIFICATION, false);
      i.removeExtra(EXTRA_FROM_NOTIFICATION);
    }

    int filterId = Filters.TAB_ALL;
    if (savedInstanceState != null && !mOpenChangelog) {
      filterId = savedInstanceState.getInt("tab_id", Filters.TAB_ALL);
      AppLog.d("Restore tab: " + filterId);
    }

    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(mViewPager);
    mViewPager.setCurrentItem(filterId);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    mRefreshAnim = new MenuItemAnimation(this, R.anim.rotate);
  }
  private void setUpPagerAndTabs() {
    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter =
        new StreamMediaPlayerPagerAdapter(StreamVideoActivity.this, getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setOffscreenPageLimit(2);
    tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setTabsFromPagerAdapter(pagerAdapter);
    tabLayout.setupWithViewPager(pager);
    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            pager.setCurrentItem(tab.getPosition());
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
            if (tab.getPosition() == 0) {
              pagerAdapter.mFragment.hideAll();
            }
          }

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recommend);
    SwipeBackHelper.getCurrentPage(this).setSwipeBackEnable(false);
    ButterKnife.bind(this);
    back.setOnClickListener(v -> finish());
    viewpager.setAdapter(pagerAdapter = new SeedFragmentListAdapter(getSupportFragmentManager()));
    tabs.setupWithViewPager(viewpager);
    viewpager.setCurrentItem(getIntent().getIntExtra("type", 0));
    tabs.setTabTextColors(
        getResources().getColor(R.color.gray), getResources().getColor(R.color.orange));
    tabs.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            title.setText(tab.getText());
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Ejemplo n.º 4
0
 private void initTabs() {
   tabLayout = (TabLayout) findViewById(R.id.tab_layout);
   tabLayout.addTab(tabLayout.newTab().setText(titles[0]));
   tabLayout.addTab(tabLayout.newTab().setText(titles[1]));
   tabLayout.addTab(tabLayout.newTab().setText(titles[2]));
   tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
 }
Ejemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_activity);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
      setupDrawerContent(navigationView);
    }

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
      setupViewPager(viewPager);
    }

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
  }
 private void setUpTabLayoutAndViewPager() {
   ContentPagerAdapter contentPagerAdapter = new ContentPagerAdapter(getSupportFragmentManager());
   mViewPager.setAdapter(contentPagerAdapter);
   mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
   mTabLayout.setTabsFromPagerAdapter(contentPagerAdapter);
   mTabLayout.setupWithViewPager(mViewPager);
 }
Ejemplo n.º 7
0
 private void setupTablayout() {
   tabLayout = (TabLayout) findViewById(R.id.tabLayout);
   tabLayout.setupWithViewPager(viewPager);
   // 如果是三个,则是下面的固定的模式
   // tabLayout.setTabMode(TabLayout.MODE_FIXED);
   tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
 }
Ejemplo n.º 8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
  }
Ejemplo n.º 9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_exam217);

    // 테이블레이아웃
    mTabLayout = (TabLayout) findViewById(R.id.tablayout);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);

    // 탭설정하기
    mTabLayout.addTab(mTabLayout.newTab().setText("플레이어"));
    mTabLayout.addTab(mTabLayout.newTab().setText("아티스트"));
    mTabLayout.addTab(mTabLayout.newTab().setText("노래"));

    // view에 들어갈 데이터를 준비해야 한다.
    mData = new ArrayList<>();
    mData.add(new ArtistFragment());

    // Adapter 준비
    mAdapter = new MyPagerAdater(getSupportFragmentManager(), mData);

    // view에 어뎁터 붙이기
    mViewPager.setAdapter(mAdapter);

    // 탭레이아웃 붙히기 (뷰페이저와 탭레이아웃 연결 하기)
    mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
  }
Ejemplo n.º 10
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.rank_dialog, container, false);

    ViewGroup.LayoutParams lp = mRoot.findViewById(R.id.rank_layout).getLayoutParams();
    lp.width = getContext().getResources().getDisplayMetrics().widthPixels * 3 / 4;
    lp.height = getContext().getResources().getDisplayMetrics().heightPixels * 3 / 4;
    mRoot.findViewById(R.id.rank_layout).setLayoutParams(lp);

    viewPager = (ViewPager) mRoot.findViewById(R.id.rank_viewpager);
    pagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
    tabLayout = (TabLayout) mRoot.findViewById(R.id.rank_tablayout);

    initFragment();
    viewPager.setAdapter(pagerAdapter);

    tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.Golden));

    // viewPager.addOnPageChangeListener(new
    // TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    // tabLayout.setOnTabSelectedListener(new
    // TabLayout.ViewPagerOnTabSelectedListener(viewPager));

    tabLayout.setupWithViewPager(viewPager);

    mRoot.findViewById(R.id.left_btn).setOnClickListener(this);
    mRoot.findViewById(R.id.right_btn).setOnClickListener(this);

    return mRoot;
  }
Ejemplo n.º 11
0
  private void updateTabs() {
    if (tabTitles != null) {

      for (DiscoverTab tabTitle : tabTitles) {

        TabLayout.Tab tab = tabBar.newTab();

        tab.setText(tabTitle.getTitle());

        tabBar.addTab(tab);

        // 根据内容类型,来设置指定的Fragment
        String type = tabTitle.getContentType();

        if ("recommend".equals(type)) {
          subFragments.add(new DiscoverRecommendFragment());
        } else if ("category".equals(type)) {
          subFragments.add(new DiscoverCategoryFragment());
        } else if ("live".equals(type)) {
          subFragments.add(new DiscoverLiveFragment());
        } else if ("ranking".equals(type)) {
          subFragments.add(new DiscoverRankingFragment());
        } else if ("anchor".equals(type)) {
          subFragments.add(new DiscoverAnchorFragment());
        }
      }

      CommonFragmentPagerAdapter adapter =
          new CommonFragmentPagerAdapter(getChildFragmentManager(), subFragments);
      pager.setAdapter(adapter);
    }
  }
Ejemplo n.º 12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    try {
      super.onCreate(savedInstanceState);
    } catch (BaseActivity.GoodException e) {
      return;
    }
    setContentView(R.layout.activity_repository);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    pager = (ViewPager) findViewById(R.id.viewPager);
    aAdapter = new AAdapter(getSupportFragmentManager());
    pager.setAdapter(aAdapter);
    tabLayout.setupWithViewPager(pager);
    Log.d(RepositoryActivity.class.getName(), "onCreate activity=" + this);
    if (savedInstanceState == null) {
      if (getIntent().getBooleanExtra(EXTRA_IS_FIRST_IN, false)) {
        pager.setCurrentItem(2);
        new LeadDialog().show(getFragmentManager(), LeadDialog.class.getName());
      }
    }
  }
Ejemplo n.º 13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mCoordinator = (CoordinatorLayout) findViewById(R.id.root_coordinator);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mToolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(mToolbar);

    navigationView = (NavigationView) findViewById(R.id.navigation_drawer);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);

    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    mAdapter = new TabPagerAdapter(this, getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.view_pager);
    mPager.setAdapter(mAdapter);
    // Notice how the Tab Layout links with the Pager Adapter
    mTabLayout.setTabsFromPagerAdapter(mAdapter);

    // Notice how The Tab Layout adn View Pager object are linked
    mTabLayout.setupWithViewPager(mPager);
    mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
    if (getIntent() != null) {
      mPager.setCurrentItem(getIntent().getIntExtra("tab", 0));
    }
    fragmentManager = getSupportFragmentManager();
  }
Ejemplo n.º 14
0
  private void configViews() {

    // 设置显示Toolbar
    setSupportActionBar(mToolbar);

    // 设置Drawerlayout开关指示器,即Toolbar最左边的那个icon
    ActionBarDrawerToggle mActionBarDrawerToggle =
        new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close);
    mActionBarDrawerToggle.syncState();
    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);

    // 给NavigationView填充顶部区域,也可在xml中使用app:headerLayout="@layout/header_nav"来设置
    mNavigationView.inflateHeaderView(R.layout.view_nav_header);
    // 给NavigationView填充Menu菜单,也可在xml中使用app:menu="@menu/menu_nav"来设置
    mNavigationView.inflateMenu(R.menu.menu_nav);
    // 自己写的方法,设置NavigationView中menu的item被选中后要执行的操作
    onNavgationViewMenuItemSelected(mNavigationView);

    // 初始化ViewPager的适配器,并设置给它
    pageAdapter = new CardPageAdapter(getSupportFragmentManager(), mTitles);
    mViewPager.setAdapter(pageAdapter);
    // 设置ViewPager最大缓存的页面个数
    mViewPager.setOffscreenPageLimit(5);
    // 给ViewPager添加页面动态监听器(为了让Toolbar中的Title可以变化相应的Tab的标题)
    mViewPager.addOnPageChangeListener(this);

    mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    // 将TabLayout和ViewPager进行关联,让两者联动起来
    mTabLayout.setupWithViewPager(mViewPager);
    // 设置Tablayout的Tab显示ViewPager的适配器中的getPageTitle函数获取到的标题
    mTabLayout.setTabsFromPagerAdapter(pageAdapter);

    // 设置FloatingActionButton的点击事件
    mFloatingActionButton.setOnClickListener(this);
  }
Ejemplo n.º 15
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();
  }
Ejemplo n.º 16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.showUpdateDialogIfNecessary(this);
    setContentView(R.layout.activity_repcast);
    if (savedInstanceState == null) {
      mPagerAdapter =
          new RepcastPageAdapter(getSupportFragmentManager(), this, getApplicationContext());
    } else {
      mBackSelectFileFragments.addAll(
          Arrays.asList(savedInstanceState.getParcelableArray(INSTANCE_STATE_BACK_STACK_FILES)));
      mBackTorrentFragments.addAll(
          Arrays.asList(savedInstanceState.getParcelableArray(INSTANCE_STATE_BACK_STACK_TORRENTS)));
      mPagerAdapter =
          new RepcastPageAdapter(
              getSupportFragmentManager(),
              getApplicationContext(),
              (JsonDirectory.JsonFileDir) mBackSelectFileFragments.peek(),
              (JsonTorrent.JsonTorrentResult) mBackTorrentFragments.peek());
    }
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setCurrentItem(RepcastPageAdapter.FILE_INDEX);
    mViewPager.addOnPageChangeListener(this);

    completeOnCreate(savedInstanceState, true);
    tabLayout.setupWithViewPager(mViewPager);
  }
Ejemplo n.º 17
0
  private void setUI() {

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    if (toolbar != null) {
      toolbar.setTitleTextColor(getResources().getColor(R.color.white));
    }

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText(R.string.current_task)); // создание вкладок
    tabLayout.addTab(tabLayout.newTab().setText(R.string.done_task)); // создание вкладок

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    TabAdapter tabAdapter = new TabAdapter(fragmentManager, 2); // 2 - кол-во вкладок

    viewPager.setAdapter(tabAdapter);
    viewPager.addOnPageChangeListener(
        new TabLayout.TabLayoutOnPageChangeListener(
            tabLayout)); // слушатель на смены события вкладок

    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(
                tab.getPosition()); // передаем необходимый для отображения фрагмент
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override // выбран ранее выбранный таб
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Ejemplo n.º 18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(view.getContext(), StatisticsActivity.class);
            startActivity(intent);
          }
        });
  }
Ejemplo n.º 19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_library);
    setTitle(R.string.title_activity_library);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Page adapter
    SectionsPagerAdapter sectionsPagerAdapter =
        new SectionsPagerAdapter(getSupportFragmentManager());
    ViewPager viewPager = (ViewPager) findViewById(R.id.container);
    viewPager.setAdapter(sectionsPagerAdapter);

    initActivityState();

    // Media service
    Intent intent = new Intent(this, MediaService.class);
    startService(intent);

    // Tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    // TODO: Attach a content observer to listen for MediaStore changes.
    //       This will require changes to many components to deal with all the edge cases.
    //       There may be some noise around this as it appears the observer is notified when
    //       tracks are simply accessed.
  }
Ejemplo n.º 20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    /** * Begin generating dummy data for In-Memory implementation ** */

    //        expenseManager = new InMemoryDemoExpenseManager();
    expenseManager = new PersistentExpenseManager();

    /** * END ** */
  }
Ejemplo n.º 21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_info);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    // Back button
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Set title if object exists.
    MalwareObject malwareObject = getIntent().getExtras().getParcelable("malware");
    if (malwareObject != null) {
      getSupportActionBar().setTitle(malwareObject.getName());
    }
  }
Ejemplo n.º 22
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);
     }
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    Intent get_weight = getIntent();

    Bundle extras = get_weight.getExtras();
    if (extras != null) {
      weight_input = extras.getString("weight").toString();

      //            System.out.println(weight_input);

    }
  }
Ejemplo n.º 24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_touristic_point);

    // Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setSubtitleTextColor(Color.WHITE);
    setSupportActionBar(toolbar);

    // Create the adapter that will return a fragment for each of the sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.addOnPageChangeListener(this);

    // Tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Recebendo dados da outra activity
    Intent intent = getIntent();
    int id = intent.getExtras().getInt("id");
    touristicPoint = DatabaseDAO.getInstance().getTouristicPointByID(id);
  }
Ejemplo n.º 25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    viewPager = (ViewPager) findViewById(R.id.tabanim_viewpager);
    setupViewPager(viewPager);

    Bitmap bm =
        decodeSampledBitmapFromResource(getResources(), R.drawable.fondo_chat_app, 500, 500);
    BitmapDrawable d = new BitmapDrawable(getResources(), bm);
    viewPager.setBackground(d);

    tabLayout = (TabLayout) findViewById(R.id.tabanim_tabs);
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setupWithViewPager(viewPager);

    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
            if (tab.getPosition() == 1) {
              if (hstl != null) {
                Log.d("NULL???", "No lo es");
                // This in lanscape doesn't work...fix it!
                hstl.mostrarElems();
              } else {
                Log.d("NULL???", "Lo es");
              }
            }
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });

    // Change the icon
    android.support.v7.app.ActionBar ab = getSupportActionBar();
    ab.setDisplayShowHomeEnabled(true);
    ab.setIcon(R.mipmap.logo_app_sin_pluma);
    ab.setTitle("");
    //

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            sendEmail(tr.getTxtTranslate());
            Log.i("Send email", tr.getTxtTranslate());
          }
        });
  }
 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);
 }
Ejemplo n.º 27
0
  private void initTabs() {
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    TabsFragmentAdapter adapter = new TabsFragmentAdapter(this, getSupportFragmentManager());
    viewPager.setAdapter(adapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    tabLayout.setupWithViewPager(viewPager);
  }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.properties_activity);

    final TableFragment tableFragment = TableFragment.getInstance();

    if (tableFragment != null) {
      supportPostponeEnterTransition();

      setEnterSharedElementCallback(tableFragment.mSharedElementCallback);

      /*
       * Work around shared view alpha state not being restored on exit transition finished.
       */
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow()
            .getDecorView()
            .addOnAttachStateChangeListener(
                new View.OnAttachStateChangeListener() {
                  @Override
                  public void onViewAttachedToWindow(View v) {}

                  @Override
                  public void onViewDetachedFromWindow(View v) {
                    if (PropertiesActivity.this.isFinishing()) {
                      tableFragment.onExitTransitionFinished();
                    }
                  }
                });
      }
    }

    ElementProperties elementProperties =
        Database.getInstance(this)
            .getElementProperties(getIntent().getIntExtra(EXTRA_ATOMIC_NUMBER, 1));
    mWikipediaUrl = elementProperties.getWikipediaLink();

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(elementProperties.getName());

    Bundle bundle = new Bundle();
    bundle.putSerializable(ARGUMENT_PROPERTIES, elementProperties);

    ViewPagerAdapter pagerAdapter = new ViewPagerAdapter(this);
    pagerAdapter.addPage(R.string.fragment_title_properties, PropertiesFragment.class, bundle);
    pagerAdapter.addPage(R.string.fragment_title_isotopes, IsotopesFragment.class, bundle);

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
  }
Ejemplo n.º 29
0
  private void initViewPager(View view) {
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mTabLayout = (TabLayout) view.findViewById(R.id.tabs);

    mViewPager.setAdapter(new NewsPagerAdapter(getActivity(), getFragmentManager()));
    mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    mTabLayout.setupWithViewPager(mViewPager);
    mTabLayout.setTabsFromPagerAdapter(mViewPager.getAdapter());
  }
 private void initViewPagerAndTabs() {
   ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
   PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager());
   pagerAdapter.addFragment(PartThreeFragment.createInstance(20), "One");
   pagerAdapter.addFragment(PartThreeFragment.createInstance(4), "Two");
   viewPager.setAdapter(pagerAdapter);
   TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
   tabLayout.setupWithViewPager(viewPager);
 }