예제 #1
0
  public PlaylistViewHolder(View itemView) {
    super(itemView);
    playlistName = (TextView) itemView.findViewById(R.id.instanceTitle);
    moreButton = (ImageView) itemView.findViewById(R.id.instanceMore);

    playlistName.setTextColor(Themes.getListText());
    moreButton.setColorFilter(Themes.getListText());

    itemView.setOnClickListener(this);
    moreButton.setOnClickListener(this);

    context = itemView.getContext();
  }
예제 #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_player_controls, container, false);

    songTitle = (TextView) view.findViewById(R.id.textSongTitle);
    songArtist = (TextView) view.findViewById(R.id.textArtistName);
    songAlbum = (TextView) view.findViewById(R.id.textAlbumTitle);

    moreInfoButton = (ImageButton) view.findViewById(R.id.songDetail);
    skipNextButton = (ImageButton) view.findViewById(R.id.nextButton);
    skipPrevButton = (ImageButton) view.findViewById(R.id.previousButton);
    playPauseButton = (ImageButton) view.findViewById(R.id.playButton);

    moreInfoButton.setOnClickListener(this);
    skipNextButton.setOnClickListener(this);
    skipPrevButton.setOnClickListener(this);
    playPauseButton.setOnClickListener(this);

    seekBar = (SeekBar) view.findViewById(R.id.songSeekBar);
    timePosition = (TimeView) view.findViewById(R.id.songTimeCurr);
    timeDuration = (TimeView) view.findViewById(R.id.songTimeMax);
    scrubberThumb = (TimeView) view.findViewById(R.id.seekThumb);

    seekBar.setOnSeekBarChangeListener(this);
    scrubberThumb.getBackground().setColorFilter(Themes.getAccent(), PorterDuff.Mode.SRC_IN);

    return view;
  }
예제 #3
0
  @Override
  public void onBackPressed() {
    if (!editedReference.isEqual(reference) || rulesChanged()) {
      AlertDialog dialog =
          new AlertDialog.Builder(this)
              .setMessage("Save changes?")
              .setPositiveButton(
                  "Save",
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      if (validateName()) {
                        saveChanges();
                        Navigate.back(AutoPlaylistEditActivity.this);
                      }
                    }
                  })
              .setNegativeButton(
                  "Discard",
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      Navigate.back(AutoPlaylistEditActivity.this);
                    }
                  })
              .setNeutralButton("Cancel", null)
              .show();

      Themes.themeAlertDialog(dialog);
    } else {
      super.onBackPressed();
    }
  }
예제 #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_instance_no_miniplayer);

    reference = getIntent().getParcelableExtra(PLAYLIST_EXTRA);
    if (reference == null) {
      reference = AutoPlaylist.EMPTY;
    }

    if (savedInstanceState != null) {
      editedReference = savedInstanceState.getParcelable(EDITED_HEADER);
      editedRules = savedInstanceState.getParcelableArrayList(EDITED_RULES);
    }

    if (editedReference == null || editedRules == null) {
      editedReference = new AutoPlaylist(reference);
      editedRules = new ArrayList<>(reference.getRules().length);
      Collections.addAll(editedRules, editedReference.getRules());
    }

    if (getSupportActionBar() != null) {
      if (reference == null) {
        getSupportActionBar().setTitle(R.string.playlist_auto_new);
      } else {
        getSupportActionBar().setTitle(reference.getPlaylistName());
      }
      getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_done_24dp);
    }

    adapter =
        new HeterogeneousAdapter()
            .addSection(new RuleHeaderSingleton(editedReference))
            .addSection(new RuleSection(editedRules, this));

    RecyclerView list = (RecyclerView) findViewById(R.id.list);
    list.setAdapter(adapter);
    list.setLayoutManager(new LinearLayoutManager(this));
    list.addItemDecoration(new BackgroundDecoration(Themes.getBackgroundElevated()));
    list.addItemDecoration(new DividerDecoration(this));
  }
예제 #5
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.add:
        editedRules.add(new AutoPlaylist.Rule(AutoPlaylist.Rule.EMPTY));
        adapter.notifyItemInserted(editedRules.size());
        return true;
      case R.id.discard:
        if (rulesChanged()) {
          AlertDialog dialog =
              new AlertDialog.Builder(this)
                  .setMessage("Discard changes?")
                  .setPositiveButton(
                      "Discard",
                      new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                          finish();
                        }
                      })
                  .setNegativeButton(R.string.action_cancel, null)
                  .show();

          Themes.themeAlertDialog(dialog);
        } else {
          finish();
        }
        return true;
      case android.R.id.home:
        if (validateName()) {
          if (!editedReference.isEqual(reference) || rulesChanged()) {
            saveChanges();
          }
        } else {
          return true;
        }
        break;
    }
    return super.onOptionsItemSelected(item);
  }