Esempio n. 1
0
  @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);
  }
Esempio n. 2
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();
  }
Esempio n. 3
0
  /** 初始化控件 */
  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();
  }