Skip to content

Commit

Permalink
Fixed theming issue with log.
Browse files Browse the repository at this point in the history
  • Loading branch information
rumboalla committed Sep 1, 2016
1 parent 65bed31 commit 4680950
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
27 changes: 25 additions & 2 deletions app/src/main/java/com/apkupdater/adapter/LogAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,38 @@

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.apkupdater.model.LogMessage;
import com.apkupdater.util.MyBus;
import com.apkupdater.view.LogView;
import com.apkupdater.view.LogView_;
import com.squareup.otto.Subscribe;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.androidannotations.annotations.UiThread;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@EBean(scope = EBean.Scope.Singleton)
@EBean
public class LogAdapter
extends ArrayAdapter<LogMessage>
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@RootContext
Context context;
Activity context;

@Bean
MyBus mBus;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand All @@ -35,6 +43,21 @@ public LogAdapter(
super(context, 0);
}

@AfterViews
public void init(
) {
mBus.register(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@Subscribe
public void onLogMessage(
LogMessage m
) {
add(m);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@Override
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/apkupdater/fragment/LogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class LogFragment
@Bean
LogAdapter mAdapter;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@AfterViews
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/apkupdater/service/UpdaterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.apkupdater.updater.UpdaterNotification;
import com.apkupdater.updater.UpdaterOptions;
import com.apkupdater.updater.UpdaterStatus;
import com.apkupdater.util.LogUtil;
import com.apkupdater.util.MyBus;

import org.androidannotations.annotations.Bean;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class UpdaterService
AppState mAppState;

@Bean
LogAdapter mLogger;
LogUtil mLogger;

private final Lock mMutex = new ReentrantLock(true);
private List<Update> mUpdates = new ArrayList<>();
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/com/apkupdater/util/LogUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.apkupdater.util;

import com.apkupdater.model.LogMessage;

import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@EBean(scope = EBean.Scope.Singleton)
public class LogUtil
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@Bean
MyBus mBus;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public void log(
String title,
String message,
int severity
) {
mBus.post(new LogMessage(title, message, severity));
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7 changes: 7 additions & 0 deletions app/src/main/java/com/apkupdater/view/LogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.apkupdater.model.InstalledApp;
import com.apkupdater.model.LogMessage;
import com.apkupdater.updater.UpdaterOptions;
import com.apkupdater.util.ColorUtitl;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
Expand Down Expand Up @@ -55,11 +56,17 @@ public LogView(
public void bind(
LogMessage message
) {
int color = ColorUtitl.getColorFromContext(getContext(), android.R.attr.textColorTertiary);

mTitle.setText(message.getTitle());
//mTitle.setTextColor(color);

mMessage.setText(message.getMessage());
//mMessage.setTextColor(color);

DateFormat df = SimpleDateFormat.getDateTimeInstance();
mTime.setText(df.format(new Date(message.getTime())));
//mTime.setTextColor(color);

if (message.getSeverity() == LogMessage.SEVERITY_INFO) {
mIcon.setContentDescription("Info");
Expand Down

0 comments on commit 4680950

Please sign in to comment.