コード例 #1
0
    @Override
    protected void initItemView(Context context, View parentView, Drone drone) {
      super.initItemView(context, parentView, drone);
      if (mItemView == null) return;

      // Initialize the popup window.
      mPopup = initPopupWindow(context, sPopupWindowLayoutId);
      final View popupView = mPopup.getContentView();

      mExtraInfoBarItems =
          new InfoBarItem[] {
            new HomeInfo(context, popupView, drone),
            new GpsInfo(context, popupView, drone),
            new BatteryInfo(context, popupView, drone),
            new ExtraFlightTimeInfo(context, popupView, drone, mItemView),
            new ExtraSignalInfo(context, popupView, drone, mItemView)
          };

      mItemView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mPopup == null) return;

              mPopup.showAsDropDown(mItemView);
            }
          });

      updateItemView(context, drone);
    }
コード例 #2
0
    @Override
    protected void initItemView(Context context, View parentView, Drone drone) {
      super.initItemView(context, parentView, drone);
      if (mItemView == null) return;

      mPopup = initPopupWindow(context, sPopupWindowLayoutId);

      final View popupView = mPopup.getContentView();
      mRssiView = (TextView) popupView.findViewById(R.id.bar_signal_rssi);
      mRemRssiView = (TextView) popupView.findViewById(R.id.bar_signal_remrssi);
      mNoiseView = (TextView) popupView.findViewById(R.id.bar_signal_noise);
      mRemNoiseView = (TextView) popupView.findViewById(R.id.bar_signal_remnoise);
      mFadeView = (TextView) popupView.findViewById(R.id.bar_signal_fade);
      mRemFadeView = (TextView) popupView.findViewById(R.id.bar_signal_remfade);

      mItemView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mPopup == null) return;

              mPopup.showAsDropDown(mItemView);
            }
          });

      updateItemView(context, drone);
    }
コード例 #3
0
    @Override
    protected void initItemView(final Context context, View parentView, final Drone drone) {
      super.initItemView(context, parentView, drone);
      if (mItemView == null) return;

      mHandler = new Handler();

      mFlightTimeUpdater =
          new Runnable() {
            @Override
            public void run() {
              mHandler.removeCallbacks(this);
              if (mDrone == null) return;

              if (mItemView != null) {
                long timeInSeconds = mDrone.state.getFlightTime();
                long minutes = timeInSeconds / 60;
                long seconds = timeInSeconds % 60;

                ((TextView) mItemView)
                    .setText(String.format("Air Time\n%02d:%02d", minutes, seconds));
              }

              mHandler.postDelayed(this, FLIGHT_TIMER_PERIOD);
            }
          };

      mPopup = initPopupWindow(context, sPopupWindowLayoutId);
      final View popupView = mPopup.getContentView();
      popupView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mDrone != null) {
                mDrone.state.resetFlightTimer();
              }
              mPopup.dismiss();
            }
          });

      mItemView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mPopup == null) return;

              mPopup.showAsDropDown(mItemView);
            }
          });

      updateItemView(context, drone);
    }
コード例 #4
0
    @Override
    protected void initItemView(final Context context, View parentView, final Drone drone) {
      super.initItemView(context, parentView, drone);
      if (mItemView == null) return;

      final SpinnerSelfSelect modesSpinner = (SpinnerSelfSelect) mItemView;

      mModeAdapter = new ModeAdapter(context, R.layout.spinner_drop_down);
      modesSpinner.setAdapter(mModeAdapter);

      modesSpinner.setOnSpinnerItemSelectedListener(
          new SpinnerSelfSelect.OnSpinnerItemSelectedListener() {
            @Override
            public void onSpinnerItemSelected(Spinner parent, int position) {
              if (mDrone != null) {
                final ApmModes newMode = (ApmModes) parent.getItemAtPosition(position);
                mDrone.state.changeFlightMode(newMode);
              }
            }
          });

      updateItemView(context, drone);
    }