@Override
 public void onSuccess(NoteList result) {
   noteListAdapter.addNotes(result);
   noteListAdapter.notifyDataSetChanged();
   currentOffset += result.getNotesSize();
   if (result.getNotesSize() >= MAX_ITEMS) {
     noteListAdapter.addLoading();
   } else {
     isLastPage = true;
   }
   hideLoading();
 }
 @Override
 public void onItemClick(View v, int position) {
   Intent noteDetailIntent = new Intent(this, NoteDetailActivity.class);
   noteDetailIntent.putExtra(
       getString(R.string.note_guid), noteListAdapter.getItem(position).getGuid());
   startActivity(noteDetailIntent);
 }
  private void initRecyclerView() {

    recyclerView.setHasFixedSize(true);

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);

    noteListAdapter = new NoteListAdapter();
    noteListAdapter.setOnItemClickListener(this);
    recyclerView.setAdapter(noteListAdapter);
  }
 private void sortBy(NoteSortOrder order) {
   currentOffset = 0;
   noteListAdapter.clearData();
   retrieveNotes(order);
 }