use of ch.hsr.sa.radiotour.dataaccess.models.Reward in project app by TourLive.
the class JudgmentDetailFragment method iniList.
private void iniList() {
textViews.add(rankOne);
textViews.add(rankTwo);
textViews.add(rankThree);
textViews.add(rankFour);
textViews.add(rankFive);
textViews.add(rankOne);
textViews.add(rankTwo);
textViews.add(rankThree);
textViews.add(rankFour);
textViews.add(rankFive);
headers.add(rankOneTxt);
headers.add(rankTwoTxt);
headers.add(rankThreeTxt);
headers.add(rankFourTxt);
headers.add(rankFiveTxt);
headers.add(rankSixTxt);
headers.add(rankSevenTxt);
headers.add(rankEightTxt);
headers.add(rankNineTxt);
headers.add(rankTenTxt);
Reward reward = judgement.getRewards();
for (int i = 0; i < reward.getPoints().size(); i++) {
headers.get(i).setText(headers.get(i).getText() + getResources().getString(R.string.judgment_points) + reward.getPoints().get(i));
}
}
use of ch.hsr.sa.radiotour.dataaccess.models.Reward in project app by TourLive.
the class Parser method parseRewardsAndPersist.
public static void parseRewardsAndPersist(JSONArray rewards) throws InterruptedException {
final JSONArray rewardsJson = rewards;
Runnable runnable = (() -> {
for (int i = 0; i < rewardsJson.length(); i++) {
try {
JSONObject jsonReward = rewardsJson.getJSONObject(i);
Reward reward = new Reward();
RealmList<Integer> moneyList = new RealmList<>();
String[] moneyString = jsonReward.getString("reward").split(",");
for (String s : moneyString) {
moneyList.add(Integer.valueOf(s));
}
reward.setMoney(moneyList);
String bonusType = jsonReward.getString("bonusType");
if (bonusType.equals("time")) {
reward.setType(RewardType.TIME);
}
if (bonusType.equals("points")) {
reward.setType(RewardType.POINTS);
}
RealmList<Integer> bonusList = new RealmList<>();
String[] bonusString = jsonReward.getString("bonus").split(",");
for (String s : bonusString) {
bonusList.add(Integer.valueOf(s));
}
reward.setPoints(bonusList);
reward.setRewardId(jsonReward.getInt("id"));
reward.setRewardJudgements(Context.getJudgmentsById(reward.getRewardId()));
Context.addReward(reward);
} catch (JSONException e) {
Log.d(Parser.class.getSimpleName(), "APP - PARSER - REWARDS - " + e.getMessage());
}
}
});
Thread threadRewards = new Thread(runnable);
threadRewards.start();
threadRewards.join();
}
Aggregations