public void startMetrialView() {
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);

    dlDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    dtToggle = new ActionBarDrawerToggle(this, dlDrawer, R.string.app_name, R.string.hello_world);
    dlDrawer.setDrawerListener(dtToggle);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new ViewPagerAdapter_1(getSupportFragmentManager(), Titles);
    pager.setAdapter(adapter);

    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(true);
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {

          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.tabsScrollColor);
          }
        });
    tabs.setViewPager(pager);
    ChoiceStartAlarmMenu choiceStartAlarmMenu = new ChoiceStartAlarmMenu(this);
    drawer = (FrameLayout) findViewById(R.id.drawer);
    drawer.addView(choiceStartAlarmMenu);
    //        dlDrawer.closeDrawer(dtToggle);
    dlDrawer.closeDrawer(drawer);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_usertab);
    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Creating The ViewPagerAdapterUserTab and Passing Fragment ManagerDashBoard_MainActivity,
    // Titles fot the Tabs and Number Of Tabs.
    adapter = new ViewPagerAdapterLTab(getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) findViewById(R.id.materialTabHost);
    tabs.setDistributeEvenly(true);
    // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width

    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.accentcolor);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Creating The Toolbar and setting it as the Toolbar for the activity

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

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(
        true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in
               // Available width

    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.tabsScrollColor);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (getIntent().hasExtra("user")) {
      mCurrentUser = getIntent().getExtras().getParcelable("user");
    }
    if (mCurrentUser == null) {
      mCurrentUser = new User("name", "level");
    }

    // set custom toolbar
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mToolbar != null) {
      setSupportActionBar(mToolbar);
    }

    mNavigationDrawerFragment =
        (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // the drawer.
    mNavigationDrawerFragment.setUp(
        R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));

    // the pager
    mArticlePagerAdapter = new UserMetricsPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mArticlePagerAdapter);
    mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.white));
    mSlidingTabLayout.setViewPager(mViewPager);
    mViewPager.setOffscreenPageLimit(3);
  }
 public void setListCategSelection(List<Categorie> listCategorieSelected) {
   adapterViewPager = new SamplePagerAdapter();
   adapterViewPager.setSlidingTabLayout(mSlidingTabLayout);
   adapterViewPager.setData(mapCategCompt, mapCompRen);
   adapterViewPager.setCategorie(listCategorieSelected);
   mViewPager.setAdapter(adapterViewPager);
   mSlidingTabLayout.setViewPager(mViewPager);
 }
  /**
   * Defines what happens when the app is opened up, and the first view the user sees is created.
   * This is where the defining of what what is displayed on each tab is accomplished
   *
   * @param savedInstanceState
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    tpAdapter = new TabsPagerAdapter(getSupportFragmentManager(), tabs, tabsNum);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(tpAdapter);
    tabLayout = (SlidingTabLayout) findViewById(R.id.tabs);
    tabLayout.setDistributeEvenly(
        true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in
               // Available width
    tabLayout.setViewPager(mViewPager);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.humidor, container, false);
    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
    mFragment = new FloatingActionButtonBasicFragment();

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) mRoot.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) mRoot.findViewById(R.id.tabs);
    // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {

          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.accent);
          }

          @Override
          public int getDividerColor(int position) {
            return getResources().getColor(R.color.tab);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
    transaction.replace(R.id.action_button_fragment, mFragment);
    transaction.commit();
    mAnimate = (ViewAnimator) mRoot.findViewById(R.id.cigaradd);
    mAnimate.setInAnimation(
        AnimationUtils.loadAnimation(getActivity(), R.anim.abc_grow_fade_in_from_bottom));
    mAnimate.setOutAnimation(
        AnimationUtils.loadAnimation(getActivity(), R.anim.abc_shrink_fade_out_from_bottom));
    mButton = (Button) mRoot.findViewById(R.id.toggle);
    mButton.setOnClickListener(this);
    return mRoot;
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    adapterViewPager.setSlidingTabLayout(mSlidingTabLayout);
    mViewPager = (ViewPager) view.findViewById(R.id.viewPager);
    mViewPager.setAdapter(adapterViewPager);

    mSlidingTabLayout.setViewPager(mViewPager);

    MultipleSelectionSpinner spinner =
        (MultipleSelectionSpinner) getActivity().findViewById(R.id.spinnerCateg);
    spinner.setVisibility(View.VISIBLE);
    spinner.setLayoutParams(
        new Toolbar.LayoutParams(
            Toolbar.LayoutParams.WRAP_CONTENT,
            Toolbar.LayoutParams.MATCH_PARENT,
            Gravity.TOP | Gravity.RIGHT));
    spinner.setItems(listCategorie);
    spinner.setTabsFragment(this);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_three_tabbed_screen);

    // action bar

    // BEGIN_INCLUDE (setup_viewpager)
    // Get the ViewPager and set it's PagerAdapter so that it can display items
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(new ScreenPagerAdapter());
    // END_INCLUDE (setup_viewpager)

    // BEGIN_INCLUDE (setup_slidingtablayout)
    // Give the SlidingTabLayout the ViewPager, this must be done AFTER the ViewPager has had
    // it's PagerAdapter set.
    mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setViewPager(mViewPager);
    // END_INCLUDE (setup_slidingtablayout)

  }
Example #10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    requestQueue = Volley.newRequestQueue(this);

    editEmailId();
    Cache.INSTANCE.initialize();
    adapter = new TestPagerAdapter(getSupportFragmentManager(), MainActivity.this);

    pager = (CustomPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    //   setSupportActionBar(toolbar);
    setSupportActionBar(toolbar);

    mTabs = (SlidingTabLayout) findViewById(R.id.tabs);

    mTabs.setDistributeEvenly(true);
    mTabs.setViewPager(pager);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

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

    adapter = new ViewPagerAdapter(getSupportFragmentManager(), Titles, Numboftabs);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(true);
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.DeepSkyBlue);
          }
        });
    tabs.setViewPager(pager);
  }
Example #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPreferences = Preferences.getInstance(this);
    LocaleManager.getInstance(this, true);

    setContentView(R.layout.activity_muazzin);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    assert toolbar != null;
    toolbar.setTitle(R.string.app_name);
    setSupportActionBar(toolbar);

    // Set up the ViewPager, attaching the adapter
    MuazzinAdapter muazzinAdapter =
        new MuazzinAdapter(getApplicationContext(), getSupportFragmentManager());
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    assert pager != null;
    pager.setAdapter(muazzinAdapter);
    final SlidingTabLayout indicator = (SlidingTabLayout) findViewById(R.id.indicator);
    assert indicator != null;
    indicator.setViewPager(pager);
  }
Example #13
0
  public void setViewPager(ViewPager navigationPager) {
    mViewPager = navigationPager;
    mAdapter = (EzzePagerAdapter) navigationPager.getAdapter();
    mTabLookup = new View[mAdapter.getCount()];
    super.setViewPager(
        navigationPager,
        new ViewPager.OnPageChangeListener() {

          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          public void onPageSelected(int pageIndex) {
            for (int i = 0; i < mTabLookup.length; i++) {
              if (i != pageIndex) {
                mTabLookup[i].animate().alpha(TAB_DIM_ALPHA).start();
              } else {
                mTabLookup[i].animate().alpha(1.0f).start();
              }
            }
          }

          public void onPageScrollStateChanged(int state) {}
        });
  }
Example #14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.toolbar_fade_in_activity);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbarTab = (Toolbar) findViewById(R.id.toolbar_tab);
    mTabLayout = (SlidingTabLayout) findViewById(R.id.tab_layout);
    mPager = (ViewPager) findViewById(R.id.page);
    mMainLayout = (MyScrollView) findViewById(R.id.main_layout);

    mBackgrounds = new String[] {"#616161", "#9E9E9E", "#F5F5F5"};
    mFragmentList = new ArrayList<>();

    setSupportActionBar(mToolbar);
    // 显示回退按钮
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    for (int i = 0; i < mBackgrounds.length; i++) {
      Fragment fragment = TextFragment.newInstance("Fragment" + i, mBackgrounds[i]);
      mFragmentList.add(fragment);
    }

    mPager.setAdapter(new TagPageAdapter(getSupportFragmentManager()));
    mTabLayout.setViewPager(mPager);
    mMainLayout.setScrollViewListener(
        new MyScrollView.ScrollViewListener() {
          @Override
          public void onScrollChanged(int y) {
            if (y >= 0 && y <= 255) {
              mToolbar.setBackgroundColor(Color.argb(y, 0, 0, 255));
            }
            int[] toolbarLocation = new int[2];
            int[] toolbarTaglocation = new int[2];
            mToolbarTab.getLocationOnScreen(toolbarTaglocation);
            mToolbar.getLocationOnScreen(toolbarLocation);
            Log.d(TAG, toolbarTaglocation[1] + "");
            //
            if (toolbarLocation[1] + mToolbar.getHeight() == toolbarTaglocation[1]) {
              Toast.makeText(mContext, "贴合", Toast.LENGTH_SHORT).show();
              mToolbar.setBackgroundColor(Color.argb(255, 0, 0, 255));
            }
          }
        });

    // 滑动停靠
    GestureDetector.OnGestureListener test =
        new GestureDetector.SimpleOnGestureListener() {
          @Override
          public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            // return super.onFling(e1, e2, velocityX, velocityY);
            // 判断上滑还是下滑
            if (e1 == null) {
              return false;
            }
            Log.d(TAG, "e1:" + e1.getY() + " e2:" + e2.getY());
            if (e2.getY() - e1.getY() > 100) {
              Log.d(TAG, "Filing Down");
              Toast.makeText(mContext, "Filing Down", Toast.LENGTH_SHORT).show();
            } else {
              Log.d(TAG, "Filing Up");
              // Toast.makeText(mContext, "Filing Up", Toast.LENGTH_SHORT).show();
              mMainLayout.smoothScrollTo(0, mToolbarTab.getTop() - mToolbar.getBottom());
              return true;
            }

            return false;
          }
        };
    final GestureDetector gestureDetector = new GestureDetector(mContext, test);

    // 如果是向上快速滑动,直接贴边后继续向上滑
    mMainLayout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            //                int[] toolbarLocation = new int[2];
            //                int[] toolbarTaglocation = new int[2];
            //                mToolbarTab.getLocationOnScreen(toolbarTaglocation);
            //                mToolbar.getLocationOnScreen(toolbarLocation);
            //                //
            //                if (toolbarLocation[1] + mToolbar.getHeight() ==
            // toolbarTaglocation[1]) {
            //                    Toast.makeText(mContext, "贴合", Toast.LENGTH_SHORT).show();
            //                    mToolbar.setBackgroundColor(Color.argb(255, 0, 0, 255));
            //                }

            //                int[] location = new int[2];
            //                mToolbarTab.getLocationOnScreen(location);
            //                //mMainLayout.smoothScrollTo(location[0], mToolbarBottonY);
            //                //mMainLayout.scrollTo(location[0], mToolbarBottonY);
            //                //
            //                if (mToolbar.getBottom() == location[1]) {
            //                    Toast.makeText(mContext, "贴合", Toast.LENGTH_SHORT).show();
            //                    mToolbar.setBackgroundColor(Color.argb(255, 0, 0, 255));
            //                }

            return gestureDetector.onTouchEvent(event);
            // return true; //停止滚动
          }
        });
  }
Example #15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    MainActivity.mContext = getApplicationContext();
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            OpenKeyBoard(getApplicationContext());
          }
        });
    TelephonyManager telephonyManager =
        (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    // register PhoneStateListener
    PhoneStateListener callStateListener =
        new PhoneStateListener() {
          public void onCallStateChanged(int state, String incomingNumber) {
            if (state == TelephonyManager.CALL_STATE_RINGING) {
              // Toast.makeText(getApplicationContext(),"Phone Is Riging",
              // Toast.LENGTH_LONG).show();
              Intent dialogIntent = new Intent(MainActivity.this, PhoneCall.class);
              dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              startActivity(dialogIntent);
            }
            // If incoming call received
            if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
              // Toast.makeText(getApplicationContext(),"Phone is Currently in A call",
              // Toast.LENGTH_LONG).show();
            }

            if (state == TelephonyManager.CALL_STATE_IDLE) {
              // Toast.makeText(getApplicationContext(),"phone is neither ringing nor in a call",
              // Toast.LENGTH_LONG).show();
            }
          }
        };
    telephonyManager.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
    // Creating The Toolbar and setting it as the Toolbar for the activity
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    // setSupportActionBar(toolbar);

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(
        true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in
               // Available width

    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.tabsScrollColor);
          }
        });

    tabs.setPadding(0, 85, 0, 0);
    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
  }
Example #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setTitle("Epic Music");
    // Generate the ActionBar on top of the Activity
    // Note to Self Remove the Navigation bar until find a better way to Navigate multiple decisions
    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    // ViewPager to allow User to swipe to go to next section
    mPager = (ViewPager) findViewById(R.id.MainViewPager);
    FragmentManager fragmentManager = getSupportFragmentManager();

    mPager.setAdapter(new MyPagerAdapter(fragmentManager));

    mTabs = (SlidingTabLayout) findViewById(R.id.slidingTab);
    mTabs.setDistributeEvenly(true);
    mTabs.setBackgroundColor(getResources().getColor(R.color.primaryColor));
    mTabs.setSelectedIndicatorColors(getResources().getColor(R.color.accentColor));

    mTabs.setViewPager(mPager);

    mTabs.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            // Change Title When for selected Page

            switch (position) {
              case 0:
                {
                  setTitle("Epic Music");
                  break;
                }
              case 1:
                {
                  setTitle("Major League Gaming");
                  break;
                }
              case 2:
                {
                  setTitle("Phoenix Wright");

                  break;
                }
              case 3:
                {
                  setTitle("Dota sounds");
                  break;
                }
              case 4:
                {
                  setTitle("Random");

                  break;
                }
              case 5:
                {
                  setTitle("Random 2");

                  break;
                }
            }
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
  }
Example #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_feed);

    gps = new GPSTracker(this);

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

    Display mdisp = getWindowManager().getDefaultDisplay();
    Point mdispSize = new Point();
    mdisp.getSize(mdispSize);
    int maxX = mdispSize.x;
    int maxY = mdispSize.y;

    float dpPadding = convertDpToPixel(20, MainFeedActivity.this);

    pivotX = maxX - (int) dpPadding;
    pivotY = maxY - (int) dpPadding;

    mPager = (ViewPager) findViewById(R.id.loginPagerMain);
    mPager.setAdapter(new MainPagerAdapter(getFragmentManager()));
    mPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            // TODO: scale Floating Action Button size
            Log.d("POSITION_OFFSET", positionOffset + "");
            Log.d("POS_OFFSET_VIEW", whichView + "");
            Log.d("JUST_POS", position + "");

            if (positionOffset < 0.5) {
              if (whichView) {
                //
                // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryColorDark)));

              } else {
                //
                // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor)));
              }
              //                    fabMainFeed.setScaleX((1 - 2 * positionOffset));
              //                    fabMainFeed.setScaleY((1 - 2 * positionOffset));

            } else {

              //
              // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryColorDark)));
              //                    fabMainFeed.setScaleX((2 * positionOffset - 1));
              //                    fabMainFeed.setScaleY((2 * positionOffset - 1));
            }
          }

          @Override
          public void onPageSelected(int position) {
            whichView = !whichView;
          }

          @Override
          public void onPageScrollStateChanged(int state) {
            if (state == ViewPager.SCROLL_STATE_IDLE) {
              // Hide the keyboard.
              ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                  .hideSoftInputFromWindow(mPager.getWindowToken(), 0);
            }
          }
        });

    mTabs = (SlidingTabLayout) findViewById(R.id.loginTabsMain);
    mTabs.setCustomTabView(R.layout.custom_tab_view_main, R.id.mainTabsText);
    mTabs.setDistributeEvenly(true);
    mTabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.primaryColorLight);
          }
        });
    mTabs.setViewPager(mPager);

    navigationView = (NavigationView) findViewById(R.id.navigationView);
    navigationView.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {

            menuItem.setChecked(false);

            mNavItemId = menuItem.getItemId();
            drawerLayout.closeDrawers();

            switch (mNavItemId) {
              case R.id.navProfile:
                Intent profIntent = new Intent(MainFeedActivity.this, ProfileActivity.class);
                startActivity(profIntent);
                return true;
              case R.id.navSettings:
                Intent settingsIntent = new Intent(MainFeedActivity.this, SettingsActivity.class);
                startActivity(settingsIntent);
                return true;
            }
            return false;
          }
        });

    fabMenu = (FloatingActionMenu) findViewById(R.id.fabMenu);
    fabCurrentLocation =
        (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabCurrentLocation);
    fabPickLocation =
        (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabPickLocation);
    fabAirport = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabAirport);

    fabCurrentLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });

    fabPickLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainFeedActivity.this, FSPickLocActivity.class);
            startActivity(intent);
          }
        });

    fabAirport.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });

    //        fabMainFeed = (FloatingActionButton) findViewById(R.id.fabMainFeed);
    //        fabMainFeed.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //
    //                // TODO: expand the FAB to give three options, each launching a different
    // intent
    //                // Can use whichView boolean value to launch the right intent by assigning
    //                // OnClickListener to the 3 options and check the whichView boolean in each
    //
    //                if (whichView) {
    //                    Toast.makeText(MainFeedActivity.this, "SECOND INTENT",
    // Toast.LENGTH_LONG).show();
    //                    Intent intent = new Intent(MainFeedActivity.this,
    // AddForSalePostActivity.class);
    //                    startActivity(intent);
    //
    //                } else {
    //                    Toast.makeText(MainFeedActivity.this, "FIRST INTENT",
    // Toast.LENGTH_LONG).show();
    //                    Intent intent = new Intent(MainFeedActivity.this,
    // AddForSalePostActivity.class);
    //                    startActivity(intent);
    //                }
    //            }
    //        });

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, drawerLayout, toolbar, R.string.openDrawer, R.string.closeDrawer);
    drawerLayout.setDrawerListener(mDrawerToggle);

    toolbar.setTitle("Browse");
    toolbar.setTitleTextColor(getResources().getColor(R.color.whiteColor));
    mPager.setCurrentItem(0);
  }
Example #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Creating The Toolbar and setting it as the Toolbar for the activity

    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(
        (Html.fromHtml("<font color=\"#ffffff\">" + getString(R.string.app_name) + "</font>")));
    actionBar.setDisplayShowHomeEnabled(true);

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(
        true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in
               // Available width
    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.ColorAccent);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);

    // 급식 및 학사 일정 Download 등 처리
    Calendar cal = Calendar.getInstance();
    int month = cal.get(cal.MONTH) + 1;

    SharedPreferences data = getSharedPreferences("month", MODE_MULTI_PROCESS);
    int dmonth = data.getInt("month", 0);

    SharedPreferences mdata = getSharedPreferences("meal", Context.MODE_MULTI_PROCESS);
    String mealdata = mdata.getString("meal", "");

    SharedPreferences mnmdata = getSharedPreferences("mealnm", Context.MODE_MULTI_PROCESS);
    String mealnmdata = mnmdata.getString("mealnm", "");

    SharedPreferences sdata = getSharedPreferences("sch", Context.MODE_MULTI_PROCESS);
    String schdata = sdata.getString("sch", "");

    SharedPreferences snmdata = getSharedPreferences("schnm", Context.MODE_MULTI_PROCESS);
    String schnmdata = snmdata.getString("schnm", "");

    // 데이터를 다운받은 달이 다른지, 급식 및 학사일정의 데이터가 비어있는지 확인하고 다운로드
    if (dmonth != month
        | mealdata.equals("")
        | mealnmdata.equals("")
        | schdata.equals("")
        | schnmdata.equals("")) {
      Log.d("MainActivity", "Data Downloading...");
      if (isNetworkAvailable() == true) {
        DataThread t = new DataThread(MainActivity.this);
        t.start();
        Toast.makeText(MainActivity.this, getString(R.string.download_start), Toast.LENGTH_SHORT)
            .show();
      } else {
        Log.d("MainActivity", "Internet Connect Failed");
        Toast.makeText(MainActivity.this, getString(R.string.internet_error), Toast.LENGTH_SHORT)
            .show();
      }
    }

    pager.setOffscreenPageLimit(3);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /* Assinging the toolbar object ot the view
    and setting the the Action bar to our toolbar
     */
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);

    mRecyclerView =
        (RecyclerView)
            findViewById(R.id.RecyclerView); // Assigning the RecyclerView Object to the xml View

    mRecyclerView.setHasFixedSize(
        true); // Letting the system know that the list objects are of fixed size

    mAdapter =
        new MyAdapter(
            TITLES, ICONS, NAME, EMAIL,
            PROFILE); // Creating the Adapter of MyAdapter class(which we are going to see in a bit)
    // And passing the titles,icons,header view name, header view email,
    // and header view profile picture

    mRecyclerView.setAdapter(mAdapter); // Setting the adapter to RecyclerView

    mLayoutManager = new LinearLayoutManager(this); // Creating a layout Manager

    mRecyclerView.setLayoutManager(mLayoutManager); // Setting the layout Manager

    Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout); // Drawer object Assigned to the view
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, Drawer, toolbar, R.string.openDrawer, R.string.closeDrawer) {

          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // code here will execute once the drawer is opened( As I dont want anything happened
            // whe drawer is
            // open I am not going to put anything here)
          }

          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            // Code here will execute once drawer is closed
          }
        }; // Drawer Toggle Object Made
    Drawer.setDrawerListener(mDrawerToggle); // Drawer Listener set to the Drawer toggle
    mDrawerToggle.syncState(); // Finally we set the drawer toggle sync State

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(
        true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in
               // Available width

    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.tabsScrollColor);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
  }