コード例 #1
0
  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    activityHelper.onCreate(this, savedInstanceState);

    final Bundle bundle;

    final Intent intent = getIntent();
    if (intent != null) {
      bundle = intent.getExtras();
    } else {
      bundle = null;
    }

    final CalculatorFragmentType fragmentType = CalculatorFragmentType.functions;

    for (FunctionCategory category : FunctionCategory.getCategoriesByTabOrder()) {
      final AndroidFunctionCategory androidCategory = AndroidFunctionCategory.valueOf(category);
      if (androidCategory != null) {

        final Bundle fragmentParameters;

        if (category == FunctionCategory.my && bundle != null) {
          AbstractMathEntityListFragment.putCategory(bundle, category.name());
          fragmentParameters = bundle;
        } else {
          fragmentParameters = AbstractMathEntityListFragment.createBundleFor(category.name());
        }

        activityHelper.addTab(
            this,
            fragmentType.createSubFragmentTag(category.name()),
            fragmentType.getFragmentClass(),
            fragmentParameters,
            androidCategory.getCaptionId(),
            R.id.main_layout);
      } else {
        Log.e(
            CalculatorFunctionsActivity.class.getSimpleName(),
            "Unable to find android function category for " + category);
      }
    }
  }
コード例 #2
0
  @Override
  public void onViewCreated(View root, Bundle savedInstanceState) {
    super.onViewCreated(root, savedInstanceState);

    final ListView lv = getListView();
    final FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
    fab.setVisibility(View.VISIBLE);
    fab.attachToListView(lv);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            VarEditDialogFragment.showDialog(
                VarEditDialogFragment.Input.newInstance(), getFragmentManager());
          }
        });
  }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Bundle bundle = getArguments();
    if (bundle != null) {
      final String varValue = bundle.getString(CREATE_VAR_EXTRA_STRING);
      if (!Strings.isEmpty(varValue)) {
        VarEditDialogFragment.showDialog(
            VarEditDialogFragment.Input.newFromValue(varValue), getFragmentManager());

        // in order to stop intent for other tabs
        bundle.remove(CREATE_VAR_EXTRA_STRING);
      }
    }

    setHasOptionsMenu(true);
  }
コード例 #4
0
  @Override
  public void onCalculatorEvent(
      @Nonnull CalculatorEventData calculatorEventData,
      @Nonnull CalculatorEventType calculatorEventType,
      @Nullable Object data) {
    super.onCalculatorEvent(calculatorEventData, calculatorEventType, data);

    switch (calculatorEventType) {
      case constant_added:
        processConstantAdded((IConstant) data);
        break;

      case constant_changed:
        processConstantChanged((Change<IConstant>) data);
        break;

      case constant_removed:
        processConstantRemoved((IConstant) data);
        break;
    }
  }