use of se.oort.diplicity.apigen.Resolution in project android-diplicity by zond.
the class GameActivity method showOrders.
public void showOrders() {
hideAllExcept(R.id.orders_view);
handleReq(JoinObservable.when(JoinObservable.from(orderService.ListOrders(game.ID, phaseMeta.PhaseOrdinal.toString())).and(phaseService.PhaseLoad(game.ID, phaseMeta.PhaseOrdinal.toString())).then(new Func2<MultiContainer<Order>, SingleContainer<Phase>, Object>() {
@Override
public Object call(MultiContainer<Order> orderMultiContainer, SingleContainer<Phase> phaseSingleContainer) {
Map<String, String> resultMap = new HashMap<String, String>();
if (phaseSingleContainer.Properties.Resolutions != null) {
for (Resolution resolution : phaseSingleContainer.Properties.Resolutions) {
resultMap.put(resolution.Province, resolution.Resolution);
}
}
List<String> orders = new ArrayList<String>();
for (SingleContainer<Order> orderContainer : orderMultiContainer.Properties) {
String resolution = resultMap.get(orderContainer.Properties.Parts.get(0));
if (resolution == null) {
orders.add(getResources().getString(R.string.nation_order, orderContainer.Properties.Nation, TextUtils.join(" ", orderContainer.Properties.Parts)));
} else {
orders.add(getResources().getString(R.string.nation_order_result, orderContainer.Properties.Nation, TextUtils.join(" ", orderContainer.Properties.Parts), resolution));
}
}
Collections.sort(orders);
final EditText ordersView = (EditText) findViewById(R.id.orders_view);
ordersView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
flickFrameLayout.onTouchEvent(motionEvent);
ordersView.onTouchEvent(motionEvent);
return true;
}
});
StringBuffer orderBuffer = new StringBuffer();
for (String order : orders) {
orderBuffer.append(order + "\n");
}
ordersView.setText(orderBuffer);
return null;
}
})).toObservable(), null, getResources().getString(R.string.loading_orders));
}
Aggregations