Merge branch 'develop' of https://github.com/wangtianrui/NutritionMaster into develop
This commit is contained in:
@@ -41,6 +41,17 @@ public class WebUtils {
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取count个随机菜谱,在回调中解析为一个Menu数组
|
||||
* @param count
|
||||
* @param callback
|
||||
*/
|
||||
public static void getRandomMenus(int count, Callback callback) {
|
||||
OkHttpClient mClient = new OkHttpClient();
|
||||
Request request = new Request.Builder().url("http://127.0.0.1:8000/menus/get_random_menus/?count=" + String.valueOf(count)).build();
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某食材可以做的菜
|
||||
* [
|
||||
@@ -226,6 +237,21 @@ public class WebUtils {
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getRandomMenus(10, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
FoodMenu[] menus = new Gson().fromJson(response.body().string(), FoodMenu[].class);
|
||||
System.out.println(Arrays.toString(menus));
|
||||
System.out.println(menus.length);
|
||||
|
||||
}
|
||||
});*/
|
||||
|
||||
/* WebUtils.getFoodMaterial("西红柿", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user