Android Open Source - alogger Log Adapter






From Project

Back to project page alogger.

License

The source code is released under:

GNU General Public License

If you think the Android project alogger listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jug6ernaut.android.logging;
/*from   w  w  w. j  ava  2s.  c om*/
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.logging.Level;

public class LogAdapter extends BaseAdapter {

    private Context mContext;
    public ArrayList<LogEntry> mEntries;
    private LayoutInflater mInflater;
    private DateFormat format = new SimpleDateFormat("'('yyyy-MM-dd')_('HH:mm:ss.SSSZ')'");

    public LogAdapter(Context context, ArrayList<LogEntry> entries) {
        this.mContext = context;
        this.mEntries = entries;
        this.mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mEntries.size();
    }

    @Override
    public LogEntry getItem(int index) {
        return mEntries.get(index);
    }

    @Override
    public long getItemId(int index) {
        return index;
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        LogEntry entry = mEntries.get(position); // get data object from array

        ViewHolder holder = null;
        TextView when = null;
        TextView what = null;
        View divider = null;

        View v = convertView;

        if (v == null) { // if convertView is null we need to load it initially
            v = mInflater.inflate(R.layout.log_row, parent, false);
            holder = new ViewHolder();

            when = (TextView)v.findViewById(R.id.tvWhen);
            what = (TextView)v.findViewById(R.id.tvWhat);
            divider = v.findViewById(R.id.divider);

            holder.when = when;
            holder.what = what;
            holder.divider = divider;

            v.setTag(holder);
        } else { // View has been initalized, use it.
            holder = (ViewHolder)convertView.getTag();
            when = holder.when;
            what = holder.what;
            divider = holder.divider;
        }

        when.setText("When: " + format.format(entry.getWhen()));
        what.setText(entry.getMessage());

        int color = 0;

        Level l = entry.getLevel();

        if(l.equals(Level.FINER)){
            color = Color.BLACK;
        }else if(l.equals(Level.FINE)){
            color = Color.BLUE;
        }else if(l.equals(Level.INFO)){
            color = Color.GREEN;
        }else if(l.equals(Level.WARNING)){
            color = Color.rgb(255,165,0);
        }else if(l.equals(Level.SEVERE)){
            color = Color.RED;
        }

        divider.setBackgroundColor(color);

        return v;
    }

    private static final class ViewHolder {
        protected TextView when = null;
        protected TextView what = null;
        protected View divider = null;
    }

}




Java Source Code List

.FileDialog.java
com.jug6ernaut.android.actiondialog.ActionDialog.java
com.jug6ernaut.android.logging.ALogger.java
com.jug6ernaut.android.logging.BriefLogFormatter.java
com.jug6ernaut.android.logging.DebugLogger.java
com.jug6ernaut.android.logging.JSONFormatter.java
com.jug6ernaut.android.logging.JSONLogReader.java
com.jug6ernaut.android.logging.JSONLogWriter.java
com.jug6ernaut.android.logging.LogAdapter.java
com.jug6ernaut.android.logging.LogEntry.java
com.jug6ernaut.android.logging.LogFragment.java
com.jug6ernaut.android.logging.Logger.java
com.jug6ernaut.android.logging.ProdLogger.java
com.jug6ernaut.android.utilites.AnalysisDir.java
com.jug6ernaut.android.utilites.Assets.java
com.jug6ernaut.android.utilites.BaseAsyncTask.java
com.jug6ernaut.android.utilites.ByteUtils.java
com.jug6ernaut.android.utilites.CopyUtils.java
com.jug6ernaut.android.utilites.DeviceWake.java
com.jug6ernaut.android.utilites.DisplayUtils.java
com.jug6ernaut.android.utilites.Eula.java
com.jug6ernaut.android.utilites.FileDownloader.java
com.jug6ernaut.android.utilites.ImagesUtils.java
com.jug6ernaut.android.utilites.PInfo.java
com.jug6ernaut.android.utilites.PackageInfo.java
com.jug6ernaut.android.utilites.ReflectionUtils.java
com.jug6ernaut.android.utilites.SecurePreferences.java
com.jug6ernaut.android.utilites.SeekBarPreference.java
com.jug6ernaut.android.utilites.SimpleCrypto.java
com.jug6ernaut.android.utilites.SuperUser.java
com.jug6ernaut.android.utilites.UserUtils.java
com.jug6ernaut.android.utilites.WakelockHelper.java
com.jug6ernaut.android.utilites.lazyloader.FileCache.java
com.jug6ernaut.android.utilites.lazyloader.ImageLoader.java
com.jug6ernaut.android.utilites.lazyloader.MemoryCache.java
com.jug6ernaut.android.utilites.lazyloader.Utils.java
com.jug6ernaut.android.utilites.time.Preconditions.java
com.jug6ernaut.android.utilites.time.Stopwatch.java
com.jug6ernaut.android.utilites.time.Ticker.java
com.jug6ernaut.android.utilites.time.TimeUtils.java
com.jug6ernaut.billing.Base64DecoderException.java
com.jug6ernaut.billing.Base64.java
com.jug6ernaut.billing.IabException.java
com.jug6ernaut.billing.IabHelper.java
com.jug6ernaut.billing.IabResult.java
com.jug6ernaut.billing.Inventory.java
com.jug6ernaut.billing.Purchase.java
com.jug6ernaut.billing.Security.java
com.jug6ernaut.billing.SkuDetails.java