package com.game.webgame.network;

import org.json.JSONObject;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import android.content.Context;

public abstract class Volleyinterface {
	public Context mcontext;
	public static Listener<JSONObject> mlistener;
	public static ErrorListener mErrorLisener;

	public Volleyinterface(Context context, Listener<JSONObject> mlistener,
			ErrorListener errorlisener) {
		
		this.mcontext = context;
		this.mErrorLisener = errorlisener;
		this.mlistener = mlistener;

	}

	public abstract void onsuccess(String result);

	public abstract void onerror(VolleyError arg0);

	public Listener<JSONObject> loadinglisener() {
		mlistener = new Listener<JSONObject>() {

			@Override
			public void onResponse(JSONObject arg0) {
				//System.out.println(arg0);
				onsuccess(arg0.toString());
			}
		};
		return mlistener;
	}

	public ErrorListener errorListener() {
		mErrorLisener = new ErrorListener() {

			@Override
			public void onErrorResponse(VolleyError arg0) {
			//	System.out.println(arg0.toString());
				onerror(arg0);

			}

		};
		return mErrorLisener;
	}
}
