Example #1
0
  public void performViewSetup() {
    final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
    IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);

    messageReceiver = new MessageReceiver();
    localBroadcastManager = LocalBroadcastManager.getInstance(this);
    localBroadcastManager.registerReceiver(messageReceiver, messageFilter);

    stub.setOnLayoutInflatedListener(
        new WatchViewStub.OnLayoutInflatedListener() {
          @Override
          public void onLayoutInflated(WatchViewStub stub) {
            mTime = (TextView) stub.findViewById(R.id.watch_time);
            mSgv = (TextView) stub.findViewById(R.id.sgv);
            mDirection = (TextView) stub.findViewById(R.id.direction);
            mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
            mUploaderBattery = (TextView) stub.findViewById(R.id.uploader_battery);
            mDelta = (TextView) stub.findViewById(R.id.delta);
            mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
            mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
            chart = (LineChartView) stub.findViewById(R.id.chart);
            layoutSet = true;
            mRelativeLayout.measure(specW, specH);
            mRelativeLayout.layout(
                0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight());
          }
        });
    ListenerService.requestData(this);
    wakeLock.acquire(50);
  }
Example #2
0
 public void missedReadingAlert() {
   int minutes_since = (int) Math.floor(timeSince() / (1000 * 60));
   if (minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
     NotificationCompat.Builder notification =
         new NotificationCompat.Builder(getApplicationContext())
             .setContentTitle("Missed BG Readings")
             .setVibrate(vibratePattern);
     NotificationManager mNotifyMgr =
         (NotificationManager)
             getApplicationContext()
                 .getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
     mNotifyMgr.notify(missed_readings_alert_id, notification.build());
     ListenerService.requestData(this); // attempt to recover missing data
   }
 }
Example #3
0
  public void setupCharts() {
    if (bgDataList.size()
        > 0) { // Dont crash things just because we dont have values, people dont like crashy things
      if (singleLine) {
        bgGraphBuilder =
            new BgGraphBuilder(getApplicationContext(), bgDataList, pointSize, midColor);
      } else {
        bgGraphBuilder =
            new BgGraphBuilder(
                getApplicationContext(), bgDataList, pointSize, highColor, lowColor, midColor);
      }

      chart.setLineChartData(bgGraphBuilder.lineData());
      chart.setViewportCalculationEnabled(true);
      chart.setMaximumViewport(chart.getMaximumViewport());
    } else {
      ListenerService.requestData(this);
    }
  }