Exemplo n.º 1
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   // 需要将ActionDrawerToggle与DrawerLayout的状态同步
   // 将ActionBarDrawerToggle中的drawer图标,设置为ActionBar中的Home-Button的Icon
   super.onPostCreate(savedInstanceState);
   mDrawerToggle.syncState();
 }
Exemplo n.º 2
0
  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    // Sync the toggle state after onRestoreInstanceState has occurred.
    mDrawerToggle.syncState();
  }
Exemplo n.º 3
0
  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    if (drawerToggle != null) {
      drawerToggle.syncState();
    }
  }
 @Override
 protected void onPostCreate(final Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   getCurrentUser();
   if (!isTablet()) { // was
     // Sync the toggle state after onRestoreInstanceState has occurred.
     drawerToggle.syncState();
   }
 }
Exemplo n.º 5
0
  @Override
  protected void initActionbar() {
    actionBar = getSupportActionBar();
    actionBar.setTitle(UIUtils.getString(R.string.app_name));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    actionBarDrawerToggle =
        new ActionBarDrawerToggle(
            this, drawer_layout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
    actionBarDrawerToggle.syncState();
  }
Exemplo n.º 6
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   if (mDrawerToggle != null) {
     mDrawerToggle.syncState();
   }
   /// M: Google update activity title to actionbar in L in this callback, we need update
   /// actionbar again to correct it, if show in ACTION_MANAGE we need skip when
   /// not load out current root(get current as recent).
   RootInfo root = getCurrentRoot();
   if (!(mState.action == ACTION_MANAGE && root.isRecents())) {
     updateActionBar();
   }
 }
Exemplo n.º 7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.dl);
    mViewPager = (ViewPager) findViewById(R.id.vp);
    mTabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip);
    mTabStrip.setTabIndicatorColor(getResources().getColor(R.color.indicatorcolor));

    mViewPager.setAdapter(new MainAdapter(getSupportFragmentManager()));

    mDrawerToggle =
        new ActionBarDrawerToggle(
            this,
            mDrawerLayout,
            R.drawable.ic_drawer_am,
            R.string.drawer_open,
            R.string.drawer_open) {

          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
          }

          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
  }
Exemplo n.º 8
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   mDrawerToogle.syncState();
 }
Exemplo n.º 9
0
 public void syncActionBarToggleState() {
   mActionBarDrawerToggle.syncState();
 }
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onPostCreate(savedInstanceState);
   left_dtToggle.syncState();
 }
Exemplo n.º 11
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) { // for syncing that 3 line icon
   // TODO Auto-generated method stub
   super.onPostCreate(savedInstanceState);
   mDrawerToggle.syncState();
 }
Exemplo n.º 12
0
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // Create the adapter that will return a fragment for each of the five
    // primary sections of the app.

    menuImg = (ImageView) findViewById(R.id.menuImg);
    linearDrawer = (LinearLayout) findViewById(R.id.linear_drawer);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    mDrawerTitles = getResources().getStringArray(R.array.drawer_menu_array);
    mDrawerItemImages = getResources().obtainTypedArray(R.array.drawer_menu_icon_array);

    utility = new Utility(MainActivity.this);
    sharedData = new SharedData(MainActivity.this);
    listner_id = sharedData.getString("ListnerId", "");
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setCurrentItem(1);
    mViewPager.setSelected(true);

    allCategories = new ArrayList<Categories>();
    featured = new ArrayList<FeaturedShows>();
    popular = new ArrayList<PopularShows>();
    recent = new ArrayList<RecentShows>();
    explore_episodes = new ArrayList<Explore_episodes>();
    explore_shows = new ArrayList<Explore_shows>();
    downloaded_shows = new ArrayList<DownloadShows>();
    following_shows = new ArrayList<FollowingShows>();

    context = MainActivity.this;

    adapter = new FeaturedSliderPagerAdapter(context);
    popularadapter = new PopularShowsAdapter(context);
    recentshowsAdapter = new RecentShowsListAdapter(context);
    episodesadapter = new Explore_Episodesadapter(context);
    showsadapter = new Explore_showsAdapter(context);

    navDrawerItems = new ArrayList<NavDrawerItem>();
    navDrawerItems.add(new NavDrawerItem(mDrawerTitles[0], mDrawerItemImages.getResourceId(0, -1)));
    navDrawerItems.add(new NavDrawerItem(mDrawerTitles[1], mDrawerItemImages.getResourceId(1, -1)));
    navDrawerItems.add(new NavDrawerItem(mDrawerTitles[2], mDrawerItemImages.getResourceId(2, -1)));
    navDrawerItems.add(new NavDrawerItem(mDrawerTitles[3], mDrawerItemImages.getResourceId(3, -1)));
    navDrawerItems.add(new NavDrawerItem(mDrawerTitles[4], mDrawerItemImages.getResourceId(4, -1)));
    navDrawerItems.add(new NavDrawerItem(mDrawerTitles[5], mDrawerItemImages.getResourceId(5, -1)));
    navDrawerItems.add(new NavDrawerItem("Log Out", mDrawerItemImages.getResourceId(5, -1)));

    menuImg.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (mDrawerLayout.isDrawerOpen(Gravity.START)) mDrawerLayout.closeDrawer(Gravity.START);
            else mDrawerLayout.openDrawer(Gravity.START);
          }
        });
    mDrawerToggle =
        new ActionBarDrawerToggle(
            MainActivity.this,
            mDrawerLayout,
            R.drawable.menu,
            R.string.abc_capital_off,
            R.string.abc_capital_on) {
          public void onDrawerClosed(View view) {
            InputMethodManager inputMethodManager =
                (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
            try {
              View focus = MainActivity.this.getCurrentFocus();
              if (focus != null)
                inputMethodManager.hideSoftInputFromWindow(focus.getWindowToken(), 0);
            } catch (Exception e) {
              // e.printStackTrace();
            }
            super.onDrawerClosed(view);
            supportInvalidateOptionsMenu();
          }

          public void onDrawerOpened(View drawerView) {
            InputMethodManager inputMethodManager =
                (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
            try {
              View focus = MainActivity.this.getCurrentFocus();
              if (focus != null)
                inputMethodManager.hideSoftInputFromWindow(focus.getWindowToken(), 0);
            } catch (Exception e) {
              // e.printStackTrace();
            }
            super.onDrawerOpened(drawerView);
            supportInvalidateOptionsMenu();
          }
        };

    /*try {
        PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (PackageManager.NameNotFoundException e) {
    } catch (NoSuchAlgorithmException e) {
    }*/

    nav_adapter = new NavDrawerListAdapter(MainActivity.this, navDrawerItems);
    mDrawerList.setAdapter(nav_adapter);
    supportInvalidateOptionsMenu();

    mDrawerList.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub

          }
        });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    mViewPager.setOffscreenPageLimit(1);
    mViewPager.setOnPageChangeListener(
        new OnPageChangeListener() {

          @Override
          public void onPageSelected(int arg0) {
            // TODO Auto-generated method stub

            switch (arg0) {
              case 0:
                // Categories
                Log.e(
                    "all cat", "" + allCategories.size() + CategoriesFragment.list.getChildCount());
                if (allCategories.size() == 0 && mViewPager.getCurrentItem() == 0) {
                  new getAllCategoriesWS(CategoriesFragment.list, context, listAdapter).execute();
                } else {
                  listAdapter =
                      new CategoriesListAdapter(context, (ArrayList<Categories>) allCategories);

                  // setting list adapter
                  CategoriesFragment.list.setAdapter(listAdapter);

                  listAdapter.notifyDataSetChanged();
                }
                CategoriesFragment.list.invalidate();
                break;
              case 1:
                // Discover
                if (featured.size() == 0 && mViewPager.getCurrentItem() == 1) {
                  new getAllFeaturedWS(DiscoverFragment.viewPager, context, adapter).execute();
                } else {
                  adapter = new FeaturedSliderPagerAdapter(context);
                  DiscoverFragment.viewPager.setAdapter(adapter);
                  adapter.notifyDataSetChanged();
                }

                if (popular.size() == 0 && mViewPager.getCurrentItem() == 1) {
                  new getAllPopularWS(DiscoverFragment.gridViewq, context, popularadapter)
                      .execute();
                } else {
                  popularadapter = new PopularShowsAdapter(context);
                  DiscoverFragment.gridViewq.setAdapter(popularadapter);
                  popularadapter.notifyDataSetChanged();
                }

                DiscoverFragment.gridViewq.setColumnWidth(100);
                DiscoverFragment.gridViewq.setNumColumns(2);

                if (recent.size() == 0 && mViewPager.getCurrentItem() == 1) {
                  new getAllRecentShowsWS(DiscoverFragment.listView, context, recentshowsAdapter)
                      .execute();

                } else {
                  recentshowsAdapter = new RecentShowsListAdapter(context);
                  DiscoverFragment.listView.setAdapter(recentshowsAdapter);
                  recentshowsAdapter.notifyDataSetChanged();
                }

                DiscoverFragment.gridViewq.invalidate();
                DiscoverFragment.listView.invalidate();
                DiscoverFragment.viewPager.invalidate();
                Log.e("list count==", "" + DiscoverFragment.listView.getChildCount());
                break;
              case 2:
                // Explore
                if (explore_episodes.size() == 0 && mViewPager.getCurrentItem() == 2) {
                  new getAllExploreEpisodesWS(
                          ExploreFragment.gridView_episodes, context, episodesadapter)
                      .execute();
                } else {
                  ExploreFragment.gridView_episodes.setAdapter(episodesadapter);
                  episodesadapter.notifyDataSetChanged();
                }

                ExploreFragment.gridView_episodes.setColumnWidth(100);
                ExploreFragment.gridView_episodes.setNumColumns(2);

                if (explore_shows.size() == 0 && mViewPager.getCurrentItem() == 2) {
                  new getAllExploreShowsWS(ExploreFragment.gridView_shows, context, showsadapter)
                      .execute();
                } else {
                  ExploreFragment.gridView_shows.setAdapter(showsadapter);
                  showsadapter.notifyDataSetChanged();
                }

                ExploreFragment.gridView_shows.setColumnWidth(100);
                ExploreFragment.gridView_shows.setNumColumns(2);

                ExploreFragment.toggleButton.setChecked(true);
                ExploreFragment.gridView_episodes.setVisibility(View.VISIBLE);
                ExploreFragment.gridView_shows.setVisibility(View.GONE);
                ExploreFragment.gridView_episodes.bringToFront();
                ExploreFragment.gridView_episodes.invalidate();
                ExploreFragment.gridView_shows.invalidate();

                break;
              case 3:
                // My Shows
                if (recent.size() == 0) {
                  new getAllRecentShowsWS(My_ShowsFragment.latest, context, recentshowsAdapter)
                      .execute();

                } else {
                  recentshowsAdapter = new RecentShowsListAdapter(context);
                  My_ShowsFragment.latest.setAdapter(recentshowsAdapter);
                  recentshowsAdapter.notifyDataSetChanged();
                }

                break;
            }
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub
            switch (arg0) {
              case 1:
                if (firstFlag == 0) {

                  firstFlag = 1;
                  if (featured.size() == 0) {
                    new getAllFeaturedWS(DiscoverFragment.viewPager, context, adapter).execute();
                  } else {
                    adapter = new FeaturedSliderPagerAdapter(context);
                    DiscoverFragment.viewPager.setAdapter(adapter);
                    adapter.notifyDataSetChanged();
                  }

                  if (popular.size() == 0) {
                    new getAllPopularWS(DiscoverFragment.gridViewq, context, popularadapter)
                        .execute();
                  } else {
                    popularadapter = new PopularShowsAdapter(context);
                    DiscoverFragment.gridViewq.setAdapter(popularadapter);
                    popularadapter.notifyDataSetChanged();
                  }

                  DiscoverFragment.gridViewq.setColumnWidth(100);
                  DiscoverFragment.gridViewq.setNumColumns(2);

                  if (recent.size() == 0) {
                    new getAllRecentShowsWS(DiscoverFragment.listView, context, recentshowsAdapter)
                        .execute();

                  } else {
                    recentshowsAdapter = new RecentShowsListAdapter(context);
                    DiscoverFragment.listView.setAdapter(recentshowsAdapter);
                    recentshowsAdapter.notifyDataSetChanged();
                  }

                  DiscoverFragment.gridViewq.requestLayout();
                  DiscoverFragment.listView.requestLayout();
                  Log.e("list count==", "" + DiscoverFragment.listView.getChildCount());
                }
                break;

              default:
                break;
            }
          }

          @Override
          public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub

          }
        });
  }
Exemplo n.º 13
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   Log.i(TAG, "onPostCreate");
   super.onPostCreate(savedInstanceState);
   mDrawerToggle.syncState();
 }
Exemplo n.º 14
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   drawerlistener.syncState();
   super.onPostCreate(savedInstanceState);
 }
Exemplo n.º 15
0
 public void onPostCreate() {
   mDrawerToggle.syncState();
 }
Exemplo n.º 16
0
 public void onConfigurationChanged(Configuration configuration) {
   mThemeImage = getThemeUpIndicator();
   mDrawerImage = mActivity.getResources().getDrawable(mDrawerImageResource);
   syncState();
 }