Search in sources :

Example 1 with Resolution

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));
}
Also used : Order(se.oort.diplicity.apigen.Order) EditText(android.widget.EditText) Phase(se.oort.diplicity.apigen.Phase) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NavigationView(android.support.design.widget.NavigationView) UserView(se.oort.diplicity.UserView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ScrollView(android.widget.ScrollView) MotionEvent(android.view.MotionEvent) SingleContainer(se.oort.diplicity.apigen.SingleContainer) MultiContainer(se.oort.diplicity.apigen.MultiContainer) Func2(rx.functions.Func2) Resolution(se.oort.diplicity.apigen.Resolution)

Aggregations

NavigationView (android.support.design.widget.NavigationView)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 ListView (android.widget.ListView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Func2 (rx.functions.Func2)1 UserView (se.oort.diplicity.UserView)1 MultiContainer (se.oort.diplicity.apigen.MultiContainer)1 Order (se.oort.diplicity.apigen.Order)1 Phase (se.oort.diplicity.apigen.Phase)1 Resolution (se.oort.diplicity.apigen.Resolution)1 SingleContainer (se.oort.diplicity.apigen.SingleContainer)1