mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-25 16:32:19 +00:00
Made making message timestamp
This commit is contained in:
parent
18c06d1b5a
commit
b0b4a0fc33
@ -4,6 +4,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import net.tomp2p.peers.PeerAddress;
|
import net.tomp2p.peers.PeerAddress;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.github.chronosx88.influence.models.roomEntities.ChatEntity;
|
import io.github.chronosx88.influence.models.roomEntities.ChatEntity;
|
||||||
@ -30,14 +31,21 @@ public class LocalDBWrapper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creating a message entry in the local database
|
||||||
|
* @param type Message type
|
||||||
|
* @param chatID ID of the chat in which need to create a message
|
||||||
|
* @param sender Message sender (username)
|
||||||
|
* @param text Message text (or technical info if technical message type)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static boolean createMessageEntry(int type, String chatID, String sender, String text) {
|
public static boolean createMessageEntry(int type, String chatID, String sender, String text) {
|
||||||
List<ChatEntity> chatEntities = AppHelper.getChatDB().chatDao().getChatByChatID(chatID);
|
List<ChatEntity> chatEntities = AppHelper.getChatDB().chatDao().getChatByChatID(chatID);
|
||||||
if(chatEntities.size() < 1) {
|
if(chatEntities.size() < 1) {
|
||||||
Log.e(LOG_TAG, "Failed to create message entry because chat " + chatID + " doesn't exists!");
|
Log.e(LOG_TAG, "Failed to create message entry because chat " + chatID + " doesn't exists!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO: Make message timestamp
|
dbInstance.messageDao().insertMessage(new MessageEntity(type, chatID, sender, new Date().getTime(), text));
|
||||||
dbInstance.messageDao().insertMessage(new MessageEntity(type, chatID, sender, "", text));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ public class MessageEntity {
|
|||||||
@ColumnInfo public int type;
|
@ColumnInfo public int type;
|
||||||
@ColumnInfo public String chatID;
|
@ColumnInfo public String chatID;
|
||||||
@ColumnInfo public String sender;
|
@ColumnInfo public String sender;
|
||||||
@ColumnInfo public String timestamp;
|
@ColumnInfo public long timestamp;
|
||||||
@ColumnInfo public String text;
|
@ColumnInfo public String text;
|
||||||
|
|
||||||
public MessageEntity(int type, String chatID, String sender, String timestamp, String text) {
|
public MessageEntity(int type, String chatID, String sender, long timestamp, String text) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.chatID = chatID;
|
this.chatID = chatID;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
@ -32,7 +32,7 @@ public class MessageEntity {
|
|||||||
return chatID;
|
return chatID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimestamp() {
|
public long getTimestamp() {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user