title: Getting recyclerview position and passing object on click
body: <p>I really need your help here guys, i'm stuck. In short i have made recyclerview to show my parsed json data. What i'm stuck at is on how to get recyclerview position and pass json object to new activity trough intent. Here is my code so you can see whats going on. 
  MainActivity:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements SearchView.OnQueryTextListener {
  
  ArrayList&lt;Item&gt; end = new ArrayList&lt;Item&gt;();
  RecyclerView recyclerView;
  Adapter adapter;
  List&lt;Item&gt; mModels;
  Context context = this;
  
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      outState.putParcelableArrayList("KEY2", end);
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      // View view = LayoutInflater.from(this).inflate(R.layout.activity_main, null, false);
      setContentView(R.layout.activity_main);
      recyclerView = (RecyclerView) findViewById(R.id.RecylerView);
      recyclerView.setLayoutManager(new LinearLayoutManager(this));
      adapter = new Adapter(this);
      recyclerView.setAdapter(adapter);
  
  
      if (isAvailable() &amp;&amp; savedInstanceState == null)
      //Check if network is available
      {
          jsonreq();
      } else if (savedInstanceState != null)
  
      {
          end = savedInstanceState.getParcelableArrayList("KEY2");
          adapter.list(end);
  
  
      } else {
          Toast.makeText(this, "Molimo, ukljucite internet.", Toast.LENGTH_LONG).show();
  
      }
  
  
  }
  
  
  private boolean isAvailable() {
      ConnectivityManager manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo networkInfo = manager.getActiveNetworkInfo();
      Boolean isAvail = false;
      if (networkInfo != null &amp;&amp; networkInfo.isConnected()) {
          isAvail = true;
      }
      return isAvail;
  
  }
  
  public void jsonreq() {
      String url = "http://www.json-generator.com/api/json/get/cfOhbHcpki?indent=2";
      RequestQueue requestQueue = VolleySingelton.getrequestQueue();
  
      JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener&lt;JSONObject&gt;() {
  
          @Override
          public void onResponse(JSONObject response) {
              end = getdata(response);
              adapter.list(end);
  
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
  
          }
      });
      requestQueue.add(request);
  
  }
  
  private ArrayList&lt;Item&gt; getdata(JSONObject response) {
      ArrayList&lt;Item&gt; listy = new ArrayList&lt;Item&gt;();
  
      try {
  
          JSONArray array = response.getJSONArray("items");
  
          for (int i = 0; i &lt; array.length(); i++) {
              JSONObject object1 = array.getJSONObject(i);
              String content = object1.getString("caption");
              String url = object1.getString("url");
              String proba = object1.getString("proba");
              // ImageView image = process(url,imageView);
              Item I = new Item(content, url, proba);
              listy.add(I);
  
          }
  
  
      } catch (JSONException e) {
          e.printStackTrace();
          Toast.makeText(this, "Error" + e, Toast.LENGTH_LONG).show();
      }
      Log.d("mohak", "" + response.length());
  
      return listy;
  
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      MenuItem menuItem = menu.findItem(R.id.action_search);
      SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
      SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
      searchView.setIconifiedByDefault(true);
      searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
              return true; // handled
          }
  
          @Override
          public boolean onQueryTextChange(String newText) {
  
             adapter.getFilter().filter(newText);
  
              return true;
          }
      });
      return true;
  }
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar Item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  
  @Override
  public boolean onQueryTextSubmit(String query) {
      return false;
  }
  
  @Override
  public boolean onQueryTextChange(String newText) {
      return false;
  }
  </code></pre>
  
  <p>This is adapter:</p>
  
  <pre><code>public class Adapter extends RecyclerView.Adapter&lt;Adapter.ViewHolder&gt; implements  Filterable{
  
  public static final String LIST_DETAIL_KEY = "list";
  
  public Item item;
  
  private LayoutInflater inflater;
  Context context;
  ArrayList&lt;Item&gt; fin = new ArrayList&lt;Item&gt;();
  
  
  Adapter(Context context) {
      inflater = LayoutInflater.from(context);
      this.context = context;
  }
  
  public void list(ArrayList&lt;Item&gt; fin) {
      this.fin = fin;
      Search search = new Search(fin);
      notifyItemRangeChanged(0, fin.size());
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
  
      View view = inflater.inflate(R.layout.rac, viewGroup, false);
      ViewHolder holder = new ViewHolder(view);
  
      return holder;
  }
  
  @Override
  public void onAttachedToRecyclerView(RecyclerView recyclerView) {
      super.onAttachedToRecyclerView(recyclerView);
  }
  
  @Override
  public void onBindViewHolder(ViewHolder viewHolder, int i) {
  
      Item current = fin.get(i);
      viewHolder.content.setText(current.content);
      viewHolder.proba.setText(current.proba);
  
  
      //  Uri uri = Uri.parse(current.url);
      //  Context context = viewHolder.imageView.getContext();
      Picasso.with(context).load(current.url).into(viewHolder.imageView);
  
  }
  
  @Override
  public int getItemCount() {
      return fin.size();
  }
  
  @Override
  public Filter getFilter() {
      Search search = new Search(fin);
      return search;
  }
  
  
  class ViewHolder extends RecyclerView.ViewHolder {
      TextView content;
      TextView proba;
      ImageView imageView;
  
  
      public ViewHolder(View itemView) {
          super(itemView);
  
          content = (TextView) itemView.findViewById(R.id.textView);
          proba = (TextView) itemView.findViewById(R.id.textView2);
          imageView = (ImageView) itemView.findViewById(R.id.imageView);
  
  
      }
  }
  }
  </code></pre>
  
  <p>Thank you in advance. </p>