From 17fd9302471ae5daebeabdd73d46330f70a7f34f Mon Sep 17 00:00:00 2001 From: serso Date: Sat, 6 Feb 2016 21:50:41 +0100 Subject: [PATCH] Add Hugo library --- app/build.gradle | 1 + .../android/calculator/BaseFragment.java | 3 +++ .../calculator/CalculatorActivity.java | 3 +++ .../calculator/CalculatorApplication.java | 22 +++++++++++-------- .../solovyev/android/calculator/Editor.java | 2 ++ .../android/calculator/Preferences.java | 2 ++ .../android/calculator/history/History.java | 2 ++ build.gradle | 1 + 8 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c8bbcf12..84e7d318 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,6 +24,7 @@ apply plugin: 'com.android.application' apply plugin: 'maven' apply plugin: 'signing' apply plugin: 'com.neenbedankt.android-apt' +apply plugin: 'com.jakewharton.hugo' android { compileSdkVersion 23 diff --git a/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java b/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java index 54b0050a..563d020f 100644 --- a/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java @@ -4,6 +4,7 @@ import android.os.Bundle; import android.support.annotation.StringRes; import android.support.v4.app.Fragment; import android.view.*; +import hugo.weaving.DebugLog; import javax.annotation.Nonnull; @@ -14,6 +15,7 @@ public abstract class BaseFragment extends Fragment { protected FragmentUi ui; + @DebugLog @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -33,6 +35,7 @@ public abstract class BaseFragment extends Fragment { protected void inject(@Nonnull AppComponent component) { } + @DebugLog @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = ui.onCreateView(inflater, container); diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 0c39b273..a47309b3 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -36,6 +36,7 @@ import android.view.*; import android.widget.TextView; import butterknife.Bind; import butterknife.ButterKnife; +import hugo.weaving.DebugLog; import org.solovyev.android.Activities; import org.solovyev.android.Android; import org.solovyev.android.calculator.history.History; @@ -152,6 +153,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference return result; } + @DebugLog @Override public void onCreate(@Nullable Bundle savedInstanceState) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); @@ -203,6 +205,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference } } + @DebugLog @Override protected void inject(@Nonnull AppComponent component) { super.inject(component); diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index 78277aab..0d11aa1e 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -26,10 +26,10 @@ import android.content.SharedPreferences; import android.os.Handler; import android.preference.PreferenceManager; import android.util.Log; - import com.squareup.leakcanary.LeakCanary; import com.squareup.otto.Bus; - +import hugo.weaving.DebugLog; +import jscl.MathEngine; import org.acra.ACRA; import org.acra.ACRAConfiguration; import org.acra.sender.HttpSender; @@ -42,14 +42,11 @@ import org.solovyev.android.calculator.plot.AndroidCalculatorPlotter; import org.solovyev.android.calculator.plot.CalculatorPlotterImpl; import org.solovyev.common.msg.MessageType; -import java.util.Locale; -import java.util.concurrent.Executor; - import javax.annotation.Nonnull; import javax.inject.Inject; import javax.inject.Named; - -import jscl.MathEngine; +import java.util.Locale; +import java.util.concurrent.Executor; public class CalculatorApplication extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -102,6 +99,7 @@ public class CalculatorApplication extends android.app.Application implements Sh @Inject ActivityLauncher launcher; + @DebugLog @Override public void onCreate() { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); @@ -110,16 +108,21 @@ public class CalculatorApplication extends android.app.Application implements Sh onPreCreate(preferences, languages); super.onCreate(); + initDagger(); + onPostCreate(preferences, languages); + } + + @DebugLog + private void initDagger() { component = DaggerAppComponent.builder() .appModule(new AppModule(this)) .build(); component.inject(this); editor.init(); history.init(initThread); - - onPostCreate(preferences, languages); } + @DebugLog private void onPostCreate(@Nonnull SharedPreferences preferences, @Nonnull Languages languages) { App.init(this, languages); @@ -154,6 +157,7 @@ public class CalculatorApplication extends android.app.Application implements Sh } } + @DebugLog private void onPreCreate(@Nonnull SharedPreferences preferences, @Nonnull Languages languages) { // first we need to setup crash handler and memory leak analyzer if (AcraErrorReporter.ENABLED) { diff --git a/app/src/main/java/org/solovyev/android/calculator/Editor.java b/app/src/main/java/org/solovyev/android/calculator/Editor.java index 71adbea7..6226e6ed 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Editor.java +++ b/app/src/main/java/org/solovyev/android/calculator/Editor.java @@ -27,6 +27,7 @@ import android.content.SharedPreferences; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; +import hugo.weaving.DebugLog; import org.solovyev.android.Check; import org.solovyev.android.calculator.text.TextProcessorEditorResult; import org.solovyev.android.calculator.view.EditorTextProcessor; @@ -55,6 +56,7 @@ public class Editor { textProcessor = new EditorTextProcessor(preferences); } + @DebugLog public void init() { bus.register(this); } diff --git a/app/src/main/java/org/solovyev/android/calculator/Preferences.java b/app/src/main/java/org/solovyev/android/calculator/Preferences.java index bec5d51a..5eebee77 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Preferences.java +++ b/app/src/main/java/org/solovyev/android/calculator/Preferences.java @@ -31,6 +31,7 @@ import android.support.annotation.LayoutRes; import android.support.annotation.StyleRes; import android.util.SparseArray; import android.view.ContextThemeWrapper; +import hugo.weaving.DebugLog; import jscl.AngleUnit; import jscl.NumeralBase; import org.solovyev.android.Check; @@ -59,6 +60,7 @@ public final class Preferences { throw new AssertionError(); } + @DebugLog static void setDefaultValues(@Nonnull SharedPreferences preferences) { // renew value after each application start Gui.showFixableErrorDialog.putDefault(preferences); diff --git a/app/src/main/java/org/solovyev/android/calculator/history/History.java b/app/src/main/java/org/solovyev/android/calculator/history/History.java index 4f232793..9c8e29a6 100644 --- a/app/src/main/java/org/solovyev/android/calculator/history/History.java +++ b/app/src/main/java/org/solovyev/android/calculator/history/History.java @@ -30,6 +30,7 @@ import android.text.TextUtils; import com.google.common.base.Strings; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; +import hugo.weaving.DebugLog; import org.json.JSONArray; import org.json.JSONException; import org.solovyev.android.Check; @@ -157,6 +158,7 @@ public class History { public History() { } + @DebugLog public void init(@NonNull Executor initThread) { Check.isMainThread(); bus.register(this); diff --git a/build.gradle b/build.gradle index 9605ba73..5fbecdbf 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' + classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1' } }