Android Open Source - legacy_bluetrack Device Cursor Adapter






From Project

Back to project page legacy_bluetrack.

License

The source code is released under:

GNU General Public License

If you think the Android project legacy_bluetrack 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 org.jonblack.bluetrack.adapters;
/*from  w  w w .  ja  va2 s.c  o  m*/
import org.jonblack.bluetrack.BluetoothClassLookup;
import org.jonblack.bluetrack.R;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class DeviceCursorAdapter extends CursorAdapter
{
  public DeviceCursorAdapter(Context context, Cursor cursor, int flags)
  {
    super(context, cursor, flags);
  }
  
  @Override
  public void bindView(View view, Context context, Cursor cursor)
  {
    int colIdMajorClass = cursor.getColumnIndexOrThrow("major_class");
    final int majorClass = cursor.getInt(colIdMajorClass);
    int colIdMinorClass = cursor.getColumnIndexOrThrow("minor_class");
    final int minorClass = cursor.getInt(colIdMinorClass);
    
    int classIconId = BluetoothClassLookup.getIconId(majorClass, minorClass);
    
    ImageView ivClass = (ImageView) view.findViewById(R.id.device_row_class);
    ivClass.setImageResource(classIconId);
    
    TextView tvMac = (TextView) view.findViewById(R.id.device_row_mac);
    int idMac = cursor.getColumnIndexOrThrow("mac_address");
    tvMac.setText(cursor.getString(idMac));
    
    TextView tvName = (TextView) view.findViewById(R.id.device_row_name);
    int idName = cursor.getColumnIndexOrThrow("name");
    tvName.setText(cursor.getString(idName));
  }

  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent)
  {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View view = inflater.inflate(R.layout.device_list_row, parent,
                                       false);
    
    return view;
  }
}




Java Source Code List

org.jonblack.bluetrack.BluetoothClassLookup.java
org.jonblack.bluetrack.BluetrackIdentifiers.java
org.jonblack.bluetrack.DeviceDiscovery.java
org.jonblack.bluetrack.Device.java
org.jonblack.bluetrack.Session.java
org.jonblack.bluetrack.activities.DevicesFragment.java
org.jonblack.bluetrack.activities.LiveTrackingFragment.java
org.jonblack.bluetrack.activities.MainActivity.java
org.jonblack.bluetrack.activities.SessionFragment.java
org.jonblack.bluetrack.activities.SettingsActivity.java
org.jonblack.bluetrack.adapters.DeviceCursorAdapter.java
org.jonblack.bluetrack.adapters.LiveTrackingCursorAdapter.java
org.jonblack.bluetrack.adapters.SessionCursorAdapter.java
org.jonblack.bluetrack.services.BluetoothLogService.java
org.jonblack.bluetrack.storage.BluetrackContentProvider.java
org.jonblack.bluetrack.storage.BluetrackOpenHelper.java
org.jonblack.bluetrack.storage.DeviceDiscoveryTable.java
org.jonblack.bluetrack.storage.DeviceTable.java
org.jonblack.bluetrack.storage.SessionTable.java