use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.
the class MainActivity method onNavigationDrawerItemSelected.
@Override
public void onNavigationDrawerItemSelected(int position) {
if (position == 1) {
Intent intent = new Intent(this, ConversationActivity.class);
if (ApplozicClient.getInstance(this).isContextBasedChat()) {
intent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
}
startActivity(intent);
return;
}
/*
if (position == 1) {
ConversationFragment conversationFragment = new ConversationFragment();
Contact contact = new Contact(this, "mobicomkit");
mTitle = getString(R.string.user_id);
addFragment(this, conversationFragment, "conversationFragment");
conversationFragment.loadConversation(contact);
return;
}*/
if (position == 0) {
mTitle = getString(R.string.ecommerce);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, EcommerceFragment.newInstance("", "")).commit();
return;
}
if (position == 2) {
UserLogoutTask.TaskListener userLogoutTaskListener = new UserLogoutTask.TaskListener() {
@Override
public void onSuccess(Context context) {
userLogoutTask = null;
Toast.makeText(getBaseContext(), getBaseContext().getString(R.string.log_out_successful), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
finish();
}
@Override
public void onFailure(Exception exception) {
userLogoutTask = null;
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle(getString(R.string.text_alert));
alertDialog.setMessage(exception.toString());
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok_alert), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
if (!isFinishing()) {
alertDialog.show();
}
}
};
userLogoutTask = new UserLogoutTask(userLogoutTaskListener, this);
userLogoutTask.execute((Void) null);
}
if (position == 3) {
Map<String, String> messageMetaData = new HashMap<>();
messageMetaData.put(Message.MetaDataType.KEY.getValue(), Message.MetaDataType.HIDDEN.getValue());
Message message = new Message();
MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(MainActivity.this);
message.setContactIds("android");
message.setTo("android");
message.setContentType(Message.ContentType.CUSTOM.getValue());
message.setMessage("this is meta data hidden");
message.setMetadata(messageMetaData);
message.setStoreOnDevice(Boolean.TRUE);
message.setRead(Boolean.TRUE);
message.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
message.setSendToDevice(Boolean.FALSE);
message.setType(Message.MessageType.MT_OUTBOX.getValue());
message.setDeviceKeyString(userPreferences.getDeviceKeyString());
message.setSource(Message.Source.MT_MOBILE_APP.getValue());
new MobiComConversationService(MainActivity.this).sendMessage(message, MessageIntentService.class);
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position + 1)).commit();
}
use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.
the class ChannelService method processChannelDeleteConversation.
public synchronized String processChannelDeleteConversation(Channel channel, Context context) {
String response = new MobiComConversationService(context).deleteSync(null, channel, null);
if (!TextUtils.isEmpty(response) && "success".equals(response)) {
channelDatabaseService.deleteChannelUserMappers(channel.getKey());
channelDatabaseService.deleteChannel(channel.getKey());
}
return response;
}
use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.
the class VideoCallNotificationHelper method init.
public void init() {
this.conversationService = new MobiComConversationService(context);
this.baseContactService = new AppContactService(context);
}
use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.
the class UserIntentService method onCreate.
@Override
public void onCreate() {
super.onCreate();
messageClientService = new MessageClientService(getApplicationContext());
mobiComConversationService = new MobiComConversationService(getApplicationContext());
}
use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.
the class ScheduleMessageService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
Calendar c = Calendar.getInstance();
long time = c.getTimeInMillis();
MessageDatabaseService messageDatabaseService = new MessageDatabaseService(getApplicationContext());
MobiComConversationService conversationService = new MobiComConversationService(getApplicationContext());
List<Message> messages = messageDatabaseService.getScheduledMessages(time);
for (Message message : messages) {
message.setScheduledAt(null);
conversationService.sendMessage(message, MessageIntentService.class);
// Todo: broadcast for scheduled message fragment.
}
messageDatabaseService.deleteScheduledMessages(time);
}
Aggregations