资源文件
activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:id="@+id/type_rvleft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"></android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:id="@+id/type_rvright"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="50dp"></android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
type_grid_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/colorWhite2"
>
<Button
android:id="@+id/tv_gv_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="234"
android:background="#ffff"
android:enabled="true"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
/>
</LinearLayout>
type_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="vertical"
>
<TextView
android:id="@+id/tv_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:enabled="true"
android:text="234"
android:textSize="21sp" />
<ImageView
android:id="@+id/iv_type_pic"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/ic_launcher"
android:visibility="gone"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
tyepeson_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="4dp"
android:layout_height="30dp"
android:background="@color/colorPrice"/>
<TextView
android:id="@+id/tv_type"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textSize="22sp"
android:text="234"
android:enabled="true"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
/>
</RelativeLayout>
<view.MyGridView
android:id="@+id/type_son"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3"
android:background="@color/colorWhite2"
></view.MyGridView>
</LinearLayout>
values colors
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorWhite">#FFFDFB</color>
<color name="colorWhite2">#F9F9F9</color>
<color name="colorWhite3">#FFFFFF</color>
<color name="colorBorder">#A1A1A1</color>
<color name="colorPblBackground">#A1A1A4</color>
<color name="colorPrice">#FF7001</color>
</resources>
适配器adapter
MyAdapter_left
package adpter;
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.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import java.util.List;
import bean.DataleftBean;
import day.com.recyclerviewleft_right.R;
import static android.R.attr.path;
/**
* autour: 樊彦龙
* date: 2017/10/20 15:14
* update: 2017/10/20
*/
public class MyAdapter_left extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<DataleftBean.DatasBean.ClassListBean> list;
public static int tagPosition;
public static int getTagPosition() {
return tagPosition;
}
public static void setTagPosition(int tagPosition) {
MyAdapter_left.tagPosition = tagPosition;
}
public MyAdapter_left(Context context, List<DataleftBean.DatasBean.ClassListBean> list) {
this.context = context;
this.list = list;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.type_item, parent, false);
final MyLeftViewHolder leftViewHolder = new MyLeftViewHolder(view);
//点击监听
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
recycleViewItemClickListener.recycleViewItemClickListener(leftViewHolder.getPosition(), view, leftViewHolder);
}
});
return leftViewHolder;
}
//view绑定数据
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//给文本框赋值
((MyLeftViewHolder) holder).tv_left_type.setText(list.get(position).getGc_name());
if (position == getTagPosition()) {
holder.itemView.setBackgroundResource(R.color.colorPblBackground);
} else {
holder.itemView.setBackgroundResource(R.color.colorWhite3);
}
//设置种类图片
if (list.get(position).getImage().length()>0) {
// Picasso.with(context).load(MyUtils.Unicode2GBK(list.get(position).getImage())).into(((MyLeftViewHolder) holder).iv_type_pic);
Glide.with(context).load(list.get(position).getImage()).into(((MyLeftViewHolder) holder).iv_type_pic);
}
}
@Override
public int getItemCount() {
return list.size();
}
public class MyLeftViewHolder extends RecyclerView.ViewHolder {
private TextView tv_left_type;
private ImageView iv_type_pic;
public MyLeftViewHolder(View itemView) {
super(itemView);
tv_left_type = (TextView) itemView.findViewById(R.id.tv_type);
iv_type_pic = (ImageView) itemView.findViewById(R.id.iv_type_pic);
}
}
//声明成员变量
public OnRecycleViewItemClickListener recycleViewItemClickListener;
//定义点击接口
public interface OnRecycleViewItemClickListener {
void recycleViewItemClickListener(int position, View view, RecyclerView.ViewHolder viewHolder);
}
//提供set方法
public void setRecycleViewItemClickListener(OnRecycleViewItemClickListener recycleViewItemClickListener) {
this.recycleViewItemClickListener = recycleViewItemClickListener;
}
}
MyAdapter_right
package adpter;
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.GridView;
import android.widget.TextView;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.List;
import java.util.Observable;
import bean.DatarightBean;
import bean.DateGridBean;
import day.com.recyclerviewleft_right.R;
import okhttp3.Call;
import utils.API;
import utils.GsonObjectCallback;
import utils.OkHttp3Utils;
import static android.os.Build.VERSION_CODES.O;
/**
* autour: 樊彦龙
* date: 2017/10/20 13:21
* update: 2017/10/20
*/
public class MyAdapter_right extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private Context context;
private List<DatarightBean.DatasBean.ClassListBean> list;
public MyAdapter_right(Context context, List<DatarightBean.DatasBean.ClassListBean> list) {
this.context = context;
this.list = list;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.typeson_item, parent, false);
final MyLeftViewHolder leftViewHolder = new MyLeftViewHolder(view);
return leftViewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//设置种类标题
final MyLeftViewHolder myHolder = new MyLeftViewHolder(holder.itemView);
//设置标题
myHolder.tv_left_type.setText(list.get(position).getGc_name());
//第三次请求网络 获取第三级数据
OkHttp3Utils.doGet(API.TYPE_PATH + "&gc_id=" + list.get(position).getGc_id(), new GsonObjectCallback<DateGridBean>() {
@Override
public void onUi(DateGridBean dateGridBean) {
myHolder.gv.setAdapter(new MyAdapter_TypeGridView(context,dateGridBean.getDatas().getClass_list()));
}
@Override
public void onFailed(Call call, IOException e) {
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class MyLeftViewHolder extends RecyclerView.ViewHolder{
private TextView tv_left_type;
private GridView gv;
public MyLeftViewHolder(View itemView) {
super(itemView);
tv_left_type = (TextView) itemView.findViewById(R.id.tv_type);
gv = (GridView) itemView.findViewById(R.id.type_son);
}
}
//声明成员变量
public OnRecycleViewItemClickListener recycleViewItemClickListener;
//定义点击接口
public interface OnRecycleViewItemClickListener{
void recycleViewItemClickListener(int position, View view, RecyclerView.ViewHolder viewHolder);
}
//提供set方法
public void setRecycleViewItemClickListener(OnRecycleViewItemClickListener recycleViewItemClickListener) {
this.recycleViewItemClickListener = recycleViewItemClickListener;
}
}
MyAdapter_TypeGridView
package adpter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
import bean.DateGridBean;
import day.com.recyclerviewleft_right.R;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class MyAdapter_TypeGridView extends BaseAdapter {
private Context context;
private List<DateGridBean.DatasBean.ClassListBean> list;
public MyAdapter_TypeGridView(Context context, List<DateGridBean.DatasBean.ClassListBean> list){
this.context = context;
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null){
convertView = View.inflate(context, R.layout.type_grid_item,null);
holder = new ViewHolder();
holder.tv = (TextView) convertView.findViewById(R.id.tv_gv_type);
convertView.setTag(holder);
}else {
holder = (ViewHolder) convertView.getTag();
}
holder.tv.setText(list.get(position).getGc_name());
return convertView;
}
class ViewHolder{
TextView tv;
}
}
app location文件
package app;
import android.app.Application;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class MyApp extends Application {
public static MyApp mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static MyApp getInstance() {
return mInstance;
}
}
View MyGridView 类
package view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;
/**
* autour:
* date: 2017/10/20 13:29
* update: 2017/10/20
*/
public class MyGridView extends GridView {
public MyGridView(Context paramContext, AttributeSet paramAttributeSet) {
super(paramContext, paramAttributeSet);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//makeMeasureSpec根据提供的大小值和模式创建一个测量值(格式)
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
Utils 工具类
API
package utils;
/**
* autour:
* date: 2017/10/20 14:16
* update: 2017/10/20
*/
public class API {
public static final String TYPE_PATH = "http://192.168.28.5/mobile/index.php?act=goods_class";
}
RecyclerViewClickListener
package utils;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
/**
* Created by liyan on 2016/11/11.
*/
public class RecyclerViewClickListener implements RecyclerView.OnItemTouchListener {
private int mLastDownX,mLastDownY;
//该值记录了最小滑动距离
private int touchSlop ;
private OnItemClickListener mListener;
//是否是单击事件
private boolean isSingleTapUp = false;
//是否是长按事件
private boolean isLongPressUp = false;
private boolean isMove = false;
private long mDownTime;
//内部接口,定义点击方法以及长按方法
public interface OnItemClickListener {
void onItemClick(View view, int position);
void onItemLongClick(View view, int position);
}
public RecyclerViewClickListener(Context context, OnItemClickListener listener){
touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mListener = listener;
}
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
int x = (int) e.getX();
int y = (int) e.getY();
switch (e.getAction()){
/**
* 如果是ACTION_DOWN事件,那么记录当前按下的位置,
* 记录当前的系统时间。
*/
case MotionEvent.ACTION_DOWN:
mLastDownX = x;
mLastDownY = y;
mDownTime = System.currentTimeMillis();
isMove = false;
break;
/**
* 如果是ACTION_MOVE事件,此时根据TouchSlop判断用户在按下的时候是否滑动了,
* 如果滑动了,那么接下来将不处理点击事件
*/
case MotionEvent.ACTION_MOVE:
if(Math.abs(x - mLastDownX)>touchSlop || Math.abs(y - mLastDownY)>touchSlop){
isMove = true;
}
break;
/**
* 如果是ACTION_UP事件,那么根据isMove标志位来判断是否需要处理点击事件;
* 根据系统时间的差值来判断是哪种事件,如果按下事件超过1ms,则认为是长按事件,
* 否则是单击事件。
*/
case MotionEvent.ACTION_UP:
if(isMove){
break;
}
if(System.currentTimeMillis()-mDownTime > 1000){
isLongPressUp = true;
}else {
isSingleTapUp = true;
}
break;
}
if(isSingleTapUp ){
//根据触摸坐标来获取childView
View childView = rv.findChildViewUnder(e.getX(),e.getY());
isSingleTapUp = false;
if(childView != null){
//回调mListener#onItemClick方法
mListener.onItemClick(childView,rv.getChildLayoutPosition(childView));
return true;
}
return false;
}
if (isLongPressUp ){
View childView = rv.findChildViewUnder(e.getX(),e.getY());
isLongPressUp = false;
if(childView != null){
mListener.onItemLongClick(childView, rv.getChildLayoutPosition(childView));
return true;
}
return false;
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
}
OkHttp3Utils
package utils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import app.MyApp;
import okhttp3.Cache;
import okhttp3.CacheControl;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
/**
* 1. 类的用途 封装OkHttp3的工具类 用单例设计模式
* 2. @author forever
* 3. @date 2017/9/6 09:19
*/
public class OkHttp3Utils {
/**
* 懒汉 安全 加同步
* 私有的静态成员变量 只声明不创建
* 私有的构造方法
* 提供返回实例的静态方法
*/
private static OkHttp3Utils okHttp3Utils = null;
private OkHttp3Utils() {
}
public static OkHttp3Utils getInstance() {
if (okHttp3Utils == null) {
//加同步安全
synchronized (OkHttp3Utils.class) {
if (okHttp3Utils == null) {
okHttp3Utils = new OkHttp3Utils();
}
}
}
return okHttp3Utils;
}
private static OkHttpClient okHttpClient = null;
public synchronized static OkHttpClient getOkHttpClient() {
if (okHttpClient == null) {
//判空 为空创建实例
// okHttpClient = new OkHttpClient();
/**
* 和OkHttp2.x有区别的是不能通过OkHttpClient直接设置超时时间和缓存了,而是通过OkHttpClient.Builder来设置,
* 通过builder配置好OkHttpClient后用builder.build()来返回OkHttpClient,
* 所以我们通常不会调用new OkHttpClient()来得到OkHttpClient,而是通过builder.build():
*/
// File sdcache = getExternalCacheDir();
//缓存目录
File sdcache = new File(Environment.getExternalStorageDirectory(), "cache");
int cacheSize = 10 * 1024 * 1024;
//OkHttp3拦截器
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
Log.i("xxx", message.toString());
}
});
//Okhttp3的拦截器日志分类 4种
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
okHttpClient = new OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS)
//添加OkHttp3的拦截器
.addInterceptor(httpLoggingInterceptor)
.addNetworkInterceptor(new CacheInterceptor())
.writeTimeout(20, TimeUnit.SECONDS).readTimeout(20, TimeUnit.SECONDS)
.cache(new Cache(sdcache.getAbsoluteFile(), cacheSize))
.build();
}
return okHttpClient;
}
private static Handler mHandler = null;
public synchronized static Handler getHandler() {
if (mHandler == null) {
mHandler = new Handler();
}
return mHandler;
}
/**
* get请求
* 参数1 url
* 参数2 回调Callback
*/
public static void doGet(String url, Callback callback) {
//创建OkHttpClient请求对象
OkHttpClient okHttpClient = getOkHttpClient();
//创建Request
Request request = new Request.Builder().url(url).build();
//得到Call对象
Call call = okHttpClient.newCall(request);
//执行异步请求
call.enqueue(callback);
}
/**
* post请求
* 参数1 url
* 参数2 回调Callback
*/
public static void doPost(String url, Map<String, String> params, Callback callback) {
//创建OkHttpClient请求对象
OkHttpClient okHttpClient = getOkHttpClient();
//3.x版本post请求换成FormBody 封装键值对参数
FormBody.Builder builder = new FormBody.Builder();
//遍历集合
for (String key : params.keySet()) {
builder.add(key, params.get(key));
}
//创建Request
Request request = new Request.Builder().url(url).post(builder.build()).build();
Call call = okHttpClient.newCall(request);
call.enqueue(callback);
}
/**
* post请求上传文件
* 参数1 url
* 参数2 回调Callback
*/
public static void uploadPic(String url, File file, String fileName) {
//创建OkHttpClient请求对象
OkHttpClient okHttpClient = getOkHttpClient();
//创建RequestBody 封装file参数
RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), file);
//创建RequestBody 设置类型等
RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("file", fileName, fileBody).build();
//创建Request
Request request = new Request.Builder().url(url).post(requestBody).build();
//得到Call
Call call = okHttpClient.newCall(request);
//执行请求
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
//上传成功回调 目前不需要处理
}
});
}
/**
* Post请求发送JSON数据
* 参数一:请求Url
* 参数二:请求的JSON
* 参数三:请求回调
*/
public static void doPostJson(String url, String jsonParams, Callback callback) {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonParams);
Request request = new Request.Builder().url(url).post(requestBody).build();
Call call = getOkHttpClient().newCall(request);
call.enqueue(callback);
}
/**
* 下载文件 以流的形式把apk写入的指定文件 得到file后进行安装
* 参数一:请求Url
* 参数二:保存文件的路径名
* 参数三:保存文件的文件名
*/
public static void download(final Context context, final String url, final String saveDir) {
Request request = new Request.Builder().url(url).build();
Call call = getOkHttpClient().newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.i("xxx", e.toString());
}
@Override
public void onResponse(Call call, final Response response) throws IOException {
InputStream is = null;
byte[] buf = new byte[2048];
int len = 0;
FileOutputStream fos = null;
try {
is = response.body().byteStream();
//apk保存路径
final String fileDir = isExistDir(saveDir);
//文件
File file = new File(fileDir, getNameFromUrl(url));
fos = new FileOutputStream(file);
while ((len = is.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fos.flush();
//apk下载完成后 调用系统的安装方法
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
context.startActivity(intent);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) is.close();
if (fos != null) fos.close();
}
}
});
}
/**
* @param saveDir
* @return
* @throws IOException 判断下载目录是否存在
*/
public static String isExistDir(String saveDir) throws IOException {
// 下载位置
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File downloadFile = new File(Environment.getExternalStorageDirectory(), saveDir);
if (!downloadFile.mkdirs()) {
downloadFile.createNewFile();
}
String savePath = downloadFile.getAbsolutePath();
Log.e("savePath", savePath);
return savePath;
}
return null;
}
/**
* @param url
* @return 从下载连接中解析出文件名
*/
private static String getNameFromUrl(String url) {
return url.substring(url.lastIndexOf("/") + 1);
}
/**
* 为okhttp添加缓存,这里是考虑到服务器不支持缓存时,从而让okhttp支持缓存
*/
private static class CacheInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
// 有网络时 设置缓存超时时间1个小时
int maxAge = 60 * 60;
// 无网络时,设置超时为1天
int maxStale = 60 * 60 * 24;
Request request = chain.request();
if (NetWorkUtils.isNetWorkAvailable(MyApp.getInstance())) {
//有网络时只从网络获取
request = request.newBuilder().cacheControl(CacheControl.FORCE_NETWORK).build();
} else {
//无网络时只从缓存中读取
request = request.newBuilder().cacheControl(CacheControl.FORCE_CACHE).build();
/* Looper.prepare();
Toast.makeText(MyApp.getInstance(), "走拦截器缓存", Toast.LENGTH_SHORT).show();
Looper.loop();*/
}
Response response = chain.proceed(request);
if (NetWorkUtils.isNetWorkAvailable(MyApp.getInstance())) {
response = response.newBuilder()
.removeHeader("Pragma")
.header("Cache-Control", "public, max-age=" + maxAge)
.build();
} else {
response = response.newBuilder()
.removeHeader("Pragma")
.header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
.build();
}
return response;
}
}
public interface OnGetServerDateLisnter {
void getData(String string);
}
}
NetWorkUtils
package utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* 1. 类的用途 联网判断
* 2. @author forever
* 3. @date 2017/9/8 12:30
*/
public class NetWorkUtils {
//判断网络是否连接
public static boolean isNetWorkAvailable(Context context) {
//网络连接管理器
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//网络信息
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
if (info != null) {
return true;
}
return false;
}
}
GsonObjectCallback
package utils;
import android.os.Handler;
import com.google.gson.Gson;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
/**
* 1. 类的用途 如果要将得到的json直接转化为集合 建议使用该类
* 该类的onUi() onFailed()方法运行在主线程
* 2. @author forever
* 3. @date 2017/9/24 18:47
*/
public abstract class GsonObjectCallback<T> implements Callback {
private Handler handler = OkHttp3Utils.getInstance().getHandler();
//主线程处理
public abstract void onUi(T t);
//主线程处理
public abstract void onFailed(Call call, IOException e);
//请求失败
@Override
public void onFailure(final Call call, final IOException e) {
handler.post(new Runnable() {
@Override
public void run() {
onFailed(call, e);
}
});
}
//请求json 并直接返回泛型的对象 主线程处理
@Override
public void onResponse(Call call, Response response) throws IOException {
String json = response.body().string();
Class<T> cls = null;
Class clz = this.getClass();
ParameterizedType type = (ParameterizedType) clz.getGenericSuperclass();
Type[] types = type.getActualTypeArguments();
cls = (Class<T>) types[0];
Gson gson = new Gson();
final T t = gson.fromJson(json, cls);
handler.post(new Runnable() {
@Override
public void run() {
onUi(t);
}
});
}
}
GsonArrayCallback
package utils;
import android.os.Handler;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
/**
* 1. 类的用途 如果要将得到的json直接转化为集合 建议使用该类
* 该类的onUi() onFailed()方法运行在主线程
* 2. @author forever
* 3. @date 2017/9/24 18:47
*/
public abstract class GsonArrayCallback<T> implements Callback {
private Handler handler = OkHttp3Utils.getInstance().getHandler();
//主线程处理
public abstract void onUi(List<T> list);
//主线程处理
public abstract void onFailed(Call call, IOException e);
//请求失败
@Override
public void onFailure(final Call call, final IOException e) {
handler.post(new Runnable() {
@Override
public void run() {
onFailed(call, e);
}
});
}
//请求json 并直接返回集合 主线程处理
@Override
public void onResponse(Call call, Response response) throws IOException {
final List<T> mList = new ArrayList<T>();
String json = response.body().string();
JsonArray array = new JsonParser().parse(json).getAsJsonArray();
Gson gson = new Gson();
Class<T> cls = null;
Class clz = this.getClass();
ParameterizedType type = (ParameterizedType) clz.getGenericSuperclass();
Type[] types = type.getActualTypeArguments();
cls = (Class<T>) types[0];
for(final JsonElement elem : array){
//循环遍历把对象添加到集合
mList.add((T) gson.fromJson(elem, cls));
}
handler.post(new Runnable() {
@Override
public void run() {
onUi(mList);
}
});
}
}
MainActivity
package day.com.recyclerviewleft_right;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.io.IOException;
import adpter.MyAdapter_left;
import adpter.MyAdapter_right;
import bean.DataleftBean;
import bean.DatarightBean;
import bean.Datebeanitem;
import okhttp3.Call;
import utils.API;
import utils.GsonObjectCallback;
import utils.OkHttp3Utils;
public class MainActivity extends AppCompatActivity {
TextView mtv;
private RecyclerView rv_left, rv_right;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT);
//得到WindowManager
WindowManager windowManager = this.getWindowManager();
Display display = windowManager.getDefaultDisplay();
//得到屏幕宽
int width = display.getWidth();
//将RecyclerView宽设置为屏幕宽的1/5
params.width = width * 1 / 5;
rv_left.setLayoutParams(params);
//得到RecyclerView布局管理器
LinearLayoutManager leftLayoutManager = new LinearLayoutManager(this);
//RecyclerView设置布局管理器
rv_left.setLayoutManager(leftLayoutManager);
//得到RecyclerView布局管理器
LinearLayoutManager rightLayoutManager = new LinearLayoutManager(this);
//RecyclerView设置布局管理器
rv_right.setLayoutManager(rightLayoutManager);
//获取后台数据,添加适配器
getServerData();
}
//获取控件的方法
private void initView() {
rv_left = (RecyclerView)findViewById(R.id.type_rvleft);
rv_right = (RecyclerView)findViewById(R.id.type_rvright);
}
//获取后台数据的方法
public void getServerData() {
OkHttp3Utils.getInstance().doGet(API.TYPE_PATH, new GsonObjectCallback<DataleftBean>() {
@Override
public void onUi(final DataleftBean dataleftBean) {
//适配器
final MyAdapter_left myAdapter_left= new MyAdapter_left(MainActivity.this, dataleftBean.getDatas().getClass_list());
rv_left.setAdapter(myAdapter_left);
//第一个子条目显示其二级数据
//子条目点击监听
myAdapter_left.setRecycleViewItemClickListener(new MyAdapter_left.OnRecycleViewItemClickListener() {
@Override
public void recycleViewItemClickListener(int position, View view, RecyclerView.ViewHolder viewHolder) {
myAdapter_left.setTagPosition(position);
myAdapter_left.notifyDataSetChanged();
//请求二级数据
getServerTypeData(dataleftBean.getDatas().getClass_list().get(position),position);
}
});
}
@Override
public void onFailed(Call call, IOException e) {
}
});
}
//获取网络数据的方法
public static void getServerData(Context context, String url, final OnGetServerDateLisnter onGetServerDateLisnter) {
OkHttp3Utils.getInstance().doGet(url, new GsonObjectCallback<Datebeanitem>() {
@Override
public void onUi(Datebeanitem datebeanitem) {
onGetServerDateLisnter.getData(datebeanitem.getDatas().toString());
}
@Override
public void onFailed(Call call, IOException e) {
}
});
}
public interface OnGetServerDateLisnter {
void getData(String string);
}
//请求二级数据
public void getServerTypeData(final DataleftBean.DatasBean.ClassListBean gc_id, final int position) {
OkHttp3Utils.doGet(API.TYPE_PATH + "&gc_id=" + gc_id, new GsonObjectCallback<DatarightBean>() {
@Override
public void onUi(DatarightBean datarightBean) {
MyAdapter_right myAdapter_right = new MyAdapter_right(MainActivity.this, datarightBean.getDatas().getClass_list());
rv_right.setAdapter(myAdapter_right);
}
@Override
public void onFailed(Call call, IOException e) {
}
});
}
}
bean类(根据接口自定义bean类)
DataleftBean
package bean;
import java.util.List;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class DataleftBean {
/**
* code : 200
* datas : {"class_list":[{"gc_id":"1","gc_name":"服饰鞋帽","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015381809285330.png","text":"女装/男装/内衣/运动/女鞋/男鞋/配饰/童装"},{"gc_id":"2","gc_name":"礼品箱包","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015381349504237.png","text":"潮流女包/时尚男包/功能箱包/礼品/奢侈品"},{"gc_id":"3","gc_name":"家居家装","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015381681266734.png","text":"家纺/灯具/生活日用/家装软饰/清洁日用/宠物生活"},{"gc_id":"256","gc_name":"数码办公","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015381190111257.png","text":"手机配件/摄影摄像/数码配件/时尚影音/电脑整机/电脑配件/外设产品/网络产品/办公打印/办公文仪/手机通讯"},{"gc_id":"308","gc_name":"家用电器","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015382063902705.png","text":"大家电/生活电器/厨房电器/个护健康/五金家装"},{"gc_id":"470","gc_name":"个护化妆","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015382211209809.png","text":"面部护理/身体护理/口腔护理/女性护理/男士护理/魅力彩妆/香水SPA"},{"gc_id":"530","gc_name":"珠宝手表","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015382869763762.png","text":"时尚饰品/纯金K金饰品/金银投资/银饰/钻石饰品/翡翠玉石/水晶玛瑙/宝石珍珠/婚庆/钟表手表"},{"gc_id":"593","gc_name":"食品饮料","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015382413708016.png","text":"进口食品/地方特产/休闲食品/粮油调味/中外名酒/饮料冲调/营养健康/亚健康调理/健康礼品/生鲜食品"},{"gc_id":"662","gc_name":"运动健康","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"","text":"户外鞋服/户外装备/运动器械/纤体瑜伽/体育娱乐/成人用品/保健器械/急救卫生"},{"gc_id":"730","gc_name":"汽车用品","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015382972892418.png","text":"电子电器/系统养护/改装配件/汽车美容/座垫脚垫/内饰精品/安全自驾/整车"},{"gc_id":"825","gc_name":"玩具乐器","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015383078446336.png","text":"适用年龄/遥控/电动/毛绒布艺/娃娃玩具/模型玩具/健身玩具/动漫玩具/益智玩具/积木拼插/DIY玩具/创意减压/乐器相关"},{"gc_id":"888","gc_name":"厨具","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015382679643040.png","text":"烹饪锅具/刀剪菜板/收纳保鲜/水具酒具/餐具/茶具/咖啡具"},{"gc_id":"959","gc_name":"母婴用品","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"0","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015383177958780.png","text":"奶粉/营养辅食/尿裤湿巾/喂养用品/洗护用品/童车童床/服饰寝居/妈妈专区"},{"gc_id":"1037","gc_name":"虚拟充值","type_id":"0","type_name":"","gc_parent_id":"0","commis_rate":"0","gc_sort":"255","gc_virtual":"1","gc_title":"","gc_keywords":"","gc_description":"","show_type":"1","image":"http://192.168.28.242/data/upload/mobile/category/05015383410379550.png","text":"充值/游戏/票务"}]}
*/
private String code;
private DatasBean datas;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public DatasBean getDatas() {
return datas;
}
public void setDatas(DatasBean datas) {
this.datas = datas;
}
public static class DatasBean {
private List<ClassListBean> class_list;
public List<ClassListBean> getClass_list() {
return class_list;
}
public void setClass_list(List<ClassListBean> class_list) {
this.class_list = class_list;
}
public static class ClassListBean {
/**
* gc_id : 1
* gc_name : 服饰鞋帽
* type_id : 0
* type_name :
* gc_parent_id : 0
* commis_rate : 0
* gc_sort : 255
* gc_virtual : 0
* gc_title :
* gc_keywords :
* gc_description :
* show_type : 1
* image : http://192.168.28.242/data/upload/mobile/category/05015381809285330.png
* text : 女装/男装/内衣/运动/女鞋/男鞋/配饰/童装
*/
private String gc_id;
private String gc_name;
private String type_id;
private String type_name;
private String gc_parent_id;
private String commis_rate;
private String gc_sort;
private String gc_virtual;
private String gc_title;
private String gc_keywords;
private String gc_description;
private String show_type;
private String image;
private String text;
public String getGc_id() {
return gc_id;
}
public void setGc_id(String gc_id) {
this.gc_id = gc_id;
}
public String getGc_name() {
return gc_name;
}
public void setGc_name(String gc_name) {
this.gc_name = gc_name;
}
public String getType_id() {
return type_id;
}
public void setType_id(String type_id) {
this.type_id = type_id;
}
public String getType_name() {
return type_name;
}
public void setType_name(String type_name) {
this.type_name = type_name;
}
public String getGc_parent_id() {
return gc_parent_id;
}
public void setGc_parent_id(String gc_parent_id) {
this.gc_parent_id = gc_parent_id;
}
public String getCommis_rate() {
return commis_rate;
}
public void setCommis_rate(String commis_rate) {
this.commis_rate = commis_rate;
}
public String getGc_sort() {
return gc_sort;
}
public void setGc_sort(String gc_sort) {
this.gc_sort = gc_sort;
}
public String getGc_virtual() {
return gc_virtual;
}
public void setGc_virtual(String gc_virtual) {
this.gc_virtual = gc_virtual;
}
public String getGc_title() {
return gc_title;
}
public void setGc_title(String gc_title) {
this.gc_title = gc_title;
}
public String getGc_keywords() {
return gc_keywords;
}
public void setGc_keywords(String gc_keywords) {
this.gc_keywords = gc_keywords;
}
public String getGc_description() {
return gc_description;
}
public void setGc_description(String gc_description) {
this.gc_description = gc_description;
}
public String getShow_type() {
return show_type;
}
public void setShow_type(String show_type) {
this.show_type = show_type;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
}
DatarightBean
package bean;
import java.util.List;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class DatarightBean {
/**
* code : 200
* datas : {"class_list":[{"gc_id":"4","gc_name":"女装"},{"gc_id":"5","gc_name":"男装"},{"gc_id":"6","gc_name":"内衣"},{"gc_id":"7","gc_name":"运动"},{"gc_id":"8","gc_name":"女鞋"},{"gc_id":"9","gc_name":"男鞋"},{"gc_id":"10","gc_name":"配饰"},{"gc_id":"11","gc_name":"童装"}]}
*/
private String code;
private DatasBean datas;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public DatasBean getDatas() {
return datas;
}
public void setDatas(DatasBean datas) {
this.datas = datas;
}
public static class DatasBean {
private List<ClassListBean> class_list;
public List<ClassListBean> getClass_list() {
return class_list;
}
public void setClass_list(List<ClassListBean> class_list) {
this.class_list = class_list;
}
public static class ClassListBean {
/**
* gc_id : 4
* gc_name : 女装
*/
private String gc_id;
private String gc_name;
public String getGc_id() {
return gc_id;
}
public void setGc_id(String gc_id) {
this.gc_id = gc_id;
}
public String getGc_name() {
return gc_name;
}
public void setGc_name(String gc_name) {
this.gc_name = gc_name;
}
}
}
}
Databean
package bean;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class Datebean {
/**
* msg : 注册成功
* code : 0
* data : {"age":null,"createtime":"2017-10-19T00:00:00","gender":0,"icon":null,"mobile":"13611101112","money":0,"nickname":null,"password":"111111","uid":880,"username":"13611101112"}
*/
private String msg;
private String code;
//private DataBean data;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public static class DataBean {
/**
* age : null
* createtime : 2017-10-19T00:00:00
* gender : 0
* icon : null
* mobile : 13611101112
* money : 0
* nickname : null
* password : 111111
* uid : 880
* username : 13611101112
*/
private Object age;
private String createtime;
private int gender;
private Object icon;
private String mobile;
private int money;
private Object nickname;
private String password;
private int uid;
private String username;
public Object getAge() {
return age;
}
public void setAge(Object age) {
this.age = age;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public int getGender() {
return gender;
}
public void setGender(int gender) {
this.gender = gender;
}
public Object getIcon() {
return icon;
}
public void setIcon(Object icon) {
this.icon = icon;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public Object getNickname() {
return nickname;
}
public void setNickname(Object nickname) {
this.nickname = nickname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
}
Databeanitem
package bean;
import java.util.List;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class Datebeanitem {
/**
* code : 200
* datas : {"class_list":[{"gc_id":"90","gc_name":"平底鞋"},{"gc_id":"91","gc_name":"高跟鞋"},{"gc_id":"92","gc_name":"单鞋"},{"gc_id":"93","gc_name":"休闲鞋"},{"gc_id":"94","gc_name":"凉鞋"},{"gc_id":"95","gc_name":"女靴"},{"gc_id":"96","gc_name":"雪地靴"},{"gc_id":"97","gc_name":"拖鞋"},{"gc_id":"98","gc_name":"裸靴"},{"gc_id":"99","gc_name":"筒靴"},{"gc_id":"100","gc_name":"帆布鞋"},{"gc_id":"101","gc_name":"雨鞋/雨靴"},{"gc_id":"102","gc_name":"妈妈鞋"},{"gc_id":"103","gc_name":"鞋配件"},{"gc_id":"104","gc_name":"特色鞋"},{"gc_id":"105","gc_name":"鱼嘴鞋"},{"gc_id":"106","gc_name":"布鞋/绣花鞋"}]}
*/
private String code;
private DatasBean datas;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public DatasBean getDatas() {
return datas;
}
public void setDatas(DatasBean datas) {
this.datas = datas;
}
public static class DatasBean {
private List<ClassListBean> class_list;
public List<ClassListBean> getClass_list() {
return class_list;
}
public void setClass_list(List<ClassListBean> class_list) {
this.class_list = class_list;
}
public static class ClassListBean {
/**
* gc_id : 90
* gc_name : 平底鞋
*/
private String gc_id;
private String gc_name;
public String getGc_id() {
return gc_id;
}
public void setGc_id(String gc_id) {
this.gc_id = gc_id;
}
public String getGc_name() {
return gc_name;
}
public void setGc_name(String gc_name) {
this.gc_name = gc_name;
}
}
}
}
DataGridBean
package bean;
import java.util.List;
/**
* description: $todo$
* autour: BlueAmer
* date: $date$ $time$
* update: $date$
* version: $version$
*/
public class DateGridBean {
/**
* code : 200
* datas : {"class_list":[{"gc_id":"12","gc_name":"T恤"},{"gc_id":"13","gc_name":"衬衫"},{"gc_id":"14","gc_name":"针织衫"},{"gc_id":"15","gc_name":"雪纺衫"},{"gc_id":"16","gc_name":"卫衣"},{"gc_id":"17","gc_name":"马甲"},{"gc_id":"18","gc_name":"连衣裙"},{"gc_id":"19","gc_name":"半身裙"},{"gc_id":"20","gc_name":"牛仔裤"},{"gc_id":"21","gc_name":"休闲裤"},{"gc_id":"22","gc_name":"打底裤"},{"gc_id":"23","gc_name":"正装裤"},{"gc_id":"24","gc_name":"西服"},{"gc_id":"25","gc_name":"短外套"},{"gc_id":"26","gc_name":"风衣"},{"gc_id":"27","gc_name":"大衣"},{"gc_id":"28","gc_name":"皮衣皮草"},{"gc_id":"29","gc_name":"棉服"},{"gc_id":"30","gc_name":"羽绒服"},{"gc_id":"31","gc_name":"孕妇装"},{"gc_id":"32","gc_name":"大码装"},{"gc_id":"33","gc_name":"中老年装"},{"gc_id":"34","gc_name":"婚纱礼服"},{"gc_id":"1053","gc_name":"女装"}]}
*/
private int code;
private DatasBean datas;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public DatasBean getDatas() {
return datas;
}
public void setDatas(DatasBean datas) {
this.datas = datas;
}
public static class DatasBean {
private List<ClassListBean> class_list;
public List<ClassListBean> getClass_list() {
return class_list;
}
public void setClass_list(List<ClassListBean> class_list) {
this.class_list = class_list;
}
public static class ClassListBean {
/**
* gc_id : 12
* gc_name : T恤
*/
private String gc_id;
private String gc_name;
public String getGc_id() {
return gc_id;
}
public void setGc_id(String gc_id) {
this.gc_id = gc_id;
}
public String getGc_name() {
return gc_name;
}
public void setGc_name(String gc_name) {
this.gc_name = gc_name;
}
}
}
}