From 96d94e3878360922162dc3ded1e97b7c9df744e1 Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Mon, 26 Sep 2016 17:52:41 +0200 Subject: [PATCH 1/7] Use the same logging interface everywhere `TiLog.setLogger(null)` - allows custom loggers - disable logging is now possible Logs by default to Timber --- .../thirtyinch/plugin/TiActivityPlugin.java | 15 ++- thirtyinch/build.gradle | 1 + .../internal/TiActivityDelegateTest.java | 32 +++---- .../grandcentrix/thirtyinch/TiActivity.java | 15 ++- .../grandcentrix/thirtyinch/TiFragment.java | 35 ++++--- .../net/grandcentrix/thirtyinch/TiLog.java | 93 +++++++++++++++++++ .../grandcentrix/thirtyinch/TiPresenter.java | 22 ++--- .../CallOnMainThreadInterceptor.java | 5 +- .../DistinctUntilChangedInterceptor.java | 6 +- ...DistinctUntilChangedInvocationHandler.java | 10 +- .../thirtyinch/internal/PresenterSavior.java | 7 +- .../internal/PresenterViewBinder.java | 19 ++-- .../internal/TiActivityDelegate.java | 44 +++++---- ...rLogger.java => TiLoggingTagProvider.java} | 15 +-- 14 files changed, 202 insertions(+), 117 deletions(-) create mode 100644 thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java rename thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/{TiPresenterLogger.java => TiLoggingTagProvider.java} (58%) diff --git a/plugin/src/main/java/net/grandcentrix/thirtyinch/plugin/TiActivityPlugin.java b/plugin/src/main/java/net/grandcentrix/thirtyinch/plugin/TiActivityPlugin.java index 7fbfe8cd..9e13f8ed 100644 --- a/plugin/src/main/java/net/grandcentrix/thirtyinch/plugin/TiActivityPlugin.java +++ b/plugin/src/main/java/net/grandcentrix/thirtyinch/plugin/TiActivityPlugin.java @@ -26,7 +26,7 @@ import net.grandcentrix.thirtyinch.internal.DelegatedTiActivity; import net.grandcentrix.thirtyinch.internal.InterceptableViewBinder; import net.grandcentrix.thirtyinch.internal.TiActivityDelegate; -import net.grandcentrix.thirtyinch.internal.TiPresenterLogger; +import net.grandcentrix.thirtyinch.internal.TiLoggingTagProvider; import net.grandcentrix.thirtyinch.internal.TiPresenterProvider; import net.grandcentrix.thirtyinch.internal.TiViewProvider; import net.grandcentrix.thirtyinch.util.AndroidDeveloperOptions; @@ -37,12 +37,11 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.util.Log; import java.util.List; public class TiActivityPlugin

, V extends TiView> extends ActivityPlugin - implements TiViewProvider, DelegatedTiActivity

, TiPresenterLogger, + implements TiViewProvider, DelegatedTiActivity

, TiLoggingTagProvider, InterceptableViewBinder { public static final String NCI_KEY_PRESENTER = "presenter"; @@ -93,6 +92,11 @@ public List getInterceptors( return mDelegate.getInterceptors(predicate); } + @Override + public String getLoggingTag() { + return TAG; + } + public P getPresenter() { return mDelegate.getPresenter(); } @@ -127,11 +131,6 @@ public boolean isDontKeepActivitiesEnabled() { return AndroidDeveloperOptions.isDontKeepActivitiesEnabled(getActivity()); } - @Override - public void logTiMessages(final String msg) { - Log.v(TAG, msg); - } - @Override public void onConfigurationChanged(final Configuration newConfig) { super.onConfigurationChanged(newConfig); diff --git a/thirtyinch/build.gradle b/thirtyinch/build.gradle index c3ce1e26..8fa5ed7a 100644 --- a/thirtyinch/build.gradle +++ b/thirtyinch/build.gradle @@ -37,6 +37,7 @@ android { dependencies { compile "com.android.support:appcompat-v7:$supportLibraryVersion" + compile "com.jakewharton.timber:timber:4.3.1" testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' diff --git a/thirtyinch/src/androidTest/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegateTest.java b/thirtyinch/src/androidTest/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegateTest.java index 95f9fcb2..ad566091 100644 --- a/thirtyinch/src/androidTest/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegateTest.java +++ b/thirtyinch/src/androidTest/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegateTest.java @@ -15,8 +15,8 @@ package net.grandcentrix.thirtyinch.internal; -import net.grandcentrix.thirtyinch.TiPresenter; import net.grandcentrix.thirtyinch.TiConfiguration; +import net.grandcentrix.thirtyinch.TiPresenter; import net.grandcentrix.thirtyinch.TiView; import org.junit.Before; @@ -144,13 +144,13 @@ public void testRestorePresenter_withNonConfigurationInstance() throws Exception } @Test - public void testRestorePresenter_withSavior_whichIsDisabled() throws Exception { + public void testRestorePresenter_withSavior() throws Exception { final TiPresenter firstPresenter = new TiPresenter(new TiConfiguration.Builder() - .setUseStaticSaviorToRetain(false) + .setUseStaticSaviorToRetain(true) .build()) { }; final TiPresenter secondPresenter = new TiPresenter(new TiConfiguration.Builder() - .setUseStaticSaviorToRetain(false) + .setUseStaticSaviorToRetain(true) .build()) { }; mPresenter = firstPresenter; @@ -169,20 +169,20 @@ public void testRestorePresenter_withSavior_whichIsDisabled() throws Exception { // check reuse of old presenter mDelegate.onCreate_afterSuper(bundle); - assertEquals(secondPresenter, mDelegate.getPresenter()); + assertEquals(firstPresenter, mDelegate.getPresenter()); - // new one got created - assertEquals(TiPresenter.State.CREATED_WITH_DETACHED_VIEW, mPresenter.getState()); + // new one got NOT created + assertEquals(TiPresenter.State.INITIALIZED, mPresenter.getState()); } @Test - public void testRestorePresenter_withSavior() throws Exception { + public void testRestorePresenter_withSavior_whichIsDisabled() throws Exception { final TiPresenter firstPresenter = new TiPresenter(new TiConfiguration.Builder() - .setUseStaticSaviorToRetain(true) + .setUseStaticSaviorToRetain(false) .build()) { }; final TiPresenter secondPresenter = new TiPresenter(new TiConfiguration.Builder() - .setUseStaticSaviorToRetain(true) + .setUseStaticSaviorToRetain(false) .build()) { }; mPresenter = firstPresenter; @@ -201,10 +201,10 @@ public void testRestorePresenter_withSavior() throws Exception { // check reuse of old presenter mDelegate.onCreate_afterSuper(bundle); - assertEquals(firstPresenter, mDelegate.getPresenter()); + assertEquals(secondPresenter, mDelegate.getPresenter()); - // new one got NOT created - assertEquals(TiPresenter.State.INITIALIZED, mPresenter.getState()); + // new one got created + assertEquals(TiPresenter.State.CREATED_WITH_DETACHED_VIEW, mPresenter.getState()); } @NonNull @@ -249,10 +249,10 @@ public TiPresenter providePresenter() { return mPresenter; } }, - new TiPresenterLogger() { + new TiLoggingTagProvider() { @Override - public void logTiMessages(final String msg) { - System.out.println(msg); + public String getLoggingTag() { + return "TestTag"; } }); } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiActivity.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiActivity.java index 7afa3755..11f49ce9 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiActivity.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiActivity.java @@ -19,7 +19,7 @@ import net.grandcentrix.thirtyinch.internal.InterceptableViewBinder; import net.grandcentrix.thirtyinch.internal.PresenterNonConfigurationInstance; import net.grandcentrix.thirtyinch.internal.TiActivityDelegate; -import net.grandcentrix.thirtyinch.internal.TiPresenterLogger; +import net.grandcentrix.thirtyinch.internal.TiLoggingTagProvider; import net.grandcentrix.thirtyinch.internal.TiPresenterProvider; import net.grandcentrix.thirtyinch.internal.TiViewProvider; import net.grandcentrix.thirtyinch.util.AndroidDeveloperOptions; @@ -30,7 +30,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; -import android.util.Log; import java.util.List; @@ -40,7 +39,7 @@ public abstract class TiActivity

, V extends TiView> extends AppCompatActivity implements TiPresenterProvider

, TiViewProvider, DelegatedTiActivity

, - TiPresenterLogger, InterceptableViewBinder { + TiLoggingTagProvider, InterceptableViewBinder { private final String TAG = this.getClass().getSimpleName() + ":" + TiActivity.class.getSimpleName() @@ -68,6 +67,11 @@ public List getInterceptors( return mDelegate.getInterceptors(predicate); } + @Override + public String getLoggingTag() { + return TAG; + } + public P getPresenter() { return mDelegate.getPresenter(); } @@ -105,11 +109,6 @@ public boolean isDontKeepActivitiesEnabled() { return AndroidDeveloperOptions.isDontKeepActivitiesEnabled(this); } - @Override - public void logTiMessages(final String msg) { - Log.v(TAG, msg); - } - @Override public void onConfigurationChanged(final Configuration newConfig) { super.onConfigurationChanged(newConfig); diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiFragment.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiFragment.java index 022193f1..7566e90b 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiFragment.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiFragment.java @@ -20,7 +20,7 @@ import net.grandcentrix.thirtyinch.internal.InterceptableViewBinder; import net.grandcentrix.thirtyinch.internal.PresenterSavior; import net.grandcentrix.thirtyinch.internal.PresenterViewBinder; -import net.grandcentrix.thirtyinch.internal.TiPresenterLogger; +import net.grandcentrix.thirtyinch.internal.TiLoggingTagProvider; import net.grandcentrix.thirtyinch.internal.TiPresenterProvider; import net.grandcentrix.thirtyinch.internal.TiViewProvider; import net.grandcentrix.thirtyinch.util.AndroidDeveloperOptions; @@ -32,7 +32,6 @@ import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -40,7 +39,7 @@ import java.util.List; public abstract class TiFragment

, V extends TiView> - extends Fragment implements TiPresenterProvider

, TiPresenterLogger, + extends Fragment implements TiPresenterProvider

, TiLoggingTagProvider, TiViewProvider, InterceptableViewBinder { private static final String SAVED_STATE_PRESENTER_ID = "presenter_id"; @@ -76,6 +75,11 @@ public List getInterceptors( return mViewBinder.getInterceptors(predicate); } + @Override + public String getLoggingTag() { + return TAG; + } + public P getPresenter() { return mPresenter; } @@ -89,22 +93,17 @@ public void invalidateView() { mViewBinder.invalidateView(); } - @Override - public void logTiMessages(final String msg) { - Log.v(TAG, msg); - } - @Override public void onAttach(final Activity activity) { super.onAttach(activity); - Log.v(TAG, "onAttach()"); + TiLog.v(TAG, "onAttach()"); } @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Log.d(TAG, "onCreate(" + savedInstanceState + ")"); + TiLog.d(TAG, "onCreate(" + savedInstanceState + ")"); if (mPresenter == null && savedInstanceState != null) { // recover with Savior @@ -112,7 +111,7 @@ public void onCreate(final Bundle savedInstanceState) { final String recoveredPresenterId = savedInstanceState .getString(SAVED_STATE_PRESENTER_ID); if (recoveredPresenterId != null) { - Log.d(TAG, "try to recover Presenter with id: " + recoveredPresenterId); + TiLog.d(TAG, "try to recover Presenter with id: " + recoveredPresenterId); //noinspection unchecked mPresenter = (P) PresenterSavior.INSTANCE.recover(recoveredPresenterId); if (mPresenter != null) { @@ -122,13 +121,13 @@ public void onCreate(final Bundle savedInstanceState) { PresenterSavior.INSTANCE.free(recoveredPresenterId); mPresenterId = PresenterSavior.INSTANCE.safe(mPresenter); } - Log.d(TAG, "recovered Presenter " + mPresenter); + TiLog.d(TAG, "recovered Presenter " + mPresenter); } } if (mPresenter == null) { mPresenter = providePresenter(); - Log.d(TAG, "created Presenter: " + mPresenter); + TiLog.d(TAG, "created Presenter: " + mPresenter); final TiConfiguration config = mPresenter.getConfig(); if (config.shouldRetainPresenter() && config.useStaticSaviorToRetain()) { mPresenterId = PresenterSavior.INSTANCE.safe(mPresenter); @@ -162,7 +161,7 @@ public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGrou public void onDestroy() { super.onDestroy(); final FragmentActivity activity = getActivity(); - Log.v(TAG, "onDestroy() recreating=" + !activity.isFinishing()); + TiLog.v(TAG, "onDestroy() recreating=" + !activity.isFinishing()); boolean destroyPresenter = false; if (activity.isFinishing()) { @@ -197,7 +196,7 @@ public void onDestroy() { @Override public void onDestroyView() { - Log.v(TAG, "onDestroyView()"); + TiLog.v(TAG, "onDestroyView()"); mPresenter.sleep(); super.onDestroyView(); } @@ -205,7 +204,7 @@ public void onDestroyView() { @Override public void onDetach() { super.onDetach(); - Log.v(TAG, "onDetach()"); + TiLog.v(TAG, "onDetach()"); } @Override @@ -217,7 +216,7 @@ public void onSaveInstanceState(final Bundle outState) { @Override public void onStart() { super.onStart(); - Log.v(TAG, "onStart()"); + TiLog.v(TAG, "onStart()"); mActivityStarted = true; if (isUiPossible()) { @@ -235,7 +234,7 @@ public void run() { @Override public void onStop() { - Log.v(TAG, "onStop()"); + TiLog.v(TAG, "onStop()"); mActivityStarted = false; mPresenter.sleep(); super.onStop(); diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java new file mode 100644 index 00000000..36a77f19 --- /dev/null +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2016 grandcentrix GmbH + * 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. + */ + +package net.grandcentrix.thirtyinch; + + +import android.support.annotation.Nullable; +import android.util.Log; + +import timber.log.Timber; + +/** + * Logging class used for all logging of ThirtyInch. + */ +public class TiLog { + + /** + * Simple logging interface for log messages from ThirtyInch + * + * @see #setLogger(Logger) + */ + interface Logger { + + /** + * @param level one of {@link Log#VERBOSE}, {@link Log#DEBUG},{@link Log#INFO}, + * {@link Log#WARN},{@link Log#ERROR} + * @param tag log tag, caller + * @param msg message to log + */ + void log(final int level, final String tag, final String msg); + } + + // logs everything to Timber by default + private static Logger logger = new Logger() { + @Override + public void log(final int level, final String tag, final String msg) { + Timber.tag(tag).log(level, msg); + } + }; + + public static void d(final String tag, final String msg) { + if (logger != null) { + logger.log(Log.DEBUG, tag, msg); + } + } + + public static void e(final String tag, final String msg) { + if (logger != null) { + logger.log(Log.ERROR, tag, msg); + } + } + + public static void i(final String tag, final String msg) { + if (logger != null) { + logger.log(Log.INFO, tag, msg); + } + } + + /** + * set a custom logger, {@code null} to disable logging + */ + public static void setLogger(@Nullable final Logger logger) { + TiLog.logger = logger; + } + + public static void v(final String tag, final String msg) { + if (logger != null) { + logger.log(Log.VERBOSE, tag, msg); + } + } + + public static void w(final String tag, final String msg) { + if (logger != null) { + logger.log(Log.WARN, tag, msg); + } + } + + TiLog() { + throw new AssertionError("no instances"); + } +} \ No newline at end of file diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiPresenter.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiPresenter.java index 2516c267..38586b4b 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiPresenter.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiPresenter.java @@ -25,8 +25,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Represents the Presenter of the popular Model-View-Presenter design pattern. If used with {@link @@ -70,9 +68,9 @@ public enum State { @VisibleForTesting final List mLifecycleObservers = new ArrayList<>(); - Logger mLogger = Logger.getLogger(this.getClass().getSimpleName() + private final String TAG = this.getClass().getSimpleName() + ":" + TiPresenter.class.getSimpleName() - + "@" + Integer.toHexString(this.hashCode())); + + "@" + Integer.toHexString(this.hashCode()); /** * used to check that lifecycle methods (starting with on..) cannot be called directly. i.e. @@ -174,12 +172,12 @@ public void bindNewView(@NonNull final V view) { */ public final void create() { if (isCreated()) { - mLogger.log(Level.WARNING, "not calling onCreate(), it was already called"); + TiLog.w(TAG, "not calling onCreate(), it was already called"); return; } moveToState(State.CREATED_WITH_DETACHED_VIEW, false); mCalled = false; - mLogger.log(Level.FINE, "onCreate()"); + TiLog.v(TAG, "onCreate()"); onCreate(); if (!mCalled) { throw new SuperNotCalledException("Presenter " + this @@ -197,13 +195,13 @@ public final void create() { */ public final void destroy() { if (!isCreated() || isDestroyed()) { - mLogger.log(Level.WARNING, "not calling onDestroy(), destroy was already called"); + TiLog.w(TAG, "not calling onDestroy(), destroy was already called"); return; } moveToState(State.DESTROYED, false); mCalled = false; - mLogger.log(Level.FINE, "onDestroy()"); + TiLog.v(TAG, "onDestroy()"); onDestroy(); if (!mCalled) { throw new SuperNotCalledException("Presenter " + this @@ -259,12 +257,12 @@ public boolean isDestroyed() { */ public final void sleep() { if (!isAwake()) { - mLogger.log(Level.FINE, "not calling onSleep(), not woken up"); + TiLog.v(TAG, "not calling onSleep(), not woken up"); return; } moveToState(State.CREATED_WITH_DETACHED_VIEW, false); mCalled = false; - mLogger.log(Level.FINE, "onSleep()"); + TiLog.v(TAG, "onSleep()"); onSleep(); if (!mCalled) { throw new SuperNotCalledException("Presenter " + this @@ -297,12 +295,12 @@ public String toString() { */ public final void wakeUp() { if (isAwake()) { - mLogger.log(Level.FINE, "not calling onWakeUp(), already woken up"); + TiLog.v(TAG, "not calling onWakeUp(), already woken up"); return; } moveToState(State.VIEW_ATTACHED_AND_AWAKE, false); mCalled = false; - mLogger.log(Level.FINE, "onWakeUp()"); + TiLog.v(TAG, "onWakeUp()"); onWakeUp(); if (!mCalled) { throw new SuperNotCalledException("Presenter " + this diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/callonmainthread/CallOnMainThreadInterceptor.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/callonmainthread/CallOnMainThreadInterceptor.java index eb5c5b65..1cb54afd 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/callonmainthread/CallOnMainThreadInterceptor.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/callonmainthread/CallOnMainThreadInterceptor.java @@ -16,10 +16,9 @@ package net.grandcentrix.thirtyinch.callonmainthread; import net.grandcentrix.thirtyinch.BindViewInterceptor; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiView; -import android.util.Log; - import java.lang.reflect.Proxy; import static net.grandcentrix.thirtyinch.util.AnnotationUtil.getInterfaceOfClassExtendingGivenInterface; @@ -32,7 +31,7 @@ public class CallOnMainThreadInterceptor implements BindViewInterceptor { @Override public V intercept(final V view) { final V wrapped = wrap(view); - Log.d(TAG, "wrapping View " + view + " in " + wrapped); + TiLog.d(TAG, "wrapping View " + view + " in " + wrapped); return wrapped; } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInterceptor.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInterceptor.java index e2663020..fb6aa483 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInterceptor.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInterceptor.java @@ -16,12 +16,12 @@ package net.grandcentrix.thirtyinch.distinctuntilchanged; import net.grandcentrix.thirtyinch.BindViewInterceptor; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiView; import net.grandcentrix.thirtyinch.internal.InterceptableViewBinder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.util.Log; import java.lang.reflect.Proxy; @@ -49,7 +49,7 @@ public void clearCache(final InterceptableViewBinder inter = DistinctUntilChangedInterceptor.unwrap(wrappedView); if (view != null) { view.clearCache(); - Log.v(TAG, "cleared the distinctUntilChanged cache of " + view); + TiLog.v(TAG, "cleared the distinctUntilChanged cache of " + view); } } } @@ -57,7 +57,7 @@ public void clearCache(final InterceptableViewBinder inter @Override public V intercept(final V view) { final V wrapped = wrap(view); - Log.d(TAG, "wrapping View " + view + " in " + wrapped); + TiLog.d(TAG, "wrapping View " + view + " in " + wrapped); return wrapped; } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInvocationHandler.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInvocationHandler.java index 1cd0c4fd..9cd2da14 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInvocationHandler.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/distinctuntilchanged/DistinctUntilChangedInvocationHandler.java @@ -15,6 +15,7 @@ package net.grandcentrix.thirtyinch.distinctuntilchanged; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiView; import net.grandcentrix.thirtyinch.util.AbstractInvocationHandler; @@ -22,20 +23,17 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; -import java.util.logging.Level; -import java.util.logging.Logger; final class DistinctUntilChangedInvocationHandler extends AbstractInvocationHandler { - private HashMap mLatestMethodCalls = new HashMap<>(); + private static final String TAG = DistinctUntilChangedInvocationHandler.class.getSimpleName(); - private final Logger mLogger; + private HashMap mLatestMethodCalls = new HashMap<>(); private final V mView; public DistinctUntilChangedInvocationHandler(V view) { mView = view; - mLogger = Logger.getLogger(toString()); } public void clearCache() { @@ -102,7 +100,7 @@ protected Object handleInvocation(final Object proxy, final Method method, final } else { // don't call the method, the exact same data was already sent to the view if (ducAnnotation.logDropped()) { - mLogger.log(Level.INFO, "not calling " + method + TiLog.d(TAG, "not calling " + method + " with args " + Arrays.toString(args) + "." + " Was already called with the same parameters before."); } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterSavior.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterSavior.java index 2eca20d6..31cd7028 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterSavior.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterSavior.java @@ -16,14 +16,13 @@ package net.grandcentrix.thirtyinch.internal; import net.grandcentrix.thirtyinch.TiActivity; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiPresenter; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.HashMap; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Activities can be destroyed when the device runs out of memory. Sometimes it doesn't work to @@ -37,7 +36,7 @@ public enum PresenterSavior { INSTANCE; - private Logger mLogger = Logger.getLogger(PresenterSavior.class.getSimpleName()); + private static final String TAG = PresenterSavior.class.getSimpleName(); private HashMap mPresenters = new HashMap<>(); @@ -52,7 +51,7 @@ public TiPresenter recover(final String id) { public String safe(@NonNull final TiPresenter presenter) { final String id = generateId(presenter); - mLogger.log(Level.FINER, "safe presenter with id " + id + " " + presenter); + TiLog.v(TAG, "safe presenter with id " + id + " " + presenter); mPresenters.put(id, presenter); return id; } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterViewBinder.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterViewBinder.java index b9cf2e94..6a823e41 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterViewBinder.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/PresenterViewBinder.java @@ -17,6 +17,7 @@ import net.grandcentrix.thirtyinch.Removable; import net.grandcentrix.thirtyinch.BindViewInterceptor; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiPresenter; import net.grandcentrix.thirtyinch.TiView; @@ -37,17 +38,17 @@ public class PresenterViewBinder implements InterceptableViewB private List mBindViewInterceptors = new ArrayList<>(); - private HashMap mIntercepterViewOutput = new HashMap<>(); + private HashMap mInterceptorViewOutput = new HashMap<>(); /** * the cached version of the view send to the presenter after it passed the interceptors */ private V mLastView; - private final TiPresenterLogger mLogger; + private final TiLoggingTagProvider mLogTag; - public PresenterViewBinder(final TiPresenterLogger logger) { - mLogger = logger; + public PresenterViewBinder(final TiLoggingTagProvider loggingTagProvider) { + mLogTag = loggingTagProvider; } @NonNull @@ -75,13 +76,13 @@ public void bindView(final TiPresenter presenter, final TiViewProvider vie V interceptedView = viewProvider.provideView(); for (final BindViewInterceptor interceptor : mBindViewInterceptors) { interceptedView = interceptor.intercept(interceptedView); - mIntercepterViewOutput.put(interceptor, interceptedView); + mInterceptorViewOutput.put(interceptor, interceptedView); } mLastView = interceptedView; - mLogger.logTiMessages("binding NEW view to Presenter " + mLastView); + TiLog.v(mLogTag.getLoggingTag(), "binding NEW view to Presenter " + mLastView); presenter.bindNewView(mLastView); } else { - mLogger.logTiMessages("binding the cached view to Presenter " + mLastView); + TiLog.v(mLogTag.getLoggingTag(), "binding the cached view to Presenter " + mLastView); presenter.bindNewView(mLastView); } } @@ -89,7 +90,7 @@ public void bindView(final TiPresenter presenter, final TiViewProvider vie @Nullable @Override public V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) { - return mIntercepterViewOutput.get(interceptor); + return mInterceptorViewOutput.get(interceptor); } @NonNull @@ -109,6 +110,6 @@ public List getInterceptors( @Override public void invalidateView() { mLastView = null; - mIntercepterViewOutput.clear(); + mInterceptorViewOutput.clear(); } } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegate.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegate.java index 194eadbe..f4dc11dc 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegate.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiActivityDelegate.java @@ -19,6 +19,7 @@ import net.grandcentrix.thirtyinch.Removable; import net.grandcentrix.thirtyinch.TiActivity; import net.grandcentrix.thirtyinch.TiConfiguration; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiPresenter; import net.grandcentrix.thirtyinch.TiView; import net.grandcentrix.thirtyinch.callonmainthread.CallOnMainThreadInterceptor; @@ -53,7 +54,7 @@ public class TiActivityDelegate

, V extends TiView> */ private volatile boolean mActivityStarted = false; - private TiPresenterLogger mLogger; + private TiLoggingTagProvider mLogTag; /** * The presenter to which this activity will be attached as view when in the right state. @@ -77,12 +78,12 @@ public class TiActivityDelegate

, V extends TiView> public TiActivityDelegate(final DelegatedTiActivity

activityProvider, final TiViewProvider viewProvider, final TiPresenterProvider

presenterProvider, - final TiPresenterLogger logger) { + final TiLoggingTagProvider logTag) { mTiActivity = activityProvider; mViewProvider = viewProvider; mPresenterProvider = presenterProvider; - mLogger = logger; - mViewBinder = new PresenterViewBinder<>(logger); + mLogTag = logTag; + mViewBinder = new PresenterViewBinder<>(logTag); } @NonNull @@ -123,16 +124,16 @@ public void onConfigurationChanged_afterSuper(final Configuration newConfig) { } public void onCreate_afterSuper(final Bundle savedInstanceState) { - mLogger.logTiMessages("onCreate(" + savedInstanceState + ")"); + TiLog.v(mLogTag.getLoggingTag(), "onCreate(" + savedInstanceState + ")"); // try recover presenter via lastNonConfigurationInstance // this works most of the time mPresenter = mTiActivity.getRetainedPresenter(); if (mPresenter == null) { - mLogger.logTiMessages( + TiLog.v(mLogTag.getLoggingTag(), "could not recover a Presenter from getLastNonConfigurationInstance()"); } else { - mLogger.logTiMessages( + TiLog.v(mLogTag.getLoggingTag(), "recovered Presenter from lastCustomNonConfigurationInstance " + mPresenter); } @@ -145,18 +146,19 @@ public void onCreate_afterSuper(final Bundle savedInstanceState) { if (recoveredPresenterId != null) { // recover with Savior // this should always work. - mLogger.logTiMessages( + TiLog.v(mLogTag.getLoggingTag(), "try to recover Presenter with id: " + recoveredPresenterId); //noinspection unchecked mPresenter = (P) PresenterSavior.INSTANCE.recover(recoveredPresenterId); - mLogger.logTiMessages("recovered Presenter from savior " + mPresenter); + TiLog.v(mLogTag.getLoggingTag(), + "recovered Presenter from savior " + mPresenter); } else { - mLogger.logTiMessages("could not recover a Presenter from savior"); + TiLog.v(mLogTag.getLoggingTag(), "could not recover a Presenter from savior"); } } if (mPresenter == null) { - mLogger.logTiMessages("could not recover the Presenter " + TiLog.w(mLogTag.getLoggingTag(), "could not recover the Presenter " + "although it's not the first start of the Activity"); } else { // save recovered presenter with new id. No other instance of this activity, @@ -170,7 +172,7 @@ public void onCreate_afterSuper(final Bundle savedInstanceState) { if (mPresenter == null) { // could not recover, create a new presenter mPresenter = mPresenterProvider.providePresenter(); - mLogger.logTiMessages("created Presenter: " + mPresenter); + TiLog.v(mLogTag.getLoggingTag(), "created Presenter: " + mPresenter); final TiConfiguration config = mPresenter.getConfig(); if (config.shouldRetainPresenter() && config.useStaticSaviorToRetain()) { mPresenterId = PresenterSavior.INSTANCE.safe(mPresenter); @@ -190,14 +192,15 @@ public void onCreate_afterSuper(final Bundle savedInstanceState) { public void onDestroy_afterSuper() { final boolean isFinishing = mTiActivity.isActivityFinishing(); - mLogger.logTiMessages("onDestroy()"); + TiLog.v(mLogTag.getLoggingTag(), "onDestroy()"); boolean destroyPresenter = false; if (isFinishing) { // Probably a backpress and not a configuration change // Activity will not be recreated and finally destroyed, also destroyed the presenter destroyPresenter = true; - mLogger.logTiMessages("Activity is finishing, destroying presenter " + mPresenter); + TiLog.v(mLogTag.getLoggingTag(), + "Activity is finishing, destroying presenter " + mPresenter); } final TiConfiguration config = mPresenter.getConfig(); @@ -206,7 +209,7 @@ public void onDestroy_afterSuper() { // configuration says the presenter should not be retained, a new presenter instance // will be created and the current presenter should be destroyed destroyPresenter = true; - mLogger.logTiMessages( + TiLog.v(mLogTag.getLoggingTag(), "presenter configured as not retaining, destroying " + mPresenter); } @@ -218,15 +221,16 @@ public void onDestroy_afterSuper() { // "don't keep activities" is enabled. // a new presenter instance will be created and the current presenter should be destroyed destroyPresenter = true; - mLogger.logTiMessages("the PresenterSavior is disabled and \"don\'t keep activities\"" - + " is activated. The presenter can't be retained. Destroying " + mPresenter); + TiLog.v(mLogTag.getLoggingTag(), + "the PresenterSavior is disabled and \"don\'t keep activities\" is activated. " + + "The presenter can't be retained. Destroying " + mPresenter); } if (destroyPresenter) { mPresenter.destroy(); PresenterSavior.INSTANCE.free(mPresenterId); } else { - mLogger.logTiMessages("not destroying " + mPresenter + TiLog.v(mLogTag.getLoggingTag(), "not destroying " + mPresenter + " which will be reused by the next Activity instance, recreating..."); } } @@ -250,7 +254,7 @@ public void run() { } public void onStart_beforeSuper() { - mLogger.logTiMessages("onStart()"); + TiLog.v(mLogTag.getLoggingTag(), "onStart()"); mViewBinder.bindView(mPresenter, mViewProvider); } @@ -259,7 +263,7 @@ public void onStop_afterSuper() { } public void onStop_beforeSuper() { - mLogger.logTiMessages("onStop()"); + TiLog.v(mLogTag.getLoggingTag(), "onStop()"); mActivityStarted = false; } } diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiPresenterLogger.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiLoggingTagProvider.java similarity index 58% rename from thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiPresenterLogger.java rename to thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiLoggingTagProvider.java index 300a40a3..9adf6d4c 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiPresenterLogger.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/internal/TiLoggingTagProvider.java @@ -15,19 +15,14 @@ package net.grandcentrix.thirtyinch.internal; -import net.grandcentrix.thirtyinch.TiActivity; - /** - * Super simple logging interface because the {@link TiActivityDelegate} - * is not responsible for actually logging. The using {@link TiActivity} - * or {@code TiActivityPlugin} takes care of logging and providing the correct logging TAG. + * Interface providing access to a logging tag for composition classes. Provides better tags for + * the log output */ -public interface TiPresenterLogger { +public interface TiLoggingTagProvider { /** - * logs a debug message from the presenter - * - * @param msg message from the presenter to display + * @return the tag which should be used for logging */ - void logTiMessages(final String msg); + String getLoggingTag(); } From 4da934b2989a0fbc99120cc421677641cc87a21b Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Mon, 26 Sep 2016 18:48:54 +0200 Subject: [PATCH 2/7] Exchange Timber with default Android logging --- thirtyinch/build.gradle | 1 - .../src/main/java/net/grandcentrix/thirtyinch/TiLog.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/thirtyinch/build.gradle b/thirtyinch/build.gradle index 8fa5ed7a..c3ce1e26 100644 --- a/thirtyinch/build.gradle +++ b/thirtyinch/build.gradle @@ -37,7 +37,6 @@ android { dependencies { compile "com.android.support:appcompat-v7:$supportLibraryVersion" - compile "com.jakewharton.timber:timber:4.3.1" testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java index 36a77f19..e5a939c4 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java @@ -19,8 +19,6 @@ import android.support.annotation.Nullable; import android.util.Log; -import timber.log.Timber; - /** * Logging class used for all logging of ThirtyInch. */ @@ -42,11 +40,13 @@ interface Logger { void log(final int level, final String tag, final String msg); } + private static final String TAG = "ThirtyInch"; + // logs everything to Timber by default private static Logger logger = new Logger() { @Override public void log(final int level, final String tag, final String msg) { - Timber.tag(tag).log(level, msg); + Log.println(level, TAG, tag + ": " + msg); } }; From 91d8439e84c38d4e1f49005bc134024e6164787a Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Mon, 26 Sep 2016 18:50:35 +0200 Subject: [PATCH 3/7] Make Logger public --- thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java index e5a939c4..4c1d41ba 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java @@ -29,7 +29,7 @@ public class TiLog { * * @see #setLogger(Logger) */ - interface Logger { + public interface Logger { /** * @param level one of {@link Log#VERBOSE}, {@link Log#DEBUG},{@link Log#INFO}, From 766741d01627c413bb9266aa43826178e7c1d798 Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Mon, 26 Sep 2016 18:59:59 +0200 Subject: [PATCH 4/7] Add documentation for Timber integration --- .../java/net/grandcentrix/thirtyinch/TiLog.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java index 4c1d41ba..afbb25f1 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java @@ -70,6 +70,19 @@ public static void i(final String tag, final String msg) { /** * set a custom logger, {@code null} to disable logging + *

+ * Combine it with Timber:
+ * + * + *

+     * TiLog.setLogger(new TiLog.Logger() {
+     *    @Override
+     *    public void log(final int level, final String tag, final String msg) {
+     *        Timber.tag(tag).log(level, msg);
+     *    }
+     * });
+     * 
+ * */ public static void setLogger(@Nullable final Logger logger) { TiLog.logger = logger; From 2be0a5c2fdd745b87e31f6a7d9d2b16fa9cdff66 Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Mon, 26 Sep 2016 19:16:07 +0200 Subject: [PATCH 5/7] Fix jvm tests from failing because Log.println isn't mocked --- .../java/net/grandcentrix/thirtyinch/rx/RxUtilsTest.java | 8 ++++++++ .../grandcentrix/thirtyinch/TiLifecycleObserverTest.java | 6 ++++++ .../java/net/grandcentrix/thirtyinch/TiPresenterTest.java | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/rx/src/test/java/net/grandcentrix/thirtyinch/rx/RxUtilsTest.java b/rx/src/test/java/net/grandcentrix/thirtyinch/rx/RxUtilsTest.java index 82138506..e85b0a2b 100644 --- a/rx/src/test/java/net/grandcentrix/thirtyinch/rx/RxUtilsTest.java +++ b/rx/src/test/java/net/grandcentrix/thirtyinch/rx/RxUtilsTest.java @@ -15,6 +15,7 @@ package net.grandcentrix.thirtyinch.rx; +import net.grandcentrix.thirtyinch.TiLog; import net.grandcentrix.thirtyinch.TiView; import org.junit.After; @@ -44,6 +45,13 @@ public class RxUtilsTest { @Before public void setUp() throws Exception { + TiLog.setLogger(new TiLog.Logger() { + @Override + public void log(final int level, final String tag, final String msg) { + // prevent RuntimeException: android.util.Log not mocked + } + }); + mView = mock(TiView.class); mPresenter = new TiMockPresenter(); diff --git a/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiLifecycleObserverTest.java b/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiLifecycleObserverTest.java index a41333e3..993c114f 100644 --- a/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiLifecycleObserverTest.java +++ b/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiLifecycleObserverTest.java @@ -34,6 +34,12 @@ public class TiLifecycleObserverTest { @Before public void setUp() throws Exception { + TiLog.setLogger(new TiLog.Logger() { + @Override + public void log(final int level, final String tag, final String msg) { + // prevent RuntimeException: android.util.Log not mocked + } + }); mView = mock(TiView.class); mPresenter = new TiMockPresenter(); } diff --git a/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiPresenterTest.java b/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiPresenterTest.java index dba9e420..dbafcca4 100644 --- a/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiPresenterTest.java +++ b/thirtyinch/src/test/java/net/grandcentrix/thirtyinch/TiPresenterTest.java @@ -39,6 +39,12 @@ public class TiPresenterTest { @Before public void setUp() throws Exception { + TiLog.setLogger(new TiLog.Logger() { + @Override + public void log(final int level, final String tag, final String msg) { + // prevent RuntimeException: android.util.Log not mocked + } + }); mView = mock(TiView.class); mPresenter = new TiMockPresenter(); } From 39632675a79ce41154c2f2497b659a4fbf2e71fb Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Tue, 27 Sep 2016 13:26:59 +0200 Subject: [PATCH 6/7] Set Logger to null by default --- .../thirtyinch/sample/HelloWorldActivity.java | 5 +++++ .../net/grandcentrix/thirtyinch/TiLog.java | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sample/src/main/java/net/grandcentrix/thirtyinch/sample/HelloWorldActivity.java b/sample/src/main/java/net/grandcentrix/thirtyinch/sample/HelloWorldActivity.java index 2ac872c4..632f5865 100644 --- a/sample/src/main/java/net/grandcentrix/thirtyinch/sample/HelloWorldActivity.java +++ b/sample/src/main/java/net/grandcentrix/thirtyinch/sample/HelloWorldActivity.java @@ -19,6 +19,7 @@ import com.jakewharton.rxbinding.view.RxView; import net.grandcentrix.thirtyinch.TiActivity; +import net.grandcentrix.thirtyinch.TiLog; import android.os.Bundle; import android.support.annotation.NonNull; @@ -36,6 +37,10 @@ public class HelloWorldActivity extends TiActivity onButtonClicked() { return RxView.clicks(mButton); diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java index afbb25f1..23935b99 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java @@ -42,14 +42,20 @@ public interface Logger { private static final String TAG = "ThirtyInch"; - // logs everything to Timber by default - private static Logger logger = new Logger() { + /** + * predefined logger using {@link Log} to print into Logcat with tag "ThirtyInch" + * + * @see #setLogger(Logger) + */ + public static Logger LOGCAT = new Logger() { @Override public void log(final int level, final String tag, final String msg) { Log.println(level, TAG, tag + ": " + msg); } }; + private static Logger logger; + public static void d(final String tag, final String msg) { if (logger != null) { logger.log(Log.DEBUG, tag, msg); @@ -71,6 +77,14 @@ public static void i(final String tag, final String msg) { /** * set a custom logger, {@code null} to disable logging *

+ * + * Use the default logcat logger for Android: + * + *

+     * TiLog.setLogger(TiLog.LOGCAT);
+     * 
+ * + *

* Combine it with Timber:
* * From 11e3ff1f54fc59731247c843d3a62f56cdde0297 Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Tue, 27 Sep 2016 13:28:10 +0200 Subject: [PATCH 7/7] Make constructor private --- thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java index 23935b99..dbb65d60 100644 --- a/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java +++ b/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiLog.java @@ -114,7 +114,7 @@ public static void w(final String tag, final String msg) { } } - TiLog() { + private TiLog() { throw new AssertionError("no instances"); } } \ No newline at end of file