Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADDED] Timber logging lib. Fixes #16 #30

Merged
merged 1 commit into from
Sep 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ ext {
apacheOltuOauth2Version = '1.0.1'
jodaTimeVersion = '2.9.4'
glassfishJavaxAnnotationVersion = '10.0-b28'
timberLibraryVersion = '4.3.1'
}
5 changes: 5 additions & 0 deletions core-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ dependencies {
compile "io.reactivex:rxandroid:$rootProject.rxAndroidVersion"


// Logging framework
// https://github.com/JakeWharton/timber
compile "com.jakewharton.timber:timber:$rootProject.timberLibraryVersion"


// ----------------------------------------------------------------
// Android Unit and Instrumentation test
// ----------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import info.hossainkhan.android.core.dagger.components.DaggerAppComponent;
import info.hossainkhan.android.core.dagger.modules.InteractorsModule;
import info.hossainkhan.android.core.dagger.modules.NetworkModule;
import timber.log.Timber;

/**
* Extended {@link Application} that is shared among all the android application modules.
Expand All @@ -44,6 +45,13 @@ public void onCreate() {
super.onCreate();

initAppComponent();
initLogger();
}

private void initLogger() {
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
}

private void initAppComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@
package info.hossainkhan.dailynewsheadlines;

import android.support.annotation.NonNull;
import android.util.Log;

import javax.inject.Inject;

import info.hossainkhan.android.core.CoreApplication;
import info.hossainkhan.android.core.base.*;
import info.hossainkhan.android.core.base.BasePresenter;
import info.hossainkhan.android.core.headlines.HeadlinesContract;
import io.swagger.client.ApiClient;
import io.swagger.client.api.StoriesApi;
Expand All @@ -40,6 +37,7 @@
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import timber.log.Timber;

import static com.google.android.gms.internal.zzs.TAG;

Expand All @@ -64,19 +62,19 @@ public void loadHeadlines(final boolean forceUpdate) {
.subscribe(new Subscriber<InlineResponse200>() {
@Override
public void onCompleted() {
Log.d(TAG, "onCompleted() called");
Timber.d(TAG, "onCompleted() called");
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, Timber.d(TAG, "onCompleted() called"); is wrong arguments

It should be Timber.d("onCompleted() called"); instead without any TAG ... this was fixed later in the project.

getView().setLoadingIndicator(false);
}

@Override
public void onError(final Throwable e) {
Log.d(TAG, "onError() called with: e = [" + e + "]");
Timber.d(TAG, "onError() called with: e = [" + e + "]");
getView().showLoadingHeadlinesError();
}

@Override
public void onNext(final InlineResponse200 inlineResponse200) {
Log.d(TAG, "onNext() called");
Timber.d(TAG, "onNext() called");
getView().showHeadlines(inlineResponse200.getResults());
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package info.hossainkhan.dailynewsheadlines;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import java.util.List;
Expand All @@ -11,6 +10,7 @@
import info.hossainkhan.android.core.base.BaseActivity;
import info.hossainkhan.android.core.headlines.HeadlinesContract;
import io.swagger.client.model.Article;
import timber.log.Timber;

public class MainActivity extends BaseActivity implements HeadlinesContract.View {
private static final String TAG = "MainActivity";
Expand All @@ -36,33 +36,33 @@ protected void onCreate(Bundle savedInstanceState) {
protected void onStart() {
super.onStart();

Log.d(TAG, "onStart() called");
Timber.d(TAG, "onStart() called");

}

@Override
public void setLoadingIndicator(final boolean active) {
Log.d(TAG, "setLoadingIndicator() called with: active = [" + active + "]");
Timber.d(TAG, "setLoadingIndicator() called with: active = [" + active + "]");
}

@Override
public void showHeadlines(final List<Article> headlines) {
Log.d(TAG, "showHeadlines() called with: Headlines = [" + headlines.size() + "]");
Timber.d(TAG, "showHeadlines() called with: Headlines = [" + headlines.size() + "]");
demoTextview.setText(headlines.toString());
}

@Override
public void showHeadlineDetailsUi(final Article article) {
Log.d(TAG, "showHeadlineDetailsUi() called with: article = [" + article + "]");
Timber.d(TAG, "showHeadlineDetailsUi() called with: article = [" + article + "]");
}

@Override
public void showLoadingHeadlinesError() {
Log.d(TAG, "showLoadingHeadlinesError() called");
Timber.d(TAG, "showLoadingHeadlinesError() called");
}

@Override
public void showNoHeadlines() {
Log.d(TAG, "showNoHeadlines() called");
Timber.d(TAG, "showNoHeadlines() called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
import android.os.Bundle;
import android.support.v17.leanback.app.BrowseFragment;
import android.support.v17.leanback.widget.ArrayObjectAdapter;
import android.support.v17.leanback.widget.ListRow;
import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.OnItemViewClickedListener;
import android.support.v17.leanback.widget.OnItemViewSelectedListener;
import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.RowPresenter;
import android.support.v4.app.ActivityOptionsCompat;
import android.util.Log;

import timber.log.Timber;


public class MainFragment extends BrowseFragment {
Expand Down Expand Up @@ -83,7 +83,7 @@ private final class ItemViewClickedListener implements OnItemViewClickedListener
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
Log.d(TAG, "onItemClicked() called with: itemViewHolder = [" + itemViewHolder + "], " +
Timber.d(TAG, "onItemClicked() called with: itemViewHolder = [" + itemViewHolder + "], " +
"item = [" + item + "], rowViewHolder = [" + rowViewHolder + "], row = [" + row + "]");

Intent intent = null;
Expand Down