FunctionsActivity doesn't set pass function to FunctionsFragment now

This commit is contained in:
serso 2016-01-30 11:20:47 +01:00
parent e82d7d2a91
commit b15856e08f

View File

@ -24,16 +24,19 @@ package org.solovyev.android.calculator.functions;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.math.edit.FunctionsFragment;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class FunctionsActivity extends BaseActivity {
public static final String EXTRA_FUNCTION = "function";
private static final CalculatorFragmentType FRAGMENT_TYPE = CalculatorFragmentType.functions;
public FunctionsActivity() {
super(R.layout.main_empty, FunctionsActivity.class.getSimpleName());
@ -43,16 +46,24 @@ public class FunctionsActivity extends BaseActivity {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Bundle extras = getIntent().getExtras();
final Parcelable function = extras != null ? extras.getParcelable(EXTRA_FUNCTION) : null;
for (FunctionCategory category : FunctionCategory.values()) {
final Bundle arguments = new Bundle(2);
if (category == FunctionCategory.my && function != null) {
arguments.putParcelable(FunctionsFragment.ARG_FUNCTION, function);
addTab(category);
}
if (savedInstanceState == null) {
final Bundle extras = getIntent().getExtras();
final Parcelable function = extras != null ? extras.getParcelable(EXTRA_FUNCTION) : null;
if (function instanceof CppFunction) {
EditFunctionFragment.showDialog((CppFunction) function, getSupportFragmentManager());
}
arguments.putString(FunctionsFragment.ARG_CATEGORY, category.name());
ui.addTab(this, CalculatorFragmentType.functions.createSubFragmentTag(category.name()), CalculatorFragmentType.functions.getFragmentClass(), arguments, category.title, R.id.main_layout);
}
}
}
private void addTab(@Nonnull FunctionCategory category) {
final Bundle arguments = new Bundle(1);
arguments.putString(FunctionsFragment.ARG_CATEGORY, category.name());
final String fragmentTag = FRAGMENT_TYPE.createSubFragmentTag(category.name());
final Class<? extends Fragment> fragmentClass = FRAGMENT_TYPE.getFragmentClass();
ui.addTab(this, fragmentTag, fragmentClass, arguments, category.title, R.id.main_layout);
}
}