Search in sources :

Example 61 with TableRow

use of android.widget.TableRow in project android-diplicity by zond.

the class GameActivity method showGameStates.

public void showGameStates() {
    hideAllExcept(R.id.game_state_view);
    if (member == null) {
        findViewById(R.id.edit_game_state_button).setVisibility(View.GONE);
    }
    handleReq(gameStateService.ListGameStates(game.ID), new Sendable<MultiContainer<GameState>>() {

        @Override
        public void send(MultiContainer<GameState> gameStateMultiContainer) {
            GameState myState = null;
            TableLayout mutedTable = (TableLayout) findViewById(R.id.muted_table);
            mutedTable.removeAllViews();
            FloatingActionButton button = ((FloatingActionButton) mutedTable.findViewById(R.id.open_button));
            if (button != null) {
                mutedTable.removeView(button);
            }
            final List<String> nations = new ArrayList<String>();
            for (Member thisMember : game.Members) {
                if (member == null || !thisMember.Nation.equals(member.Nation)) {
                    nations.add(thisMember.Nation);
                }
                GameState foundState = null;
                for (SingleContainer<GameState> singleContainer : gameStateMultiContainer.Properties) {
                    if (singleContainer.Properties.Nation.equals(thisMember.Nation)) {
                        foundState = singleContainer.Properties;
                    }
                }
                if (member != null && thisMember.Nation.equals(member.Nation)) {
                    myState = foundState;
                }
                TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1.0f);
                int margin = getResources().getDimensionPixelSize(R.dimen.muted_table_margin);
                params.bottomMargin = margin;
                params.topMargin = margin;
                params.leftMargin = margin;
                params.rightMargin = margin;
                TableRow tableRow = new TableRow(GameActivity.this);
                tableRow.setLayoutParams(params);
                LinearLayout playerSide = new LinearLayout(GameActivity.this);
                LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                playerSide.setLayoutParams(params);
                playerSide.setOrientation(LinearLayout.VERTICAL);
                UserView user = new UserView(GameActivity.this, null);
                user.setUser(GameActivity.this, thisMember.User, true);
                user.setLayoutParams(linearParams);
                playerSide.addView(user);
                TextView nation = new TextView(GameActivity.this);
                nation.setText(thisMember.Nation);
                nation.setLayoutParams(linearParams);
                playerSide.addView(nation);
                tableRow.addView(playerSide);
                TextView muteds = new TextView(GameActivity.this);
                muteds.setLayoutParams(params);
                if (foundState != null && foundState.Muted != null) {
                    muteds.setText(TextUtils.join(", ", foundState.Muted));
                } else {
                    muteds.setText("");
                }
                tableRow.addView(muteds);
                mutedTable.addView(tableRow);
            }
            final GameState finalMyState = myState;
            if (finalMyState != null) {
                ((FloatingActionButton) findViewById(R.id.edit_game_state_button)).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        final boolean[] checked = new boolean[nations.size()];
                        if (finalMyState.Muted != null) {
                            for (String muted : finalMyState.Muted) {
                                int pos = nations.indexOf(muted);
                                if (pos > -1) {
                                    checked[pos] = true;
                                }
                            }
                        }
                        final AlertDialog dialog = new AlertDialog.Builder(GameActivity.this).setMultiChoiceItems(nations.toArray(new String[] {}), checked, new DialogInterface.OnMultiChoiceClickListener() {

                            @Override
                            public void onClick(DialogInterface dialogInterface, int i, boolean b) {
                                checked[i] = b;
                            }
                        }).setTitle(R.string.muted).setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialogInterface, int j) {
                                List<String> mutedMembers = new ArrayList<String>();
                                for (int i = 0; i < checked.length; i++) {
                                    if (checked[i]) {
                                        mutedMembers.add(nations.get(i));
                                    }
                                }
                                Collections.sort(mutedMembers);
                                finalMyState.Muted = mutedMembers;
                                handleReq(gameStateService.GameStateUpdate(finalMyState, game.ID, finalMyState.Nation), new Sendable<SingleContainer<GameState>>() {

                                    @Override
                                    public void send(SingleContainer<GameState> gameStateSingleContainer) {
                                        showGameStates();
                                    }
                                }, getResources().getString(R.string.updating_game_state));
                            }
                        }).show();
                    }
                });
            }
        }
    }, getResources().getString(R.string.loading_game_settings));
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) UserView(se.oort.diplicity.UserView) MultiContainer(se.oort.diplicity.apigen.MultiContainer) FloatingActionButton(android.support.design.widget.FloatingActionButton) List(java.util.List) ArrayList(java.util.ArrayList) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout) Member(se.oort.diplicity.apigen.Member) GameState(se.oort.diplicity.apigen.GameState) 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) SingleContainer(se.oort.diplicity.apigen.SingleContainer) TableRow(android.widget.TableRow) LinearLayout(android.widget.LinearLayout)

Example 62 with TableRow

use of android.widget.TableRow in project android-diplicity by zond.

the class UserStatsTable method addRow.

public void addRow(RetrofitActivity retrofitActivity, String text1, String text2) {
    TableRow tableRow = new TableRow(retrofitActivity);
    tableRow.setLayoutParams(matchParentParams);
    addText(retrofitActivity, tableRow, text1);
    addText(retrofitActivity, tableRow, text2);
    addView(tableRow);
}
Also used : TableRow(android.widget.TableRow)

Example 63 with TableRow

use of android.widget.TableRow in project satstat by mvglasow.

the class RadioSectionFragment method addWifiResult.

private final void addWifiResult(ScanResult result) {
    // needed to pass a persistent reference to the OnClickListener
    final ScanResult r = result;
    android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onWifiEntryClick(r.BSSID);
        }
    };
    LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
    wifiLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
    wifiLayout.setWeightSum(22);
    wifiLayout.setMeasureWithLargestChildEnabled(false);
    ImageView wifiType = new ImageView(wifiAps.getContext());
    wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
    if (WifiCapabilities.isAdhoc(result)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
    } else if ((WifiCapabilities.isEnterprise(result)) || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_open);
    } else {
        wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
    }
    wifiType.setScaleType(ScaleType.CENTER);
    wifiLayout.addView(wifiType);
    TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
    wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    TableRow innerRow1 = new TableRow(wifiAps.getContext());
    TextView newMac = new TextView(wifiAps.getContext());
    newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
    newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newMac.setText(result.BSSID);
    innerRow1.addView(newMac);
    TextView newCh = new TextView(wifiAps.getContext());
    newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newCh.setText(getChannelFromFrequency(result.frequency));
    innerRow1.addView(newCh);
    TextView newLevel = new TextView(wifiAps.getContext());
    newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newLevel.setText(String.valueOf(result.level));
    innerRow1.addView(newLevel);
    innerRow1.setOnClickListener(clis);
    wifiDetails.addView(innerRow1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    TableRow innerRow2 = new TableRow(wifiAps.getContext());
    TextView newSSID = new TextView(wifiAps.getContext());
    newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
    newSSID.setText(result.SSID);
    innerRow2.addView(newSSID);
    innerRow2.setOnClickListener(clis);
    wifiDetails.addView(innerRow2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    wifiLayout.addView(wifiDetails);
    wifiLayout.setOnClickListener(clis);
    wifiAps.addView(wifiLayout);
}
Also used : ScanResult(android.net.wifi.ScanResult) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TableRow(android.widget.TableRow) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TableLayout(android.widget.TableLayout) LinearLayout(android.widget.LinearLayout)

Example 64 with TableRow

use of android.widget.TableRow in project satstat by mvglasow.

the class RadioSectionFragment method showCellGsm.

protected void showCellGsm(CellTowerGsm cellTower) {
    TableRow row = (TableRow) mainActivity.getLayoutInflater().inflate(R.layout.ril_list_item, null);
    TextView type = (TextView) row.findViewById(R.id.type);
    TextView mcc = (TextView) row.findViewById(R.id.mcc);
    TextView mnc = (TextView) row.findViewById(R.id.mnc);
    TextView area = (TextView) row.findViewById(R.id.area);
    TextView cell = (TextView) row.findViewById(R.id.cell);
    TextView cell2 = (TextView) row.findViewById(R.id.cell2);
    TextView unit = (TextView) row.findViewById(R.id.unit);
    TextView dbm = (TextView) row.findViewById(R.id.dbm);
    type.setTextColor(rilCells.getContext().getResources().getColor(getColorFromGeneration(cellTower.getGeneration())));
    type.setText(rilCells.getContext().getResources().getString(R.string.smallDot));
    mcc.setText(formatCellData(rilCells.getContext(), "%03d", cellTower.getMcc()));
    mnc.setText(formatCellData(rilCells.getContext(), "%02d", cellTower.getMnc()));
    area.setText(formatCellData(rilCells.getContext(), null, cellTower.getLac()));
    int rtcid = cellTower.getCid() / 0x10000;
    int cid = cellTower.getCid() % 0x10000;
    if ((mainActivity.prefCid) && (cellTower.getCid() != CellTower.UNKNOWN) && (cellTower.getCid() > 0x0ffff)) {
        cell.setText(String.format("%d-%d", rtcid, cid));
        cell2.setText(formatCellData(rilCells.getContext(), null, cellTower.getCid()));
    } else {
        cell.setText(formatCellData(rilCells.getContext(), null, cellTower.getCid()));
        cell2.setText(String.format("%d-%d", rtcid, cid));
    }
    cell2.setVisibility((mainActivity.prefCid2 && (cellTower.getCid() > 0x0ffff)) ? View.VISIBLE : View.GONE);
    unit.setText(formatCellData(rilCells.getContext(), null, cellTower.getPsc()));
    dbm.setText(formatCellDbm(rilCells.getContext(), null, cellTower.getDbm()));
    rilCells.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
Also used : TableRow(android.widget.TableRow) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout) SuppressLint(android.annotation.SuppressLint)

Example 65 with TableRow

use of android.widget.TableRow in project opacclient by opacapp.

the class MultiStepResultHelper method askForConfirmation.

public void askForConfirmation(final MultiStepResult result) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater inflater = context.getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_reservation_details, null, false);
    TableLayout table = (TableLayout) view.findViewById(R.id.tlDetails);
    if (result.getDetails().size() == 1 && result.getDetails().get(0).length == 1) {
        ((ViewGroup) view.findViewById(R.id.rlConfirm)).removeView(table);
        TextView tv = new TextView(context);
        tv.setText(result.getDetails().get(0)[0]);
        tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        ((ViewGroup) view.findViewById(R.id.rlConfirm)).addView(tv);
    } else {
        for (String[] detail : result.getDetails()) {
            TableRow tr = new TableRow(context);
            if (detail.length == 2) {
                TextView tv1 = new TextView(context);
                tv1.setText(Html.fromHtml(detail[0]));
                tv1.setTypeface(null, Typeface.BOLD);
                tv1.setPadding(0, 0, 8, 0);
                TextView tv2 = new TextView(context);
                tv2.setText(Html.fromHtml(detail[1]));
                tv2.setEllipsize(TruncateAt.END);
                tv2.setSingleLine(false);
                tr.addView(tv1);
                tr.addView(tv2);
            } else if (detail.length == 1) {
                TextView tv1 = new TextView(context);
                tv1.setText(Html.fromHtml(detail[0]));
                tv1.setPadding(0, 2, 0, 2);
                TableRow.LayoutParams params = new TableRow.LayoutParams(0);
                params.span = 2;
                tv1.setLayoutParams(params);
                tr.addView(tv1);
            }
            table.addView(tr);
        }
    }
    builder.setTitle(R.string.confirm_title).setView(view).setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            doStep(MultiStepResult.ACTION_CONFIRMATION, "confirmed");
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            adialog.cancel();
            if (callback != null) {
                callback.onUserCancel();
            }
        }
    });
    adialog = builder.create();
    adialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LayoutParams(android.view.ViewGroup.LayoutParams) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) TableRow(android.widget.TableRow) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout)

Aggregations

TableRow (android.widget.TableRow)77 TextView (android.widget.TextView)53 TableLayout (android.widget.TableLayout)37 View (android.view.View)30 Button (android.widget.Button)11 ImageView (android.widget.ImageView)10 SuppressLint (android.annotation.SuppressLint)7 ScrollView (android.widget.ScrollView)7 CPU (brunonova.drmips.simulator.CPU)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 CheckBox (android.widget.CheckBox)6 ViewGroup (android.view.ViewGroup)5 CompoundButton (android.widget.CompoundButton)5 ImageButton (android.widget.ImageButton)5 LinearLayout (android.widget.LinearLayout)5 ListView (android.widget.ListView)5 LayoutParams (android.widget.TableLayout.LayoutParams)5 SpannableStringBuilder (android.text.SpannableStringBuilder)4 ArrayList (java.util.ArrayList)4 Context (android.content.Context)3