Google Analytics services updated + memory leaks fixed
This commit is contained in:
parent
77cb165b2a
commit
be0916d9b8
@ -74,43 +74,42 @@
|
||||
<orderEntry type="library" exported="" scope="TEST" name="xercesMinimal-1.9.6.2" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="nekohtml-1.9.6.2" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="jscl-1.0.11" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="simple-xml-2.6.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="core" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="commons-cli-1.2" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="annotations-2.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="internal_impl-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="core" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="stax-1.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="common-msg-1.0.5" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="common-listeners-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="guava-11.0.2" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_com_squareup_leakcanary_leakcanary_android_1_3_1_jars_classes_jar" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="common-text-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="library-2.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="common-text-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="acra-4.5.0" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="leakcanary-analyzer-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-22.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="common-core-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="leakcanary-analyzer-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="common-security-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="jscl-1.0.11" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="leakcanary-watcher-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="haha-1.3" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_classes_debug" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_dependency_cache_debug" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_android_calculatorpp_android_app_build_intermediates_classes_debug" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_android_calculatorpp_android_app_build_intermediates_dependency_cache_debug" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="android" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -69,12 +69,12 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.1.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/21.0.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.1.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.3.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.3.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.3.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.5.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.5.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.melnykov/floatingactionbutton/1.1.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.squareup.leakcanary/leakcanary-android/1.3.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/android-common-core/1.1.18/jars" />
|
||||
@ -84,7 +84,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/android-common-preferences/1.1.18/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/android-common-views/1.1.18/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/checkout/0.7.2/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/material/0.1.2/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/material/0.1.3/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||
@ -102,9 +102,9 @@
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="play-services-base-7.5.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="acra-4.5.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="annotations-2.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-ads-7.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="common-core-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" name="common-listeners-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" name="common-text-1.0.7" level="project" />
|
||||
@ -112,29 +112,29 @@
|
||||
<orderEntry type="library" exported="" name="stax-1.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="jscl-1.0.11" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-base-7.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="material-0.1.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="material-0.1.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="android-common-menus-1.1.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="leakcanary-analyzer-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-analytics-7.5.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="common-security-1.0.7" level="project" />
|
||||
<orderEntry type="library" exported="" name="leakcanary-watcher-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-analytics-7.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="android-common-core-1.1.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="haha-1.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="common-msg-1.0.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="android-common-other-1.1.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="floatingactionbutton-1.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="checkout-0.7.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="android-common-preferences-1.1.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="android-common-lists-1.1.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="guava-11.0.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-cli-1.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="leakcanary-android-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="simple-xml-2.6.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />
|
||||
<orderEntry type="module" module-name="core" exported="" />
|
||||
</component>
|
||||
</module>
|
@ -56,8 +56,8 @@ dependencies {
|
||||
compile 'org.solovyev:common-core:1.0.7'
|
||||
compile 'org.solovyev:common-text:1.0.7'
|
||||
compile 'org.solovyev:common-security:1.0.7'
|
||||
compile 'com.android.support:support-v4:22.1.1'
|
||||
compile 'com.android.support:appcompat-v7:22.1.1'
|
||||
compile 'com.android.support:support-v4:22.2.0'
|
||||
compile 'com.android.support:appcompat-v7:22.2.0'
|
||||
compile('ch.acra:acra:4.5.0') {
|
||||
exclude group: 'org.json'
|
||||
}
|
||||
@ -71,10 +71,10 @@ dependencies {
|
||||
exclude(module: 'xercesImpl')
|
||||
}
|
||||
compile 'org.solovyev.android:checkout:0.7.2@aar'
|
||||
compile 'org.solovyev.android:material:0.1.2@aar'
|
||||
compile 'com.google.android.gms:play-services-ads:7.3.0@aar'
|
||||
compile 'com.google.android.gms:play-services-base:7.3.0@aar'
|
||||
compile 'com.google.android.gms:play-services-analytics:7.3.0@aar'
|
||||
compile 'org.solovyev.android:material:0.1.3@aar'
|
||||
compile 'com.google.android.gms:play-services-ads:7.5.0@aar'
|
||||
compile 'com.google.android.gms:play-services-base:7.5.0@aar'
|
||||
compile 'com.google.android.gms:play-services-analytics:7.5.0@aar'
|
||||
compile 'com.melnykov:floatingactionbutton:1.1.0'
|
||||
|
||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
||||
|
@ -5,15 +5,21 @@ import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.google.android.gms.ads.AdListener;
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
|
||||
import org.solovyev.android.Check;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AdView extends FrameLayout {
|
||||
|
||||
@Nullable
|
||||
private com.google.android.gms.ads.AdView admobView;
|
||||
@Nullable
|
||||
private AdView.AdViewListener admobListener;
|
||||
|
||||
public AdView(Context context) {
|
||||
super(context);
|
||||
@ -28,8 +34,18 @@ public class AdView extends FrameLayout {
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
destroyAdmobView();
|
||||
}
|
||||
|
||||
private void destroyAdmobView() {
|
||||
if (admobView != null) {
|
||||
admobView.destroy();
|
||||
admobView.setAdListener(null);
|
||||
admobView = null;
|
||||
}
|
||||
if(admobListener != null) {
|
||||
admobListener.destroy();
|
||||
admobListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,22 +68,13 @@ public class AdView extends FrameLayout {
|
||||
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.admob, this);
|
||||
admobView = (com.google.android.gms.ads.AdView) findViewById(R.id.admob);
|
||||
if (admobView == null) throw new AssertionError();
|
||||
Check.isNotNull(admobView);
|
||||
if (admobView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
admobView.setAdListener(new AdListener() {
|
||||
@Override
|
||||
public void onAdFailedToLoad(int errorCode) {
|
||||
hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoaded() {
|
||||
if (admobView != null) {
|
||||
admobView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
});
|
||||
admobListener = new AdView.AdViewListener(this);
|
||||
admobView.setAdListener(admobListener);
|
||||
|
||||
final AdRequest.Builder b = new AdRequest.Builder();
|
||||
b.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
|
||||
@ -87,7 +94,40 @@ public class AdView extends FrameLayout {
|
||||
|
||||
admobView.setVisibility(View.GONE);
|
||||
admobView.pause();
|
||||
admobView.destroy();
|
||||
admobView = null;
|
||||
destroyAdmobView();
|
||||
}
|
||||
|
||||
private static class AdViewListener extends AdListener {
|
||||
|
||||
@Nullable
|
||||
private AdView adView;
|
||||
|
||||
public AdViewListener(@Nonnull AdView adView) {
|
||||
this.adView = adView;
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
adView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdFailedToLoad(int errorCode) {
|
||||
if (adView != null) {
|
||||
adView.hide();
|
||||
adView = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoaded() {
|
||||
if (adView != null) {
|
||||
final com.google.android.gms.ads.AdView admobView = adView.admobView;
|
||||
if (admobView != null) {
|
||||
admobView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
adView.setVisibility(VISIBLE);
|
||||
adView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ import javax.annotation.Nonnull;
|
||||
public class CalculatorDisplayFragment extends Fragment {
|
||||
|
||||
@Nonnull
|
||||
private FragmentUi fragmentHelper;
|
||||
private FragmentUi fragmentUi;
|
||||
@Nonnull
|
||||
private AndroidCalculatorDisplayView displayView;
|
||||
|
||||
@ -52,17 +52,17 @@ public class CalculatorDisplayFragment extends Fragment {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(prefs);
|
||||
if (!layout.isOptimized()) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display_mobile, R.string.result);
|
||||
fragmentUi = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display_mobile, R.string.result);
|
||||
} else {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display, R.string.result);
|
||||
fragmentUi = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display, R.string.result);
|
||||
}
|
||||
|
||||
fragmentHelper.onCreate(this);
|
||||
fragmentUi.onCreate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
return fragmentUi.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,7 +73,7 @@ public class CalculatorDisplayFragment extends Fragment {
|
||||
displayView.init(getActivity());
|
||||
Locator.getInstance().getDisplay().setView(displayView);
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
fragmentUi.onViewCreated(this, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,12 +85,12 @@ public class CalculatorDisplayFragment extends Fragment {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
fragmentHelper.onResume(this);
|
||||
fragmentUi.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
fragmentHelper.onPause(this);
|
||||
fragmentUi.onPause(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
@ -98,12 +98,13 @@ public class CalculatorDisplayFragment extends Fragment {
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
Locator.getInstance().getDisplay().clearView(displayView);
|
||||
fragmentUi.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
fragmentHelper.onDestroy(this);
|
||||
fragmentUi.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public class CalculatorEditorFragment extends Fragment {
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
Locator.getInstance().getEditor().clearView(editorView);
|
||||
fragmentUi.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
@ -40,18 +40,18 @@ import javax.annotation.Nonnull;
|
||||
public abstract class CalculatorFragment extends Fragment {
|
||||
|
||||
@Nonnull
|
||||
private final FragmentUi fragmentHelper;
|
||||
private final FragmentUi fragmentUi;
|
||||
|
||||
protected CalculatorFragment(int layoutResId, int titleResId) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
||||
fragmentUi = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
||||
}
|
||||
|
||||
protected CalculatorFragment(@Nonnull CalculatorFragmentType fragmentType) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||
fragmentUi = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||
}
|
||||
|
||||
protected CalculatorFragment(@Nonnull FragmentUi fragmentHelper) {
|
||||
this.fragmentHelper = fragmentHelper;
|
||||
protected CalculatorFragment(@Nonnull FragmentUi fragmentUi) {
|
||||
this.fragmentUi = fragmentUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,43 +63,44 @@ public abstract class CalculatorFragment extends Fragment {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
fragmentHelper.onCreate(this);
|
||||
fragmentUi.onCreate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
return fragmentUi.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
fragmentHelper.onViewCreated(this, view);
|
||||
fragmentUi.onViewCreated(this, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.fragmentHelper.onResume(this);
|
||||
this.fragmentUi.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
this.fragmentHelper.onPause(this);
|
||||
this.fragmentUi.onPause(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
fragmentUi.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
fragmentHelper.onDestroy(this);
|
||||
fragmentUi.onDestroy(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@ -109,6 +110,6 @@ public abstract class CalculatorFragment extends Fragment {
|
||||
}
|
||||
|
||||
public boolean isPaneFragment() {
|
||||
return fragmentHelper.isPane(this);
|
||||
return fragmentUi.isPane(this);
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,12 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
ui.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -40,18 +40,18 @@ import javax.annotation.Nonnull;
|
||||
public abstract class CalculatorListFragment extends ListFragment {
|
||||
|
||||
@Nonnull
|
||||
private final FragmentUi fragmentHelper;
|
||||
private final FragmentUi ui;
|
||||
|
||||
protected CalculatorListFragment(int layoutResId, int titleResId) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
||||
ui = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
||||
}
|
||||
|
||||
protected CalculatorListFragment(@Nonnull CalculatorFragmentType fragmentType) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||
ui = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||
}
|
||||
|
||||
protected CalculatorListFragment(@Nonnull FragmentUi fragmentHelper) {
|
||||
this.fragmentHelper = fragmentHelper;
|
||||
protected CalculatorListFragment(@Nonnull FragmentUi ui) {
|
||||
this.ui = ui;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,43 +63,42 @@ public abstract class CalculatorListFragment extends ListFragment {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
fragmentHelper.onCreate(this);
|
||||
ui.onCreate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
return ui.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
fragmentHelper.onViewCreated(this, view);
|
||||
ui.onViewCreated(this, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.fragmentHelper.onResume(this);
|
||||
this.ui.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
this.fragmentHelper.onPause(this);
|
||||
|
||||
this.ui.onPause(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
ui.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
fragmentHelper.onDestroy(this);
|
||||
ui.onDestroy(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,18 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.solovyev.android.checkout.ActivityCheckout;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
import org.solovyev.android.checkout.Inventory;
|
||||
import org.solovyev.android.checkout.ProductTypes;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@ -169,11 +172,6 @@ public class FragmentUi extends BaseUi {
|
||||
}
|
||||
|
||||
public void onDestroy(@Nonnull Fragment fragment) {
|
||||
if (adView != null) {
|
||||
adView.destroy();
|
||||
adView = null;
|
||||
}
|
||||
|
||||
if (listenersOnCreate) {
|
||||
if (fragment instanceof CalculatorEventListener) {
|
||||
Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment);
|
||||
@ -189,4 +187,11 @@ public class FragmentUi extends BaseUi {
|
||||
public View onCreateView(@Nonnull Fragment fragment, @Nonnull LayoutInflater inflater, @Nullable ViewGroup container) {
|
||||
return inflater.inflate(layoutId, container, false);
|
||||
}
|
||||
|
||||
public void onDestroyView(@Nonnull Fragment fragment) {
|
||||
if (adView != null) {
|
||||
adView.destroy();
|
||||
adView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,15 +32,36 @@ import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import org.solovyev.android.calculator.*;
|
||||
|
||||
import org.solovyev.android.calculator.App;
|
||||
import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import org.solovyev.android.calculator.CalculatorEventData;
|
||||
import org.solovyev.android.calculator.CalculatorEventListener;
|
||||
import org.solovyev.android.calculator.CalculatorEventType;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.FragmentUi;
|
||||
import org.solovyev.android.calculator.Locator;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||
import org.solovyev.android.menu.*;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.ActivityMenu;
|
||||
import org.solovyev.android.menu.AndroidMenuHelper;
|
||||
import org.solovyev.android.menu.ContextMenuBuilder;
|
||||
import org.solovyev.android.menu.IdentifiableMenuItem;
|
||||
import org.solovyev.android.menu.ListActivityMenu;
|
||||
import org.solovyev.android.menu.ListContextMenu;
|
||||
import org.solovyev.common.JPredicate;
|
||||
import org.solovyev.common.collections.Collections;
|
||||
import org.solovyev.common.equals.Equalizer;
|
||||
@ -48,12 +69,13 @@ import org.solovyev.common.filter.Filter;
|
||||
import org.solovyev.common.filter.FilterRulesChain;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.clear_history_requested;
|
||||
|
||||
public abstract class BaseHistoryFragment extends ListFragment implements CalculatorEventListener {
|
||||
@ -97,7 +119,7 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
private HistoryArrayAdapter adapter;
|
||||
|
||||
@Nonnull
|
||||
private FragmentUi fragmentHelper;
|
||||
private FragmentUi ui;
|
||||
|
||||
private final ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromResource(R.menu.history_menu, HistoryMenu.class, AndroidMenuHelper.getInstance(), new HistoryMenuFilter());
|
||||
|
||||
@ -119,14 +141,14 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
private AlertDialog clearDialog;
|
||||
|
||||
protected BaseHistoryFragment(@Nonnull CalculatorFragmentType fragmentType) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId(), false);
|
||||
ui = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
fragmentHelper.onCreate(this);
|
||||
ui.onCreate(this);
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
@ -139,7 +161,7 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
return ui.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,7 +171,7 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
final Boolean showDatetime = Preferences.History.showDatetime.getPreference(preferences);
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
ui.onViewCreated(this, root);
|
||||
|
||||
adapter = new HistoryArrayAdapter(this.getActivity(), getItemLayoutId(), org.solovyev.android.calculator.R.id.history_item, new ArrayList<CalculatorHistoryState>(), showDatetime);
|
||||
setListAdapter(adapter);
|
||||
@ -213,7 +235,7 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.fragmentHelper.onResume(this);
|
||||
this.ui.onResume(this);
|
||||
|
||||
updateAdapter();
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(preferencesListener);
|
||||
@ -223,11 +245,17 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
public void onPause() {
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(preferencesListener);
|
||||
|
||||
this.fragmentHelper.onPause(this);
|
||||
this.ui.onPause(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
ui.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
logDebug("onDestroy");
|
||||
@ -235,7 +263,7 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
clearDialog.dismiss();
|
||||
clearDialog = null;
|
||||
}
|
||||
fragmentHelper.onDestroy(this);
|
||||
ui.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
@ -425,7 +453,7 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
if (menuItem instanceof IdentifiableMenuItem<?>) {
|
||||
switch (((IdentifiableMenuItem) menuItem).getItemId()) {
|
||||
case R.id.menu_history_fullscreen:
|
||||
result = !fragmentHelper.isPane(BaseHistoryFragment.this);
|
||||
result = !ui.isPane(BaseHistoryFragment.this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ package org.solovyev.android.calculator.math.edit;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -33,20 +34,13 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import org.solovyev.android.calculator.CalculatorEventData;
|
||||
import org.solovyev.android.calculator.CalculatorEventListener;
|
||||
import org.solovyev.android.calculator.CalculatorEventType;
|
||||
import org.solovyev.android.calculator.FragmentUi;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.CalculatorMathRegistry;
|
||||
import org.solovyev.android.calculator.Locator;
|
||||
import org.solovyev.android.calculator.FragmentUi;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.ContextMenuBuilder;
|
||||
@ -58,7 +52,11 @@ import org.solovyev.common.filter.Filter;
|
||||
import org.solovyev.common.math.MathEntity;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import android.support.v4.app.ListFragment;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
@ -94,13 +92,13 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
private String category;
|
||||
|
||||
@Nonnull
|
||||
private final FragmentUi fragmentHelper;
|
||||
private final FragmentUi ui;
|
||||
|
||||
@Nonnull
|
||||
private final Handler uiHandler = new Handler();
|
||||
|
||||
protected AbstractMathEntityListFragment(@Nonnull CalculatorFragmentType fragmentType) {
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||
ui = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,19 +110,19 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
category = bundle.getString(MATH_ENTITY_CATEGORY_EXTRA_STRING);
|
||||
}
|
||||
|
||||
fragmentHelper.onCreate(this);
|
||||
ui.onCreate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
return ui.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
ui.onViewCreated(this, root);
|
||||
|
||||
final ListView lv = getListView();
|
||||
lv.setTextFilterEnabled(true);
|
||||
@ -161,9 +159,15 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
@Nullable
|
||||
protected abstract AMenuItem<T> getOnClickAction();
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
ui.onDestroyView(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
fragmentHelper.onDestroy(this);
|
||||
ui.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
@ -173,7 +177,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
this.fragmentHelper.onPause(this);
|
||||
this.ui.onPause(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
@ -182,7 +186,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.fragmentHelper.onResume(this);
|
||||
this.ui.onResume(this);
|
||||
|
||||
adapter = new MathEntityArrayAdapter<T>(getDescriptionGetter(), this.getActivity(), getMathEntitiesByCategory());
|
||||
setListAdapter(adapter);
|
||||
|
@ -172,6 +172,30 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (adView != null) {
|
||||
adView.resume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (adView != null) {
|
||||
adView.pause();
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (adView != null) {
|
||||
adView.destroy();
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
App.getPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
Loading…
Reference in New Issue
Block a user