Android Open Source - checkin Check In List Item






From Project

Back to project page checkin.

License

The source code is released under:

# License Copyright ? 2014 Sam Whited Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ?Software??), to deal ...

If you think the Android project checkin 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.samwhited.checkin;
//from w w w.  jav  a 2s .c  o  m

import android.content.Context;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.samwhited.checkin.database.CheckInOpenHelper;
import com.samwhited.checkin.model.CheckIn;
import com.samwhited.checkin.util.Formatting;

import java.util.Set;

public class CheckInListItem extends RelativeLayout {

  private long              itemId;
  private Set<Long>         selectedItems;
  private TextView          coordinatesView;
  private TextView          dateView;

  public CheckInListItem(final Context context) {
    super(context);
  }

  public CheckInListItem(final Context context, final AttributeSet attrs) {
    super(context, attrs);
  }

  @Override
  protected void onFinishInflate() {
    this.coordinatesView = (TextView) findViewById(R.id.coordinates);
    this.dateView        = (TextView) findViewById(R.id.date);
  }

  public void set(final Cursor cursor, final Set<Long> selectedItems, final boolean batchMode) {
    if (cursor != null) {
      final CheckIn checkIn = new CheckIn(cursor);
      this.itemId = cursor.getLong(cursor.getColumnIndex(CheckInOpenHelper.ID_NAME));
      if (coordinatesView != null && dateView != null) {
        coordinatesView.setText(Formatting.formatCoordinates(getContext(), checkIn.getLocation()));
        dateView.setText(Formatting.formatDateTime(getContext(), checkIn.getTime()));
        // Show an icon by the date view.
        final String icon = checkIn.getIcon();
        if (!icon.isEmpty()
            && !icon.equalsIgnoreCase("none")
            && getContext() != null
            && getResources() != null) {
          dateView.setCompoundDrawablesWithIntrinsicBounds(
              getResources().getIdentifier(icon.replace("-", "_"),
                  "drawable",
                  getContext().getPackageName()), 0, 0, 0);
        } else {
          dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
        }
      }
    }

    if (batchMode && selectedItems.contains(this.itemId)) {
      setBackground();
    }
  }

  public long getItemId() {
    return itemId;
  }

  private void setBackground() {
    if (this.getContext() != null) {
      int[] attributes = new int[]{
          R.attr.list_item_selected_background_color,
      };

      final TypedArray drawables = getContext().obtainStyledAttributes(attributes);
      if (drawables != null) {
        setBackground(drawables.getDrawable(0));
        drawables.recycle();
      }
    }
  }
}




Java Source Code List

com.samwhited.checkin.CheckInActivity.java
com.samwhited.checkin.CheckInDB.java
com.samwhited.checkin.CheckInFragment.java
com.samwhited.checkin.CheckInHandler.java
com.samwhited.checkin.CheckInListAdapter.java
com.samwhited.checkin.CheckInListFragment.java
com.samwhited.checkin.CheckInListItem.java
com.samwhited.checkin.CheckInListLoader.java
com.samwhited.checkin.CheckInList.java
com.samwhited.checkin.CheckInOpenHelper.java
com.samwhited.checkin.IconSpinnerAdapter.java
com.samwhited.checkin.SettingsActivity.java
com.samwhited.checkin.SettingsFragment.java
com.samwhited.checkin.database.CheckInDB.java
com.samwhited.checkin.database.CheckInOpenHelper.java
com.samwhited.checkin.model.CheckIn.java
com.samwhited.checkin.util.CheckInPreferences.java
com.samwhited.checkin.util.Formatting.java
com.samwhited.checkin.util.GeoJSON.java
com.samwhited.checkin.util.NetworkUtils.java