Реализация отправки фото в чате wifi-direct

343
27 января 2017, 05:34

Необходимо реализовать передачу фото в чате посредством wi-fi direct, как использовать камеру мне понятно, но ничего не получается с самой передачей, нашел на гитхабе Реализация передачи фото, но не могу прикрутить это к своему коду, если кто поможет разобраться, буду очень признателен, всем заранее спасибо!

public class ChatAdapter extends BaseAdapter{ 
    public static Bitmap bitmap; 
    private HashMap<String,Bitmap> mapThumb; 
  
    private Context mContext; 
    private ArrayList<ChatMessage> mMessages; 
    private HashMap<String, Integer> mColorsForUsers; 
    private int[] mColors = null; 
    private final int NUM_OF_COLORS = 16; 
  
  
    public ChatAdapter(Context context, ArrayList<ChatMessage> messages) { 
  
        super(); 
        this.mContext = context; 
        this.mMessages = messages; 
        this.mColorsForUsers = new HashMap<String, Integer>(); 
        mapThumb = new HashMap<String, Bitmap>(); 
  
  
  
        mColors = new int[NUM_OF_COLORS]; 
        int i=0; 
        mColors[i++]=R.color.AntiqueWhite; 
        mColors[i++]=R.color.Cyan; 
        mColors[i++]=R.color.DarkGray; 
        mColors[i++]=R.color.Blue; 
        mColors[i++]=R.color.Yellow; 
        mColors[i++]=R.color.Azure; 
        mColors[i++]=R.color.Lavender; 
        mColors[i++]=R.color.Magenta; 
        mColors[i++]=R.color.Gold; 
        mColors[i++]=R.color.Black; 
        mColors[i++]=R.color.Green; 
        mColors[i++]=R.color.Gray; 
        mColors[i++]=R.color.BlanchedAlmond; 
        mColors[i++]=R.color.MediumTurquoise; 
        mColors[i++]=R.color.PaleGoldenrod; 
        mColors[i++]=R.color.Silver; 
    } 
  
  
  
    @Override 
    public int getCount() {return mMessages.size();} 
  
    @Override 
    public Object getItem(int position) {return mMessages.get(position);} 
     
  
     
  
    @SuppressLint("ResourceAsColor") 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
  
        View view = convertView; 
  
         
        ChatMessage message = (ChatMessage) this.getItem(position); 
        int msgColor; 
  
        ViewHolder holder; 
        if(convertView == null) 
        { 
            holder = new ViewHolder(); 
  
            holder.image = (ImageView) view.findViewById(R.id.image); 
  
  
            convertView = LayoutInflater.from(mContext).inflate(R.layout.chat_activity_list_item, parent, false); //get the xml layout 
            holder.mMessage = (TextView) convertView.findViewById(R.id.message_text); 
            holder.mTimeAndUserName =(TextView) convertView.findViewById(R.id.message_time_and_userName); 
  
            convertView.setTag(holder); 
        } 
        else 
            holder = (ViewHolder) convertView.getTag(); 
  
        holder.mMessage.setText(message.getMessage()); 
        holder.mTimeAndUserName.setText("   "+message.getTime()+"  "+message.getUserName()+"   "); 
  
        holder.mTimeAndUserName.setTextColor(R.color.textFieldColor); 
        holder.mTimeAndUserName.setTextSize(14); 
  
        LayoutParams lp = (LayoutParams) holder.mMessage.getLayoutParams(); 
        LayoutParams lp2 = (LayoutParams) holder.mTimeAndUserName.getLayoutParams(); 
  
        if(message.isMine()) 
        { 
            holder.mMessage.setBackgroundResource(R.drawable.speech_bubble_green); 
            lp.gravity = Gravity.RIGHT; 
            lp2.gravity = Gravity.RIGHT; 
            holder.mMessage.setTextColor(mContext.getResources().getColor(R.color.Black)); 
        } 
  
        else 
        { 
            holder.mMessage.setBackgroundResource(R.drawable.speech_bubble_orange); 
  
            msgColor = getColorForUser(message.mUserUnique); 
  
            holder.mMessage.setTextColor(mContext.getResources().getColor(msgColor)); 
  
            lp.gravity = Gravity.LEFT; 
            lp2.gravity = Gravity.LEFT; 
  
        } 
        holder.mMessage.setLayoutParams(lp); 
  
  
        holder.mTimeAndUserName.setLayoutParams(lp2); 
  
        return convertView; 
    }

READ ALSO
Как получить ответ из POST запроса

Как получить ответ из POST запроса

Как получить ответ из POST запроса, заранее спасибо Вызов в мэйне:

614
Экземпляр обобщенного класса

Экземпляр обобщенного класса

Компилятор вообще не создает экземпляры обобщенного класса или компилятор не создает более одного экземпляра обобщенного класса?

381
Недостаточная точность типа double

Недостаточная точность типа double

У меня есть метод для деления многочленов с остаткомОн хорошо работает для многочленов, коэффициенты которых делятся точно

437
Как сделать из rectangle кнопку?

Как сделать из rectangle кнопку?

Делаю игру точки, есть rectangle dot(сама точка), хочу сделать, что бы при нажатии на ту или иную кнопку, dot меня свой цвет на красный/синий, но когда...

343