コード例 #1
0
ファイル: PlayerControllerView.java プロジェクト: ruwank/Book
  void initViews(Context context, AttributeSet attrs) {
    this.context = context;

    LayoutInflater.from(context).inflate(R.layout.view_player_controller, this, true);
    playPauseButton = (ImageButton) this.findViewById(R.id.playPauseButton);
    bookCoverImage = (ImageView) this.findViewById(R.id.bookCoverImage);
    audioTitle = (TextView) this.findViewById(R.id.audioTitle);
    subTitle = (TextView) this.findViewById(R.id.subTitle);

    playPauseButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            playPauseAudio();
          }
        });
    AudioBook audioBook = AppController.getInstance().getCurrentAudioBook();
    if (audioBook != null) {
      audioTitle.setText(audioBook.getEnglish_title());

      String img_path =
          AppUtils.getDataDirectory(context)
              + audioBook.getBook_id()
              + File.separator
              + "book_cover.jpg";

      File imgFile = new File(img_path);

      if (imgFile.exists()) {
        Picasso.with(context).load(imgFile).into(bookCoverImage);

      } else {
        Picasso.with(context)
            .load(audioBook.getCover_image())
            .placeholder(R.drawable.ic_launcher)
            .into(bookCoverImage);
      }
    }

    updateView();
  }
コード例 #2
0
ファイル: PlayerControllerView.java プロジェクト: ruwank/Book
  public void updateView() {
    AudioBook audioBook = AppController.getInstance().getCurrentAudioBook();
    if (audioBook != null) {
      audioTitle.setText(audioBook.getEnglish_title());

      String img_path =
          AppUtils.getDataDirectory(context)
              + audioBook.getBook_id()
              + File.separator
              + "book_cover.jpg";

      File imgFile = new File(img_path);

      if (imgFile.exists()) {
        Picasso.with(context).load(imgFile).into(bookCoverImage);

      } else {
        Picasso.with(context)
            .load(audioBook.getCover_image())
            .placeholder(R.drawable.ic_launcher)
            .into(bookCoverImage);
      }
    }

    if (AudioPlayerService.mediaPlayer != null) {

      if (AudioPlayerService.mediaPlayer.isPlaying()) {
        playPauseButton.setImageResource(R.drawable.btn_play_preview_pause);

      } else {
        playPauseButton.setImageResource(R.drawable.btn_play_preview_start);
      }
    }

    subTitle.setText(AppController.getInstance().getPlayerControllerTitle());
  }