Requesting JSON with Volley - android

I'm trying to do an application that display some article stored in a SQLite database.
I use a php function on my server to get a JSON file containing my database. In my Android app I want to get that JSON and put it in a JSONObject, I did the following :
private void initDataset() {
mDataset = new ArrayList<>();
Log.d("InitDataset", String.valueOf(mDataset.size()));
getArticles();
Log.d("InitDataset", String.valueOf(mDataset.size()));
}
public void getResponse(int method, String url, JSONObject jsonValue, final VolleyCallback callback) {
StringRequest strreq = new StringRequest(method, url, new Response.Listener < String > () {
#Override
public void onResponse(String Response) {
callback.onSuccessResponse(Response);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError e) {
e.printStackTrace();
Toast.makeText(getContext(), e + "error", Toast.LENGTH_LONG).show();
}
});
AppController.getInstance().addToRequestQueue(strreq);
}
public void getArticles() {
getResponse(Request.Method.GET, AppConfig.URL_ARTICLE, null,
new VolleyCallback() {
#Override
public void onSuccessResponse(String result) {
for (int i = 1; i < 3; i++) {
try {
Article article = new Article();
JSONObject response = new JSONObject(result);
// Now store the articles in SQLite
JSONObject articleObj = response.getJSONObject("article" + i);
article.setArticle_id(i);
article.setPicture_url(articleObj.getString("picture_url"));
article.setName(articleObj.getString("name"));
article.setDescription(articleObj.getString("description"));
article.setQuantity(Float.parseFloat(articleObj.getString("quantity")));
article.setPrice(Float.parseFloat(articleObj.getString("price")));
mDataset.add(article);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
}
public interface VolleyCallback {
void onSuccessResponse(String result);
}
But in the Log, the size of mDataset is always 0. Or if I Log for example the name of the article in onResponse() I can see every name is in the database. (thus the connection and php function are alright I think)
Any idea ?
Here is the php file :
<?php
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// JSON response array
$response = array("error" => FALSE);
$article = $db->getAllArticles();
if ($article != false) {
// use is found
$response["error"] = FALSE;
while($row = $article->fetch_assoc()) {
$response["article".$row["article_id"]]["article_id"] = $row["article_id"];
$response["article".$row["article_id"]]["picture_url"] = $row["picture_url"];
$response["article".$row["article_id"]]["name"] = $row["name"];
$response["article".$row["article_id"]]["description"] = $row["description"];
$response["article".$row["article_id"]]["quantity"] = $row["quantity"];
$response["article".$row["article_id"]]["price"] = $row["price"];
}
echo json_encode($response);
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($response));
fclose($fp);
} else {
$response["error"] = TRUE;
$response["error_msg"] = "Error";
echo json_encode($response);
}
?>
And the JSON I get when executing the php :
{
"error": false,
"article1": {
"article_id": "1",
"picture_url": "https://static.webshopapp.com/shops/019852/files/024106649/600x600x2/brasserie-dachouffe-la-chouffe-33cl.jpg",
"name": "Chouffe",
"description": "Ceci est une description de la chouffe.",
"quantity": "33",
"price": "2.54"
},
"article2": {
"article_id": "2",
"picture_url": "https://www.latelierdesbieres.fr/1266-large_default/biere-belge-noel-n-ice-chouffe-33-cl.jpg",
"name": "Chouffe de Noel",
"description": "Ceci est une description de la chouffe de Noel.",
"quantity": "33",
"price": "3.23"
}
}

You're misunderstanding some asynchronous execution ordering.
You need to rewrite your method to wait for the returned results, not immediately log the list size twice without letting the network call finish
getArticles(new VolleyCallback() {
#Override
public void onSuccessResponse(String result) {
// parse result
// print list size <-- shouldn't be empty
}
});
// your list will be empty here still
Where the method is defined as
public void getArticles(VolleyCallback vcb) {
getResponse(Request.Method.GET, AppConfig.URL_ARTICLE, null, vcb);
}
However, that seems really pointless to wrap two methods when you could just call getResponse directly with the correct parameters

Related

Iterating a JSONObject doesn't fill the spinner

I have an issue that i unable to understand i.e when i make an http request i get following JSONObject as response. I have to loop-iterate every keys, take the data that i need, build them in an object and fill the spinner, but i think there is something wrong in the loop or i don't know, cause when i take every object, alone without a loop, all work fine,
when i loop to build object and add to array list dynamically it don't work:
{
"Conteggio": 2,
"0": {
"Distributore Information": {
"id_distributore": "1",
"NomeDistributore": "Colonnina 0",
"litriiniziocolonna": "444",
}
},
"1": {
"Distributore Information": {
"id_distributore": "2",
"NomeDistributore": "Colonnina 1",
"litriiniziocolonna": "555",
}
}
}
I know that it's wrong loop through a JSONObject but i cant change this JSON.
Here the android code code:
private void getInfoColonnina(){
String url = "https://icantshowtheurlbutitworkfine_module.json";
final SharedPreferences myPref = getSharedPreferences("loginPref", MODE_PRIVATE);
final SharedPreferences.Editor myPreff = myPref.edit();
RequestQueue requestQueue = Volley.newRequestQueue(this);
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
List<DistrBean> distrBeansList = new ArrayList<>();
try {
JSONObject jsonObject = new JSONObject(response);
Iterator keys = jsonObject.keys();
while (keys.hasNext()) {
Object key = keys.next();
JSONObject value = jsonObject.getJSONObject((String) key);
JSONObject info = value.getJSONObject("Distributore Information");
String LitriColonnina1 = info.getString("litriiniziocolonna");
String NomeDistributore1 = info.getString("NomeDistributore");
String id_distributore1 = info.getString("id_distributore");
DistrBean distrBean = new DistrBean();
distrBean.setLitriColonnina(LitriColonnina1);
distrBean.setNomeDistributore(NomeDistributore1);
distrBean.setIdDistributore(id_distributore1);
distrBeansList.add(distrBean);
}
ArrayAdapter<DistrBean> adapter = new ArrayAdapter<DistrBean>(InizioTurnoActivity.this, android.R.layout.simple_spinner_item, distrBeansList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
DistrBean distrBean = (DistrBean) adapterView.getSelectedItem();
getSelectedDistr(distrBean);
}
#Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
Toast.makeText(InizioTurnoActivity.this, "CHIAMATA INFOCOLONNINA FALLITA", Toast.LENGTH_SHORT).show();
}
});
requestQueue.add(stringRequest);
}
public void getSelectedDistr(DistrBean v){
DistrBean distrBean = (DistrBean) spinner.getSelectedItem();
setDistrData(distrBean);
}
private void setDistrData(DistrBean distrBean){
String name = distrBean.getNomeDistributore();
String litri = distrBean.getLitriColonnina();
String id = distrBean.getIdDistributore();
tvProgressivo.setText(litri);
tvColonnina.setText(name);
Toast.makeText(this, "Hai selezionato " + name + "che ha litri: " + litri, Toast.LENGTH_LONG).show();
}
}
Can you guys help me? thank you in advance!
your json is not valid
{
"Conteggio": 2,
"0": {
"Distributore Information": {
"id_distributore": "1",
"NomeDistributore": "Colonnina 0",
"litriiniziocolonna": "444", //this line
}
},
"1": {
"Distributore Information": {
"id_distributore": "2",
"NomeDistributore": "Colonnina 1",
"litriiniziocolonna": "555", //this line
}
}
}
You should test your rest api on postman before integrating it in android app and use Gson library, response model to handle all json response. Gson library automatically parse data according to your model so you dont need to get data by specifying individual key.
I think that your parsing algorithm has issue.
Iterator keys = jsonObject.keys();
-> Conteggio, 0, 1
So you should skip one.

CardStackView adding spots with database information

Sorry if this post is not correctly filled but ill try to do my best. I am attempting to create an android app with android studio where i need a TinderLike swipe holder.
For this purpose i am using this library: CardStackView
Everything is working fine if i use the default code to populate the pictures.
private List<TouristSpot> createTouristSpots() {
List<TouristSpot> spots = new ArrayList<>();
spots.add(new TouristSpot("Yasaka Shrine", "Kyoto", "https://source.unsplash.com/Xq1ntWruZQI/600x800"));
spots.add(new TouristSpot("Fushimi Inari Shrine", "Kyoto", "https://source.unsplash.com/NYyCqdBOKwc/600x800"));
spots.add(new TouristSpot("Bamboo Forest", "Kyoto", "https://source.unsplash.com/buF62ewDLcQ/600x800"));
spots.add(new TouristSpot("Brooklyn Bridge", "New York", "https://source.unsplash.com/THozNzxEP3g/600x800"));
spots.add(new TouristSpot("Empire State Building", "New York", "https://source.unsplash.com/USrZRcRS2Lw/600x800"));
spots.add(new TouristSpot("The statue of Liberty", "New York", "https://source.unsplash.com/PeFk7fzxTdk/600x800"));
spots.add(new TouristSpot("Louvre Museum", "Paris", "https://source.unsplash.com/LrMWHKqilUw/600x800"));
spots.add(new TouristSpot("Eiffel Tower", "Paris", "https://source.unsplash.com/HN-5Z6AmxrM/600x800"));
spots.add(new TouristSpot("Big Ben", "London", "https://source.unsplash.com/CdVAUADdqEc/600x800"));
spots.add(new TouristSpot("Great Wall of China", "China", "https://source.unsplash.com/AWh9C-QjhE4/600x800"));
return spots;
}
But when i try to change the default population code with a code that retrieve information from a database, nothing is displayed anymore.
private List<TouristSpot> createTouristSpots() {
final List<TouristSpot> spots = new ArrayList<>();
String url = AppData.api + "radar_2.php";
alerttext.setVisibility(View.VISIBLE);
SharedPreferences token = getApplicationContext().getSharedPreferences(AppData.sp_user_info, 0);
String user_id = token.getString(AppData.sp_user_id, "0");
UserData userData=new AppData().getUserData();
Map<String, String> params = new HashMap<String, String>();
params.put("user_id", user_id);
params.put("number", String.valueOf(n));
params.put("gender", userData.getLooking_gender());
params.put("looking_age_start",userData.getLooking_age_start());
params.put("looking_age_end", userData.getLooking_age_end());
params.put("latitude", userData.getLatitude());
params.put("longitude", userData.getLongitude());
params.put("distance", "100");
CustomRequest jsObjRequest = new CustomRequest(Request.Method.POST, url, params, new Response.Listener<JSONObject>()
{
#Override
public void onResponse(JSONObject response)
{
if (n == 1)
{
SharedPreferences.Editor editor = pref.edit();
editor.putString("MATCHDATALIST", response.toString());
editor.commit();
}
try
{
String str = response.getString("Error");
if (str.equals("None"))
{
JSONArray jsonArray = response.getJSONArray("Responsedata");
//Toast.makeText(getActivity(), jsonArray.toString(), Toast.LENGTH_LONG).show();
for (int i = 0; jsonArray.length() > i; i++)
{
JSONObject jsonObject = jsonArray.getJSONObject(i);
spots.add(new TouristSpot(jsonObject.getString("user_id"),jsonObject.getString("username"),jsonObject.getString("hometown"),jsonObject.getString("age"),jsonObject.getString("gender"),jsonObject.getString("profile_image"),jsonObject.getString("interests"),jsonObject.getString("distance")));
}
alerttext.setVisibility(View.GONE);
} else {
//Toast.makeText(getActivity(), response.getString("Error"), Toast.LENGTH_LONG).show();
}
} catch (JSONException e)
{
e.printStackTrace();
}
}
}, new Response.ErrorListener()
{
#Override
public void onErrorResponse(VolleyError response)
{
//Toast.makeText(getActivity(), response.toString(), Toast.LENGTH_LONG).show();
}
});
jsObjRequest.setRetryPolicy(new DefaultRetryPolicy(15000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
AppController.getInstance().addToRequestQueue(jsObjRequest);
//Toast.makeText(getActivity(), spots.toString(), Toast.LENGTH_LONG).show();
return spots;
}
In my OnCreateView, i am calling the function reload();
private void reload() {
cardStackView.setVisibility(View.GONE);
adapter = createTouristSpotCardAdapter();
cardStackView.setAdapter(adapter);
cardStackView.setVisibility(View.VISIBLE);
}
private TouristSpotCardAdapter createTouristSpotCardAdapter() {
final TouristSpotCardAdapter adapter = new TouristSpotCardAdapter(getApplicationContext());
adapter.addAll(createTouristSpots());
return adapter;
}
I did checked the JSONArray to string and all information retrieved from the database is inside it.
PS: the TouristSpot is adapted to contain all the variables from the database.
If some one could bring me on the correct path to make it working with values retrieved from my database, i would be very gratfull
Sincerely,
Jeremy

Null Response in retrofit

I am having a issue to get response by using retrofit library.
My JSON is below
{
"regData": [
{
"registrationType": "User",
"userDetails": {
"city": "Bangalore ",
"country": "Bangalore ",
"email": "hfhg#lll.com",
"name": "Cxhcc",
"password": "123456",
"phoneno": "486586"
},
"vehicleRegsiration": {}
}
]
}
Please note that above json i got after debug of my application and when i used same JSON with postman rest client application, it is working fine.
Below is my code
public void postRegistrationData(Registeration reqBody){
ApiInterface apiService = ApiClient.getClient().create(ApiInterface.class);
Call<Long> call = apiService.registrationApi(reqBody);
call.enqueue(new Callback<Long>() {
#Override
public void onResponse(Call<Long> call, Response<Long> response) {
if(response.isSuccessful()){
Long id = response.body().longValue();
Log.d(TAG, "Response: " + id);
} else{
Log.d(TAG, "Response failed: ");
}
}
#Override
public void onFailure(Call<Long>call, Throwable t) {
Log.e(TAG, t.toString());
}
});
}
After execution of above code its always executing below code
Log.d(TAG, "Response failed: ");
public Registeration prepareRegRequestBody(UserDetails uDetail , VehicleRegsiration vDedail, String regType){
RegDatum reg = new RegDatum();
List<RegDatum> regList = new ArrayList<RegDatum>();
Registeration regUV = new Registeration();
reg.setRegistrationType(regType);
reg.setUserDetails(uDetail);
reg.setVehicleRegsiration(vDedail);
regList.add(reg);
regUV.setRegData(regList);
return regUV;
}
public Registeration inputDataUV(){
UserDetails userDetail = new UserDetails();
VehicleRegsiration vehicleRegsiration = new VehicleRegsiration();
Registeration reqbody = new Registeration();
if(userType.getSelectedItem().toString().equalsIgnoreCase("User")){
userDetail.setEmail(signupInputEmail.getText().toString());
userDetail.setPassword(signupInputPassword.getText().toString());
userDetail.setPhoneno(signupInputMobile.getText().toString());
userDetail.setName(signupInputName.getText().toString());
userDetail.setCountry(countryName1.getText().toString());
userDetail.setCity(signupInputCity.getText().toString());
reqbody = prepareRegRequestBody(userDetail, vehicleRegsiration, "User" );
return reqbody;
} else if(userType.getSelectedItem().toString().equalsIgnoreCase("Vehicle")){
vehicleRegsiration.setVehicleOwner(vSignupEmailId.getText().toString());
vehicleRegsiration.setVehicleNoPlate(vSignupVnumber.getText().toString());
vehicleRegsiration.setVehicleType(vSignupType.getText().toString());
vehicleRegsiration.setImeiNo(Long.parseLong(vSignupImeiNo.getText().toString()));
vehicleRegsiration.setPassword(vSignupPassword.getText().toString());
vehicleRegsiration.setCountry(vcountryName1.getText().toString());
vehicleRegsiration.setCity(vSignupCity.getText().toString());
reqbody = prepareRegRequestBody(userDetail, vehicleRegsiration, "Vehicle" );
return reqbody;
} else{
return reqbody;
}
}
Where i am doing wrong please help me get rid of this issue.

How to get the id of the selected item of the Autocompletetextview in android?

My question is when i select the state from the autocompletetextview it always return 1 as an id. but i want to get the id accordingly to the state as per shown my json. Example (StateName = Assam then StateId = 4).but i am always getting id as 1. i am using model class to set the id and get from it.but there is no change i am getting the id as a 1. If anyone know how can i resolve this problem.then please tell me. thanks in advance.
This is my jsonResponce :-
{
"ReplyCode": 1,
"Message": "Franchisee and Plans List",
"data2": [
{
"StateId": 1,
"StateName": "Andaman and Nicobar Island",
"CountryId": 1
},
{
"StateId": 2,
"StateName": "Andhra Pradesh",
"CountryId": 1
},
{
"StateId": 3,
"StateName": "Arunachal Pradesh",
"CountryId": 1
},
{
"StateId": 4,
"StateName": "Assam",
"CountryId": 1
},
This is the method by which i am getting the data from the json :-
public void volleyStatedata() {
if (mGeneralUtilities.isConnected()) {
mProgressDialog.show();
StringRequest stateRequest = new StringRequest(Request.Method.POST, GlobalData.REGISTER_DATA_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
mProgressDialog.dismiss();
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("data2");
for (int i = 0; i < jsonArray.length(); i++) {
PojoState pojoState = new PojoState();
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
String stateId = jsonObject1.getString("StateId");
String stateName = jsonObject1.getString("StateName");
mStateList.add(stateName);
mStateIdList.add(stateId);
pojoState.setmStateList(mStateList);
pojoState.setmStateId(stateId);
mpojoStateList.add(pojoState);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError volleyError) {
Log.e("error", "" + volleyError.getMessage());
}
}) {
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
return params;
}
};
RequestQueue stateQueue = Volley.newRequestQueue(getContext());
stateQueue.add(stateRequest);
} else {
mGeneralUtilities.showAlertDialog("Hey User !", "Please connect to the internet", "Ok");
}
}
And this is my adapter where i am applying onItemclick listner on the autocompltetextview :-
ArrayAdapter<String> mStateAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, mStateList);
mActState.setAdapter(mStateAdapter);
mActState.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
mpojoStateList.get(i).getmStateId();
}
});
Your code uses i that returns in the onItemClick callback, which refers to the item you clicked from the visible items in the auto-complete list, not your original list. When you click on the first item in the auto-complete list, i=0, which means it always returns the "Andaman and Nicobar Island" item whose StateId=1.
Off the top of my head, you can get the item String from the mStateAdapter and compare it to your mpojoStateList and find the corresponding item. (Check the sample code)
final ArrayAdapter<String> mStateAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, mStateList);
mActState.setAdapter(mStateAdapter);
mActState.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String itemName = mStateAdapter.getItem(i);
for (PojoState pojo : mpojoStateList) {
if (pojo.mStateName.equals(itemName)) {
String id = pojo.getmStateId(); // This is the correct ID
break; // No need to keep looping once you found it.
}
}
}
});
It also is better if, inside your PojoState object, you override your toString() method and make it return the mStateName, and pass the mpojoStateList to the adapter without having to make 3 ArrayLists. That way, mStateAdapter.getItem(i) will return a PojoState object instead of a String, and you can use its ID without referring to the returned position (i).

Parse JSON with both sides values

I'm using volley to get response from API but the response consist of STATE_ID:STATE_NAME pair (i.e. value:value pair) and I need both side's values in different Strings. I need these values to put in a spinner so that when user selects a State I can get its corresponding ID also.
// JSON response
{
"1": "West bengal",
"3": "Himachal Pradesh",
"4": "Maharashtra",
"11": "Queensland"
}
My Code
public class MainActivity extends AppCompatActivity {
private static final String STATE = "MY_API";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void login(View v){
loginRequest();
}
private void loginRequest() {
StringRequest stringRequest = new StringRequest(Request.Method.POST, STATE,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, response, Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "VolleyError" + error.toString(), Toast.LENGTH_LONG).show();
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("country_id","2");
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
}
}
You already have the iterate() method as we discussed in comments.
Done some work to give you value :
try {
JSONObject jsonObject = new JSONObject(response);
for (String key : iterate(jsonObject.keys()))
{
Toast.makeText(this, "Key : "+key+" Value: "+jsonObject.optString(key), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
Please refer the iterate method from this answer. I have posted this as a new answer because OP was unable to make it for the values..!!
I used iterator to find a key. May this will help:
private void parseRespone(String response){
try {
JSONObject MainjsonObject = new JSONObject(response)
Iterator<String> iter= MainjsonObject.keys();
//To get keys of an object
while (iter.hasNext())
{
String key = (String)iter.next();
//Object value = jsonobj.get(key); //To use by object
String valueStr = jsonobj.get.getString(key);
Log.i("Jsonparsing", "key= "+key + "\n Value=" +valueStr );
Toast.makeText(getActivity(),"key= "+ key + "\n value= " + valueStr ,Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
I could find an unknown key by this.
Please check in a Log in your android studio...
here I have put Toast also..
And call this function here...
...........
#Override
public void onResponse(String response) {
parseRespone(response); //Function to parse json
}
Thanks..
It will be much better if you consider changing your response to something like this:
[
{"ID":"1","name": "West bengal"},
{"ID":"3","name": "Himachal Pradesh"},
{"ID":"4","name": "Maharashtra"},
{"ID":"11","name": "Queensland"}
]
You can use jsonObject.names() (or keys() for an Iterator) to retrieve all keys.
After that you can iterate through the array using the keys and store your strings.
https://developer.android.com/reference/org/json/JSONObject.html#names()
https://developer.android.com/reference/org/json/JSONObject.html#keys()
I tried this solution and it worked out.`Here, "key" will toast the key_value[1,3,4,11] and value will print the names[West bengal,Himachal Pradesh,Maharashtra,Queensland].
JSONObject list_object = inner_json_object.getJSONObject("");
for (String key : iterate(list_object.keys()))
{
// here key will be containing your OBJECT NAME YOU CAN SET IT IN TEXTVIEW.
Toast.makeText(Activity.this, ""+key, Toast.LENGTH_SHORT).show();
String value = bank_list_object.optString(key);
}`
private <T> Iterable<T> iterate(final Iterator<T> i){
return new Iterable<T>() {
#Override
public Iterator<T> iterator() {
return i;
}
};
}

Categories

Resources