个人信息添加
This commit is contained in:
@@ -6,9 +6,18 @@ import android.os.Bundle;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.MyUser;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.Occupation;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
||||
/**
|
||||
@@ -70,6 +79,7 @@ public class NutritionMaster extends Application {
|
||||
|
||||
}
|
||||
});
|
||||
initOccupations();
|
||||
}
|
||||
|
||||
public static NutritionMaster getInstance() {
|
||||
@@ -94,6 +104,27 @@ public class NutritionMaster extends Application {
|
||||
user.setNickName("ScorpioMiku");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化职业常量
|
||||
*/
|
||||
private void initOccupations() {
|
||||
|
||||
WebUtils.getAllOccupations(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Occupation[] occupations = new Gson().fromJson(response.body().string(), Occupation[].class);
|
||||
for (int i = 0; i < occupations.length; i++) {
|
||||
ConstantUtils.occupationList.add(occupations[i].getOccupation_name());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user