@Override
        public void onClick(View v) {

          String msg = "";
          switch (curPlayMode) {
            case CommonConstDef.PLAY_MODE_CIRCLE_LIST:
              {
                curPlayMode = CommonConstDef.PLAY_MODE_SHUFFLE_LIST;
                ((ImageButton) v).setImageResource(R.drawable.btn_shuffle_off_holo_dark);
                v.invalidate();
                msg = "随机播放模式";
              }
              break;
            case CommonConstDef.PLAY_MODE_CIRCLE_SINGLE:
              {
                curPlayMode = CommonConstDef.PLAY_MODE_CIRCLE_LIST;
                ((ImageButton) v).setImageResource(R.drawable.btn_repeat_all_off_holo_dark);
                v.invalidate();
                msg = "列表循环播放模式";
              }
              break;
            case CommonConstDef.PLAY_MODE_SHUFFLE_LIST:
              {
                curPlayMode = CommonConstDef.PLAY_MODE_CIRCLE_SINGLE;
                ((ImageButton) v).setImageResource(R.drawable.btn_repeat_once_off_holo_dark);
                v.invalidate();
                msg = "单曲循环播放模式";
              }
              break;
          }

          Toast.makeText(getActivity(), msg, Toast.LENGTH_LONG).show();
        }
 @Override
 public void onPageSelected(int position) {
   for (int i = 0; i < mTabsLinearLayout.getChildCount(); i++) {
     ImageButton ib = (ImageButton) mTabsLinearLayout.getChildAt(i);
     switch (i) {
       case 0:
         if (i == position) ib.setImageResource(R.drawable.ic_action_event_highlighted);
         else ib.setImageResource(R.drawable.ic_action_event);
         break;
       case 1:
         if (i == position) ib.setImageResource(R.drawable.ic_action_cc_bcc_highlighted);
         else ib.setImageResource(R.drawable.ic_action_cc_bcc);
         break;
       case 2:
         if (i == position) ib.setImageResource(R.drawable.ic_action_chat_highlighted);
         else ib.setImageResource(R.drawable.ic_action_chat);
         break;
       case 3:
         if (i == position) ib.setImageResource(R.drawable.ic_action_web_site_highlighted);
         else ib.setImageResource(R.drawable.ic_action_web_site);
         break;
       case 4:
         if (i == position) ib.setImageResource(R.drawable.ic_action_more_highlighted);
         else ib.setImageResource(R.drawable.ic_action_more);
         break;
       default:
         break;
     }
   }
 }
  private void scanLeDevice(final boolean enable) {
    if (enable) {
      // Stops scanning after a pre-defined scan period.
      mHandler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              mScanning = false;
              mBluetoothAdapter.stopLeScan(mLeScanCallback);
              mFabButton.setImageResource(R.drawable.ic_autorenew_white_24dp);
            }
          },
          SCAN_PERIOD);

      mScanning = true;
      mBluetoothAdapter.startLeScan(mLeScanCallback);
      mFabButton.setImageResource(R.drawable.ic_not_interested_white_24dp);
      Toast.makeText(getApplicationContext(), "正在扫描设备...5秒后自动停止扫描,可点击右下角按钮手动停止", Toast.LENGTH_LONG)
          .show();
    } else {
      mScanning = false;
      mBluetoothAdapter.stopLeScan(mLeScanCallback);
      mFabButton.setImageResource(R.drawable.ic_autorenew_white_24dp);
    }
  }
  /**
   * 绘制导航布局
   *
   * @return
   */
  private LinearLayout drawNavTitle() {
    LinearLayout navTitle =
        createLinearLayout(LinearLayout.HORIZONTAL, LayoutParams.MATCH_PARENT, 0, 1.5f);
    navTitle.setGravity(Gravity.CENTER);

    // 左右按键和中间标题应该很容易看懂
    ImageButton left = new ImageButton(getContext());
    left.setBackgroundColor(Color.TRANSPARENT);
    ImageButton right = new ImageButton(getContext());
    right.setBackgroundColor(Color.TRANSPARENT);
    title = new TextView(getContext());
    title.setTextSize(getResources().getDimension(R.dimen.calendar_title));
    title.setPadding((int) (0.5 * tb), (int) (0.5 * tb), (int) (0.5 * tb), (int) (0.5 * tb));
    navTitle.addView(left);
    navTitle.addView(title);
    navTitle.addView(right);
    left.setImageResource(R.drawable.calendar_prev);
    right.setImageResource(R.drawable.calendar_next);
    // 点击事件
    left.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            lastMonth();
          }
        });
    right.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            nextMonth();
          }
        });
    return navTitle;
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_title_bar_back:
       finish();
       break;
     case R.id.btn_send:
       send();
       break;
     case R.id.ll_input_root:
     case R.id.et_forward_content:
       faceKeyboard.setImageResource(R.drawable.happy_face);
       faceGrid.setVisibility(View.GONE);
       inputMethodManager.showSoftInput(replyContent, InputMethodManager.SHOW_IMPLICIT);
       break;
     case R.id.btn_face_keyboard:
       if (faceGrid.getVisibility() == View.GONE) { // 先关闭输入法,再打开表情面板
         faceKeyboard.setImageResource(R.drawable.keyboard);
         inputMethodManager.hideSoftInputFromWindow(
             getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
         faceGrid.setVisibility(View.VISIBLE);
       } else { // 先关闭面板,再打开输入法
         faceKeyboard.setImageResource(R.drawable.happy_face);
         faceGrid.setVisibility(View.GONE);
         inputMethodManager.showSoftInput(replyContent, InputMethodManager.SHOW_IMPLICIT);
       }
       break;
   }
 }
 private void updateRepeatIcon(Boolean activate) {
   if (activate) {
     ibRepeat.setImageResource(R.drawable.ic_repeat_active);
   } else {
     ibRepeat.setImageResource(R.drawable.ic_repeat);
   }
 }
  @Override
  protected void initActionBar() {
    ActionBar actionBar = getSherlockActivity().getSupportActionBar();
    ActionBar.LayoutParams params =
        new ActionBar.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER);
    View view =
        LayoutInflater.from(getSherlockActivity())
            .inflate(R.layout.custom_actionbar_with_image_text, null);
    titleLeft = (TextView) view.findViewById(R.id.actionbar_title_left);
    titleRight = (TextView) view.findViewById(R.id.actionbar_title_right);
    titleLL = (LinearLayout) view.findViewById(R.id.actionbar_center);
    ImageButton leftButton = (ImageButton) view.findViewById(R.id.actionbar_left);
    ImageButton rightButton = (ImageButton) view.findViewById(R.id.actionbar_right);

    titleLeft.setText(getString(string.history_trend_recent));
    titleRight.setText(getString(string.history_trend_monthly_report));
    leftButton.setImageResource(drawable.public_ic_back);
    rightButton.setImageResource(drawable.detailsoftheresultsview_ic_share);

    titleLeft.setOnClickListener(this);
    titleRight.setOnClickListener(this);
    rightButton.setOnClickListener(this);
    leftButton.setOnClickListener(this);

    switchActionBar(isRecentState);

    actionBar.setCustomView(view, params);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setDisplayShowCustomEnabled(true);
  }
 @Override
 public void onClick(View v) {
   int viewId = v.getId();
   switch (viewId) {
     case R.id.ib_play_pause:
       if (mMediaPlayerService.isPlaying()) {
         mMediaPlayerService.pauseTrack();
         seekHandler.removeCallbacks(updateSeekBar);
         ibPlayPause.setImageResource(R.drawable.ic_play);
       } else {
         mMediaPlayerService.resumeTrack();
         seekHandler.postDelayed(updateSeekBar, 100);
         ibPlayPause.setImageResource(R.drawable.ic_pause);
       }
       break;
     case R.id.ib_previous:
       mCurrentTrack = mMediaPlayerService.playPrevious();
       break;
     case R.id.ib_next:
       mCurrentTrack = mMediaPlayerService.playNext();
       break;
     case R.id.ib_repeat:
       repeat = mMediaPlayerService.turnOnRepeateat();
       updateRepeatIcon(repeat);
       break;
     case R.id.ib_shuffle:
       shuffle = mMediaPlayerService.turnOnShuffle();
       updateShuffleIcon(shuffle);
       break;
     case R.id.ib_share:
       shareSong();
       break;
   }
 }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_start:
       startActivity(new Intent(context, SpeedGameActivity.class));
       break;
     case R.id.btn_shengyin:
       if (SPUtil.getObject(V_SP.SP_USER_Audio_Boolean, Boolean.class, false)) {
         AudioHandleUtils.getInstance().playMusic("mp3/bg.mp3", true);
         btn_shengyin.setImageResource(R.drawable.icon_audio_on);
         SPUtil.saveObject(V_SP.SP_USER_Audio_Boolean, false);
         AudioHandleUtils.getInstance().setAllEnable(true);
       } else {
         AudioHandleUtils.getInstance().stopMusic();
         btn_shengyin.setImageResource(R.drawable.icon_audio_off);
         SPUtil.saveObject(V_SP.SP_USER_Audio_Boolean, true);
         AudioHandleUtils.getInstance().setAllEnable(false);
       }
       break;
     case R.id.btn_paihangbang:
       startActivity(new Intent(context, RanKingActivity.class));
       break;
     case R.id.btn_continue: // 继续游戏
       Intent intent = new Intent(context, SpeedGameActivity.class);
       intent.putExtra(SpeedGameActivity.INTENT_IS_NEW_GAME, false);
       startActivity(intent);
       break;
   }
 }
  @Override
  public void onClick(View v) {
    resetImg();
    switch (v.getId()) {
      case R.id.Weixin:
        mViewPager.setCurrentItem(0);
        mWeixinImg.setImageResource(R.drawable.tab_weixin_pressed);

        break;
      case R.id.contact:
        mViewPager.setCurrentItem(1);
        mAddressImg.setImageResource(R.drawable.tab_address_pressed);
        break;
      case R.id.find:
        mViewPager.setCurrentItem(2);
        mFrdImg.setImageResource(R.drawable.tab_find_frd_pressed);
        break;

      case R.id.setting:
        mViewPager.setCurrentItem(3);
        mSettingImg.setImageResource(R.drawable.tab_settings_pressed);
        break;

      default:
        break;
    }
  }
 @Override
 public void onGetPositioninforesult(Map obj) {
   if (obj != null) {
     int positionInt = (int) fromDateStringToInt((String) obj.get("relTime"));
     mRemotePlayPosition = positionInt;
     if (!mSeekBarTouchMode && (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC)) {
       mNowPosition.setText(setDurationFormat(positionInt));
       mMusicProgress.setProgress(positionInt);
       postGetPositionInfo();
     }
   } else {
     //			mIsPlayOnLocal = true;
     try {
       //				mMusicPlayService.setPlayOnPhone(true);
       mMusicPlayService.seekTo(mRemotePlayPosition);
     } catch (RemoteException e) {
       e.printStackTrace();
     }
     try {
       if (mMusicPlayService.isPlaying()) {
         mStatusButton.setImageResource(R.drawable.video_btn_pause);
       } else {
         mStatusButton.setImageResource(R.drawable.video_btn_start);
       }
     } catch (RemoteException e) {
       e.printStackTrace();
     }
   }
 }
 /*
  * Toggle switch button images
  * changing image states to on / off
  * */
 private void toggleButtonImage() {
   if (isFlashOn) {
     btnSwitch.setImageResource(R.drawable.btn_switch_on);
   } else {
     btnSwitch.setImageResource(R.drawable.btn_switch_off);
   }
 }
  @Override
  public void initButtons() {
    ImageButton take_picture = new ImageButton(a);
    take_picture.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    take_picture.setPadding(0, 0, 0, 0);
    take_picture.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            ((FragmentListener) a).doWait(true);

            cover_image_file = new File(DUMP, "temp_img.jpg");
            cover_image_uri = Uri.fromFile(cover_image_file);
            path_to_cover_image = cover_image_file.getAbsolutePath();
            Intent cameraIntent =
                new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                    .putExtra(MediaStore.EXTRA_OUTPUT, cover_image_uri);
            startActivityForResult(cameraIntent, Source.CAMERA);
          }
        });
    take_picture.setImageResource(R.drawable.camera_selector);

    ImageButton choose_picture = new ImageButton(a);
    choose_picture.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    choose_picture.setPadding(0, 0, 0, 0);
    choose_picture.setOnClickListener(choose_picture_listener);
    choose_picture.setImageResource(R.drawable.gallery_selector);

    ((FragmentListener) a).setButtonOptions(new ImageButton[] {take_picture, choose_picture});
  }
  @MainThread
  public void onEventMainThread(HandshakeComplete event) {
    // Event might arrive before this fragment has connected to the service (e.g.,
    // the activity connected before this fragment did).
    // XXX: Verify that this is possible, since the fragment can't register for events
    // until it's connected to the service.
    if (mService == null) {
      return;
    }

    Log.d(TAG, "Handshake complete");

    dismissConnectingDialog();

    if (mFullHeightLayout) {
      nextButton.setEnabled(true);
      prevButton.setEnabled(true);
      shuffleButton.setEnabled(true);
      repeatButton.setEnabled(true);

      nextButton.setImageResource(mActivity.getAttributeValue(R.attr.ic_action_av_next));
      prevButton.setImageResource(mActivity.getAttributeValue(R.attr.ic_action_av_previous));
      seekBar.setEnabled(true);
    } else {
      mProgressBar.setEnabled(true);
    }

    PlayerState playerState = getPlayerState();

    // May be no players connected.
    // TODO: These views should be cleared if there's no player connected.
    if (playerState == null) return;

    updateUiFromPlayerState(playerState);
  }
  @MainThread
  public void onEventMainThread(ConnectionChanged event) {
    Log.d(TAG, "ConnectionChanged: " + event);

    // The fragment may no longer be attached to the parent activity.  If so, do nothing.
    if (!isAdded()) {
      return;
    }

    // Handle any of the reasons for disconnection, clear the dialog and show the
    // DisconnectedActivity.
    if (event.connectionState == ConnectionState.DISCONNECTED) {
      dismissConnectingDialog();
      DisconnectedActivity.show(mActivity);
      return;
    }

    if (event.connectionState == ConnectionState.CONNECTION_FAILED) {
      dismissConnectingDialog();
      DisconnectedActivity.showConnectionFailed(mActivity);
      return;
    }

    if (event.connectionState == ConnectionState.LOGIN_FAILED) {
      dismissConnectingDialog();
      DisconnectedActivity.showLoginFailed(mActivity);
      return;
    }

    // Any other event means that a connection is in progress, make sure the dialog is showing.
    showConnectingDialog();

    // Ensure that option menu item state is adjusted as appropriate.
    getActivity().supportInvalidateOptionsMenu();

    playPauseButton.setImageResource(mActivity.getAttributeValue(R.attr.ic_action_av_connect));

    if (mFullHeightLayout) {
      nextButton.setEnabled(false);
      prevButton.setEnabled(false);
      shuffleButton.setEnabled(false);
      repeatButton.setEnabled(false);

      albumArt.setImageResource(R.drawable.icon_album_noart_fullscreen);
      nextButton.setImageResource(0);
      prevButton.setImageResource(0);
      shuffleButton.setImageResource(0);
      repeatButton.setImageResource(0);
      updatePlayerDropDown(Collections.<Player>emptyList(), null);
      artistText.setText(getText(R.string.disconnected_text));
      currentTime.setText("--:--");
      totalTime.setText("--:--");
      seekBar.setEnabled(false);
      seekBar.setProgress(0);
    } else {
      albumArt.setImageResource(R.drawable.icon_album_noart);
      mProgressBar.setEnabled(false);
      mProgressBar.setProgress(0);
    }
  }
  @Override
  public void onUpdate() {
    Song nowPlaying = PlayerController.getNowPlaying();
    if (nowPlaying != null) {
      songTitle.setText(nowPlaying.getSongName());
      songArtist.setText(nowPlaying.getArtistName());
      songAlbum.setText(nowPlaying.getAlbumName());

      int duration = PlayerController.getDuration();
      timeDuration.setTime(duration);
      seekBar.setMax(duration);

      if (!observer.isRunning()) {
        observerThread = new Thread(observer);
        observerThread.start();
      }
    } else {
      songTitle.setText(R.string.nothing_playing);
      songArtist.setText(R.string.unknown_artist);
      songAlbum.setText(R.string.unknown_album);
    }

    seekBar.setEnabled(nowPlaying != null);

    if (PlayerController.isPlaying()) {
      playPauseButton.setImageResource(R.drawable.ic_pause_36dp);
    } else {
      playPauseButton.setImageResource(R.drawable.ic_play_arrow_36dp);
    }
  }
Beispiel #17
0
 public void onClick(View view) {
   int id = view.getId();
   if (id == 1000) {
     Intent intent = new Intent(this, ViewMyMap.class);
     startActivity(intent);
     finish();
   } else {
     int i = id / 10;
     int j = id % 10;
     if (P2[i][j] == 88 || P2[i][j] == 99) ; // trying to hit an already hit/missed spot
     else {
       if (P2[i][j] == 0) {
         ((ImageButton) view).setImageResource(R.drawable.x);
         P2[i][j] = 88;
       } else {
         ((ImageButton) view).setImageResource(R.drawable.explosion);
         P2[i][j] = 99;
       }
       int counter = 0;
       for (i = 0; i <= 9; i++) for (j = 0; j <= 9; j++) if (P2[i][j] == 99) counter++;
       if (counter == 12) {
         Toast.makeText(getApplicationContext(), "CONGRATS!!!", Toast.LENGTH_LONG).show();
         finish();
       } else {
         Intent intent = new Intent(this, Enemy.class);
         writeToFile();
         startActivity(intent);
         finish();
       }
     }
   }
 }
Beispiel #18
0
 // 스위치 상태 변경
 private void viewSwitchSet(int sw) {
   if (sw == 0) {
     mBtnPlayer.setImageResource(R.drawable.player_play);
   } else {
     mBtnPlayer.setImageResource(R.drawable.player_pause);
   }
 }
  private void updateViews() {
    if (!mDebugging) {
      mViewDebug.setVisibility(View.GONE);
      mLvDebug.setVisibility(View.GONE);

      if (mIsLoading && !mSharedPrefs.getBoolean("pref_disable_splash", false)) {
        mIitcWebView.setVisibility(View.GONE);
        mImageLoading.setVisibility(View.VISIBLE);
      } else {
        mIitcWebView.setVisibility(View.VISIBLE);
        mImageLoading.setVisibility(View.GONE);
      }
    } else {
      // if the debug container is invisible (and we are about to show it), select the text box
      final boolean select = mViewDebug.getVisibility() != View.VISIBLE;

      mImageLoading.setVisibility(View.GONE); // never show splash screen while debugging
      mViewDebug.setVisibility(View.VISIBLE);

      if (select) {
        mEditCommand.requestFocus();
        mEditCommand.selectAll();
      }

      if (mShowMapInDebug) {
        mBtnToggleMap.setImageResource(R.drawable.ic_action_view_as_list);
        mIitcWebView.setVisibility(View.VISIBLE);
        mLvDebug.setVisibility(View.GONE);
      } else {
        mBtnToggleMap.setImageResource(R.drawable.ic_action_map);
        mIitcWebView.setVisibility(View.GONE);
        mLvDebug.setVisibility(View.VISIBLE);
      }
    }
  }
  @Subscribe
  public void changePlayerControls(PlayerControlsChangeEvent playerControlsChangeEvent) {
    if (playerControlsChangeEvent.state == PlayerControlsChangeEvent.SHOW_PLAY_ICON) {
      playPauseBtn.setImageResource(R.drawable.ic_play_circle_outline_white_24dp);

      Resources resources = getResources();
      String name =
          String.format(
              resources.getString(R.string.favourite_station_playing),
              resources.getString(R.string.listen),
              playerControlsChangeEvent.getStation().getName());
      stationName.setText(name);

    } else if (playerControlsChangeEvent.state == PlayerControlsChangeEvent.SHOW_PAUSE_ICON) {
      playPauseBtn.setImageResource(R.drawable.ic_pause_circle_outline_white_24dp);

      Resources resources = getResources();
      String name =
          String.format(
              resources.getString(R.string.favourite_station_playing),
              resources.getString(R.string.listening),
              playerControlsChangeEvent.getStation().getName());
      stationName.setText(name);
    }
  }
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.ButtonTestPlayPause) {
      /** ImageButton onClick event handler. Method which start/pause mediaplayer playing */
      try {
        mediaPlayer.setDataSource(
            "http://stream7.cache12.vcdn.vn/fsfsdfdsfdserwrwq3/df399b944be816f5fcf8d0671209dad5/55a0a05d/2015/05/15/6/6/66dd8254b28ea00774d136e251a40a98.mp3"); // setup song from http://www.hrupin.com/wp-content/uploads/mp3/testsong_20_sec.mp3 URL to mediaplayer data source
        mediaPlayer
            .prepare(); // you must call this method after setup the datasource in setDataSource
        // method. After calling prepare() the instance of MediaPlayer starts load
        // data from URL to internal buffer.
      } catch (Exception e) {
        e.printStackTrace();
      }

      mediaFileLengthInMilliseconds =
          mediaPlayer.getDuration(); // gets the song length in milliseconds from URL

      if (!mediaPlayer.isPlaying()) {
        mediaPlayer.start();
        buttonPlayPause.setImageResource(R.drawable.button_pause);
      } else {
        mediaPlayer.pause();
        buttonPlayPause.setImageResource(R.drawable.button_play);
      }

      primarySeekBarProgressUpdater();
    }
  }
 private void updateShuffleIcon(Boolean activate) {
   if (activate) {
     ibShuffle.setImageResource(R.drawable.ic_shuffle_active);
   } else {
     ibShuffle.setImageResource(R.drawable.ic_shuffle);
   }
 }
Beispiel #23
0
  public void setUser(ArrayList<MimicData> playdata) {
    this.mimicdatas = playdata;
    final MimicData x = mimicdatas.get(0);
    String na = x.geturl();
    ImageView dp = (ImageView) findViewById(R.id.commentpagedisplaypic);
    imageloader.DisplayImage(na, dp);
    TextView user = (TextView) findViewById(R.id.commentpageusername);
    user.setText(x.getUsername());
    TextView description = (TextView) findViewById(R.id.commentpagedescription);
    description.setText(x.getsharecount());
    TextView like = (TextView) findViewById(R.id.commentpagelikecount);
    like.setText(x.getlikecounter());
    TextView commentcount = (TextView) findViewById(R.id.commentpagereplycount);
    commentcount.setText(x.getcommentcounter());
    final ImageButton s = (ImageButton) findViewById(R.id.commentpagelike);

    final boolean w = x.getLikes();
    if (w == true) {
      s.setImageResource(R.drawable.liked);
    } else {
      s.setImageResource(R.drawable.like);
    }

    s.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            final liking likes = new liking();
            final dislike dislike = new dislike();
            if (w == true) {
              s.setImageResource(R.drawable.like);
              String m = Integer.toString(postid);
              dislike.execute(m);
            } else {
              s.setImageResource(R.drawable.liked);
              String m = Integer.toString(postid);
              likes.execute(m);
            }
          }
        });
    playpostbutton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            String url = x.getposturl();

            if (player.isPlaying()) {
              playpostbutton.setImageResource(R.drawable.playbutton);
              player.stop();
              startPlaying(url);
            } else {
              playpostbutton.setImageResource(R.drawable.playbutton);
              startPlaying(url);
            }
          }
        });
  }
        @Override
        public void onClick(View arg0) {
          // Toggle shuffle on/off.
          boolean shuffleOn = mApp.getService().toggleShuffleMode();

          if (shuffleOn) mShuffleButton.setImageResource(R.drawable.shuffle_highlighted);
          else mShuffleButton.setImageResource(UIElementsHelper.getIcon(mContext, "shuffle"));
        }
Beispiel #25
0
  @Override
  public void onClick(View v) {
    if (mPlaybackService == null) return;
    if (v == mVideoSurface || v == playButton) {
      if (mPlaybackService != null) {
        MyMediaPlayer.PLAYBACK_STATE state = mPlaybackService.getPlaybackState();
        switch (state) {
          case PAUSED:
            mPlaybackService.resumePlayback();
            mediaControllerLayout.setVisibility(View.VISIBLE);
            playButton.setImageResource(R.drawable.ic_media_pause);
            //                    mPauseImage.setImageResource(R.drawable.ic_media_pause);
            break;
          case PLAYING:
            mPlaybackService.pausePlayback();
            mediaControllerLayout.setVisibility(View.VISIBLE);
            playButton.setImageResource(R.drawable.ic_media_play);
            //                    mPauseImage.setImageResource(R.drawable.ic_media_play);
            break;
          default:
            pickVideo();
            break;
        }
      }
    } else if (v == mNextButton_slider) {

      mPlaybackService.setNextPic();

      Leg.i(TAG, "mNextButton_slider ====================== ");

    } else if (v == mPreviousButton_slider) {
      Leg.i(TAG, "mPreviousButton_slider ====================== ");
      mPlaybackService.setPreviousPic();

    } else if (v == mPlay_pauseButton_slider) {
      mPlaybackService.setpausePlayback();

    } else if (v == slidingMenu_open || v == slidingMenu_open_image || v == slidingMenu_open_text) {
      pickVideo();
      showContent();

    } else if (v == slidingMenu_repeat
        || v == slidingMenu_repeat_image
        || v == slidingMenu_repeat_text) {
      switchLooping();
    } else if (v == slidingMenu_about
        || v == slidingMenu_about_image
        || v == slidingMenu_about_text) {
      openAboutDialog();

    } else if (v == sliding_floatwindow || v == sliding_floatwindow_text) {
      if (sliding_checkbox_floatwindow.isChecked()) {
        sliding_checkbox_floatwindow.setChecked(false);
      } else {
        sliding_checkbox_floatwindow.setChecked(true);
      }
    }
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    final Audio audio = (Audio) mAudioList.get(position);
    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.gallery_audio_list_item, null);
    }
    final ImageButton playAudio =
        (ImageButton) convertView.findViewById(R.id.gallery_audio_list_item_play);

    // If current audio is being played than put pause button else put play button
    if (currentPlayingAudioId.equals(audio.getId())) {
      playAudio.setImageResource(R.drawable.ic_pause_black_24dp);
    } else {
      playAudio.setImageResource(R.drawable.ic_play_arrow_black_24dp);
    }

    playAudio.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Condition 1: if already playing and clicked for the audio which is already playing
            if (isPlaying && audio.getId().equals(currentPlayingAudioId)) {
              mPlayer.stopPlaying();
              playAudio.setImageResource(R.drawable.ic_play_arrow_black_24dp);
              currentPlayingAudioId = "-1";
              lastPlayedAudioPlayButton = playAudio;
              isPlaying = false;
            } else {
              // Condition : If already playing and play clicked for different audio, than change
              // the icon of the previous playing audio
              if (isPlaying) {
                mPlayer.stopPlaying();
                if (lastPlayedAudioPlayButton != null) {
                  lastPlayedAudioPlayButton.setImageResource(R.drawable.ic_play_arrow_black_24dp);
                }
              }

              if (audio.getDataLocalURL() == null) {
                mProgressDialog.show();
                DownloadAudioAsyncTask asyncTask =
                    new DownloadAudioAsyncTask(DOWNLOAD_EVENT_CODE, audio);
                asyncTask.execute();
              } else {
                mPlayer = new AudioPlayer(audio.getDataLocalURL(), AudioGalleryAdapter.this);
                mPlayer.startPlaying();
              }
              playAudio.setImageResource(R.drawable.ic_pause_black_24dp);
              currentPlayingAudioId = audio.getId();
              lastPlayedAudioPlayButton = playAudio;
              isPlaying = true;
            }
          }
        });

    return convertView;
  }
 /** Sets the shuffle button icon based on the current shuffle mode. */
 private void setShuffleButtonIcon() {
   if (mApp.isServiceRunning())
     if (mApp.getService().isShuffleOn() == true) {
       mShuffleButton.setImageResource(R.drawable.shuffle_highlighted);
     } else {
       mShuffleButton.setImageResource(UIElementsHelper.getIcon(mContext, "shuffle"));
     }
   else mShuffleButton.setImageResource(UIElementsHelper.getIcon(mContext, "shuffle"));
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    int pos = (position - 1) / 2;
    if (position % 2 == 0) {
      convertView = View.inflate(context, R.layout.fram_cart1_listitem_blank, null);
    } else {
      convertView = View.inflate(context, R.layout.fram_cart1_listitem, null);
      LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.content);
      TextView title = (TextView) convertView.findViewById(R.id.title);

      ImageButton group = (ImageButton) convertView.findViewById(R.id.groupbtn);
      group.setOnClickListener(this);
      group.setTag(pos);
      // groupstate.put(pos+"", 0);   //为选择状态
      if (grouplist.get(pos).groupstate == 0) {
        group.setImageResource(R.drawable.selectno);
      } else {
        group.setImageResource(R.drawable.selected);
      }

      GroupItem groupItem = grouplist.get(pos).groupItem;
      title.setText(groupItem.company);
      // Map<String,Integer> childmap = new HashMap<String, Integer>();
      for (int i = 0; i < groupItem.cartlist.size(); i++) {
        ChildItem chlidItem = grouplist.get(pos).childlist.get(i).childItem;
        View view = View.inflate(context, R.layout.fram_cart1_listitem_content, null);
        ll.addView(view);

        ImageButton chlid = (ImageButton) view.findViewById(R.id.childbtn);
        chlid.setOnClickListener(this);
        chlid.setTag(pos + "|" + i);

        if (grouplist.get(pos).childlist.get(i).childstate == 0) {
          chlid.setImageResource(R.drawable.selectno);
        } else {
          chlid.setImageResource(R.drawable.selected);
        }

        // childmap.put(i+"", 0);

        TextView cartname = (TextView) view.findViewById(R.id.cartname);
        TextView type = (TextView) view.findViewById(R.id.type);
        TextView price = (TextView) view.findViewById(R.id.price);
        TextView number = (TextView) view.findViewById(R.id.number);

        cartname.setText(chlidItem.catname);
        type.setText("类别:" + chlidItem.title);
        price.setText("¥" + chlidItem.price);
        number.setText("x" + chlidItem.number);
      }
      // childstate.put(pos+"", childmap);

    }

    return convertView;
  }
Beispiel #29
0
  /** @hide */
  protected void updatePausePlay() {
    if (mRoot == null || mPauseButton == null) return;

    if (mPlayer.isPlaying()) {
      mPauseButton.setImageResource(R.drawable.ic_media_pause);
    } else {
      mPauseButton.setImageResource(R.drawable.ic_media_play);
    }
  }
  private void updatePausePlay() {
    if (mRoot == null || mPauseButton == null) return;

    if (mPlayer.isPlaying()) {
      mPauseButton.setImageResource(com.android.internal.R.drawable.ic_media_pause);
    } else {
      mPauseButton.setImageResource(com.android.internal.R.drawable.ic_media_play);
    }
  }