title: Move item in RecyclerView to another position
body: <p>I have a list of items in a RecyclerView which gets populated from a Firebase Database. I'd like to implement movement of items inside the RecyclerView by long press and dragging. (Similar to Google's note app "Keep")</p>
  
  <p>I have already seen some other similar questions but I was not able to find any solution which suits my needs.</p>
  
  <p>Following some code examples.</p>
  
  <p><strong>MainActivity</strong> (onCreate)</p>
  
  <pre><code> mRecycler = (RecyclerView) findViewById(R.id.messages_list);
      mRecycler.setHasFixedSize(true);
  
  
  
      mManager = new LinearLayoutManager(getApplicationContext());
      mManager.setReverseLayout(false);
      mManager.setStackFromEnd(false);
      mRecycler.setLayoutManager(mManager);
  
  
      findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              startActivity(new Intent(RecordActivity.this, NewRecordActivity.class));
          }
      });
  
      // Set up FirebaseRecyclerAdapter with the Query
  
      mAdapter = new FirebaseRecyclerAdapter&lt;Record, RecordViewHolder&gt;(Record.class, R.layout.item_record, RecordViewHolder.class, mDatabase.child("user-record").child(getUid())) {
          @Override
          protected void populateViewHolder(final RecordViewHolder viewHolder, final Record model, final int position) {
              final DatabaseReference postRef = getRef(position);
  
              // Set click listener for the whole post view
              final String postKey = postRef.getKey();
              viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      // Launch RecordDetailActivity
                      Intent intent = new Intent(getApplicationContext(), RecordDetailActivity.class);
  
                      //MANDARE TESTO A POSTDETAILACTIVITY
                      intent.putExtra(RecordDetailActivity.EXTRA_POST_KEY, postKey);
                      intent.putExtra(RecordDetailActivity.TITLE, model.title);
                      intent.putExtra(RecordDetailActivity.BODY, model.body);
                      intent.putExtra(RecordDetailActivity.DATE, model.date);
                      intent.putExtra(RecordDetailActivity.NOTE, model.note);
                      intent.putExtra(RecordDetailActivity.COLOR, model.color);
                      startActivity(intent);
                  }
              });
              // Bind Record to ViewHolder, setting OnClickListener for the star button
  
              viewHolder.bindToPost( model);
  </code></pre>
  
  <p><strong>RecordViewHolder</strong></p>
  
  <pre><code>public class RecordViewHolder extends RecyclerView.ViewHolder {
  
  public TextView titleView;
  public TextView bodyView;
  public TextView dateView;
  public TextView noteView;
  public TextView colorView;
  public CardView cardView;
  
  
  public RecordViewHolder(View itemView) {
      super(itemView);
  
      titleView = (TextView) itemView.findViewById(R.id.post_title);
      bodyView = (TextView) itemView.findViewById(R.id.post_body);
      dateView = (TextView) itemView.findViewById(R.id.record_item_date);
      noteView = (TextView) itemView.findViewById(R.id.record_item_note);
      colorView = (TextView) itemView.findViewById(R.id.record_item_color);
      cardView = (CardView) itemView.findViewById(R.id.record_item_card);
  }
  
  public void bindToPost(Record record) {
      titleView.setText(record.title);
      bodyView.setText(record.body);
      dateView.setText(record.date);
      noteView.setText(record.note);
      colorView.setText(record.color);
  }
  </code></pre>