mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Created Conversation Message object
This commit is contained in:
parent
5343372f21
commit
e30b3ea988
@ -55,7 +55,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -15,7 +15,7 @@ public final class DatabaseContract {
|
||||
public DatabaseContract(){}
|
||||
|
||||
/* Database basic information */
|
||||
static final int DATABASE_VERSION = 3;
|
||||
static final int DATABASE_VERSION = 4;
|
||||
static final String DATABASE_NAME = "database.db";
|
||||
|
||||
/* Users info table */
|
||||
@ -53,4 +53,16 @@ public final class DatabaseContract {
|
||||
public static final String COLUMN_NAME_CONVERSATION_MEMBERS = "members";
|
||||
}
|
||||
|
||||
/* Conversations messages table */
|
||||
public static abstract class ConversationsMessagesSchema implements BaseColumns {
|
||||
public static final String TABLE_NAME = "conversation_messages";
|
||||
|
||||
public static final String COLUMN_NAME_MESSAGE_ID = "message_id";
|
||||
public static final String COLUMN_NAME_CONVERSATION_ID = "conversation_id";
|
||||
public static final String COLUMN_NAME_USER_ID = "user_id";
|
||||
public static final String COLUMN_NAME_IMAGE_PATH = "image_path";
|
||||
public static final String COLUMN_NAME_MESSAGE = "message";
|
||||
public static final String COLUMN_NAME_TIME_INSERT = "time_insert";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseContract.FriendsListSchema;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseContract.UsersInfoSchema;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseContract.ConversationsListSchema;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseContract.ConversationsMessagesSchema;
|
||||
|
||||
/**
|
||||
* Database helper. This file handles the creation / upgrade of the local database
|
||||
@ -75,6 +76,24 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
ConversationsListSchema.TABLE_NAME;
|
||||
|
||||
|
||||
/**
|
||||
* Creation and deletion of the conversation messages table
|
||||
*/
|
||||
private static final String SQL_CREATE_CONVERSATION_MESSAGES_TABLE =
|
||||
"CREATE TABLE " + ConversationsMessagesSchema.TABLE_NAME + " (" +
|
||||
ConversationsMessagesSchema._ID + " INTEGER PRIMARY KEY," +
|
||||
ConversationsMessagesSchema.COLUMN_NAME_MESSAGE_ID + INTEGER_TYPE + COMMA_SEP +
|
||||
ConversationsMessagesSchema.COLUMN_NAME_CONVERSATION_ID + INTEGER_TYPE + COMMA_SEP +
|
||||
ConversationsMessagesSchema.COLUMN_NAME_USER_ID + INTEGER_TYPE + COMMA_SEP +
|
||||
ConversationsMessagesSchema.COLUMN_NAME_IMAGE_PATH + TEXT_TYPE + COMMA_SEP +
|
||||
ConversationsMessagesSchema.COLUMN_NAME_MESSAGE + TEXT_TYPE + COMMA_SEP +
|
||||
ConversationsMessagesSchema.COLUMN_NAME_TIME_INSERT + INTEGER_TYPE +
|
||||
" )";
|
||||
|
||||
private static final String SQL_DELETE_CONVERSATION_MESSAGES_TABLE = "DROP TABLE IF EXISTS " +
|
||||
ConversationsMessagesSchema.TABLE_NAME;
|
||||
|
||||
|
||||
/**
|
||||
* Public constructor
|
||||
* @param context The context where the database is used
|
||||
@ -98,6 +117,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
//Create conversations list table
|
||||
db.execSQL(SQL_CREATE_CONVERSATIONS_LIST_TABLE);
|
||||
|
||||
//Create messages list table
|
||||
db.execSQL(SQL_CREATE_CONVERSATION_MESSAGES_TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,6 +136,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
//Delete conversations list table
|
||||
db.execSQL(SQL_DELETE_CONVERSATIONS_LIST_TABLE);
|
||||
|
||||
//Delete conversations messages table
|
||||
db.execSQL(SQL_DELETE_CONVERSATION_MESSAGES_TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,137 @@
|
||||
package org.communiquons.android.comunic.client.data.conversations;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Conversation content object
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
* Created by pierre on 12/16/17.
|
||||
*/
|
||||
|
||||
public class ConversationMessage {
|
||||
|
||||
/**
|
||||
* Message values
|
||||
*/
|
||||
private int id;
|
||||
private int conversation_id;
|
||||
private int user_id;
|
||||
private String image_path = null;
|
||||
private String content;
|
||||
private int time_insert;
|
||||
|
||||
/**
|
||||
* Set the ID of a content
|
||||
*
|
||||
* @param id The id of the content
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content ID
|
||||
*
|
||||
* @return The ID of the content
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ID of the conversation attached to the content
|
||||
*
|
||||
* @param conversation_id The ID of the conversation
|
||||
*/
|
||||
public void setConversation_id(int conversation_id) {
|
||||
this.conversation_id = conversation_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the conversation ID attached to a content
|
||||
*
|
||||
* @return The ID of the conversation
|
||||
*/
|
||||
public int getConversation_id() {
|
||||
return conversation_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ID of the user who posted the content
|
||||
*
|
||||
* @param user_id The ID of the user
|
||||
*/
|
||||
public void setUser_id(int user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of the user who posted the content
|
||||
*
|
||||
* @return The ID of the user who posted the content
|
||||
*/
|
||||
public int getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path of the image associated to the content
|
||||
*
|
||||
* @param image_path The path of the image
|
||||
*/
|
||||
public void setImage_path(String image_path) {
|
||||
if(image_path != null && !Objects.equals(image_path, "null"))
|
||||
this.image_path = image_path;
|
||||
else
|
||||
this.image_path = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the image associated with the content
|
||||
*
|
||||
* @return The path of the image
|
||||
*/
|
||||
@Nullable
|
||||
public String getImage_path() {
|
||||
return image_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content of the message
|
||||
*
|
||||
* @param content The content of the content
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the message
|
||||
*
|
||||
* @return The content
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image of insertion of the message
|
||||
*
|
||||
* @param time_insert The time of insertion of the message
|
||||
*/
|
||||
public void setTime_insert(int time_insert) {
|
||||
this.time_insert = time_insert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time of insertion of the message
|
||||
*
|
||||
* @return The time of insertion of the message
|
||||
*/
|
||||
public int getTime_insert() {
|
||||
return time_insert;
|
||||
}
|
||||
}
|
@ -31,14 +31,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Error message -->
|
||||
<!-- Error content -->
|
||||
<TextView
|
||||
android:id="@+id/login_error_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FF2222"
|
||||
tools:text="Error message"
|
||||
tools:text="Error content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<!-- Email field -->
|
||||
|
Loading…
Reference in New Issue
Block a user