コード例 #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_frame_content);
    setBehindContentView(R.layout.map_frame_left_menu);
    setSecondaryBehindContentView(R.layout.map_frame_right_menu);

    Button left = (Button) findViewById(R.id.map_left);
    left.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            toggle();
          }
        });

    Button right = (Button) findViewById(R.id.map_right);
    right.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            showSecondaryMenu();
          }
        });

    // mMapView = (MapView)findViewById(R.id.mapview);
    // if (mMapView == null) {
    //	return;
    // }
    // mMapView.addLayer(new
    // ArcGISTiledMapServiceLayer(getResources().getString(R.string.map_url)));

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    MapLeftMenuFragment leftMenuFragment = new MapLeftMenuFragment();
    MapRightMenuFragment rightMenuFragment = new MapRightMenuFragment();
    MapContentFragment mapFragment = new MapContentFragment();
    fragmentTransaction.replace(R.id.map_left_menu, leftMenuFragment);
    fragmentTransaction.replace(R.id.map_right_menu, rightMenuFragment);
    fragmentTransaction.replace(R.id.map_content, mapFragment);
    fragmentTransaction.commit();

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidth(50);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffset(200);
    sm.setFadeDegree(0.35f);
    sm.setMode(SlidingMenu.LEFT_RIGHT);
    // 设置slding menu的几种手势模式
    // TOUCHMODE_FULLSCREEN 全屏模式,在content页面中,滑动,可以打开sliding menu
    // TOUCHMODE_MARGIN 边缘模式,在content页面中,如果想打开slding ,你需要在屏幕边缘滑动才可以打开slding menu
    // TOUCHMODE_NONE 自然是不能通过手势打开啦
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);

    // 使用左上方icon可点,这样在onOptionsItemSelected里面才可以监听到R.id.home
    // getActionBar().setDisplayHomeAsUpEnabled(true);
  }
コード例 #2
0
ファイル: Personal.java プロジェクト: aaron875499765/Master
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.personal);

    //////////////////
    Bitmap bm = BitmapFactory.decodeResource(this.getResources(), R.drawable.background_personal);
    BitmapDrawable bd = new BitmapDrawable(this.getResources(), bm);
    allLayout = (RelativeLayout) findViewById(R.id.layout_personal);
    allLayout.setBackgroundDrawable(bd);
    //////////////////

    btnPersonal = (Button) findViewById(R.id.btnPersonal);
    btnExpert = (Button) findViewById(R.id.btnExpert);
    btnMessage = (Button) findViewById(R.id.btnMessage);

    btnPersonal.setOnClickListener(new MyButtonOnClickListener());
    btnExpert.setOnClickListener(new MyButtonOnClickListener());
    btnMessage.setOnClickListener(new MyButtonOnClickListener());

    //////////////////
    final SlidingMenu menu = new SlidingMenu(this);
    btnDetails = (Button) findViewById(R.id.btnDetails);
    btnDetails.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            menu.toggle();
          }
        });
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setBehindWidth(500);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.sliding_detalis);
    //////////////////

    btnPersonalData = (Button) findViewById(R.id.btnPersonalData);
    btnEveryDay = (Button) findViewById(R.id.btnEveryDay);
    btnMyPlan = (Button) findViewById(R.id.btnMyPlan);
    btnMyTeacher = (Button) findViewById(R.id.btnMyTeacher);
    btnMyCollection = (Button) findViewById(R.id.btnMyCollection);
    btnMyCard = (Button) findViewById(R.id.btnMyCard);

    btnPersonalData.setOnClickListener(new MyButtonOnClickListener());
    btnEveryDay.setOnClickListener(new MyButtonOnClickListener());
    btnMyPlan.setOnClickListener(new MyButtonOnClickListener());
    btnMyTeacher.setOnClickListener(new MyButtonOnClickListener());
    btnMyCollection.setOnClickListener(new MyButtonOnClickListener());
    btnMyCard.setOnClickListener(new MyButtonOnClickListener());
  }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.style.DrawerTheme);
    // setTitle(mTitleRes);
    // set the Behind View
    setBehindContentView(R.layout.menu_scrollview);

    final ActionBar actionbar = getActionBar();
    actionbar.setDisplayShowTitleEnabled(false);
    actionbar.setDisplayHomeAsUpEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // customize the SlidingMenu
    sm = getSlidingMenu();
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    sm.setMode(SlidingMenu.LEFT);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setFadeEnabled(true);
    sm.setFadeEnabled(true);
    sm.setFadeDegree(0.95f);
    // sm.setSecondaryMenu(R.layout.sidemenumap);
    // sm.setSecondaryShadowDrawable(R.drawable.shadowright);
    sm.setBackgroundColor(0x000000000);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getSlidingMenu()
        .setOnOpenedListener(
            new OnOpenedListener() {
              public void onOpened() {
                getSlidingMenu().invalidate();
                // mMap.setMyLocationEnabled(true);
              }
            });

    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.item9).setOnClickListener(this);
    findViewById(R.id.item10).setOnClickListener(this);
    findViewById(R.id.item11).setOnClickListener(this);
    findViewById(R.id.item12).setOnClickListener(this);
    findViewById(R.id.item13).setOnClickListener(this);
  }
コード例 #4
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   if (Build.VERSION.SDK_INT > 10) {
     getWindow().setFlags(0x01000000, 0x01000000);
   }
   super.onCreate(savedInstanceState);
   Bundle bundle = new Bundle();
   if (getIntent() != null) {
     Serializable serializable = getIntent().getSerializableExtra("SUBLIST");
     bundle.putSerializable("SUBLIST", serializable);
   }
   if (savedInstanceState != null) {
     weatherCitySelectFragment =
         (WeatherCitySelectFragment)
             getSupportFragmentManager()
                 .getFragment(savedInstanceState, "WeatherCitySelectFragment");
     weatherSettingFragment =
         (WeatherSettingFragment)
             getSupportFragmentManager().getFragment(savedInstanceState, "WeatherSettingFragment");
   }
   if (weatherCitySelectFragment == null) {
     weatherCitySelectFragment = WeatherCitySelectFragment.newInstance(bundle);
   }
   if (weatherSettingFragment == null) {
     weatherSettingFragment = new WeatherSettingFragment();
   }
   // set the Behind View
   setBehindContentView(R.layout.menu_frame);
   FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
   t.replace(R.id.menu_frame, weatherCitySelectFragment);
   t.commit();
   // customize the SlidingMenu
   SlidingMenu sm = getSlidingMenu();
   sm.setMode(SlidingMenu.LEFT_RIGHT);
   sm.setShadowWidthRes(R.dimen.shadow_width);
   sm.setShadowDrawable(R.drawable.shadow);
   sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
   sm.setFadeDegree(0.35f);
   sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
   sm.setSecondaryMenu(R.layout.menu_frame_two);
   sm.setSecondaryShadowDrawable(R.drawable.shadowright);
   getSupportFragmentManager()
       .beginTransaction()
       .replace(R.id.menu_frame_two, weatherSettingFragment)
       .commit();
 }
コード例 #5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // set the Behind View
    setBehindContentView(R.layout.act_sliding_menu_frame);
    FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
    mFrag = new SampleListFragment();
    t.replace(R.id.sliding_menu_frame, mFrag);
    t.commit();

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setFadeDegree(0.35f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
  }
コード例 #6
0
  @Override
  protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    // configure the SlidingMenu
    SlidingMenu menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
    menu.setShadowWidth(15);
    menu.setBehindOffset(60);
    menu.setFadeDegree(0.35f);
    menu.setMenu(R.layout.sidemenu_frame);

    getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame, new SideMenu())
        .commit();
  }
コード例 #7
0
ファイル: MainActivity.java プロジェクト: vitoziv/xmutEMS
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle(getString(R.string.notification));
    // 使actionbar上的logo可以点击
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      getSupportActionBar().setHomeButtonEnabled(true);
      getSupportActionBar()
          .setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
    }

    // set the Above View
    if (savedInstanceState != null)
      mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
    if (mContent == null) {
      mContent = new NotificationFragment();
    }

    // set the Above View
    setContentView(R.layout.content_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit();

    // set the Behind View
    setBehindContentView(R.layout.menu_frame);
    getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame, new MenuFragment())
        .commit();

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setFadeDegree(0.35f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    // 设置menu动画
    //		setSlidingActionBarEnabled(true);
    //		sm.setBehindScrollScale(0.0f);
    //		sm.setBehindCanvasTransformer(mTransformer);
  }
コード例 #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_layout);
    // ActionBar gets initiated
    actionBar = getSupportActionBar();
    actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("Compose");
    myDataBase = new TaskDataBaseSQL(this);

    drawer = new SlidingMenu(this);
    drawer.setMode(SlidingMenu.LEFT);
    drawer.setShadowDrawable(R.drawable.shadow);
    drawer.setShadowWidthRes(R.dimen.shadow_width);
    drawer.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    drawer.setFadeDegree(0.35f);
    drawer.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    drawer.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    drawer.offsetTopAndBottom(25);
    drawer.setMenu(R.layout.alarmslidingmenu);
    drawer.setSlidingEnabled(false);
    positionOftaskToEdit = -1;
    initilizeViewVariables();
    coder = new Geocoder(this);
    myGPSManager = new TaskGPSManager(this);
    myalarmmanager = new MyAlarmManager(this);
    timepicker.setCurrentHour(myalarmmanager.getHourOfDay());

    if (getIntent().hasExtra("ob")) {
      positionOftaskToEdit = getIntent().getIntExtra("ob", 0);
      taskBeforeEdit = TaskList.getTasksList().get(positionOftaskToEdit);
      initilizeViewForExistingTask();
      actionBar.setTitle("Edit");
      Log.d(getClass().getSimpleName(), "Editing A Task" + "id: " + taskBeforeEdit.getTaskId());
    } else {
      initilizeForNewTask();
      Log.d(getClass().getSimpleName(), "Creating New Task");
    }
  }
コード例 #9
0
  private void configSlidingMenu(boolean phone) {
    SlidingMenu slidingMenu = getSlidingMenu();
    slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
    slidingMenu.setShadowDrawable(R.drawable.shadow_slidingmenu);
    if (phone) {
      slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    } else {
      slidingMenu.setBehindOffset(Utility.getScreenWidth());
    }

    slidingMenu.setFadeDegree(0.35f);
    slidingMenu.setOnPageScrollListener(
        new SlidingMenu.OnPageScrollListener() {
          @Override
          public void onPageScroll() {
            LongClickableLinkMovementMethod.getInstance().setLongClickable(false);
            (getFriendsTimeLineFragment()).clearActionMode();
            (getFavFragment()).clearActionMode();
            (getCommentsTimeLineFragment()).clearActionMode();
            (getMentionsTimeLineFragment()).clearActionMode();
            (getMyProfileFragment()).clearActionMode();

            if (GlobalContext.getInstance().getAccountBean().isBlack_magic()) {
              (getSearchFragment()).clearActionMode();
              (getDMFragment()).clearActionMode();
            }
          }
        });

    slidingMenu.setOnClosedListener(
        new SlidingMenu.OnClosedListener() {
          @Override
          public void onClosed() {
            LongClickableLinkMovementMethod.getInstance().setLongClickable(true);
            LocalBroadcastManager.getInstance(MainTimeLineActivity.this)
                .sendBroadcast(new Intent(AppEventAction.SLIDING_MENU_CLOSED_BROADCAST));
          }
        });
  }
コード例 #10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    init = false;

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setBehindContentView(R.layout.menu_frame);
    getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame, new MenuFragment())
        .commit();

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setFadeDegree(0.35f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    setContentView(R.layout.activity_main);

    downloadView = findViewById(R.id.DownloadView);
    progressBar = (ProgressBar) findViewById(R.id.ProgressBar);
    progressMessageTextView = (TextView) findViewById(R.id.ProgressTextView);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean alwaysTurnOnScreen =
        preferences.getBoolean(getString(R.string.preference_always_turn_on_key), true);
    if (alwaysTurnOnScreen) {
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
  }
コード例 #11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frame_content);
    setBehindContentView(R.layout.frame_menu);

    //	setSecondaryMenu

    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidth(50);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffset(60);
    sm.setFadeDegree(0.35f);
    sm.setMode(SlidingMenu.LEFT_RIGHT);
    //  sm.set

    sm.setSecondaryMenu(R.layout.test1);
    sm.setSecondaryShadowDrawable(R.drawable.shadow);

    //    sm.setMenu(R.layout.frame_menu);
    // sm.setLeft(R.layout.frame_menu);
    // 设置slding menu的几种手势模式
    // TOUCHMODE_FULLSCREEN 全屏模式,在content页面中,滑动,可以打开sliding menu
    // TOUCHMODE_MARGIN 边缘模式,在content页面中,如果想打开slding ,你需要在屏幕边缘滑动才可以打开slding menu
    // TOUCHMODE_NONE 自然是不能通过手势打开啦
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    //		FragmentTransaction fragmentTransaction=getFragmentManager().beginTransaction();
    //		MenuFragment menuFragment = new MenuFragment();
    //      //  fragmentTransaction.replace(R.id.menu, menuFragment);
    //        fragmentTransaction.replace(R.id.content, new ContentFragment("Welcome"),"Welcome");
    //        fragmentTransaction.commit();
    //
    //    //    getActionBar().setDisplayHomeAsUpEnabled(true);
  }
コード例 #12
0
  private void setUpViews() {

    setContentView(R.layout.activity_base_assembly);
    activityContentLayout = (LinearLayout) findViewById(R.id.activity_content);
    errorMessageView = (TextView) findViewById(R.id.error_not_logged_in);

    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.slidebar);

    mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mInflater.inflate(resLayout, activityContentLayout);

    menuAdapter = new MenuListAdapter(this);
    menuListView = (ListView) findViewById(R.id.sidebar_list);
    menuListView.setAdapter(menuAdapter);
    menuListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            MenuListItem item = (MenuListItem) arg1;
            item.getItem().getAction().run();
          }
        });

    menuListView.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> arg0, View view, int arg2, long arg3) {
            MenuListItem item = (MenuListItem) view;
            OnLongClickListener longClickAction = item.getItem().getLongClickAction();
            if (longClickAction != null) {
              item.getItem().getLongClickAction().onLongClick(view);
            }
            return true;
          }
        });

    loginItem = menuAdapter.getLoginItem();
    loginItem.setAction(
        new Runnable() {
          @Override
          public void run() {
            if (loggedIn) {
              showUserProfile();
            } else {
              authorizeUser();
            }
          }
        });

    loginItem.setLongClickAction(
        new OnLongClickListener() {
          @SuppressLint("NewApi")
          @Override
          public boolean onLongClick(View view) {
            if (loggedIn) {
              if (app.isSupportsHoneyComb()) {
                showProfilePopup(view);
              } else {
                showProfileDialog();
              }
              return true;
            } else {
              return false;
            }
          }
        });
  }
コード例 #13
0
  /**
   * Instantiates a new SlidingMenu.
   *
   * @param context the associated Context
   * @param attrs the attrs
   * @param defStyle the def style
   */
  public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    LayoutParams behindParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mViewBehind = new CustomViewBehind(context);
    addView(mViewBehind, behindParams);
    LayoutParams aboveParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mViewAbove = new CustomViewAbove(context);
    addView(mViewAbove, aboveParams);
    // register the CustomViewBehind with the CustomViewAbove
    mViewAbove.setCustomViewBehind(mViewBehind);
    mViewBehind.setCustomViewAbove(mViewAbove);
    mViewAbove.setOnPageChangeListener(
        new OnPageChangeListener() {
          public static final int POSITION_OPEN = 0;
          public static final int POSITION_CLOSE = 1;

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

          public void onPageSelected(int position) {
            if (position == POSITION_OPEN && mOpenListener != null) {
              mOpenListener.onOpen();
            } else if (position == POSITION_CLOSE && mCloseListener != null) {
              mCloseListener.onClose();
            }
          }
        });

    // now style everything!
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingMenu);
    // set the above and behind views if defined in xml
    int mode = ta.getInt(R.styleable.SlidingMenu_mode, LEFT);
    setMode(mode);
    int viewAbove = ta.getResourceId(R.styleable.SlidingMenu_viewAbove, -1);
    if (viewAbove != -1) {
      setContent(viewAbove);
    } else {
      setContent(new FrameLayout(context));
    }
    int viewBehind = ta.getResourceId(R.styleable.SlidingMenu_viewBehind, -1);
    if (viewBehind != -1) {
      setMenu(viewBehind);
    } else {
      setMenu(new FrameLayout(context));
    }
    int touchModeAbove = ta.getInt(R.styleable.SlidingMenu_touchModeAbove, TOUCHMODE_MARGIN);
    setTouchModeAbove(touchModeAbove);
    int touchModeBehind = ta.getInt(R.styleable.SlidingMenu_touchModeBehind, TOUCHMODE_MARGIN);
    setTouchModeBehind(touchModeBehind);

    int offsetBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindOffset, -1);
    int widthBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindWidth, -1);
    if (offsetBehind != -1 && widthBehind != -1)
      throw new IllegalStateException(
          "Cannot set both behindOffset and behindWidth for a SlidingMenu");
    else if (offsetBehind != -1) setBehindOffset(offsetBehind);
    else if (widthBehind != -1) setBehindWidth(widthBehind);
    else setBehindOffset(0);
    float scrollOffsetBehind = ta.getFloat(R.styleable.SlidingMenu_behindScrollScale, 0.33f);
    setBehindScrollScale(scrollOffsetBehind);
    int shadowRes = ta.getResourceId(R.styleable.SlidingMenu_shadowDrawable, -1);
    if (shadowRes != -1) {
      setShadowDrawable(shadowRes);
    }
    int shadowWidth = (int) ta.getDimension(R.styleable.SlidingMenu_shadowWidth, 0);
    setShadowWidth(shadowWidth);
    boolean fadeEnabled = ta.getBoolean(R.styleable.SlidingMenu_fadeEnabled, true);
    setFadeEnabled(fadeEnabled);
    float fadeDeg = ta.getFloat(R.styleable.SlidingMenu_fadeDegree, 0.33f);
    setFadeDegree(fadeDeg);
    boolean selectorEnabled = ta.getBoolean(R.styleable.SlidingMenu_selectorEnabled, false);
    setSelectorEnabled(selectorEnabled);
    int selectorRes = ta.getResourceId(R.styleable.SlidingMenu_selectorDrawable, -1);
    if (selectorRes != -1) setSelectorDrawable(selectorRes);
    ta.recycle();
  }
コード例 #14
0
ファイル: Player.java プロジェクト: maxplayer2013/maxplayer
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Leg.i(TAG, "onCreate()================================");
    super.onCreate(savedInstanceState);

    if (!isPortrait()) {
      // requestWindowFeature(Window.FEATURE_NO_TITLE);
      updateFullscreenStatus(true);
    }
    setContentView(R.layout.activity_player);

    mMediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE);
    mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);

    mContentView = getWindow().getDecorView().findViewById(android.R.id.content);
    mBackgroundImage = (ImageView) findViewById(R.id.background);

    //        mPauseImage = (ImageView) findViewById(R.id.play_pause);
    mVideoSurface = (SurfaceView) findViewById(R.id.video_surface);

    mPreviousButton_slider = (ImageButton) findViewById(R.id.prev);
    mPlay_pauseButton_slider = (ImageButton) findViewById(R.id.pause);
    mNextButton_slider = (ImageButton) findViewById(R.id.next);

    mVideoSurface.setZOrderOnTop(true);
    mVideoSurface.setAlpha((float) 0.18);
    mVideoSurface.getHolder().setFormat(PixelFormat.TRANSLUCENT);

    //        mPauseImage.setOnClickListener(this);
    mVideoSurface.setOnClickListener(this);
    mVideoSurface.setOnTouchListener(this);

    mPreviousButton_slider.setOnClickListener(this);
    mPlay_pauseButton_slider.setOnClickListener(this);
    mNextButton_slider.setOnClickListener(this);

    //
    mPredict = 0;
    getSurfaceHolder();

    //
    mDefaultDM = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(mDefaultDM);

    this.registerReceiver(
        new BroadcastReceiver() {

          @Override
          public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            dismissSlidingController();
          }
        },
        mIntentfl);

    mediaControllerLayout = findViewById(R.id.mediaControllerLayout);
    mSeekBar = (SeekBar) findViewById(R.id.videoSeekBar);

    mSeekBar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
              mPlaybackService.seekTo(
                  (int) (progress * 1.0 / seekBar.getMax() * (mPlaybackService.getDuration())));
              seekBar.setProgress(progress);
            }
          }
        });

    scheduledExecutorService = Executors.newScheduledThreadPool(1);
    handler = new Handler();

    scheduledExecutorService.scheduleAtFixedRate(
        new Runnable() {

          @Override
          public void run() {
            handler.post(
                new Runnable() {
                  @Override
                  public void run() {
                    Log.d(TAG, "test-----");
                    if (mPlaybackService.isPlaying()) {
                      Log.d(TAG, "test++++");
                      int position = mPlaybackService.getCurrentPosition();
                      int duration = mPlaybackService.getDuration();
                      Log.d(
                          TAG,
                          "test++++" + Integer.toString(duration) + Integer.toString(position));
                      mSeekBar.setProgress(
                          (int) ((float) position / (float) duration * mSeekBar.getMax()));

                      mediaControllerLayout.setVisibility(View.VISIBLE);
                      playButton.setImageResource(R.drawable.ic_media_pause);

                      Log.d(TAG, "test++++" + (int) (position / duration * mSeekBar.getMax()));
                    }
                  }
                });
          }
        },
        1000,
        1000,
        TimeUnit.MILLISECONDS);

    playButton = (ImageButton) findViewById(R.id.playButton);
    playButton.setOnClickListener(this);

    // icon show sliding menu
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // sliding menu
    setBehindContentView(R.layout.slidingmenu_left);

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setMode(SlidingMenu.LEFT);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setFadeDegree(0.0f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    sm.setBehindScrollScale(0.0f);
    // animation
    sm.setBehindCanvasTransformer(
        new CanvasTransformer() {
          @Override
          public void transformCanvas(Canvas canvas, float percentOpen) {
            // TODO Auto-generated method stub
            Log.d(TAG, "testAni---------------");
            canvas.translate(0, 0);
          }
        });

    slidingMenu_open = (LinearLayout) findViewById(R.id.sliding_open);
    slidingMenu_open_image = (ImageView) findViewById(R.id.sliding_open_image);
    slidingMenu_open_text = (TextView) findViewById(R.id.sliding_open_text);

    slidingMenu_repeat = (LinearLayout) findViewById(R.id.sliding_loop);
    slidingMenu_repeat_image = (ImageView) findViewById(R.id.sliding_loop_image);
    slidingMenu_repeat_text = (TextView) findViewById(R.id.sliding_loop_text);

    slidingMenu_about = (LinearLayout) findViewById(R.id.sliding_about);
    slidingMenu_about_image = (ImageView) findViewById(R.id.sliding_about_image);
    slidingMenu_about_text = (TextView) findViewById(R.id.sliding_about_text);

    sliding_floatwindow = (LinearLayout) findViewById(R.id.sliding_floatwindow);
    sliding_checkbox_floatwindow = (CheckBox) findViewById(R.id.sliding_checkbox_floatwindow);
    sliding_floatwindow_text = (TextView) findViewById(R.id.sliding_floatwindow_text);

    slidingMenu_open.setOnClickListener(this);
    slidingMenu_open.setOnClickListener(this);
    slidingMenu_open_text.setOnClickListener(this);

    slidingMenu_repeat.setOnClickListener(this);
    slidingMenu_repeat_image.setOnClickListener(this);
    slidingMenu_repeat_text.setOnClickListener(this);

    slidingMenu_about.setOnClickListener(this);
    slidingMenu_about_image.setOnClickListener(this);
    slidingMenu_about_text.setOnClickListener(this);

    sliding_floatwindow.setOnClickListener(this);
    sliding_floatwindow_text.setOnClickListener(this);

    sliding_checkbox_floatwindow.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            boolean float_window_value = sliding_checkbox_floatwindow.isChecked();
            editor.putBoolean("sliding_checkbox_floatwindow", float_window_value);
            editor.commit();
            Log.d(
                TAG,
                "<><><><><><><> if float windows set to: " + Boolean.toString(float_window_value));
          }
        });

    settings = getSharedPreferences("floatWindow", 0);
    editor = settings.edit();

    boolean ifPlayInFloatWindow = settings.getBoolean("sliding_checkbox_floatwindow", false);
    Log.d(TAG, "<><><><><><><> play in float window: " + Boolean.toString(ifPlayInFloatWindow));
    sliding_checkbox_floatwindow.setChecked(ifPlayInFloatWindow);
  }
コード例 #15
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Utils.isWide(this)) { // wide enough, switch to tablet layout
      final Intent intent = new Intent();
      intent.setClass(this, TabletActivity.class);
      startActivity(intent);
      finish();

      return;
    }

    mPrefs = getPreferences(MODE_PRIVATE);

    mMenu = getSlidingMenu();
    mMenu.setMode(SlidingMenu.LEFT_RIGHT);
    mMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    mMenu.setBehindOffset((int) getResources().getDimension(R.dimen.sliding_menu_offset));
    mMenu.setFadeDegree(0.5f);
    mMenu.setShadowWidthRes(R.dimen.sliding_menu_shadow);
    mMenu.setShadowDrawable(R.drawable.shadow_left);
    mMenu.setSecondaryShadowDrawable(R.drawable.shadow_right);

    // activity content
    setContentView(R.layout.activity_phone);

    mContainerVcard = findViewById(R.id.container_vcard);
    mVerticalLeft = findViewById(R.id.vertical_left);
    mVerticalRight = findViewById(R.id.vertical_right);
    mHintLeft = findViewById(R.id.side_hint_left);
    mHintRight = findViewById(R.id.side_hint_right);

    setBehindContentView(R.layout.menu_primary);
    mMenu.setSecondaryMenu(R.layout.menu_secondary);

    if (savedInstanceState == null) {
      // vcard
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.container_vcard, new VcardFragment())
          .commit();

      /*
       *  displaying of layout waits until onCreate completes
       *  load another fragments little bit later to allow fast displaying of activity_phone one
       */
      sHandler.postDelayed(
          new Runnable() {
            @Override
            public void run() {

              // networks
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.container_networks, new NetworksFragment())
                  .commit();

              // timeline
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.container_timeline, new TimelineFragment())
                  .commit();
            }
          },
          250);
    }

    mMenu.setOnOpenedListener(
        new SlidingMenu.OnOpenedListener() {
          @Override
          public void onOpened() {
            if (mAnimVcardOut.isRunning()) {
              mAnimVcardOut.end();
            }
            mAnimVcardOut.setTarget(mContainerVcard);
            mAnimVcardOut.start();

            if (mMenu.isSecondaryMenuShowing()) {
              if (mAnimVerticalRightIn.isRunning()) {
                mAnimVerticalRightIn.end();
              }
              mAnimVerticalRightIn.setTarget(mVerticalRight);
              mAnimVerticalRightIn.start();
            } else {
              if (mAnimVerticalLeftIn.isRunning()) {
                mAnimVerticalLeftIn.end();
              }
              mAnimVerticalLeftIn.setTarget(mVerticalLeft);
              mAnimVerticalLeftIn.start();
            }

            final SharedPreferences.Editor edit = mPrefs.edit();
            edit.putBoolean(Constants.PREF_SIDE_USED, true);
            edit.commit();

            if (mTracker != null) {
              mTracker.sendEvent("activity_phone", "open", "slide_menu", 0l);

              GAServiceManager.getInstance().dispatch();
            }
          }
        });

    mMenu.setOnClosingListener(
        new SlidingMenu.OnClosingListener() {
          @Override
          public void onClosing() {
            if (mVerticalLeft.getVisibility() == View.VISIBLE) {
              if (mAnimVerticalLeftIn.isRunning()) {
                mAnimVerticalLeftIn.end();
              }
              mVerticalLeft.setVisibility(View.INVISIBLE);
            } else if (mVerticalRight.getVisibility() == View.VISIBLE) {
              if (mAnimVerticalRightIn.isRunning()) {
                mAnimVerticalRightIn.end();
              }
              mVerticalRight.setVisibility(View.INVISIBLE);
            }

            if (mAnimVcardOut.isRunning()) {
              mAnimVcardOut.end();
            }
            mContainerVcard.setAlpha(1.0f); // TODO: level 11+
            mContainerVcard.setVisibility(View.VISIBLE);
          }
        });
  }
コード例 #16
0
ファイル: MainActivity.java プロジェクト: yan96in/Note
  /** 初始化控件 */
  public void initWidget() {
    slidingMenu = new SlidingMenu(this);
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    slidingMenu.setBehindScrollScale(0);
    slidingMenu.setFadeDegree(1f);
    slidingMenu.setFadeEnabled(true);
    slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);

    slidingMenu.setBehindOffset(getScreenWidth() / 2);
    slidingMenu.setMenu(R.layout.sidebar_layout);

    editTopLayout = (RelativeLayout) findViewById(R.id.edit_top_title);
    searchTitle = (RelativeLayout) findViewById(R.id.main_top_search);
    bottomLayout = (LinearLayout) findViewById(R.id.main_bottom);
    seeAllButton = (ImageButton) findViewById(R.id.seeallbtn);
    addNoteButton = (ImageButton) findViewById(R.id.addnotebtn);
    addTypeButton = (ImageButton) findViewById(R.id.addtype_btn);
    deleteButton = (ImageButton) findViewById(R.id.delete_btn_main);
    shareButton = (ImageButton) findViewById(R.id.share_btn_main);
    moveButton = (ImageButton) findViewById(R.id.move_btn_main);
    lockedButton = (ImageButton) findViewById(R.id.locked_btn_main);
    unlockedButton = (ImageButton) findViewById(R.id.unlocked_btn_main);
    showTypeView = (TextView) findViewById(R.id.showtype);
    showSelectView = (TextView) findViewById(R.id.showselect);
    showNowDateView = (TextView) findViewById(R.id.nowdate_tv);
    typeGroup = (RadioGroup) findViewById(R.id.typegroup);
    noteListView = (ListView) findViewById(R.id.notelist);
    showEmptyView = (LinearLayout) findViewById(R.id.showempty_view);
    showSearchButton = (Button) findViewById(R.id.searchbtn_sidebar);
    calendarButton = (Button) findViewById(R.id.calendarbtn_sidebar);
    albumButton = (Button) findViewById(R.id.albumbtn_sidebar);
    passwdButton = (Button) findViewById(R.id.passwdbtn_sidebar);
    feedbackButton = (Button) findViewById(R.id.feedbackbtn_sidebar);
    shareAppButton = (Button) findViewById(R.id.shareappbtn_sidebar);
    aboutButton = (Button) findViewById(R.id.aboutbtn_sidebar);
    startSearchButton = (ImageButton) findViewById(R.id.startsearch_btn);
    voiceSearchButton = (ImageButton) findViewById(R.id.voice_search_btn);
    searchEditText = (EditText) findViewById(R.id.edittext_search);
    changeOrderButton = (ImageButton) findViewById(R.id.changebtn);

    seeAllButton.setOnClickListener(this);
    addNoteButton.setOnClickListener(this);
    addTypeButton.setOnClickListener(this);
    deleteButton.setOnClickListener(this);
    shareButton.setOnClickListener(this);
    moveButton.setOnClickListener(this);
    lockedButton.setOnClickListener(this);
    unlockedButton.setOnClickListener(this);
    showSearchButton.setOnClickListener(this);
    startSearchButton.setOnClickListener(this);
    calendarButton.setOnClickListener(this);
    albumButton.setOnClickListener(this);
    passwdButton.setOnClickListener(this);
    feedbackButton.setOnClickListener(this);
    shareAppButton.setOnClickListener(this);
    aboutButton.setOnClickListener(this);
    voiceSearchButton.setOnClickListener(this);
    changeOrderButton.setOnClickListener(this);
    noteListView.setOnItemClickListener(this);
    noteListView.setOnItemLongClickListener(this);

    noteTypeDao = new NoteTypeDao(MainActivity.this);

    // 初始化语音识别器
    initVoiceRecognizer();

    // 获取所有分类
    typeList = noteTypeDao.getAllTyep();
    // 动态加载radiobutton
    for (int i = 0; i < typeList.size(); i++) {
      AddRadioButton(typeList.get(i).get("type").toString());
    }

    // 初始化所有的记事本并显示
    noteDetailDao = new NoteDetailDao(MainActivity.this);

    // 显示当前时间
    showNowDate();

    // 创建需要用到的文件夹
    createDir();
  }