FragmentUi removed, AdUi added

This commit is contained in:
serso 2016-02-20 14:34:23 +01:00
parent 07d3ebd65c
commit 8b87de2f29
19 changed files with 199 additions and 281 deletions

View File

@ -27,7 +27,6 @@ public interface AppComponent {
void inject(CalculatorApplication application); void inject(CalculatorApplication application);
void inject(EditorFragment fragment); void inject(EditorFragment fragment);
void inject(BaseUi ui); void inject(BaseUi ui);
void inject(FragmentUi ui);
void inject(FloatingCalculatorService service); void inject(FloatingCalculatorService service);
void inject(BaseHistoryFragment fragment); void inject(BaseHistoryFragment fragment);
void inject(BaseDialogFragment fragment); void inject(BaseDialogFragment fragment);
@ -49,4 +48,5 @@ public interface AppComponent {
void inject(BaseKeyboardUi ui); void inject(BaseKeyboardUi ui);
void inject(FloatingCalculatorView view); void inject(FloatingCalculatorView view);
void inject(DragButtonWizardStep fragment); void inject(DragButtonWizardStep fragment);
void inject(BaseFragment fragment);
} }

View File

@ -1,71 +1,72 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.*; import android.view.*;
import org.solovyev.android.calculator.ads.AdUi;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.inject.Inject;
import static android.view.Menu.NONE; import static android.view.Menu.NONE;
import static org.solovyev.android.calculator.App.cast; import static org.solovyev.android.calculator.App.cast;
public abstract class BaseFragment extends Fragment { public abstract class BaseFragment extends Fragment {
protected FragmentUi ui; private final int layout;
@Inject
AdUi adUi;
@Override protected BaseFragment(@LayoutRes int layout) {
public void onCreate(Bundle savedInstanceState) { this.layout = layout;
super.onCreate(savedInstanceState);
inject(cast(getActivity().getApplication()).getComponent());
ui = createUi();
ui.onCreate(this);
}
@Nonnull
protected abstract FragmentUi createUi();
@Nonnull
protected final FragmentUi createUi(@Nonnull FragmentTab tab) {
return new FragmentUi(tab.layout);
}
protected void inject(@Nonnull AppComponent component) {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = ui.onCreateView(inflater, container);
ui.onCreateView(this, view);
return view;
}
@Override
public void onResume() {
super.onResume();
ui.onResume();
}
@Override
public void onPause() {
ui.onPause();
super.onPause();
}
@Override
public void onDestroyView() {
ui.onDestroyView();
super.onDestroyView();
}
@Override
public void onDestroy() {
ui.onDestroy();
super.onDestroy();
} }
@Nonnull @Nonnull
public static MenuItem addMenu(@Nonnull ContextMenu menu, @StringRes int label, @Nonnull MenuItem.OnMenuItemClickListener listener) { public static MenuItem addMenu(@Nonnull ContextMenu menu, @StringRes int label, @Nonnull MenuItem.OnMenuItemClickListener listener) {
return menu.add(NONE, label, NONE, label).setOnMenuItemClickListener(listener); return menu.add(NONE, label, NONE, label).setOnMenuItemClickListener(listener);
} }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
inject(cast(getActivity().getApplication()).getComponent());
adUi.onCreate();
}
protected void inject(@Nonnull AppComponent component) {
component.inject(this);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(layout, container, false);
adUi.onCreateView(view);
return view;
}
@Override
public void onResume() {
super.onResume();
adUi.onResume();
}
@Override
public void onPause() {
adUi.onPause();
super.onPause();
}
@Override
public void onDestroyView() {
adUi.onDestroyView();
super.onDestroyView();
}
@Override
public void onDestroy() {
adUi.onDestroy();
super.onDestroy();
}
} }

View File

@ -26,6 +26,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
@ -93,10 +94,8 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
@Inject @Inject
Calculator calculator; Calculator calculator;
@Nonnull public DisplayFragment() {
@Override super(R.layout.cpp_app_display);
protected FragmentUi createUi() {
return new FragmentUi(R.layout.cpp_app_display);
} }
@Override @Override

View File

@ -50,6 +50,10 @@ public class EditorFragment extends BaseFragment {
@Bind(R.id.calculator_editor) @Bind(R.id.calculator_editor)
EditorView editorView; EditorView editorView;
public EditorFragment() {
super(R.layout.cpp_app_editor);
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -62,12 +66,6 @@ public class EditorFragment extends BaseFragment {
component.inject(this); component.inject(this);
} }
@Nonnull
@Override
protected FragmentUi createUi() {
return new FragmentUi(R.layout.cpp_app_editor);
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState); final View view = super.onCreateView(inflater, container, savedInstanceState);
@ -79,7 +77,6 @@ public class EditorFragment extends BaseFragment {
@Override @Override
public void onDestroyView() { public void onDestroyView() {
editor.clearView(editorView); editor.clearView(editorView);
ui.onDestroyView();
super.onDestroyView(); super.onDestroyView();
} }

View File

@ -22,7 +22,6 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import org.solovyev.android.calculator.about.AboutFragment; import org.solovyev.android.calculator.about.AboutFragment;
@ -38,22 +37,17 @@ import javax.annotation.Nonnull;
public enum FragmentTab { public enum FragmentTab {
editor(EditorFragment.class, R.layout.cpp_app_editor, R.string.editor), history(RecentHistoryFragment.class, R.string.cpp_history_tab_recent),
//display(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history), saved_history(SavedHistoryFragment.class, R.string.cpp_history_tab_saved),
//keyboard(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history), variables(VariablesFragment.class, R.string.c_vars),
history(RecentHistoryFragment.class, R.layout.fragment_history, R.string.cpp_history_tab_recent), functions(FunctionsFragment.class, R.string.c_functions),
saved_history(SavedHistoryFragment.class, R.layout.fragment_history, R.string.cpp_history_tab_saved), operators(OperatorsFragment.class, R.string.c_operators),
variables(VariablesFragment.class, R.layout.fragment_entities, R.string.c_vars), about(AboutFragment.class, R.string.c_about),
functions(FunctionsFragment.class, R.layout.fragment_entities, R.string.c_functions),
operators(OperatorsFragment.class, R.layout.fragment_entities, R.string.c_operators),
about(AboutFragment.class, R.layout.about_fragment, R.string.c_about),
// todo serso: strings // todo serso: strings
matrix_edit(EditMatrixFragment.class, R.layout.matrix_edit_fragment, R.string.c_release_notes), matrix_edit(EditMatrixFragment.class, R.string.c_release_notes),
release_notes(ReleaseNotesFragment.class, R.layout.release_notes_fragment, R.string.c_release_notes); release_notes(ReleaseNotesFragment.class, R.string.c_release_notes);
@LayoutRes
public final int layout;
@Nonnull @Nonnull
public final Class<? extends Fragment> type; public final Class<? extends Fragment> type;
@StringRes @StringRes
@ -61,9 +55,8 @@ public enum FragmentTab {
@Nonnull @Nonnull
public final String tag; public final String tag;
FragmentTab(@Nonnull Class<? extends Fragment> type, int layout, int title) { FragmentTab(@Nonnull Class<? extends Fragment> type, int title) {
this.type = type; this.type = type;
this.layout = layout;
this.title = title; this.title = title;
this.tag = name(); this.tag = name();
} }

View File

@ -1,117 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.Bind;
import butterknife.ButterKnife;
import org.solovyev.android.checkout.CppCheckout;
import org.solovyev.android.checkout.Inventory;
import org.solovyev.android.checkout.ProductTypes;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import static org.solovyev.android.calculator.App.cast;
public class FragmentUi {
private final int layoutId;
@Nullable
private Boolean adFree = null;
@Inject
CppCheckout checkout;
@Nullable
@Bind(R.id.admob)
AdView adView;
public FragmentUi(int layoutId) {
this.layoutId = layoutId;
}
public void onCreate(@Nonnull Fragment fragment) {
cast(fragment).getComponent().inject(this);
checkout.start();
}
public void onResume() {
if (adView != null) {
adView.resume();
}
checkout.loadInventory().whenLoaded(new Inventory.Listener() {
@Override
public void onLoaded(@Nonnull Inventory.Products products) {
adFree = products.get(ProductTypes.IN_APP).isPurchased("ad_free");
updateAdView();
}
});
}
private void updateAdView() {
if (adFree == null || adView == null) {
return;
}
if (adFree) {
adView.hide();
} else {
adView.show();
}
}
public void onPause() {
adFree = null;
if (adView != null) {
adView.pause();
}
}
public void onCreateView(@Nonnull Fragment fragment, @Nonnull View root) {
ButterKnife.bind(this, root);
if (fragment instanceof DisplayFragment || fragment instanceof EditorFragment || fragment instanceof KeyboardFragment) {
// no ads in those fragments
} else if (adView != null) {
updateAdView();
}
}
public void onDestroy() {
checkout.stop();
}
@Nonnull
public View onCreateView(@Nonnull LayoutInflater inflater, @Nullable ViewGroup container) {
return inflater.inflate(layoutId, container, false);
}
public void onDestroyView() {
if (adView == null) {
return;
}
adView.destroy();
adView = null;
}
}

View File

@ -41,6 +41,10 @@ public class KeyboardFragment extends BaseFragment {
@Inject @Inject
KeyboardUi keyboardUi; KeyboardUi keyboardUi;
public KeyboardFragment() {
super(R.layout.cpp_app_keyboard);
}
@Override @Override
protected void inject(@Nonnull AppComponent component) { protected void inject(@Nonnull AppComponent component) {
super.inject(component); super.inject(component);
@ -56,12 +60,6 @@ public class KeyboardFragment extends BaseFragment {
return view; return view;
} }
@Nonnull
@Override
protected FragmentUi createUi() {
return new FragmentUi(R.layout.cpp_app_keyboard);
}
@Override @Override
public void onDestroyView() { public void onDestroyView() {
keyboardUi.onDestroyView(); keyboardUi.onDestroyView();

View File

@ -30,11 +30,6 @@ import org.solovyev.android.calculator.R;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/**
* User: serso
* Date: 9/16/11
* Time: 11:52 PM
*/
public class AboutActivity extends EmptyActivity { public class AboutActivity extends EmptyActivity {
@Override @Override

View File

@ -33,13 +33,9 @@ import butterknife.Bind;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.BaseFragment; import org.solovyev.android.calculator.BaseFragment;
import org.solovyev.android.calculator.FragmentUi;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import static android.view.View.GONE; import static android.view.View.GONE;
import static org.solovyev.android.calculator.FragmentTab.about;
import static org.solovyev.common.text.Strings.isEmpty; import static org.solovyev.common.text.Strings.isEmpty;
public class AboutFragment extends BaseFragment { public class AboutFragment extends BaseFragment {
@ -53,10 +49,8 @@ public class AboutFragment extends BaseFragment {
@Bind(R.id.about_translators) @Bind(R.id.about_translators)
TextView translatorsView; TextView translatorsView;
@Nonnull public AboutFragment() {
@Override super(R.layout.about_fragment);
protected FragmentUi createUi() {
return createUi(about);
} }
@Override @Override

View File

@ -32,23 +32,16 @@ import android.widget.TextView;
import butterknife.Bind; import butterknife.Bind;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import org.solovyev.android.calculator.BaseFragment; import org.solovyev.android.calculator.BaseFragment;
import org.solovyev.android.calculator.FragmentUi;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.release.ReleaseNotes; import org.solovyev.android.calculator.release.ReleaseNotes;
import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.FragmentTab.release_notes;
public class ReleaseNotesFragment extends BaseFragment { public class ReleaseNotesFragment extends BaseFragment {
@Bind(R.id.releasenotes_text) @Bind(R.id.releasenotes_text)
TextView text; TextView text;
@Nonnull public ReleaseNotesFragment() {
@Override super(R.layout.release_notes_fragment);
protected FragmentUi createUi() {
return createUi(release_notes);
} }
@Override @Override

View File

@ -0,0 +1,109 @@
package org.solovyev.android.calculator.ads;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.view.View;
import butterknife.Bind;
import butterknife.ButterKnife;
import org.solovyev.android.calculator.AdView;
import org.solovyev.android.calculator.R;
import org.solovyev.android.checkout.CppCheckout;
import org.solovyev.android.checkout.Inventory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import static org.solovyev.android.checkout.ProductTypes.IN_APP;
public class AdUi {
@NonNull
private final CppCheckout checkout;
@NonNull
private final Handler handler;
@Nullable
@Bind(R.id.ad)
AdView adView;
@Nullable
private Boolean adFree = null;
@Inject
public AdUi(@NonNull CppCheckout checkout, @NonNull Handler handler) {
this.checkout = checkout;
this.handler = handler;
}
public void onCreate() {
checkout.start();
}
public void onResume() {
if (adView == null) {
return;
}
adView.resume();
checkout.loadInventory().whenLoaded(onMainThread(new Inventory.Listener() {
@Override
public void onLoaded(@Nonnull Inventory.Products products) {
adFree = products.get(IN_APP).isPurchased("ad_free");
updateAdView();
}
}));
}
private void updateAdView() {
if (adFree == null || adView == null) {
return;
}
if (adFree) {
adView.hide();
} else {
adView.show();
}
}
@Nonnull
private Inventory.Listener onMainThread(@Nonnull final Inventory.Listener listener) {
return new Inventory.Listener() {
@Override
public void onLoaded(@Nonnull final Inventory.Products products) {
if (handler.getLooper() == Looper.myLooper()) {
listener.onLoaded(products);
return;
}
handler.post(new Runnable() {
@Override
public void run() {
listener.onLoaded(products);
}
});
}
};
}
public void onCreateView(@NonNull View view) {
ButterKnife.bind(this, view);
}
public void onPause() {
adFree = null;
if (adView != null) {
adView.pause();
}
}
public void onDestroyView() {
if (adView == null) {
return;
}
adView.destroy();
adView = null;
}
public void onDestroy() {
checkout.stop();
}
}

View File

@ -71,6 +71,10 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
@Nullable @Nullable
private String category; private String category;
public BaseEntitiesFragment() {
super(R.layout.fragment_entities);
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -83,7 +87,7 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = ui.onCreateView(inflater, container); final View view = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
final Context context = inflater.getContext(); final Context context = inflater.getContext();
adapter = new EntitiesAdapter(context, TextUtils.isEmpty(category) ? getEntities() : getEntities(category)); adapter = new EntitiesAdapter(context, TextUtils.isEmpty(category) ? getEntities() : getEntities(category));

View File

@ -32,7 +32,9 @@ import com.squareup.otto.Subscribe;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IFunction; import jscl.math.function.IFunction;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.AppComponent;
import org.solovyev.android.calculator.Calculator;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.entities.BaseEntitiesFragment; import org.solovyev.android.calculator.entities.BaseEntitiesFragment;
import org.solovyev.android.calculator.entities.Category; import org.solovyev.android.calculator.entities.Category;
import org.solovyev.android.calculator.entities.EntityRemovalDialog; import org.solovyev.android.calculator.entities.EntityRemovalDialog;
@ -43,8 +45,6 @@ import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.solovyev.android.calculator.FragmentTab.functions;
public class FunctionsFragment extends BaseEntitiesFragment<Function> { public class FunctionsFragment extends BaseEntitiesFragment<Function> {
@Inject @Inject
@ -54,12 +54,6 @@ public class FunctionsFragment extends BaseEntitiesFragment<Function> {
@Inject @Inject
Bus bus; Bus bus;
@Nonnull
@Override
protected FragmentUi createUi() {
return createUi(functions);
}
@Override @Override
protected void inject(@Nonnull AppComponent component) { protected void inject(@Nonnull AppComponent component) {
super.inject(component); super.inject(component);

View File

@ -69,6 +69,7 @@ public abstract class BaseHistoryFragment extends BaseFragment {
private HistoryAdapter adapter; private HistoryAdapter adapter;
protected BaseHistoryFragment(boolean recentHistory) { protected BaseHistoryFragment(boolean recentHistory) {
super(R.layout.fragment_history);
this.recentHistory = recentHistory; this.recentHistory = recentHistory;
} }

View File

@ -22,20 +22,9 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.FragmentUi;
import javax.annotation.Nonnull;
public class RecentHistoryFragment extends BaseHistoryFragment { public class RecentHistoryFragment extends BaseHistoryFragment {
public RecentHistoryFragment() { public RecentHistoryFragment() {
super(true); super(true);
} }
@Nonnull
@Override
protected FragmentUi createUi() {
return createUi(FragmentTab.history);
}
} }

View File

@ -22,21 +22,9 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import org.solovyev.android.calculator.FragmentUi;
import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.FragmentTab.saved_history;
public class SavedHistoryFragment extends BaseHistoryFragment { public class SavedHistoryFragment extends BaseHistoryFragment {
public SavedHistoryFragment() { public SavedHistoryFragment() {
super(false); super(false);
} }
@Nonnull
@Override
protected FragmentUi createUi() {
return createUi(saved_history);
}
} }

View File

@ -24,16 +24,14 @@ package org.solovyev.android.calculator.matrix;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import org.solovyev.android.calculator.BaseFragment;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.R;
import org.solovyev.android.view.IntegerRange; import org.solovyev.android.view.IntegerRange;
import org.solovyev.android.view.Picker; import org.solovyev.android.view.Picker;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static org.solovyev.android.calculator.FragmentTab.matrix_edit;
public class EditMatrixFragment extends BaseFragment implements Picker.OnChangedListener<Integer> { public class EditMatrixFragment extends BaseFragment implements Picker.OnChangedListener<Integer> {
private static final int MAX_COUNT = 10; private static final int MAX_COUNT = 10;
private static final int MIN_COUNT = 2; private static final int MIN_COUNT = 2;
@ -43,15 +41,10 @@ public class EditMatrixFragment extends BaseFragment implements Picker.OnChanged
private static final String MATRIX = "matrix"; private static final String MATRIX = "matrix";
public EditMatrixFragment() { public EditMatrixFragment() {
super(R.layout.matrix_edit_fragment);
setRetainInstance(true); setRetainInstance(true);
} }
@Nonnull
@Override
protected FragmentUi createUi() {
return createUi(matrix_edit);
}
@Override @Override
public void onViewCreated(View root, @Nullable Bundle in) { public void onViewCreated(View root, @Nullable Bundle in) {
super.onViewCreated(root, in); super.onViewCreated(root, in);

View File

@ -26,7 +26,8 @@ import android.support.annotation.NonNull;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.MenuItem; import android.view.MenuItem;
import jscl.math.operator.Operator; import jscl.math.operator.Operator;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.AppComponent;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.entities.BaseEntitiesFragment; import org.solovyev.android.calculator.entities.BaseEntitiesFragment;
import org.solovyev.android.calculator.entities.Category; import org.solovyev.android.calculator.entities.Category;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
@ -37,8 +38,6 @@ import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.solovyev.android.calculator.FragmentTab.operators;
public class OperatorsFragment extends BaseEntitiesFragment<Operator> { public class OperatorsFragment extends BaseEntitiesFragment<Operator> {
@Inject @Inject
@ -46,12 +45,6 @@ public class OperatorsFragment extends BaseEntitiesFragment<Operator> {
@Inject @Inject
PostfixFunctionsRegistry postfixFunctionsRegistry; PostfixFunctionsRegistry postfixFunctionsRegistry;
@Nonnull
@Override
protected FragmentUi createUi() {
return createUi(operators);
}
@Override @Override
protected void inject(@Nonnull AppComponent component) { protected void inject(@Nonnull AppComponent component) {
super.inject(component); super.inject(component);

View File

@ -32,10 +32,10 @@ import com.squareup.otto.Subscribe;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.entities.BaseEntitiesFragment;
import org.solovyev.android.calculator.entities.Category; import org.solovyev.android.calculator.entities.Category;
import org.solovyev.android.calculator.entities.EntityRemovalDialog; import org.solovyev.android.calculator.entities.EntityRemovalDialog;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.entities.BaseEntitiesFragment;
import org.solovyev.common.JPredicate; import org.solovyev.common.JPredicate;
import org.solovyev.common.collections.Collections; import org.solovyev.common.collections.Collections;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
@ -57,12 +57,6 @@ public class VariablesFragment extends BaseEntitiesFragment<IConstant> {
@Inject @Inject
Bus bus; Bus bus;
@Nonnull
@Override
protected FragmentUi createUi() {
return createUi(variables);
}
public static boolean isValidValue(@Nonnull String value) { public static boolean isValidValue(@Nonnull String value) {
try { try {
final PreparedExpression pe = ToJsclTextProcessor.getInstance().process(value); final PreparedExpression pe = ToJsclTextProcessor.getInstance().process(value);