Пример #1
0
  private boolean validateName() {
    boolean valid =
        editedReference
                .getPlaylistName()
                .trim()
                .equalsIgnoreCase(reference.getPlaylistName().trim())
            || Library.verifyPlaylistName(this, editedReference.getPlaylistName()) == null;

    if (!valid) {
      RecyclerView list = (RecyclerView) findViewById(R.id.list);
      list.scrollToPosition(0);
    }
    return valid;
  }
Пример #2
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));
  }