Beispiel #1
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View v;
      if (convertView == null) {
        v = mInflater.inflate(R.layout.monitor, parent, false);
      } else {
        v = convertView;
      }

      Monitor monitor = getMonitorByPosition(position);

      TextView monitorName = (TextView) v.findViewById(R.id.monitorName);
      monitorName.setText(monitor.name());

      TextView monitorDescription = (TextView) v.findViewById(R.id.monitorDescription);
      monitorDescription.setText(monitor.desc());

      Button removeButton = (Button) v.findViewById(R.id.removeMonitorButton);
      removeButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              new DeleteMonitorDialogFragment(
                      new Runnable() {
                        @Override
                        public void run() {
                          monitoringService.removeMonitor(getMonitorIdByPosition(position));
                          onDataChange();
                        }
                      })
                  .show(getFragmentManager(), "DeleteMonitor");
            }
          });

      Button editButton = (Button) v.findViewById(R.id.editMonitorButton);
      editButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent(MainActivity.this, TickerMonitorEditActivity.class);
              intent.putExtra(MONITOR_ID, getMonitorIdByPosition(position));
              startActivityForResult(intent, 1);
              // actual change the monitor is done on onActivityResult
            }
          });

      GridView monitorResponses = (GridView) v.findViewById(R.id.monitorResponses);
      try {
        ResponseAdapter adapter = monitorResultsAdapters.get(monitor);
        monitorResponses.setAdapter(adapter);
      } catch (RuntimeException e) {
        Log.e(CoynesMonitoring.TAG, "caught exception", e);
        throw e;
      }

      return v;
    }
Beispiel #2
0
 @Override
 public View getView(final int position, View convertView, ViewGroup parent) {
   View v;
   if (convertView == null) {
     v = mInflater.inflate(R.layout.monitor_response, parent, false);
   } else {
     v = convertView;
   }
   TextView responseTextView = (TextView) v.findViewById(R.id.responseString);
   final Monitor.Sample sample = monitor.getSamples().get(position);
   responseTextView.setText(sample.getResponseString());
   responseTextView.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent =
               new Intent(MainActivity.this, TickerMonitorSampleBlowoutActivity.class);
           intent.putExtra(MONITOR_ID, monitor.getId());
           intent.putExtra(SAMPLE_POSITION, position);
           startActivityForResult(intent, 1);
         }
       });
   return v;
 }
Beispiel #3
0
 @Override
 public Object getItem(int position) {
   return monitor.getSamples().get(position);
 }
Beispiel #4
0
 @Override
 public int getCount() {
   return monitor.getSamples().size();
 }
Beispiel #5
0
 public ResponseAdapter(Monitor monitor) {
   this.monitor = monitor;
   monitor.addListener(this);
 }