Search in sources :

Example 6 with Conversation

use of com.applozic.mobicommons.people.channel.Conversation in project Applozic-Android-SDK by AppLozic.

the class ConversationDatabaseService method getConversationByConversationId.

// Cleanup: default
public Conversation getConversationByConversationId(final Integer conversationId) {
    Conversation conversation = null;
    SQLiteDatabase database = dbHelper.getReadableDatabase();
    String conversationParameters = "";
    List<String> structuredNameParamsList = new ArrayList<>();
    conversationParameters += "key = ? ";
    structuredNameParamsList.add(String.valueOf(conversationId));
    Cursor cursor = database.query(MobiComDatabaseHelper.CONVERSATION, null, conversationParameters, structuredNameParamsList.toArray(new String[structuredNameParamsList.size()]), null, null, null);
    if (cursor.moveToFirst()) {
        conversation = getConversation(cursor);
        cursor.close();
    }
    dbHelper.close();
    return conversation;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Conversation(com.applozic.mobicommons.people.channel.Conversation) Cursor(android.database.Cursor)

Example 7 with Conversation

use of com.applozic.mobicommons.people.channel.Conversation in project Applozic-Android-SDK by AppLozic.

the class ConversationDatabaseService method getConversation.

// Cleanup: private
public static Conversation getConversation(Cursor cursor) {
    Conversation conversation = new Conversation();
    conversation.setId(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.KEY)));
    conversation.setGroupId(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_KEY)));
    String topicId = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_ID));
    if (!TextUtils.isEmpty(topicId)) {
        conversation.setTopicId(topicId);
    }
    String topicDetail = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_DETAIL));
    if (!TextUtils.isEmpty(topicDetail)) {
        conversation.setTopicDetail(topicDetail);
    }
    String userId = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.USERID));
    if (!TextUtils.isEmpty(userId)) {
        conversation.setUserId(userId);
    }
    conversation.setTopicLocalImageUri(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_LOCAL_IMAGE_URL)));
    return conversation;
}
Also used : Conversation(com.applozic.mobicommons.people.channel.Conversation)

Example 8 with Conversation

use of com.applozic.mobicommons.people.channel.Conversation in project Applozic-Android-SDK by AppLozic.

the class ConversationDatabaseService method isConversationExit.

// Cleanup: default
public Integer isConversationExit(String userId, String topicId) {
    Conversation conversation = null;
    SQLiteDatabase database = dbHelper.getReadableDatabase();
    String conversationParameters = "";
    List<String> structuredNameParamsList = new ArrayList<>();
    conversationParameters += "userId = ? ";
    structuredNameParamsList.add(userId);
    conversationParameters += " and topicId = ? ";
    structuredNameParamsList.add(topicId);
    Cursor cursor = database.query(MobiComDatabaseHelper.CONVERSATION, null, conversationParameters, structuredNameParamsList.toArray(new String[structuredNameParamsList.size()]), null, null, null);
    if (cursor.moveToFirst()) {
        conversation = getConversation(cursor);
        cursor.close();
        return conversation.getId();
    }
    if (cursor != null) {
        cursor.close();
    }
    return null;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Conversation(com.applozic.mobicommons.people.channel.Conversation) Cursor(android.database.Cursor)

Example 9 with Conversation

use of com.applozic.mobicommons.people.channel.Conversation in project Applozic-Android-SDK by AppLozic.

the class ConversationDatabaseService method getConversationByTopicId.

// Cleanup: private
public Conversation getConversationByTopicId(final String topicId, Context context) {
    if (TextUtils.isEmpty(topicId)) {
        return null;
    }
    Conversation conversation = null;
    SQLiteDatabase database = MobiComDatabaseHelper.getInstance(context).getReadableDatabase();
    String conversationParameters = "";
    List<String> structuredNameParamsList = new ArrayList<>();
    conversationParameters += MobiComDatabaseHelper.TOPIC_ID + "= ? ";
    structuredNameParamsList.add(topicId);
    Cursor cursor = database.query(MobiComDatabaseHelper.CONVERSATION, null, conversationParameters, structuredNameParamsList.toArray(new String[structuredNameParamsList.size()]), null, null, null);
    if (cursor.moveToFirst()) {
        conversation = getConversation(cursor);
    }
    if (cursor != null) {
        cursor.close();
    }
    dbHelper.close();
    return conversation;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Conversation(com.applozic.mobicommons.people.channel.Conversation) Cursor(android.database.Cursor)

Example 10 with Conversation

use of com.applozic.mobicommons.people.channel.Conversation in project Applozic-Android-SDK by AppLozic.

the class ConversationClientService method getConversation.

// Cleanup: default
public Conversation getConversation(Integer conversationId) {
    String response = "";
    try {
        if (conversationId != null) {
            response = httpRequestUtils.getResponse(getConversationUrl() + "?id=" + String.valueOf(conversationId), "application/json", "application/json");
            ConversationFeed apiResponse = (ConversationFeed) GsonUtils.getObjectFromJson(response, ConversationFeed.class);
            Utils.printLog(context, TAG, "Conversation response  is :" + response);
            if (apiResponse != null && apiResponse.isSuccess()) {
                return (Conversation) apiResponse.getResponse();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ConversationFeed(com.applozic.mobicomkit.feed.ConversationFeed) Conversation(com.applozic.mobicommons.people.channel.Conversation)

Aggregations

Conversation (com.applozic.mobicommons.people.channel.Conversation)14 ArrayList (java.util.ArrayList)6 Intent (android.content.Intent)5 Cursor (android.database.Cursor)4 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 Channel (com.applozic.mobicommons.people.channel.Channel)4 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)3 TopicDetail (com.applozic.mobicomkit.feed.TopicDetail)3 Contact (com.applozic.mobicommons.people.contact.Contact)3 Context (android.content.Context)2 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)2 UserDetail (com.applozic.mobicomkit.api.account.user.UserDetail)2 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)2 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)2 Configuration (android.content.res.Configuration)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 Bundle (android.os.Bundle)1 CountDownTimer (android.os.CountDownTimer)1 ResultReceiver (android.os.ResultReceiver)1 Editable (android.text.Editable)1