Search in sources :

Example 31 with TableLayout

use of android.widget.TableLayout in project project1-ICS372 by sandip-rai.

the class PatientReadingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_patient_readings);
    // Get the toolbar and assign
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.patient_readings);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Get the Patient object using the selected_patientId
    String selectedPatientId = (String) getIntent().getExtras().get(SELECTED_PATIENTID);
    Patient patient = clinicalTrial.findPatient(selectedPatientId);
    // Fill the textView with the selectedPatient
    TextView textViewPatientId = (TextView) findViewById(R.id.textViewPatientIdinPatientReadings);
    textViewPatientId.setText(selectedPatientId);
    if (patient.getState().getReadings() != null) {
        // Get the TableLayout
        TableLayout table = (TableLayout) findViewById(R.id.readingsTable);
        // Counter to count number of rows and setting colors to even rows
        int count = 0;
        for (Reading reading : patient.getReadings()) {
            // Get all the readings of the Patient
            // Create a table row using the readings_row XML
            TableRow row = (TableRow) LayoutInflater.from(PatientReadingsActivity.this).inflate(R.layout.readings_row, null);
            if (count % 2 == 0) {
                // set the color to even rows
                row.setBackgroundColor(Color.LTGRAY);
            }
            // Fill the TextViews in the rows using the reading of the Patient Object
            ((TextView) row.findViewById(R.id.readingIdColumn)).setText(reading.getReadingId());
            ((TextView) row.findViewById(R.id.typeColumn)).setText(reading.getType());
            ((TextView) row.findViewById(R.id.valueColumn)).setText(reading.getValue());
            ((TextView) row.findViewById(R.id.dateColumn)).setText(reading.getDate().toString());
            ((TextView) row.findViewById(R.id.clinicIdColumn)).setText(reading.getClinic().getId());
            ((TextView) row.findViewById(R.id.clinicNameColumn)).setText(reading.getClinic().getName());
            // Add the row to the TableLayout
            table.addView(row);
            count++;
        }
        table.requestLayout();
    }
}
Also used : Reading(trial.Reading) TableRow(android.widget.TableRow) Patient(trial.Patient) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 32 with TableLayout

use of android.widget.TableLayout in project drmips by brunonova.

the class DlgCodeHelp method setContents.

private void setContents(View rootView) {
    DrMIPSActivity activity = (DrMIPSActivity) getActivity();
    TableLayout tblInstructions = (TableLayout) rootView.findViewById(R.id.tblInstructions);
    TableLayout tblPseudos = (TableLayout) rootView.findViewById(R.id.tblPseudos);
    TableRow row;
    TextView inst, desc;
    tblInstructions.removeAllViews();
    tblPseudos.removeAllViews();
    CPU cpu = activity.getCPU();
    for (Instruction i : cpu.getInstructionSet().getInstructions()) {
        row = new TableRow(activity);
        inst = new TextView(activity);
        inst.setText(i.getUsage() + " ");
        row.addView(inst);
        desc = new TextView(activity);
        desc.setText("# " + (i.hasDescription() ? i.getDescription() : "-"));
        row.addView(desc);
        tblInstructions.addView(row);
    }
    for (PseudoInstruction i : cpu.getInstructionSet().getPseudoInstructions()) {
        row = new TableRow(activity);
        inst = new TextView(activity);
        inst.setText(i.getUsage() + " ");
        row.addView(inst);
        desc = new TextView(activity);
        desc.setText("# " + (i.hasDescription() ? i.getDescription() : "-"));
        row.addView(desc);
        tblPseudos.addView(row);
    }
}
Also used : PseudoInstruction(brunonova.drmips.simulator.PseudoInstruction) TableRow(android.widget.TableRow) CPU(brunonova.drmips.simulator.CPU) TextView(android.widget.TextView) PseudoInstruction(brunonova.drmips.simulator.PseudoInstruction) Instruction(brunonova.drmips.simulator.Instruction) DrMIPSActivity(brunonova.drmips.android.DrMIPSActivity) TableLayout(android.widget.TableLayout)

Example 33 with TableLayout

use of android.widget.TableLayout in project sexytopo by richsmith.

the class StatsActivity method updateLinkedStats.

private void updateLinkedStats() {
    Set<Survey> surveys = getSurvey().getRecursiveConnectedSurveys();
    surveys.add(getSurvey());
    int numberSurveys = surveys.size();
    TableLayout tableLayout = findViewById(R.id.statsAllLinkedSurveys);
    if (numberSurveys <= 1) {
        tableLayout.setVisibility(View.GONE);
    } else {
        tableLayout.setVisibility(View.VISIBLE);
    }
    float length = 0;
    float lowestHeight = Float.POSITIVE_INFINITY;
    float highestHeight = Float.NEGATIVE_INFINITY;
    int numberOfStations = 0;
    int numberOfLegs = 0;
    int numberOfSplays = 0;
    float shortestLeg = Float.POSITIVE_INFINITY;
    float longestLeg = 0;
    for (Survey survey : surveys) {
        length += SurveyStats.calcTotalLength(survey);
        float[] heightRange = SurveyStats.calcHeightRangeArray(survey);
        lowestHeight = Math.min(heightRange[0], lowestHeight);
        highestHeight = Math.max(heightRange[1], highestHeight);
        numberOfStations += SurveyStats.calcNumberStations(survey);
        numberOfLegs = SurveyStats.calcNumberSubFullLegs(survey.getOrigin());
        numberOfSplays += SurveyStats.calcNumberSubSplays(survey.getOrigin());
        longestLeg = Math.max(longestLeg, SurveyStats.calcLongestLeg(survey));
        shortestLeg = Math.min(shortestLeg, SurveyStats.calcShortestLeg(survey));
    }
    float heightRange = highestHeight - lowestHeight;
    if (Float.isInfinite(heightRange)) {
        heightRange = 0;
    }
    if (Float.isInfinite(shortestLeg)) {
        shortestLeg = 0;
    }
    setStatsField(R.id.statsFieldNumberLinkedSurveys, TextTools.formatWithComma(numberSurveys));
    setStatsField(R.id.statsFieldLinkedLength, TextTools.formatTo2dpWithComma(length));
    setStatsField(R.id.statsFieldLinkedDepth, TextTools.formatTo2dpWithComma(heightRange));
    setStatsField(R.id.statsFieldLinkedNumberStations, TextTools.formatWithComma(numberOfStations));
    setStatsField(R.id.statsFieldLinkedNumberLegs, TextTools.formatWithComma(numberOfLegs));
    setStatsField(R.id.statsFieldLinkedNumberSplays, TextTools.formatWithComma(numberOfSplays));
    setStatsField(R.id.statsFieldLinkedShortestLeg, TextTools.formatTo2dpWithComma(shortestLeg));
    setStatsField(R.id.statsFieldLinkedLongestLeg, TextTools.formatTo2dpWithComma(longestLeg));
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) TableLayout(android.widget.TableLayout)

Example 34 with TableLayout

use of android.widget.TableLayout in project sexytopo by richsmith.

the class TableActivity method syncTableWithSurvey.

public void syncTableWithSurvey() {
    Survey survey = getSurvey();
    stationsToTableIndex.clear();
    List<GraphToListTranslator.SurveyListEntry> tableEntries = graphToListTranslator.toChronoListOfSurveyListEntries(survey);
    if (tableEntries.size() == 0) {
        Toast.makeText(getApplicationContext(), R.string.no_data, Toast.LENGTH_SHORT).show();
    }
    final TableLayout tableLayout = findViewById(R.id.BodyTable);
    tableLayout.removeAllViews();
    for (GraphToListTranslator.SurveyListEntry entry : tableEntries) {
        TableRow tableRow = (TableRow) LayoutInflater.from(this).inflate(R.layout.table_row, null);
        final Map<TableCol, Object> map = GraphToListTranslator.createMap(entry);
        for (TableCol col : TableCol.values()) {
            if (col == TableCol.COMMENT) {
                continue;
            }
            String display = map.containsKey(col) ? col.format(map.get(col)) : "?";
            int id = TABLE_COL_BY_ANDROID_ID.get(col);
            TextView textView = tableRow.findViewById(id);
            textView.setText(display);
            if (isActiveStation(map.get(col))) {
                textView.setBackgroundColor(GraphView.HIGHLIGHT_COLOUR.intValue);
            }
            if (entry.getLeg().hasDestination()) {
                textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
            } else {
                textView.setTypeface(textView.getTypeface(), Typeface.NORMAL);
            }
            fieldToSurveyEntry.put(textView, entry);
            fieldToTableCol.put(textView, col);
            textView.setOnLongClickListener(this);
        }
        int rowCount = tableLayout.getChildCount();
        tableLayout.addView(tableRow, rowCount);
        if (entry.getLeg().hasDestination()) {
            Station to = entry.getLeg().getDestination();
            stationsToTableIndex.put(to, rowCount);
        }
    }
    tableLayout.requestLayout();
}
Also used : TableCol(org.hwyl.sexytopo.model.table.TableCol) SuppressLint(android.annotation.SuppressLint) Station(org.hwyl.sexytopo.model.survey.Station) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphToListTranslator(org.hwyl.sexytopo.control.util.GraphToListTranslator) TableRow(android.widget.TableRow) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout)

Example 35 with TableLayout

use of android.widget.TableLayout in project sexytopo by richsmith.

the class TableActivity method jumpToStation.

private void jumpToStation(Station station) {
    try {
        final TableLayout tableLayout = findViewById(R.id.BodyTable);
        int requestedIndex = stationsToTableIndex.get(station);
        final View requestedRow = tableLayout.getChildAt(requestedIndex);
        final ScrollView scrollView = findViewById(R.id.BodyTableScrollView);
        scrollView.post(new Runnable() {

            @Override
            public void run() {
                scrollView.smoothScrollTo(0, requestedRow.getTop());
            }
        });
    } catch (Exception exception) {
        String name = station == null ? "Unknown" : station.getName();
        Log.e("Could not jump to station " + name);
        Log.e(exception);
    }
}
Also used : ScrollView(android.widget.ScrollView) TableLayout(android.widget.TableLayout) View(android.view.View) GraphView(org.hwyl.sexytopo.control.graph.GraphView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint)

Aggregations

TableLayout (android.widget.TableLayout)43 TextView (android.widget.TextView)36 TableRow (android.widget.TableRow)35 View (android.view.View)22 Button (android.widget.Button)10 SuppressLint (android.annotation.SuppressLint)6 SpannableStringBuilder (android.text.SpannableStringBuilder)5 LinearLayout (android.widget.LinearLayout)5 ScrollView (android.widget.ScrollView)5 Switch (android.widget.Switch)5 ArrayList (java.util.ArrayList)5 Context (android.content.Context)4 AdapterView (android.widget.AdapterView)4 CompoundButton (android.widget.CompoundButton)4 DialogInterface (android.content.DialogInterface)3 ImageView (android.widget.ImageView)3 NavigationView (android.support.design.widget.NavigationView)2 AlertDialog (android.support.v7.app.AlertDialog)2 StyleSpan (android.text.style.StyleSpan)2 LayoutInflater (android.view.LayoutInflater)2