Beispiel #1
0
 /** 提供给fragment设置menudrawer触摸模式 */
 public void setMenuDrawerEnable(boolean enable) {
   if (enable) {
     mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
   } else {
     mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_BEZEL);
   }
 }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDrawer = MenuDrawer.attach(this, Position.RIGHT);
    mDrawer.setContentView(R.layout.activity_alloy_list_stock_in);
    mDrawer.setMenuView(R.layout.drawer_layout_for_alloystockin);
    mDrawer.setDropShadowColor(R.color.client_colour_grey_dark);
    ButterKnife.bind(this);
    activity = this;
    SaleActivitiesStatus.isAlloyListInSAlemOduleIsOpen = true;
    bus.register(this);
    finishpreviousActivities();

    next_Bucket.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (SaleActivitiesStatus.isBucketInSalemoduleisopen == true) {
              finish();
              overridePendingTransition(R.anim.no_sliding, R.anim.slide_out_bottom);
            } else {
              startActivity(new Intent(AlloyListSALE.this, SaleBucketActivity.class));
              overridePendingTransition(R.anim.pull_in_right, R.anim.no_sliding);
            }
          }
        });
  }
  @Override
  public void onCreate(Bundle inState) {
    super.onCreate(inState);

    mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT);

    TextView menuView = new TextView(this);
    menuView.setGravity(Gravity.CENTER);
    menuView.setTextColor(0xFFFFFFFF);
    final int padding = dpToPx(16);
    menuView.setPadding(padding, padding, padding, padding);
    menuView.setText(R.string.sample_listactivity);
    mMenuDrawer.setMenuView(menuView);
    mMenuDrawer.setOffsetMenuEnabled(false);

    List<String> items = new ArrayList<String>();
    for (int i = 1; i <= 20; i++) {
      items.add("Item " + i);
    }

    setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));

    // When running on ICS or higher, the "up" button blinks until it is clicked.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      mHandler = new Handler();
      getActionBar().setDisplayHomeAsUpEnabled(true);
      mToggleUpRunnable =
          new Runnable() {
            @Override
            public void run() {
              mDisplayUp = !mDisplayUp;
              getActionBar().setDisplayHomeAsUpEnabled(mDisplayUp);
              mHandler.postDelayed(mToggleUpRunnable, 500);
            }
          };

      mHandler.postDelayed(mToggleUpRunnable, 500);

      mMenuDrawer.setOnDrawerStateChangeListener(
          new MenuDrawer.OnDrawerStateChangeListener() {
            @Override
            public void onDrawerStateChange(int oldState, int newState) {
              if (newState == MenuDrawer.STATE_OPEN) {
                mHandler.removeCallbacks(mToggleUpRunnable);
                if (!mDisplayUp) getActionBar().setDisplayHomeAsUpEnabled(true);
                mMenuDrawer.setOnDrawerStateChangeListener(null);
              }
            }

            @Override
            public void onDrawerSlide(float openRatio, int offsetPixels) {
              // Do nothing
            }
          });
    }
  }
  @Override
  public void onBackPressed() {
    final int drawerState = mMenuDrawer.getDrawerState();
    if (drawerState == MenuDrawer.STATE_OPEN || drawerState == MenuDrawer.STATE_OPENING) {
      mMenuDrawer.closeMenu();
      return;
    }

    super.onBackPressed();
  }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   mActivePosition = position;
   mMenuDrawer.setActiveView(view, position);
   mAdapter.setActivePosition(position);
   onMenuItemClicked(position, (Item) mAdapter.getItem(position));
 }
  /** Create menu drawer ListView and listeners */
  private void initMenuDrawer() {
    mListView = new ListView(this);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mListView.setDivider(null);
    mListView.setDividerHeight(0);
    mListView.setCacheColorHint(android.R.color.transparent);

    String[] blogNames = getBlogNames();
    if (blogNames.length > 1) {
      addBlogSpinner(blogNames);
    }

    mListView.setOnItemClickListener(mItemClickListener);
    mListView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {}

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            mMenuDrawer.invalidate();
          }
        });

    mMenuDrawer.setMenuView(mListView);

    updateMenuDrawer();
  }
  @Override
  protected void onCreate(Bundle inState) {
    super.onCreate(inState);

    mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.TOP);
    mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
    mMenuDrawer.setContentView(R.layout.activity_topmenu);
    mMenuDrawer.setMenuView(R.layout.menu_top);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
      getActionBar().setDisplayHomeAsUpEnabled(true);

    mContentTextView = (TextView) findViewById(R.id.contentText);
    findViewById(R.id.item1).setOnClickListener(this);
    findViewById(R.id.item2).setOnClickListener(this);
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    pagerAdapter = new PagerAdapter(getChildFragmentManager());
    pager.setAdapter(pagerAdapter);
    tabStrip.setViewPager(pager);
    tabStrip.setOnPageChangeListener(new OnPageScrollListener());

    pullRefreshListViewMap = new HashMap<Integer, PullRefreshListView>(3);
    memberAdapterMap = new HashMap<Integer, MemberAdapter>(3);

    // 设置右侧触摸监听
    sideBar.setOnTouchingLetterChangedListener(
        new SideBar.OnTouchingLetterChangedListener() {

          @Override
          public void onTouchingLetterChanged(String s) {
            // 该字母首次出现的位置
            int position =
                memberAdapterMap.get(pager.getCurrentItem()).getPositionForSection(s.charAt(0));
            if (position != -1) {
              pullRefreshListViewMap.get(pager.getCurrentItem()).setSelection(position);
            }
          }
        });
    menuDrawer = activity.getMenuDrawer();
    if (menuDrawer != null) {
      menuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
    }
  }
  /**
   * Create a menu drawer and attach it to the activity.
   *
   * @param contentView {@link View} of the main content for the activity.
   */
  protected void createMenuDrawer(View contentView) {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mMenuDrawer = attachMenuDrawer();
    mMenuDrawer.setContentView(contentView);

    initMenuDrawer();
  }
  @Override
  public void onConfigurationChanged(Configuration newConfig) {

    if (mIsXLargeDevice) {
      if (mMenuDrawer != null) {
        // Re-attach the drawer if an XLarge device is rotated, so it can be static if in landscape
        View content = mMenuDrawer.getContentContainer().getChildAt(0);
        if (content != null) {
          mMenuDrawer.getContentContainer().removeView(content);
          mMenuDrawer = attachMenuDrawer();
          mMenuDrawer.setContentView(content);
          initMenuDrawer();
        }
      }
    }

    super.onConfigurationChanged(newConfig);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        mMenuDrawer.toggleMenu();
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
Beispiel #12
0
 /** 主界面初始化 */
 public void initContentview() {
   // actionbar
   ActionBar supportActionBar = getSupportActionBar();
   supportActionBar.setIcon(R.drawable.ic_duobei);
   supportActionBar.setTitle("多贝公开课");
   // menudrawer
   mDrawer = MenuDrawer.attach(this, Type.OVERLAY);
   mDrawer.setContentView(R.layout.activity_main);
   // 初始化3个tab
   fm = getSupportFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   mhomeFragment = new HomeFragment();
   mhomeFragment.addpager("新课速递", new NewCourseFragment());
   mhomeFragment.addpager("每日推荐", new DailyRecFragment());
   mhomeFragment.addpager("精选课程", new PickCourseFragment());
   ft.add(R.id.container, mhomeFragment);
   ft.addToBackStack(null);
   ft.commit();
 }
Beispiel #13
0
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       mDrawer.toggleMenu();
       break;
       //		case R.id.action_refresh:
       //			mhomeFragment.refresh();
     default:
       break;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
     case MENU_OVERFLOW:
       mMenuDrawer.toggleMenu();
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  protected void onCreate(Bundle inState) {
    super.onCreate(inState);

    if (inState != null) {
      mActivePosition = inState.getInt(STATE_ACTIVE_POSITION);
    }

    mMenuDrawer =
        MenuDrawer.attach(this, MenuDrawer.Type.BEHIND, getDrawerPosition(), getDragMode());

    List<Object> items = new ArrayList<Object>();
    items.add(new Item("Item 1", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 2", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 1"));
    items.add(new Item("Item 3", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 4", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 2"));
    items.add(new Item("Item 5", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 6", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 3"));
    items.add(new Item("Item 7", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 8", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 4"));
    items.add(new Item("Item 9", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 10", R.drawable.ic_action_select_all_dark));

    mList = new ListView(this);

    mAdapter = new MenuAdapter(this, items);
    mAdapter.setListener(this);
    mAdapter.setActivePosition(mActivePosition);

    mList.setAdapter(mAdapter);
    mList.setOnItemClickListener(mItemClickListener);

    mMenuDrawer.setMenuView(mList);
  }
  @Override
  protected void onCreate(Bundle inState) {
    super.onCreate(inState);
    mDrawer =
        MenuDrawer.attach(
            this, MenuDrawer.MENU_DRAG_CONTENT, Position.RIGHT, MenuDrawer.Type.OVERLAY);

    List<Object> items = new ArrayList<Object>();
    items.add(new Item("Item 1", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 2", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 1"));
    items.add(new Item("Item 3", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 4", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 2"));
    items.add(new Item("Item 5", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 6", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 3"));
    items.add(new Item("Item 7", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 8", R.drawable.ic_action_select_all_dark));
    items.add(new Category("Cat 4"));
    items.add(new Item("Item 9", R.drawable.ic_action_refresh_dark));
    items.add(new Item("Item 10", R.drawable.ic_action_select_all_dark));

    mList = new ListView(this);

    mAdapter = new MenuAdapter(this, items);

    mList.setAdapter(mAdapter);

    mDrawer.setMenuView(mList);

    TextView content = new TextView(this);
    content.setText("This is a sample of an overlayed right drawer.");
    content.setGravity(Gravity.CENTER);
    mDrawer.setContentView(content);
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
      case ADD_ACCOUNT_REQUEST:
        if (resultCode == RESULT_OK) {
          // new blog has been added, so rebuild cache of blogs and
          // setup current blog
          getBlogNames();
          setupCurrentBlog();
          initMenuDrawer();
          mMenuDrawer.peekDrawer(0);
        } else {
          finish();
        }
        break;
      case SETTINGS_REQUEST:
        if (resultCode == RESULT_OK) {
          if (mMenuDrawer != null) {
            updateMenuDrawer();
            String[] blogNames = getBlogNames();
            // If we need to add or remove the blog spinner, init the drawer again
            if ((blogNames.length > 1 && mListView.getHeaderViewsCount() == 0)
                || blogNames.length == 1 && mListView.getHeaderViewsCount() > 0)
              this.initMenuDrawer();
            else if (blogNames.length > 1 && mBlogSpinner != null) {
              SpinnerAdapter mSpinnerAdapter =
                  new ArrayAdapter<String>(
                      getSupportActionBar().getThemedContext(),
                      R.layout.sherlock_spinner_dropdown_item,
                      blogNames);
              mBlogSpinner.setAdapter(mSpinnerAdapter);
            }

            if (blogNames.length >= 1) {
              setupCurrentBlog();
              onBlogChanged();
            }
          }
        }
        break;
    }
  }
Beispiel #18
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.search: // on pressing home
        search = (EditText) item.getActionView();
        search.addTextChangedListener(filterTextWatcher);
        search.requestFocus();
        InputMethodManager imm =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

        return true;

      case android.R.id.home: // on pressing home
        mMenuDrawer.toggleMenu();
        return true;
      default:
        return false;
    }
  }
Beispiel #19
0
 /** 侧滑菜单初始化 */
 public void initMenuview() {
   View settingview = getLayoutInflater().inflate(R.layout.main_setting, null);
   mDrawer.setMenuView(settingview);
   // menudrawer的侧滑界面的listview
   mListView = (ListView) settingview.findViewById(R.id.listView1);
   String[] mTitle = getResources().getStringArray(R.array.menu_str);
   int images[] =
       new int[] {
         R.drawable.ic_menu_login,
         R.drawable.ic_menu_home,
         R.drawable.ic_menu_group,
         R.drawable.ic_menu_public,
         R.drawable.ic_menu_setting
       };
   /** 用户登陆判断* */
   //		SharedPreferences sp = getPreferences(MODE_PRIVATE);
   SharedPreferences sp = getSharedPreferences("userinfo", 0);
   // 自动登陆
   autologin = sp.getBoolean("autologin", false);
   if (autologin) {
     username = sp.getString("username", "cpoopc");
   } else {
     sp.edit().putString("username", "").commit();
   }
   // 用户名
   if (username != null && !"".equals(username)) {
     mTitle[0] = username;
   }
   settingAdapter = new SettingAdapter(this, mTitle, images);
   mListView.setAdapter(settingAdapter);
   mListView.setOnItemClickListener(this);
   //		mDrawer.setDropShadowColor(Color.BLUE);
   mDrawer.setSlideDrawable(R.drawable.ic_setting);
   mDrawer.setDrawerIndicatorEnabled(true);
   mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
   mDrawer.setMenuSize(250);
   // 第一次使用提示可以侧滑
   boolean firstUse = sp.getBoolean("firstUse", true);
   if (firstUse) {
     mDrawer.peekDrawer(1000, 0);
     Editor edit = sp.edit();
     edit.putBoolean("firstUse", false);
     edit.commit();
   }
 }
 /**
  * Attach a menu drawer to the Activity Set to be a static drawer if on a landscape x-large device
  */
 private MenuDrawer attachMenuDrawer() {
   MenuDrawer menuDrawer = null;
   if (mIsXLargeDevice) {
     // on a x-large screen device
     if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
       menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.LEFT, true);
       getSupportActionBar().setDisplayHomeAsUpEnabled(false);
     } else {
       menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT);
       getSupportActionBar().setDisplayHomeAsUpEnabled(true);
     }
   } else {
     menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT);
   }
   int shadowSizeInPixels = getResources().getDimensionPixelSize(R.dimen.menu_shadow_width);
   menuDrawer.setDropShadowSize(shadowSizeInPixels);
   menuDrawer.setDropShadowColor(getResources().getColor(R.color.md__shadowColor));
   return menuDrawer;
 }
 /** Click handler for top drawer items. */
 @Override
 public void onClick(View v) {
   String tag = (String) v.getTag();
   mContentTextView.setText(String.format("%s clicked.", tag));
   mMenuDrawer.setActiveView(v);
 }
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
          // Adjust position if only one blog is in the app
          if (mListView.getHeaderViewsCount() > 0 && position > 0) position--;

          if (!mIsDotComBlog) position++;

          if (position == mActivePosition) {
            // Same row selected
            mMenuDrawer.closeMenu();
            return;
          }

          int activityTag = (Integer) view.getTag();

          mActivePosition = position;
          mAdapter.notifyDataSetChanged();
          Intent intent = null;

          SharedPreferences settings =
              PreferenceManager.getDefaultSharedPreferences(WPActionBarActivity.this);
          SharedPreferences.Editor editor = settings.edit();

          switch (activityTag) {
            case READER_ACTIVITY:
              if (!(WPActionBarActivity.this instanceof ReaderActivity)) mShouldFinish = true;
              int readerBlogID = WordPress.wpDB.getWPCOMBlogID();
              if (WordPress.currentBlog.isDotcomFlag()) {
                intent = new Intent(WPActionBarActivity.this, ReaderActivity.class);
                intent.putExtra("id", readerBlogID);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                editor.putInt("wp_pref_last_activity", READER_ACTIVITY);
              }
              break;
            case POSTS_ACTIVITY:
              if (!(WPActionBarActivity.this instanceof PostsActivity)
                  || (WPActionBarActivity.this instanceof PagesActivity)) mShouldFinish = true;
              intent = new Intent(WPActionBarActivity.this, PostsActivity.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              editor.putInt("wp_pref_last_activity", POSTS_ACTIVITY);
              break;
            case PAGES_ACTIVITY:
              if (!(WPActionBarActivity.this instanceof PagesActivity)) mShouldFinish = true;
              intent = new Intent(WPActionBarActivity.this, PagesActivity.class);
              intent.putExtra("id", WordPress.currentBlog.getId());
              intent.putExtra("isNew", true);
              intent.putExtra("viewPages", true);
              intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              editor.putInt("wp_pref_last_activity", PAGES_ACTIVITY);
              break;
            case COMMENTS_ACTIVITY:
              if (!(WPActionBarActivity.this instanceof CommentsActivity)) mShouldFinish = true;
              intent = new Intent(WPActionBarActivity.this, CommentsActivity.class);
              intent.putExtra("id", WordPress.currentBlog.getId());
              intent.putExtra("isNew", true);
              intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              editor.putInt("wp_pref_last_activity", COMMENTS_ACTIVITY);
              break;
              //                case STATS_ACTIVITY:
              //                    if (!(WPActionBarActivity.this instanceof StatsActivity))
              //                        mShouldFinish = true;
              //                    intent = new Intent(WPActionBarActivity.this,
              // StatsActivity.class);
              //                    intent.putExtra("id", WordPress.currentBlog.getId());
              //                    intent.putExtra("isNew",
              //                            true);
              //                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              //                    editor.putInt("wp_pref_last_activity", STATS_ACTIVITY);
              //                    break;
            case QUICK_PHOTO_ACTIVITY:
              mShouldFinish = false;
              intent = new Intent(WPActionBarActivity.this, EditPostActivity.class);
              intent.putExtra(
                  "quick-media",
                  DeviceUtils.getInstance().hasCamera(getApplicationContext())
                      ? Constants.QUICK_POST_PHOTO_CAMERA
                      : Constants.QUICK_POST_PHOTO_LIBRARY);
              intent.putExtra("isNew", true);
              break;
            case QUICK_VIDEO_ACTIVITY:
              mShouldFinish = false;
              intent = new Intent(WPActionBarActivity.this, EditPostActivity.class);
              intent.putExtra(
                  "quick-media",
                  DeviceUtils.getInstance().hasCamera(getApplicationContext())
                      ? Constants.QUICK_POST_VIDEO_CAMERA
                      : Constants.QUICK_POST_VIDEO_LIBRARY);
              intent.putExtra("isNew", true);
              break;
            case VIEW_SITE_ACTIVITY:
              if (!(WPActionBarActivity.this instanceof ViewSiteActivity)) mShouldFinish = true;
              intent = new Intent(WPActionBarActivity.this, ViewSiteActivity.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              editor.putInt("wp_pref_last_activity", VIEW_SITE_ACTIVITY);
              break;
            case DASHBOARD_ACTIVITY:
              if (!(WPActionBarActivity.this instanceof DashboardActivity)) mShouldFinish = true;
              intent = new Intent(WPActionBarActivity.this, DashboardActivity.class);
              intent.putExtra("loadAdmin", true);
              intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              editor.putInt("wp_pref_last_activity", DASHBOARD_ACTIVITY);
              break;
            case SETTINGS_ACTIVITY:
              // Settings shouldn't be launched with a delay, or close the drawer
              mShouldFinish = false;
              Intent settingsIntent =
                  new Intent(WPActionBarActivity.this, PreferencesActivity.class);
              startActivityForResult(settingsIntent, SETTINGS_REQUEST);
              return;
          }

          editor.commit();
          if (intent != null) {
            mMenuDrawer.closeMenu();
            startActivityWithDelay(intent);
          }
        }
Beispiel #23
0
 public void iamcallin() {
   mMenuDrawer.setContentView(R.layout.live); // givin layout to drawer
   setSupportProgressBarIndeterminateVisibility(true); // onload show
 }
 @Override
 public void onActiveViewChanged(View v) {
   mMenuDrawer.setActiveView(v, mActivePosition);
 }
Beispiel #25
0
 // rest functinality for of navigation
 @Override
 protected void onRestoreInstanceState(Bundle inState) {
   super.onRestoreInstanceState(inState);
   mMenuDrawer.restoreState(inState.getParcelable(STATE_MENUDRAWER));
 }
Beispiel #26
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putParcelable(STATE_MENUDRAWER, mMenuDrawer.saveState());
   outState.putInt(STATE_ACTIVE_VIEW_ID, mActiveViewId);
 }
 @Override
 public void setContentView(int layoutResID) {
   // This override is only needed when using MENU_DRAG_CONTENT.
   mMenuDrawer.setContentView(layoutResID);
   onContentChanged();
 }
Beispiel #28
0
  @Override
  public void onClick(View v) { // for the click view

    switch (v.getId()) {
      case R.id.item1:
        mMenuDrawer.setActiveView(v);
        // mMenuDrawer.closeMenu();
        Intent myIntent = new Intent(live_first.this, Home.class); // refreshing
        myIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

        startActivity(myIntent);
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;
        break;
      case R.id.item2:
        mMenuDrawer.setActiveView(v);

        startActivity(new Intent(this, Event_activity.class));
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;
        // overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);//calling anim

        break;
      case R.id.item3:
        startActivity(new Intent(this, Event_top.class));
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;
        break;
      case R.id.item4:
        mMenuDrawer.setActiveView(v);
        mMenuDrawer.closeMenu();
        // startActivity(new Intent(this, Event_top.class));

        break;
      case R.id.item5:
        mMenuDrawer.setActiveView(v);
        // mMenuDrawer.closeMenu();
        startActivity(new Intent(this, Funnel_activity.class));
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;

        break;
      case R.id.item6:
        mMenuDrawer.setActiveView(v);
        // mMenuDrawer.closeMenu();
        startActivity(new Intent(this, Revenue_first.class));
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;

        break;
      case R.id.item7:
        mMenuDrawer.setActiveView(v);
        // mMenuDrawer.closeMenu();
        startActivity(new Intent(this, People_first.class));
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;

        break;
      case R.id.item8:
        mMenuDrawer.setActiveView(v);
        // mMenuDrawer.closeMenu();
        startActivity(new Intent(this, About.class));
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        anmi = 1;

        break;
    }

    mActiveViewId = v.getId();
  }
Beispiel #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(
        Window.FEATURE_INDETERMINATE_PROGRESS); // for progress it will be passed before layout

    // navigation
    if (savedInstanceState != null) {
      mActiveViewId = savedInstanceState.getInt(STATE_ACTIVE_VIEW_ID);
    }

    mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_WINDOW);
    mMenuDrawer.setMenuView(R.layout.menu_scrollview); // this is the layout for

    ////////////////////////////////////////////////////
    // Action bar
    ActionBar mActionBar;
    LayoutInflater mInflater;
    View mCustomView;
    TextView mTitleTextView;
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    mInflater = LayoutInflater.from(this);
    mCustomView = mInflater.inflate(R.layout.menu, null);
    mTitleTextView = (TextView) mCustomView.findViewById(R.id.title_text);
    mTitleTextView.setText("Live");
    mTitleTextView.setTextSize(20);

    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);
    // mActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.at_header_bg));
    ImageButton ibItem1 = (ImageButton) findViewById(R.id.btn_slide);
    ibItem1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mMenuDrawer.toggleMenu();
          }
        });

    /////////////////////////////////////////////

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      //           getActionBar().setDisplayHomeAsUpEnabled(true);
      // this is for the color of title bar
      ColorDrawable colorDrawable = new ColorDrawable();
      int myColor = this.getResources().getColor(R.color.menu4);
      colorDrawable.setColor(myColor);
      android.app.ActionBar actionBar = getActionBar();
      actionBar.setBackgroundDrawable(colorDrawable);
    }

    // mContentTextView = (TextView) findViewById(R.id.contentText);
    findViewById(R.id.item1).setOnClickListener(this);
    findViewById(R.id.item2).setOnClickListener(this);
    findViewById(R.id.item3).setOnClickListener(this);
    findViewById(R.id.item4).setOnClickListener(this);
    findViewById(R.id.item5).setOnClickListener(this);
    findViewById(R.id.item6).setOnClickListener(this);
    findViewById(R.id.item7).setOnClickListener(this);
    findViewById(R.id.item8).setOnClickListener(this);

    TextView activeView = (TextView) findViewById(mActiveViewId);
    if (activeView != null) {
      mMenuDrawer.setActiveView(activeView);
      // mContentTextView.setText("Active item: " + activeView.getText());
    }

    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    mMenuDrawer.setMenuSize(width / 4); // size of menu
    mMenuDrawer.setDropShadow(android.R.color.transparent); // removin showdo
    // navigation

    if (isNetworkOnline() == true) { // starting settings if internet is not working
      internt_count = true;
      iamcallin(); // calling the function to build everything

    } else if (isNetworkOnline() == false) {
      setContentView(R.layout.nointernet); // giving new layout to drawer
      // setContentView(R.layout.nointernet);
      internt_count = false;
      Button button = (Button) findViewById(R.id.nointernet_refresh);

      button.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {

              Intent myIntent = new Intent(live_first.this, live_first.class); // refreshing

              startActivity(myIntent);
              finish();
            }
          });
    }
  }
Beispiel #30
0
  /** 点击切换fragment */
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Fragment fragment = null;
    switch (position) {
      case MENU_LOGIN:
        if (username != null && !"".equals(username)) {
          if (mloginFragment != null) {
            fragment = mloginFragment;
            break;
          }
          mloginFragment = new HomeFragment();
          mloginFragment.addpager("我的课表", new MyCourseFragment());
          mloginFragment.addpager("我的资料", new MyInfoFragment());
          fragment = mloginFragment;
        } else {
          if (mloginFragment != null) {
            fragment = mloginFragment;
            break;
          }
          mloginFragment = new HomeFragment();
          mloginFragment.addpager("登陆", new LoginFragment());
          mloginFragment.addpager("注册", new RegistFragment());
          fragment = mloginFragment;
        }
        break;
      case MENU_HOME:
        if (mhomeFragment != null) {
          fragment = mhomeFragment;
          break;
        }
        mhomeFragment = new HomeFragment();
        mhomeFragment.addpager("新课速递", new NewCourseFragment());
        mhomeFragment.addpager("每日推荐", new DailyRecFragment());
        mhomeFragment.addpager("精选课程", new PickCourseFragment());
        fragment = mhomeFragment;

        break;
      case MENU_GROUP:
        if (mgroupFragment != null) {
          fragment = mgroupFragment;
          break;
        }
        mgroupFragment = new HomeFragment();
        mgroupFragment.addpager("热门话题", new TopicHotFragment());
        mgroupFragment.addpager("发现小组", new GroupFindFragment());
        fragment = mgroupFragment;
        break;
      case MENU_COURSE:
        if (mCourseListFragment != null) {
          fragment = mCourseListFragment;
          break;
        }
        mCourseListFragment = new PublicCourseListFragment();
        fragment = mCourseListFragment;
        break;
      case MENU_SETTING:
        startActivity(new Intent(this, SettingActivity.class));
        break;
      default:
        break;
    }
    if (fragment != null) {
      FragmentTransaction ft = fm.beginTransaction();
      ft.replace(R.id.container, fragment);
      ft.addToBackStack(null);
      ft.commit();
    }
    mDrawer.closeMenu(true);
  }