package se.kth.csc.stayawhile;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class QueueAdapter extends RecyclerView.Adapter<QueueAdapter.ViewHolder> {

    private JSONArray mDataset;

    public class ViewHolder extends RecyclerView.ViewHolder {

        public View mCardView;
        public JSONObject mData;

        public ViewHolder(View v) {
            super(v);
            mCardView = v;
        }

        public void setData(JSONObject data) {
            this.mData = data;
            try {
                TextView title = (TextView) mCardView.findViewById(R.id.queuee_name);
                title.setText(data.getString("realname"));
                TextView length = (TextView) mCardView.findViewById(R.id.queuee_location);
                length.setText(data.getString("location"));
            } catch (JSONException e) {
                //TODO
            }
        }
    }

    // Provide a suitable constructor (depends on the kind of dataset)
    public QueueAdapter(JSONArray myDataset, Context context) {
        mDataset = myDataset;
    }

    // Create new views (invoked by the layout manager)
    @Override
    public QueueAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        // create a new view
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.queuee, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        try {
            JSONObject queue = mDataset.getJSONObject(position);
            holder.setData(queue);
        } catch (JSONException e) {
            e.printStackTrace();
            // TODO
        }
    }

    // Return the size of your dataset (invoked by the layout manager)
    @Override
    public int getItemCount() {
        return mDataset.length();
    }

}

@@ -57,16 +57,50 @@
 ontext;%0A
+import android.graphics.Typeface;%0A
 import a
@@ -134,24 +134,24 @@
 cyclerView;%0A
-
 import andro
@@ -466,17 +466,57 @@
 ataset;%0A
+    private boolean firstInQueue = true;
 %0A
-
     publ
@@ -998,21 +998,23 @@
 xtView l
-ength
+ocation
  = (Text
@@ -1082,21 +1082,23 @@
        l
-ength
+ocation
 .setText
@@ -1123,24 +1123,487 @@
 ocation%22));%0A
+%0A                if(firstInQueue &&!data.getBoolean(%22gettingHelp%22))%7B%0A                    title.setText(%22%5Cu25B6 %22 + title.getText());%0A                    title.setTypeface(Typeface.DEFAULT_BOLD);%0A                    location.setTypeface(Typeface.DEFAULT_BOLD);%0A                    firstInQueue = false;%0A                %7D else %7B%0A                    title.setTypeface(Typeface.DEFAULT);%0A                    location.setTypeface(Typeface.DEFAULT);%0A                %7D%0A%0A
             

Add basic highlighting of first user that does not receive help in queue