// Path: app/src/main/java/ca/marklauman/dominionpicker/userinterface/recyclerview/AdapterSortCard.java
// public class AdapterSortCard extends BasicTouchAdapter<AdapterSortCard.ViewHolder> {
// 
//     /** The current sort order (stores the sort ids in the order in which they are applied) */
//     private final ArrayList<Integer> sortOrder;
//     /** Names used to label the individual items. Sorted by sort id. */
//     private final String[] names;
// 
// 
//     public AdapterSortCard(Context context, RecyclerView view) {
//         super(view, TouchCallback.forDragList());
//         hasStableIds();
//         Resources res = context.getResources();
//         names = res.getStringArray(R.array.sort_card_names);
// 
//         // load the sort order
//         String[] prefOrder = Pref.get(context)
//                                  .getString(Pref.SORT_CARD, res.getString(R.string.sort_card_def))
//                                  .split(",");
//         sortOrder = new ArrayList<>(prefOrder.length);
//         for(String id : prefOrder)
//             sortOrder.add(Integer.parseInt(id));
//     }
// 
// 
//     public ArrayList<Integer> getSortOrder() {
//         return sortOrder;
//     }
// 
// 
//     @Override
//     public long getItemId(int position) {
//         return sortOrder.get(position);
//     }
// 
// 
//     @Override
//     public int getItemCount() {
//         return sortOrder.size();
//     }
// 
// 
//     @Override
//     public void onItemMove(int fromPosition, int toPosition) {
//         Collections.swap(sortOrder, fromPosition, toPosition);
//         notifyItemMoved(fromPosition, toPosition);
//     }
// 
// 
//     @Override
//     public void onDismiss(int position) { /* Never called */ }
// 
// 
//     @Override @NonNull
//     public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//         LayoutInflater inflater = LayoutInflater.from(parent.getContext());
//         return new ViewHolder(inflater.inflate(R.layout.list_item_sort, parent, false));
//     }
// 
// 
//     @Override
//     public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//         int id = sortOrder.get(position);
//         holder.text1.setText(names[id]);
//         holder.text2.setVisibility(id==1 ? View.VISIBLE : View.GONE);
//     }
// 
// 
//     public class ViewHolder extends RecyclerView.ViewHolder
//                             implements View.OnTouchListener {
//         @BindView(android.R.id.text1) public TextView text1;
//         @BindView(android.R.id.text2) public TextView text2;
//         @BindView(android.R.id.icon)  ImageView drag;
// 
//         public ViewHolder(View itemView) {
//             super(itemView);
//             ButterKnife.bind(this, itemView);
//             drag.setOnTouchListener(this);
//         }
// 
//         @Override
//         public boolean onTouch(View v, MotionEvent event) {
//             if(event.getAction() == MotionEvent.ACTION_DOWN)
//                 startDrag(this);
//             return true;
//         }
//     }
// }


import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import ca.marklauman.dominionpicker.R;
import ca.marklauman.dominionpicker.userinterface.recyclerview.AdapterSortCard;
import ca.marklauman.tools.Utils;
import ca.marklauman.tools.recyclerview.ListDivider;
package ca.marklauman.dominionpicker.settings;



/** Activity used to change the card sort order.
 *  @author Mark Lauman */
public class ActivitySortCard extends AppCompatActivity {

    private AdapterSortCard mAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Pref.checkLanguage(this);
        setContentView(R.layout.activity_sort_card);
        ActionBar ab = getSupportActionBar();
        if(ab != null) ab.setDisplayHomeAsUpEnabled(true);

        RecyclerView list = findViewById(android.R.id.list);
        if(list == null) return;
        list.setLayoutManager(new LinearLayoutManager(this));
        list.addItemDecoration(new ListDivider(this));
        mAdapter = new AdapterSortCard(this, list);
        list.setAdapter(mAdapter);
        list.hasFixedSize();
    }

    @Override
    public void onStop() {
        super.onStop();
        Pref.edit(this)
            .putString(Pref.SORT_CARD, Utils.join(",", mAdapter.getSortOrder()))
            .commit();
    }

// Path: app/src/main/java/ca/marklauman/dominionpicker/userinterface/recyclerview/AdapterSortCard.java
// public class AdapterSortCard extends BasicTouchAdapter<AdapterSortCard.ViewHolder> {
// 
//     /** The current sort order (stores the sort ids in the order in which they are applied) */
//     private final ArrayList<Integer> sortOrder;
//     /** Names used to label the individual items. Sorted by sort id. */
//     private final String[] names;
// 
// 
//     public AdapterSortCard(Context context, RecyclerView view) {
//         super(view, TouchCallback.forDragList());
//         hasStableIds();
//         Resources res = context.getResources();
//         names = res.getStringArray(R.array.sort_card_names);
// 
//         // load the sort order
//         String[] prefOrder = Pref.get(context)
//                                  .getString(Pref.SORT_CARD, res.getString(R.string.sort_card_def))
//                                  .split(",");
//         sortOrder = new ArrayList<>(prefOrder.length);
//         for(String id : prefOrder)
//             sortOrder.add(Integer.parseInt(id));
//     }
// 
// 
//     public ArrayList<Integer> getSortOrder() {
//         return sortOrder;
//     }
// 
// 
//     @Override
//     public long getItemId(int position) {
//         return sortOrder.get(position);
//     }
// 
// 
//     @Override
//     public int getItemCount() {
//         return sortOrder.size();
//     }
// 
// 
//     @Override
//     public void onItemMove(int fromPosition, int toPosition) {
//         Collections.swap(sortOrder, fromPosition, toPosition);
//         notifyItemMoved(fromPosition, toPosition);
//     }
// 
// 
//     @Override
//     public void onDismiss(int position) { /* Never called */ }
// 
// 
//     @Override @NonNull
//     public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//         LayoutInflater inflater = LayoutInflater.from(parent.getContext());
//         return new ViewHolder(inflater.inflate(R.layout.list_item_sort, parent, false));
//     }
// 
// 
//     @Override
//     public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//         int id = sortOrder.get(position);
//         holder.text1.setText(names[id]);
//         holder.text2.setVisibility(id==1 ? View.VISIBLE : View.GONE);
//     }
// 
// 
//     public class ViewHolder extends RecyclerView.ViewHolder
//                             implements View.OnTouchListener {
//         @BindView(android.R.id.text1) public TextView text1;
//         @BindView(android.R.id.text2) public TextView text2;
//         @BindView(android.R.id.icon)  ImageView drag;
// 
//         public ViewHolder(View itemView) {
//             super(itemView);
//             ButterKnife.bind(this, itemView);
//             drag.setOnTouchListener(this);
//         }
// 
//         @Override
//         public boolean onTouch(View v, MotionEvent event) {
//             if(event.getAction() == MotionEvent.ACTION_DOWN)
//                 startDrag(this);
//             return true;
//         }
//     }
// }


// Path: app/src/main/java/ca/marklauman/dominionpicker/settings/ActivitySortCard.java
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import ca.marklauman.dominionpicker.R;
import ca.marklauman.dominionpicker.userinterface.recyclerview.AdapterSortCard;
import ca.marklauman.tools.Utils;
import ca.marklauman.tools.recyclerview.ListDivider;

package ca.marklauman.dominionpicker.settings;



/** Activity used to change the card sort order.
 *  @author Mark Lauman */
public class ActivitySortCard extends AppCompatActivity {

    private AdapterSortCard mAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Pref.checkLanguage(this);
        setContentView(R.layout.activity_sort_card);
        ActionBar ab = getSupportActionBar();
        if(ab != null) ab.setDisplayHomeAsUpEnabled(true);

        RecyclerView list = findViewById(android.R.id.list);
        if(list == null) return;
        list.setLayoutManager(new LinearLayoutManager(this));
        list.addItemDecoration(new ListDivider(this));
        mAdapter = new AdapterSortCard(this, list);
        list.setAdapter(mAdapter);
        list.hasFixedSize();
    }

    @Override
    public void onStop() {
        super.onStop();
        Pref.edit(this)
            .putString(Pref.SORT_CARD, Utils.join(",", mAdapter.getSortOrder()))
            .commit();
    }

    @Override