Android Open Source - daisy_main A P I Message Array Adapter






From Project

Back to project page daisy_main.

License

The source code is released under:

GNU General Public License

If you think the Android project daisy_main 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 de.uvwxy.daisy.nodemap.listobjects;
//from   w ww . j  a  va 2s . c o m
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import de.uvwxy.daisy.nodemap.R;
import de.uvwxy.daisy.nodemap.guicontent.CM;
import de.uvwxy.daisy.nodemap.guiviews.CVXBee;
import de.uvwxy.daisy.proto.Messages.NodeCommunicationData;
import de.uvwxy.daisy.sensornode.SensorNetworkMessageParser;
import de.uvwxy.xbee.apimode.messages.APIMessage;

public class APIMessageArrayAdapter extends ArrayAdapter<APIMessage> {
  @SuppressWarnings("unused")
  private final CVXBee cvXBee;
  private Context context;
  private LayoutInflater inflater;
  private ArrayList<APIMessage> messageList;

  public APIMessageArrayAdapter(CVXBee cvXBee, Context context, List<APIMessage> objects) {
    super(context, R.layout.chat_item_msg, objects);
    this.cvXBee = cvXBee;
    this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.context = context;
    this.messageList = (ArrayList<APIMessage>) objects;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View entry = inflater.inflate(R.layout.chat_item_msg, parent, false);

    TextView tvTimeStamp = (TextView) entry.findViewById(R.id.tvTimeStamp);
    TextView tvMessage = (TextView) entry.findViewById(R.id.tvMessage);
    // ImageView ivIcon = (ImageView) entry.findViewById(R.id.ivIcon);

    final APIMessage msg = messageList.get(position);

    String line1 = "API Message:";
    String line2 = (msg.getMessage() != null ? msg.getMessage() : "[empty]");

    tvMessage.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        Toast.makeText(context, msg.getInfo(), Toast.LENGTH_LONG).show();
      }
    });

    NodeCommunicationData.Builder ncd = SensorNetworkMessageParser.apiMessageToNodeCommunicationData(CM.DAISY, msg);

    if (ncd != null) {
      line2 += "\n" + ncd.buildPartial().toString();
    }

    tvTimeStamp.setText(line1);
    tvMessage.setText(line2);
    tvMessage.setTextSize(10);

    // r = context.getResources();
    // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64,
    // r.getDisplayMetrics());
    // ivIcon.setImageBitmap(ToolBox.createIcon((int)px,(int)px,
    // item.getColor()));

    return entry;
  }

}




Java Source Code List

de.uvwxy.daisy.nodemap.gui.ActivityAnnotation.java
de.uvwxy.daisy.nodemap.gui.ActivityNodeDetails.java
de.uvwxy.daisy.nodemap.gui.DetailActivity.java
de.uvwxy.daisy.nodemap.gui.DetailFragment.java
de.uvwxy.daisy.nodemap.gui.MainListActivity.java
de.uvwxy.daisy.nodemap.gui.MainListFragment.java
de.uvwxy.daisy.nodemap.guicontent.CMARView.java
de.uvwxy.daisy.nodemap.guicontent.CMBalloon.java
de.uvwxy.daisy.nodemap.guicontent.CMLocation.java
de.uvwxy.daisy.nodemap.guicontent.CMLogs.java
de.uvwxy.daisy.nodemap.guicontent.CMMap.java
de.uvwxy.daisy.nodemap.guicontent.CMSensors.java
de.uvwxy.daisy.nodemap.guicontent.CMXBee.java
de.uvwxy.daisy.nodemap.guicontent.CM.java
de.uvwxy.daisy.nodemap.guicontent.IDestroy.java
de.uvwxy.daisy.nodemap.guiviews.CVARView.java
de.uvwxy.daisy.nodemap.guiviews.CVBalloonClient.java
de.uvwxy.daisy.nodemap.guiviews.CVBalloon.java
de.uvwxy.daisy.nodemap.guiviews.CVChat.java
de.uvwxy.daisy.nodemap.guiviews.CVDeploymentData.java
de.uvwxy.daisy.nodemap.guiviews.CVDeployment.java
de.uvwxy.daisy.nodemap.guiviews.CVLogs.java
de.uvwxy.daisy.nodemap.guiviews.CVMap.java
de.uvwxy.daisy.nodemap.guiviews.CVMenuItem.java
de.uvwxy.daisy.nodemap.guiviews.CVParticipantScan.java
de.uvwxy.daisy.nodemap.guiviews.CVXBee.java
de.uvwxy.daisy.nodemap.guiviews.CV.java
de.uvwxy.daisy.nodemap.listobjects.APIMessageArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.CVArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.ChatMessageArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.LogMessageArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.SampleGridViewAdapter.java