private boolean rulesChanged() { if (editedRules.size() != reference.getRules().length) { return true; } for (int i = 0; i < editedRules.size(); i++) { if (!reference.getRules()[i].equals(editedRules.get(i))) { return true; } } return false; }
@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)); }