SReplyComponent.java :  » UnTagged » snaio » edu » uta » cse » snaio » core » model » post » Android Open Source

Android Open Source » UnTagged » snaio 
snaio » edu » uta » cse » snaio » core » model » post » SReplyComponent.java
/*
Copyright (c) 2010, SNAIO team
All rights reserved.
 */
package edu.uta.cse.snaio.core.model.post;

import android.content.Context;
import android.view.View;
import android.widget.Gallery;
import android.widget.LinearLayout;
import edu.uta.cse.snaio.R;
import edu.uta.cse.snaio.core.Constants;
import edu.uta.cse.snaio.core.SystemEnvironment;
import edu.uta.cse.snaio.core.model.SRequest;
import edu.uta.cse.snaio.core.model.SimpleRequestData;

/**
 * The Class SReplyComponent.
 *
 * @author Tuan Nguyen - tnguyen@mavs.uta.edu
 */
public class SReplyComponent extends LinearLayout {
  
  /** The post. */
  private IPost post;
  
  /**The iconImage **/
  
  protected IconImageView imgData;
  
  /** The reply edit text. */
  private ReplyEditText replyEditText;
  
  /** The reply button. */
  ReplyButton replyButton;

  /**
   * Instantiates a new s reply component.
   *
   * @param context the context
   * @param iPost the i post
   */
  public SReplyComponent(Context context, final IPost iPost) {
    super(context);
    this.setPost(iPost);
    imgData = new IconImageView(context);
    setReplyEditText(new ReplyEditText(context));
    replyButton = new ReplyButton(context);
    
    
    imgData.setImageResource(R.drawable.s1_icon);
    imgData.setAdjustViewBounds(true);
    imgData.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    
    
       addView(imgData);
    addView(getReplyEditText());
    addView(replyButton);
    imgData.setMaxWidth(40);
    imgData.setMaxHeight(40);
    getReplyEditText().setWidth(220);
    setOrientation(LinearLayout.HORIZONTAL);
    replyButton.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        SimpleRequestData data = new SimpleRequestData();
        data.setTransferData(getReplyEditText().getText().toString());
        getReplyEditText().setText(Constants.BLANK);
        data.setPost(post);
        SRequest request = new SRequest(iPost.getPluginType(), data, Constants.REQUEST_MESSAGE_ADD_COMMENT);
        SystemEnvironment.get().addRequest(request);
      }
    });

    // TODO Auto-generated constructor stub
  }

  /**
   * Gets the post.
   *
   * @return the post
   */
  public IPost getPost() {
    return post;
  }

  /**
   * Sets the post.
   *
   * @param post the post to set
   */
  public void setPost(IPost post) {
    this.post = post;
  }

  /**
   * @param replyEditText the replyEditText to set
   */
  public void setReplyEditText(ReplyEditText replyEditText) {
    this.replyEditText = replyEditText;
  }

  /**
   * @return the replyEditText
   */
  public ReplyEditText getReplyEditText() {
    return replyEditText;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.