Dieses Feld darf nicht leer sein.
This commit is contained in:
@@ -141,23 +141,31 @@ public class ChatActivity extends ActionBarActivity {
|
||||
@Override
|
||||
public void updateUserInterface(final Packet chatPacket) {
|
||||
try {
|
||||
if(!chatPacket.ChatDataIdentifier.equals(DataIdentifier.MESSAGE)) {
|
||||
return;
|
||||
switch(chatPacket.ChatDataIdentifier) {
|
||||
case MESSAGE:
|
||||
listView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatPacket.writeToLog();
|
||||
|
||||
ChatMessage message = new ChatMessage(chatPacket.SenderPersonOid, chatPacket.RecipientPersonOid, chatPacket.MessageTimeStamp, chatPacket.ChatMessage, false, chatPacket.ServerseitigeOid);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case MESSAGE_RESPONSE:
|
||||
ChatMessage cm = databaseHandler.getChatMessageById(chatPacket.ClientseitigeOid);
|
||||
|
||||
cm.ServerseitigeOid = chatPacket.ServerseitigeOid;
|
||||
|
||||
databaseHandler.updateChatMessage(cm);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
listView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatPacket.writeToLog();
|
||||
|
||||
ChatMessage message = new ChatMessage(chatPacket.SenderPersonOid, chatPacket.RecipientPersonOid, chatPacket.MessageTimeStamp, chatPacket.ChatMessage, false, chatPacket.ServerseitigeOid);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
} catch(Exception pe) {
|
||||
pe.printStackTrace();
|
||||
}
|
||||
@@ -191,7 +199,7 @@ public class ChatActivity extends ActionBarActivity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
packet.writeToLog();
|
||||
|
||||
|
||||
final ChatMessage message = new ChatMessage(packet.SenderPersonOid, packet.RecipientPersonOid, packet.MessageTimeStamp, packet.ChatMessage, false, 0);
|
||||
|
||||
@@ -199,6 +207,8 @@ public class ChatActivity extends ActionBarActivity {
|
||||
|
||||
packet.ClientseitigeOid = Long.valueOf(coid).intValue();
|
||||
|
||||
packet.writeToLog();
|
||||
|
||||
SocketManager.sendMessage(packet);
|
||||
|
||||
listView.post(new Runnable() {
|
||||
@@ -215,6 +225,12 @@ public class ChatActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<Integer> test = databaseHandler.getExistingChatMessageIds();
|
||||
|
||||
for(int id : test) {
|
||||
Log.i("CHATMESSAGE-ID", "" + id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,8 +79,6 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
Log.i("ZEIT_CHECK_DB", getDateTimeString(message.InsTs));
|
||||
|
||||
values.put(KEY_SENDER_PERSON_OID_CHATMESSAGE, message.SenderPersonOid);
|
||||
values.put(KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, message.RecipientPersonOid);
|
||||
values.put(KEY_INSTS_CHATMESSAGE, getDateTimeString(message.InsTs));
|
||||
@@ -89,12 +87,43 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
values.put(KEY_SERVERSEITIGE_OID_CHATMESSAGE, message.ServerseitigeOid);
|
||||
|
||||
long rowId = db.insert(TABLE_CHATMESSAGE, null, values);
|
||||
Log.i("CHAT_MESSAGE_INSERT", "RowID: " + rowId);
|
||||
db.close();
|
||||
|
||||
return rowId;
|
||||
}
|
||||
|
||||
void updateChatMessage(ChatMessage message) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
values.put(KEY_SENDER_PERSON_OID_CHATMESSAGE, message.SenderPersonOid);
|
||||
values.put(KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, message.RecipientPersonOid);
|
||||
values.put(KEY_INSTS_CHATMESSAGE, getDateTimeString(message.InsTs));
|
||||
values.put(KEY_CHAT_TEXT_CHATMESSAGE, message.ChatText);
|
||||
values.put(KEY_IS_DELIVERED_CHATMESSAGE, (message.IsDelivered ? 1 : 0));
|
||||
values.put(KEY_SERVERSEITIGE_OID_CHATMESSAGE, message.ServerseitigeOid);
|
||||
|
||||
db.update(TABLE_CHATMESSAGE, values, KEY_ID_CHATMESSAGE + " = ?", new String[] { String.valueOf(message.Id)});
|
||||
}
|
||||
|
||||
ArrayList<Integer> getExistingChatMessageIds() {
|
||||
ArrayList<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
|
||||
String selectQuery = "SELECT "+ KEY_SERVERSEITIGE_OID_CHATMESSAGE + " FROM " + TABLE_CHATMESSAGE + " WHERE " + KEY_SERVERSEITIGE_OID_CHATMESSAGE + " <> 0";
|
||||
|
||||
Cursor cursor = db.rawQuery(selectQuery, null);
|
||||
|
||||
if(cursor.moveToFirst()) {
|
||||
do {
|
||||
result.add(cursor.getInt(0));
|
||||
} while(cursor.moveToNext());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getDateTimeString(Date date) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);
|
||||
return dateFormat.format(date);
|
||||
|
||||
@@ -52,11 +52,11 @@ public class KontaktChatActivity extends ListActivity {
|
||||
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
|
||||
private DatabaseHandler databaseHandler;
|
||||
|
||||
private ArrayList<Integer> onlinePersonOids = new ArrayList<>();
|
||||
private static ArrayList<Integer> onlinePersonOids = new ArrayList<>();
|
||||
|
||||
private UIHandler kontaktChatUIHandler;
|
||||
|
||||
public ListView listView;
|
||||
public static ListView listView;
|
||||
|
||||
ArrayList<ContactListItem> contactList = new ArrayList<>();
|
||||
|
||||
@@ -195,6 +195,10 @@ public class KontaktChatActivity extends ListActivity {
|
||||
@Override
|
||||
public void onResume() {
|
||||
SocketManager.uiHandler = kontaktChatUIHandler;
|
||||
|
||||
// Update der Kontaktliste
|
||||
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ public enum DataIdentifier {
|
||||
STATUS_NOTIFICATION_LOGOUT(5),
|
||||
OLD_MESSAGE(6),
|
||||
DELIVERING_STATUS_CHANGE(7),
|
||||
STATUS_NOTIFICATION_LOGIN_BROADCAST(8);
|
||||
STATUS_NOTIFICATION_LOGIN_BROADCAST(8),
|
||||
TEAM(9),
|
||||
MESSAGE_RESPONSE(10);
|
||||
|
||||
private final int value;
|
||||
DataIdentifier(int value) {
|
||||
|
||||
Reference in New Issue
Block a user