Android Open Source - m-app Log Array Adapter






From Project

Back to project page m-app.

License

The source code is released under:

GNU General Public License

If you think the Android project m-app 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

/*
 *  Copyright 2013-2014 Sagar Gugwad <saagar.gugwad@gmail.com>
 */*from   w w w .j  a v a 2  s.co m*/
 *  This file is part of mApp project.
 *
 *  mApp is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 *
 *  mApp is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with mApp.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.example.app;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LogArrayAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final List<CallLog> values;

    public LogArrayAdapter(Context context, List<CallLog> logs) {
        super(context, R.layout.view_log);
        this.context = context;
        this.values = logs;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View rowView = inflater.inflate(R.layout.view_log, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.label);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
        textView.setText(values.get(position).getCallerNumber());

        // Change icon based on name
        String s = values.get(position).getCalleeStatusId();

        System.out.println(s);

        if (s.equals("WindowsMobile")) {
            imageView.setImageResource(R.drawable.ic_launcher);
        } else if (s.equals("iOS")) {
            imageView.setImageResource(R.drawable.ic_launcher);
        } else if (s.equals("Blackberry")) {
            imageView.setImageResource(R.drawable.ic_launcher);
        } else {
            imageView.setImageResource(R.drawable.ic_launcher);
        }
        return rowView;
    }
}




Java Source Code List

com.example.app.CallLog.java
com.example.app.DBHelper.java
com.example.app.DataSource.java
com.example.app.HomeActivity.java
com.example.app.LogArrayAdapter.java
com.example.app.ObserverService.java
com.example.app.Status.java
com.example.app.ViewLogActivity.java