Android Open Source - schat Chat Adapter






From Project

Back to project page schat.

License

The source code is released under:

MIT License

If you think the Android project schat 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.data;
/**/*w ww .  j av  a2  s.  co m*/
 * Created with IntelliJ IDEA.
 * User: Wolfram
 * Date: 11.11.13
 * Time: 14:56
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.activities.R;
import data.Message;
import data.contents.ChatContent;

import java.util.ArrayList;

public class ChatAdapter extends ArrayAdapter<Message<ChatContent>> {
    private final Context context;
    private final ArrayList<Message<ChatContent>> messages;
    private final String you;

    public ChatAdapter(Context context, ArrayList<Message<ChatContent>> msg, String you) {
        super(context, R.layout.layout_chathistory_list_you, msg);
        this.context = context;
        this.you = you;
        messages = msg;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Message<ChatContent> currentMessage = messages.get(position);
        //LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView;
        /* todo: change layout names? */
        if (!(currentMessage.getSender().equals(you))) {
            rowView = LayoutInflater.from(context).inflate(R.layout.layout_chathistory_list_you, parent, false);
        } else {
            rowView = LayoutInflater.from(context).inflate(R.layout.layout_chathistory_list_notyou, parent, false);
        }
        TextView msg = (TextView) rowView.findViewById(R.id.msg);
        TextView time = (TextView) rowView.findViewById(R.id.timestamp);
        msg.setText(currentMessage.getContent().getMessage());
        time.setText(currentMessage.getTimestampString());
        return rowView;
    }
}




Java Source Code List

.ServerMain.java
com.activities.Activity_Chat.java
com.activities.Activity_ContactList.java
com.activities.ContactView.java
com.data.AddContact.java
com.data.AndroidSQLManager.java
com.data.ApplicationUser.java
com.data.ChatAdapter.java
com.data.ChatArrayList.java
com.data.MySQLiteHelper.java
com.security.AndroidKeyPairManager.java
com.security.PRNGFixes.java
com.services.MessageService.java
crypto.CryptoConstants.java
crypto.Cryptography.java
crypto.Envelope.java
crypto.SecureMessage.java
crypto.TestCrypto.java
data.ChatMessage.java
data.Content.java
data.DatabaseManager.java
data.KeyPairManager.java
data.Message.java
data.SQLiteManager.java
data.User.java
data.contents.ChatContent.java
data.contents.LoginSuccess.java
data.contents.Login.java
data.contents.PublicKeyRequest.java
data.contents.PublicKeyResponse.java
data.contents.Registration.java
networking.SChatClientListener.java
networking.SChatClientWriter.java
networking.SChatClient.java
networking.SChatServerThread.java
networking.SChatServer.java