com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton Java Examples

The following examples show how to use com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActionController.java    From science-journal with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the stop recording button for {@link ExperimentDetailsFragment} when a recording
 * starts/stops.
 */
public void attachStopButton(
    ExtendedFloatingActionButton recordButton, FragmentManager fragmentManager) {
  recordButton.setAllCaps(false);
  RxView.clicks(recordButton)
      .flatMapMaybe(click -> recordingStatus.firstElement())
      .subscribe(
          status -> {
            if (status.isRecording()) {
              tryStopRecording(recordButton, fragmentManager);
            }
          });

  recordingStatus
      .takeUntil(RxView.detaches(recordButton))
      .subscribe(
          status -> {
            if (status.state.shouldShowStopButton()) {
              recordButton.setVisibility(View.VISIBLE);
            } else {
              recordButton.setVisibility(View.INVISIBLE);
            }
          });
}
 
Example #2
Source File: ExtendedFabBehaviorDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateDemoView(
    LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
  View root =
      layoutInflater.inflate(getExtendedFabContent(), viewGroup, false /* attachToRoot */);

  Toolbar toolbar = root.findViewById(R.id.toolbar);
  AppCompatActivity activity = (AppCompatActivity) getActivity();
  activity.setSupportActionBar(toolbar);

  List<ExtendedFloatingActionButton> extendedFabs =
      DemoUtils.findViewsWithType(root, ExtendedFloatingActionButton.class);
  for (ExtendedFloatingActionButton extendedFab : extendedFabs) {
    extendedFab.setOnClickListener(
        v ->
            Snackbar.make(
                    v, R.string.cat_extended_fab_clicked, Snackbar.LENGTH_SHORT)
                .show());
  }

  return root;
}
 
Example #3
Source File: BottomAppBar.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Nullable
private View findDependentView() {
  if (!(getParent() instanceof CoordinatorLayout)) {
    // If we aren't in a CoordinatorLayout we won't have a dependent FAB.
    return null;
  }

  List<View> dependents = ((CoordinatorLayout) getParent()).getDependents(this);
  for (View v : dependents) {
    if (v instanceof FloatingActionButton || v instanceof ExtendedFloatingActionButton) {
      return v;
    }
  }

  return null;
}
 
Example #4
Source File: DynamicFABUtils.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Same animation that FloatingActionButton.Behavior uses to hide the extended FAB when the
 * AppBarLayout exits.
 *
 * @param extendedFab The extended FAB to set hide animation.
 */
public static void hide(@NonNull ExtendedFloatingActionButton extendedFab,
        boolean shrinkBefore) {
    if (shrinkBefore && (extendedFab instanceof DynamicExtendedFloatingActionButton
            && ((DynamicExtendedFloatingActionButton) extendedFab).isFABExtended())) {
        extendedFab.shrink();
        return;
    }

    extendedFab.hide();
}
 
Example #5
Source File: DynamicFABUtils.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Same animation that FloatingActionButton.Behavior uses to show the extended FAB when the
 * AppBarLayout enters.
 *
 * @param extendedFab The FAB to set show animation.
 */
public static void show(@NonNull ExtendedFloatingActionButton extendedFab,
        boolean extendAfter) {
    extendedFab.show();

    if (extendAfter && (extendedFab instanceof DynamicExtendedFloatingActionButton
            && ((DynamicExtendedFloatingActionButton) extendedFab).isAllowExtended()
            && !((DynamicExtendedFloatingActionButton) extendedFab).isFABExtended())) {
        extendedFab.extend();
    }
}
 
Example #6
Source File: RangesActivity.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ranges);
    ButterKnife.bind(this);
    mViewModel = new ViewModelProvider(this, mViewModelFactory).get(RangesViewModel.class);
    mType = getIntent().getExtras().getInt(Utils.RANGE_TYPE);

    //Bind ui
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final RecyclerView recyclerView = findViewById(R.id.recycler_view);
    final View rangesContainer = findViewById(R.id.info_ranges);
    rangesContainer.findViewById(R.id.container).setVisibility(View.VISIBLE);
    mRangeView = rangesContainer.findViewById(R.id.range);
    final TextView startAddress = rangesContainer.findViewById(R.id.start_address);
    final TextView endAddress = rangesContainer.findViewById(R.id.end_address);
    final ExtendedFloatingActionButton fab_add = findViewById(R.id.fab_add);

    mProvisioner = mViewModel.getSelectedProvisioner().getValue();

    switch (mType) {
        case Utils.GROUP_RANGE:
            startAddress.setText(MeshAddress.formatAddress(MeshAddress.START_GROUP_ADDRESS, true));
            endAddress.setText(MeshAddress.formatAddress(MeshAddress.END_GROUP_ADDRESS, true));
            getSupportActionBar().setTitle(R.string.title_edit_group_ranges);
            mRangeAdapter = new RangeAdapter(this,
                    mProvisioner.getProvisionerUuid(),
                    mProvisioner.getAllocatedGroupRanges(),
                    mViewModel.getNetworkLiveData().getProvisioners());
            break;
        case Utils.SCENE_RANGE:
            startAddress.setText(MeshAddress.formatAddress(0x0000, true));
            endAddress.setText(MeshAddress.formatAddress(0xFFFF, true));
            getSupportActionBar().setTitle(R.string.title_edit_scene_ranges);
            mRangeAdapter = new RangeAdapter(this,
                    mProvisioner.getProvisionerUuid(),
                    mProvisioner.getAllocatedSceneRanges(),
                    mViewModel.getNetworkLiveData().getProvisioners());
            break;
        default:
        case Utils.UNICAST_RANGE:
            startAddress.setText(MeshAddress.formatAddress(MeshAddress.START_UNICAST_ADDRESS, true));
            endAddress.setText(MeshAddress.formatAddress(MeshAddress.END_UNICAST_ADDRESS, true));
            getSupportActionBar().setTitle(R.string.title_edit_unicast_ranges);
            mRangeAdapter = new RangeAdapter(this,
                    mProvisioner.getProvisionerUuid(),
                    mProvisioner.getAllocatedUnicastRanges(),
                    mViewModel.getNetworkLiveData().getProvisioners());
            break;
    }

    mRangeAdapter.setOnItemClickListener(this);

    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    final DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
    recyclerView.addItemDecoration(dividerItemDecoration);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mRangeAdapter);
    final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
    final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);

    fab_add.setOnClickListener(v -> {
        switch (mType) {
            case Utils.GROUP_RANGE:
                final DialogFragmentGroupRange groupRange = DialogFragmentGroupRange.newInstance(null);
                groupRange.show(getSupportFragmentManager(), null);
                break;
            case Utils.SCENE_RANGE:
                final DialogFragmentSceneRange sceneRange = DialogFragmentSceneRange.newInstance(null);
                sceneRange.show(getSupportFragmentManager(), null);
                break;
            default:
            case Utils.UNICAST_RANGE:
                final DialogFragmentUnicastRange unicastRange = DialogFragmentUnicastRange.newInstance(null);
                unicastRange.show(getSupportFragmentManager(), null);
                break;
        }
    });

    mFabResolve.setOnClickListener(v -> resolveRanges());

    updateRanges();
    updateOtherRanges();
    updateEmptyView();
    updateResolveFab();
}
 
Example #7
Source File: NetworkFragment.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    @SuppressLint("InflateParams") final View rootView = inflater.inflate(R.layout.fragment_network, null);
    mViewModel = new ViewModelProvider(requireActivity(), mViewModelFactory).get(SharedViewModel.class);
    ButterKnife.bind(this, rootView);

    final ExtendedFloatingActionButton fab = rootView.findViewById(R.id.fab_add_node);
    final View noNetworksConfiguredView = rootView.findViewById(R.id.no_networks_configured);

    // Configure the recycler view
    mNodeAdapter = new NodeAdapter(this, mViewModel.getNodes());
    mNodeAdapter.setOnItemClickListener(this);
    mRecyclerViewNodes.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerViewNodes.addItemDecoration(new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL));
    final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
    final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
    itemTouchHelper.attachToRecyclerView(mRecyclerViewNodes);
    mRecyclerViewNodes.setAdapter(mNodeAdapter);

    // Create view model containing utility methods for scanning
    mViewModel.getNodes().observe(getViewLifecycleOwner(), nodes -> {
        if (nodes != null && !nodes.isEmpty()) {
            noNetworksConfiguredView.setVisibility(View.GONE);
        } else {
            noNetworksConfiguredView.setVisibility(View.VISIBLE);
        }
        requireActivity().invalidateOptionsMenu();
    });

    mViewModel.isConnectedToProxy().observe(getViewLifecycleOwner(), isConnected -> {
        if (isConnected != null) {
            requireActivity().invalidateOptionsMenu();
        }
    });

    mRecyclerViewNodes.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
            super.onScrolled(recyclerView, dx, dy);
            final LinearLayoutManager m = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (m != null) {
                if (m.findFirstCompletelyVisibleItemPosition() == 0) {
                    fab.extend();
                } else {
                    fab.shrink();
                }
            }
        }
    });

    fab.setOnClickListener(v -> {
        final Intent intent = new Intent(requireContext(), ScannerActivity.class);
        intent.putExtra(Utils.EXTRA_DATA_PROVISIONING_SERVICE, true);
        startActivityForResult(intent, Utils.PROVISIONING_SUCCESS);
    });

    return rootView;
}
 
Example #8
Source File: GroupsFragment.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    @SuppressLint("InflateParams") final View rootView = inflater.inflate(R.layout.fragment_groups, null);
    mViewModel = new ViewModelProvider(requireActivity(), mViewModelFactory).get(SharedViewModel.class);
    ButterKnife.bind(this, rootView);

    final ExtendedFloatingActionButton fab = rootView.findViewById(R.id.fab_add_group);

    // Configure the recycler view
    final RecyclerView recyclerViewGroups = rootView.findViewById(R.id.recycler_view_groups);
    recyclerViewGroups.setLayoutManager(new LinearLayoutManager(requireContext()));
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerViewGroups.getContext(), DividerItemDecoration.VERTICAL);
    recyclerViewGroups.addItemDecoration(dividerItemDecoration);
    final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
    final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
    itemTouchHelper.attachToRecyclerView(recyclerViewGroups);
    final GroupAdapter adapter = new GroupAdapter(requireContext());
    adapter.setOnItemClickListener(this);
    recyclerViewGroups.setAdapter(adapter);

    mViewModel.getNetworkLiveData().observe(getViewLifecycleOwner(), meshNetworkLiveData -> {
        if (meshNetworkLiveData != null) {
            if (meshNetworkLiveData.getMeshNetwork().getGroups().isEmpty()) {
                mEmptyView.setVisibility(View.VISIBLE);
            } else {
                mEmptyView.setVisibility(View.INVISIBLE);
            }
        }
    });

    mViewModel.getGroups().observe(getViewLifecycleOwner(), groups -> {
        final MeshNetwork network = mViewModel.getNetworkLiveData().getMeshNetwork();
        adapter.updateAdapter(network, groups);
    });

    fab.setOnClickListener(v -> {
        DialogFragmentCreateGroup fragmentCreateGroup = DialogFragmentCreateGroup.newInstance();
        fragmentCreateGroup.show(getChildFragmentManager(), null);
    });

    recyclerViewGroups.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
            super.onScrolled(recyclerView, dx, dy);
            final LinearLayoutManager m = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (m != null) {
                if (m.findFirstCompletelyVisibleItemPosition() == 0) {
                    fab.extend();
                } else {
                    fab.shrink();
                }
            }
        }
    });

    return rootView;

}
 
Example #9
Source File: AppKeysActivity.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_keys);
    mViewModel = new ViewModelProvider(this, mViewModelFactory).get(AppKeysViewModel.class);

    //Bind ui
    ButterKnife.bind(this);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final ExtendedFloatingActionButton fab = findViewById(R.id.fab_add);
    final RecyclerView appKeysRecyclerView = findViewById(R.id.recycler_view_keys);
    appKeysRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    final DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(appKeysRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
    appKeysRecyclerView.addItemDecoration(dividerItemDecoration);
    appKeysRecyclerView.setItemAnimator(new DefaultItemAnimator());

    final Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        switch (bundle.getInt(EXTRA_DATA)) {
            case MANAGE_APP_KEY:
                break;
            case ADD_APP_KEY:
                getSupportActionBar().setTitle(R.string.title_select_app_key);
                fab.hide();
                mAdapter = new ManageAppKeyAdapter(this, mViewModel.getNetworkLiveData());
                mAdapter.setOnItemClickListener(this);
                appKeysRecyclerView.setAdapter(mAdapter);
                setUpObserver();
                break;
            case BIND_APP_KEY:
            case PUBLICATION_APP_KEY:
                getSupportActionBar().setTitle(R.string.title_select_app_key);
                fab.hide();
                //Get selected mesh node
                final ProvisionedMeshNode node = mViewModel.getSelectedMeshNode().getValue();
                if (node != null) {
                    final List<NodeKey> applicationKeys = node.getAddedAppKeys();
                    if (!applicationKeys.isEmpty()) {
                        mAdapter = new ManageAppKeyAdapter(mViewModel.getNetworkLiveData().getAppKeys(), applicationKeys);
                        mAdapter.setOnItemClickListener(this);
                        appKeysRecyclerView.setAdapter(mAdapter);
                    } else {
                        final TextView textView = mEmptyView.findViewById(R.id.rationale);
                        textView.setText(R.string.no_added_app_keys_rationale);
                        mEmptyView.setVisibility(View.VISIBLE);
                    }
                }
                break;
        }
    } else {
        getSupportActionBar().setTitle(R.string.title_manage_app_keys);
        final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
        final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
        itemTouchHelper.attachToRecyclerView(appKeysRecyclerView);
        mAdapter = new ManageAppKeyAdapter(this, mViewModel.getNetworkLiveData());
        mAdapter.setOnItemClickListener(this);
        appKeysRecyclerView.setAdapter(mAdapter);
        setUpObserver();
    }


    fab.setOnClickListener(v -> {
        final Intent intent = new Intent(this, AddAppKeyActivity.class);
        startActivity(intent);
    });

    appKeysRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
            super.onScrolled(recyclerView, dx, dy);
            final LinearLayoutManager m = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (m != null) {
                if (m.findFirstCompletelyVisibleItemPosition() == 0) {
                    fab.extend();
                } else {
                    fab.shrink();
                }
            }
        }
    });
}
 
Example #10
Source File: DynamicFABScrollBehavior.java    From dynamic-support with Apache License 2.0 4 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
    return super.layoutDependsOn(parent, child, dependency)
            || dependency instanceof FloatingActionButton
            || dependency instanceof ExtendedFloatingActionButton;
}
 
Example #11
Source File: ExperimentDetailsFragment.java    From science-journal with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(
    LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view =
      inflater.inflate(
          R.layout.fragment_panes_experiment_details, container, false);

  emptyView = (TextView) view.findViewById(R.id.empty_list);
  emptyView.setText(R.string.empty_experiment);
  emptyView.setCompoundDrawablesRelativeWithIntrinsicBounds(
      null, null, null, view.getResources().getDrawable(R.drawable.empty_run));

  progressBar = (ProgressBar) view.findViewById(R.id.detailsIndeterminateBar);

  details = (RecyclerView) view.findViewById(R.id.details_list);
  details.setLayoutManager(
      new LinearLayoutManager(
          view.getContext(), LinearLayoutManager.VERTICAL, /* don't reverse layout */ false));
  DetailsAdapter adapter = new DetailsAdapter(this, savedInstanceState);
  loadedExperiment.subscribe(
      experiment -> {
        boolean includeInvalidRuns = false;
        adapter.setScalarDisplayOptions(scalarDisplayOptions);
        adapter.setData(experiment, experiment.getTrials(includeArchived, includeInvalidRuns));
        if (activeTrialId != null) {
          adapter.addActiveRecording(experiment.getTrial(activeTrialId));
        }
        Context context = getContext();
        if (context != null) {
          setTitle(experiment.getDisplayTitle(context));
        }
      },
      error -> {
        if (Log.isLoggable(TAG, Log.ERROR)) {
          Log.e(TAG, "loadedExperiment next failed", error);
        }
        throw new IllegalStateException("loadedExperiment next failed", error);
      });
  this.adapter = adapter;

  details.setAdapter(adapter);

  // TODO: Because scalarDisplayOptions are static, if the options are changed during the
  // time we are on this page it probably won't have an effect. Since graph options are
  // hidden from non-userdebug users, and not shown in the ExperimentDetails menu even when
  // enabled, this is OK for now.
  scalarDisplayOptions = new ScalarDisplayOptions();
  GraphOptionsController graphOptionsController = new GraphOptionsController(getActivity());
  graphOptionsController.loadIntoScalarDisplayOptions(scalarDisplayOptions, view);

  ActionAreaView actionArea = view.findViewById(R.id.action_area);
  ExtendedFloatingActionButton recordButton = view.findViewById(R.id.record);

  ExperimentActivity experimentActivity = (ExperimentActivity) getActivity();
  if (experimentActivity.isTwoPane()) {
    recordButton.setVisibility(View.GONE);
    actionArea.setVisibility(View.GONE);
  } else {
    actionController.attachStopButton(recordButton, getChildFragmentManager());
    actionArea.addItems(
        getContext(), experimentActivity.getActionAreaItems(), experimentActivity);
    actionArea.setUpScrollListener(details);
    actionController.attachActionArea(actionArea);
  }
  if (savedInstanceState != null) {
    includeArchived = savedInstanceState.getBoolean(EXTRA_INCLUDE_ARCHIVED, false);
    getActivity().invalidateOptionsMenu();
  }

  return view;
}
 
Example #12
Source File: ActionController.java    From science-journal with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the recording button for {@link SensorFragment} when a recording starts/stops.
 */
public void attachSensorFragmentView(
    ExtendedFloatingActionButton recordButton,
    FragmentManager fragmentManager) {
  recordButton.setAllCaps(false);
  recordButton.setVisibility(View.VISIBLE);
  RxView.clicks(recordButton)
      .flatMapMaybe(click -> recordingStatus.firstElement())
      .subscribe(
          status -> {
            if (status.isRecording()) {
              tryStopRecording(recordButton, fragmentManager);
            } else {
              tryStartRecording(recordButton);
            }
          });

  recordingStatus
      .takeUntil(RxView.detaches(recordButton))
      .subscribe(
          status -> {
            recordButton.setEnabled(status.state.shouldEnableRecordButton());
            Resources resources = recordButton.getResources();
            int titleId = 0;
            int contentDescriptionId = 0;
            int imageResourceId = 0;

            if (status.state.shouldShowStopButton()) {
              titleId = R.string.btn_stop_label;
              contentDescriptionId = R.string.btn_stop_description;
              imageResourceId = R.drawable.ic_stop_icon;
            } else {
              titleId = R.string.btn_record_label;
              contentDescriptionId = R.string.btn_record_description;
              imageResourceId = R.drawable.ic_record_icon;
            }
            recordButton.setText(titleId);
            recordButton.setIcon(resources.getDrawable(imageResourceId));
            recordButton.setContentDescription(resources.getString(contentDescriptionId));
            recordButton.invalidate();
          });
}
 
Example #13
Source File: SensorFragment.java    From science-journal with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(
    LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  final ViewGroup rootView =
      (ViewGroup) inflater.inflate(R.layout.fragment_sensor, container, false);
  actionAreaView = rootView.findViewById(R.id.action_area);
  actionAreaView.setUpScrollListener(rootView.findViewById(R.id.sensor_card_recycler_view));

  View resetButton = rootView.findViewById(R.id.btn_reset);
  ExternalAxisView axisView = (ExternalAxisView) rootView.findViewById(R.id.external_x_axis);
  externalAxis =
      new ExternalAxisController(
          axisView,
          (xMin, xMax, isPinnedToNow) -> {
            if (sensorCardAdapter == null) {
              return;
            }
            List<SensorCardPresenter> sensorCardPresenters =
                sensorCardAdapter.getSensorCardPresenters();
            for (SensorCardPresenter sensorCardPresenter : sensorCardPresenters) {
              SensorPresenter presenter = sensorCardPresenter.getSensorPresenter();
              if (presenter != null) {
                presenter.onGlobalXAxisChanged(xMin, xMax, isPinnedToNow, getDataController());
              }
            }
          }, /* IsLive */
          true,
          new CurrentTimeClock(),
          resetButton);

  graphOptionsController.loadIntoScalarDisplayOptions(scalarDisplayOptions, getView());
  sensorCardLayoutManager = new LinearLayoutManager(getActivity());

  ExtendedFloatingActionButton record = rootView.findViewById(R.id.record);
  sensorCardRecyclerView = (RecyclerView) rootView.findViewById(R.id.sensor_card_recycler_view);
  NoteTakingActivity activity = (NoteTakingActivity) getActivity();
  actionController.attachSensorFragmentView(
      record,
      getChildFragmentManager());
  actionController.attachActionAreaAndSensorCardViews(actionAreaView,
      this, sensorCardRecyclerView);
  setUpTitleBar(rootView, true, R.string.action_bar_sensor_note, R.drawable.ic_sensor);

  if (savedInstanceState != null) {
    sensorCardLayoutManager.onRestoreInstanceState(
        savedInstanceState.getParcelable(KEY_SAVED_RECYCLER_LAYOUT));
  }
  return rootView;
}
 
Example #14
Source File: DynamicActivity.java    From dynamic-support with Apache License 2.0 2 votes vote down vote up
/**
 * Get the extended floating action button used by this activity.
 *
 * @return The extended floating action button used by this activity.
 */
public @Nullable ExtendedFloatingActionButton getExtendedFAB() {
    return mExtendedFAB;
}