Android Open Source - geocamTalkAndroid Geo Cam Talk Message Adapter






From Project

Back to project page geocamTalkAndroid.

License

The source code is released under:

NASA OPEN SOURCE AGREEMENT VERSION 1.3 THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORI...

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

// __BEGIN_LICENSE__
// Copyright (C) 2008-2010 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__
//from  ww w.j a  va  2  s.com
package gov.nasa.arc.geocam.talk.activity;

import gov.nasa.arc.geocam.talk.R;
import gov.nasa.arc.geocam.talk.UIUtils;
import gov.nasa.arc.geocam.talk.bean.GeoCamTalkMessage;
import gov.nasa.arc.geocam.talk.service.IAudioPlayer;
import gov.nasa.arc.geocam.talk.service.ISiteAuth;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import roboguice.adapter.IterableAdapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.inject.Inject;

// TODO: Auto-generated Javadoc
/**
 * The Class GeoCamTalkMessageAdapter.
 */
public class GeoCamTalkMessageAdapter extends IterableAdapter<GeoCamTalkMessage> {

  /** The m inflater. */
  @Inject
  LayoutInflater mInflater;

  /** The player. */
  @Inject
  IAudioPlayer player;
  
  /** The site auth. */
  @Inject
  ISiteAuth siteAuth;
  
  /**
   * Instantiates a new geo cam talk message adapter.
   *
   * @param context the context
   */
  @Inject
  public GeoCamTalkMessageAdapter(Context context) {
    super(context, R.layout.list_item);
  }

  /**
   * Sets the talk messages.
   *
   * @param talkMessages the new talk messages
   */
  public void setTalkMessages(List<GeoCamTalkMessage> talkMessages) {
    this.clear();
    for (GeoCamTalkMessage m : talkMessages) {
      add(m);
    }
  }

  /**
   * Gets the talk message.
   *
   * @param position the position
   * @return the talk message
   */
  public GeoCamTalkMessage getTalkMessage(int position) {
    GeoCamTalkMessage msg = getItem(position);
    return msg;
  }

  /* (non-Javadoc)
   * @see android.widget.ArrayAdapter#getView(int, android.view.View, android.view.ViewGroup)
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row;

    if (null == convertView) {
      row = mInflater.inflate(R.layout.list_item, null);
    } else {
      row = convertView;
    }

    TextView contentTextView = (TextView) row.findViewById(R.id.content);
    TextView fullnameTextView = (TextView) row.findViewById(R.id.fullname);
    TextView contentTimestampTextView = (TextView) row.findViewById(R.id.content_timestamp);
    ImageView geolocationImageView = (ImageView) row.findViewById(R.id.hasGeoLocation);
    ImageButton audioImageButton = (ImageButton) row.findViewById(R.id.hasAudio);
    
    audioImageButton.setSelected(false);                                                                                                                                                   
    audioImageButton.setFocusable(false);
                
    GeoCamTalkMessage msg = getItem(position);

    contentTextView.setText(msg.getContent());
    fullnameTextView.setText(msg.getAuthorFullname());
    
    Date contentTimestamp = msg.getContentTimestampDate();

    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
    contentTimestampTextView.setText(sdf.format(contentTimestamp));

    if (msg.hasGeolocation()) {
      geolocationImageView.setVisibility(View.VISIBLE);
    } else {
      geolocationImageView.setVisibility(View.INVISIBLE);
    }
    if (msg.hasAudio()) {
      audioImageButton.setVisibility(View.VISIBLE);
    } else {
      audioImageButton.setVisibility(View.GONE);
    }
    audioImageButton.setTag(msg);
    
    row.setTag(msg);
    row.setOnClickListener(new OnClickListener(){
      @Override
      public void onClick(View v) {
        GeoCamTalkMessage msg = (GeoCamTalkMessage)v.getTag();        
        if (msg.hasGeolocation()) {
          UIUtils.showMapView(v.getContext(), msg);
        }        
      }      
    });
    
    return row;
  }
}




Java Source Code List

gov.nasa.arc.geocam.talk.GeoCamTalkModule.java
gov.nasa.arc.geocam.talk.GeoCamTalkRoboApplication.java
gov.nasa.arc.geocam.talk.UIUtils.java
gov.nasa.arc.geocam.talk.activity.AuthenticatedBaseActivity.java
gov.nasa.arc.geocam.talk.activity.GeoCamTalkActivity.java
gov.nasa.arc.geocam.talk.activity.GeoCamTalkCreateActivity.java
gov.nasa.arc.geocam.talk.activity.GeoCamTalkLogon.java
gov.nasa.arc.geocam.talk.activity.GeoCamTalkMapActivity.java
gov.nasa.arc.geocam.talk.activity.GeoCamTalkMessageAdapter.java
gov.nasa.arc.geocam.talk.activity.SettingsActivity.java
gov.nasa.arc.geocam.talk.bean.GeoCamTalkMessage.java
gov.nasa.arc.geocam.talk.bean.ServerResponse.java
gov.nasa.arc.geocam.talk.bean.TalkServerIntent.java
gov.nasa.arc.geocam.talk.exception.AuthenticationFailedException.java
gov.nasa.arc.geocam.talk.service.AudioPlayer.java
gov.nasa.arc.geocam.talk.service.AudioRecorder.java
gov.nasa.arc.geocam.talk.service.C2DMReciever.java
gov.nasa.arc.geocam.talk.service.DatabaseHelper.java
gov.nasa.arc.geocam.talk.service.GeoCamSynchronizationTimerTask.java
gov.nasa.arc.geocam.talk.service.GeoLocationListener.java
gov.nasa.arc.geocam.talk.service.IAudioPlayer.java
gov.nasa.arc.geocam.talk.service.IAudioRecorder.java
gov.nasa.arc.geocam.talk.service.IDatabaseHelper.java
gov.nasa.arc.geocam.talk.service.IGeoCamSynchronizationTimerTask.java
gov.nasa.arc.geocam.talk.service.IIntentHelper.java
gov.nasa.arc.geocam.talk.service.IMessageStore.java
gov.nasa.arc.geocam.talk.service.ISiteAuth.java
gov.nasa.arc.geocam.talk.service.ITalkJsonConverter.java
gov.nasa.arc.geocam.talk.service.ITalkServer.java
gov.nasa.arc.geocam.talk.service.IntentHelper.java
gov.nasa.arc.geocam.talk.service.MessageStore.java
gov.nasa.arc.geocam.talk.service.SiteAuthCookie.java
gov.nasa.arc.geocam.talk.service.TalkJsonConverter.java
gov.nasa.arc.geocam.talk.service.TalkMapOverlay.java
gov.nasa.arc.geocam.talk.service.TalkServer.java