// Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
//         ActivityCollector.addActivity(this);
//         ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
//     }
// 
//     @Override
//     protected void onResume() {
//         super.onResume();
//         AVAnalytics.onResume(this);
//     }
// 
//     @Override
//     protected void onPause() {
//         super.onPause();
//         AVAnalytics.onPause(this);
//     }
// 
//     public void showToast(String message) {
//         Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
// 
//     }
// 
//     @Override
//     protected void onDestroy() {
//         super.onDestroy();
//         Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
//         ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
// 
//         ActivityCollector.removeActivity(this);
//     }
// }
// 
// Path: app/src/main/java/cn/daixiaodong/myapp/adapter/AssociationListAdapter.java
// public class AssociationListAdapter extends RecyclerView.Adapter<AssociationListAdapter.MyViewHolder> {
// 
//     private Context mContext;
//     private List<AVObject> mDataSet;
//     private LayoutInflater mLayoutInflater;
//     private OnItemClickListener mListener;
// 
//     public AssociationListAdapter(Context context) {
//         this.mContext = context;
//         this.mLayoutInflater = LayoutInflater.from(context);
//     }
// 
//     public AssociationListAdapter(Context context, List<AVObject> data) {
//         this.mContext = context;
//         this.mDataSet = data;
//         this.mLayoutInflater = LayoutInflater.from(context);
// 
//     }
// 
//     public void setDataSet(List<AVObject> data) {
//         this.mDataSet = data;
//         notifyDataSetChanged();
//     }
// 
//     public void addData(List<AVObject> data) {
//         this.mDataSet.addAll(0, data);
//         this.notifyItemInserted(1);
//     }
// 
//     @Override
//     public AssociationListAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
// 
//         View view = mLayoutInflater.inflate(R.layout.item_association, viewGroup, false);
//         MyViewHolder viewHolder = new MyViewHolder(view);
//         return viewHolder;
//     }
// 
//     @Override
//     public void onBindViewHolder(final AssociationListAdapter.MyViewHolder viewHolder, final int i) {
//         viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 if (mListener != null) {
//                     mListener.onItemClick(viewHolder, i);
//                 }
//             }
//         });
// 
//         viewHolder.btnJoin.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 if (mListener != null) {
//                     mListener.onItemJoinClick(viewHolder,i);
//                 }
//             }
//         });
//         viewHolder.name.setText(mDataSet.get(i).getString("name"));
//     }
// 
//     @Override
//     public int getItemCount() {
//         if (mDataSet == null) {
//             return 0;
//         }
//         return mDataSet.size();
//     }
// 
// 
//     public interface OnItemClickListener {
//         void onItemClick(MyViewHolder viewHolder, int pos);
// 
//         void onItemJoinClick(MyViewHolder viewHolder, int pos);
//     }
// 
//     public void setOnItemClickListener(OnItemClickListener listener) {
//         this.mListener = listener;
//     }
// 
//     public class MyViewHolder extends RecyclerView.ViewHolder {
// 
//         public TextView name;
//         public Button btnJoin;
// 
//         public MyViewHolder(View itemView) {
//             super(itemView);
//             name = (TextView) itemView.findViewById(R.id.id_tv_name);
//             btnJoin = (Button) itemView.findViewById(R.id.id_btn_join);
//         }
//     }
// 
// 
// }


import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.FindCallback;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import java.util.ArrayList;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.adapter.AssociationListAdapter;
    }

    private void setUpRecyclerView() {
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2,
                StaggeredGridLayoutManager.VERTICAL));
        mData = new ArrayList<>();
        mAdapter = new AssociationListAdapter(this, mData);
        mAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mAdapter);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_association_topic);
    }

    @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_topic, menu);
        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.
// Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
//         ActivityCollector.addActivity(this);
//         ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
//     }
// 
//     @Override
//     protected void onResume() {
//         super.onResume();
//         AVAnalytics.onResume(this);
//     }
// 
//     @Override
//     protected void onPause() {
//         super.onPause();
//         AVAnalytics.onPause(this);
//     }
// 
//     public void showToast(String message) {
//         Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
// 
//     }
// 
//     @Override
//     protected void onDestroy() {
//         super.onDestroy();
//         Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
//         ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
// 
//         ActivityCollector.removeActivity(this);
//     }
// }
// 
// Path: app/src/main/java/cn/daixiaodong/myapp/adapter/AssociationListAdapter.java
// public class AssociationListAdapter extends RecyclerView.Adapter<AssociationListAdapter.MyViewHolder> {
// 
//     private Context mContext;
//     private List<AVObject> mDataSet;
//     private LayoutInflater mLayoutInflater;
//     private OnItemClickListener mListener;
// 
//     public AssociationListAdapter(Context context) {
//         this.mContext = context;
//         this.mLayoutInflater = LayoutInflater.from(context);
//     }
// 
//     public AssociationListAdapter(Context context, List<AVObject> data) {
//         this.mContext = context;
//         this.mDataSet = data;
//         this.mLayoutInflater = LayoutInflater.from(context);
// 
//     }
// 
//     public void setDataSet(List<AVObject> data) {
//         this.mDataSet = data;
//         notifyDataSetChanged();
//     }
// 
//     public void addData(List<AVObject> data) {
//         this.mDataSet.addAll(0, data);
//         this.notifyItemInserted(1);
//     }
// 
//     @Override
//     public AssociationListAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
// 
//         View view = mLayoutInflater.inflate(R.layout.item_association, viewGroup, false);
//         MyViewHolder viewHolder = new MyViewHolder(view);
//         return viewHolder;
//     }
// 
//     @Override
//     public void onBindViewHolder(final AssociationListAdapter.MyViewHolder viewHolder, final int i) {
//         viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 if (mListener != null) {
//                     mListener.onItemClick(viewHolder, i);
//                 }
//             }
//         });
// 
//         viewHolder.btnJoin.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 if (mListener != null) {
//                     mListener.onItemJoinClick(viewHolder,i);
//                 }
//             }
//         });
//         viewHolder.name.setText(mDataSet.get(i).getString("name"));
//     }
// 
//     @Override
//     public int getItemCount() {
//         if (mDataSet == null) {
//             return 0;
//         }
//         return mDataSet.size();
//     }
// 
// 
//     public interface OnItemClickListener {
//         void onItemClick(MyViewHolder viewHolder, int pos);
// 
//         void onItemJoinClick(MyViewHolder viewHolder, int pos);
//     }
// 
//     public void setOnItemClickListener(OnItemClickListener listener) {
//         this.mListener = listener;
//     }
// 
//     public class MyViewHolder extends RecyclerView.ViewHolder {
// 
//         public TextView name;
//         public Button btnJoin;
// 
//         public MyViewHolder(View itemView) {
//             super(itemView);
//             name = (TextView) itemView.findViewById(R.id.id_tv_name);
//             btnJoin = (Button) itemView.findViewById(R.id.id_btn_join);
//         }
//     }
// 
// 
// }


// Path: app/src/main/java/cn/daixiaodong/myapp/activity/AssociationTopicActivity.java
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.FindCallback;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import java.util.ArrayList;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.adapter.AssociationListAdapter;

    }

    private void setUpRecyclerView() {
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2,
                StaggeredGridLayoutManager.VERTICAL));
        mData = new ArrayList<>();
        mAdapter = new AssociationListAdapter(this, mData);
        mAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mAdapter);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_association_topic);
    }

    @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_topic, menu);
        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();