use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class StickerDialogFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView stickerRecyclerView = view.findViewById(R.id.rv_stickerDialog);
progressBar = view.findViewById(R.id.fl_stickerDialog_progressContainer);
groupNameTv = view.findViewById(R.id.tv_stickerDialog_groupName);
addOrRemoveTv = view.findViewById(R.id.tv_stickerDialog_add);
previewIv = view.findViewById(R.id.iv_stickerDialog_preview);
stickerCell = view.findViewById(R.id.iv_stickerDialog_lottiePreview);
retryView = view.findViewById(R.id.retryView);
addOrRemoveProgressBar = view.findViewById(R.id.pb_stickerDialog_addOrRemove);
addOrRemoveProgressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
progressBar.getIndeterminateDrawable().setColorFilter(new Theme().getPrimaryDarkColor(getContext()), PorterDuff.Mode.SRC_IN);
stickerRecyclerView.setAdapter(adapter);
stickerCell.setFailureListener(result -> Log.e(TAG, "setFailureListener: ", result));
viewModel.getProgressMutableLiveData().observe(getViewLifecycleOwner(), visibility -> progressBar.setVisibility(visibility));
viewModel.getStickersMutableLiveData().observe(getViewLifecycleOwner(), structIGStickerGroup -> {
if (!stickerGroup.hasData())
stickerGroup = structIGStickerGroup;
adapter.setIgStickers(structIGStickerGroup.getStickers());
groupNameTv.setText(structIGStickerGroup.getName());
});
viewModel.getAddOrRemoveStickerLiveData().observe(getViewLifecycleOwner(), resourceId -> {
addOrRemoveTv.setText(getResources().getString(resourceId, HelperCalander.isPersianUnicode ? HelperCalander.convertToUnicodeFarsiNumber(String.valueOf(stickerGroup.getStickersSize())) : String.valueOf(stickerGroup.getStickersSize())));
addOrRemoveTv.setVisibility(View.VISIBLE);
});
adapter.setListener(new StickerAdapter.AddStickerDialogListener() {
@Override
public void onStickerClick(StructIGSticker structIGSticker) {
viewModel.onStickerInListModeClick(structIGSticker);
}
@Override
public void onStickerLongClick(StructIGSticker structIGSticker) {
}
});
viewModel.getOpenPreviewViewLiveData().observe(getViewLifecycleOwner(), structIGSticker -> {
// TODO: 12/8/19 must create custom dialog for add just once view for handle stickers view type
if (structIGSticker != null && previewIv.getVisibility() == View.GONE) {
if (structIGSticker.getType() == StructIGSticker.ANIMATED_STICKER) {
stickerCell.playAnimation(structIGSticker.getPath());
stickerCell.animate().alpha(1.0f).setDuration(100).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
stickerCell.setVisibility(View.VISIBLE);
}
});
} else if (structIGSticker.getType() == StructIGSticker.NORMAL_STICKER) {
if (getContext() != null)
Glide.with(getContext()).load(structIGSticker.getPath()).into(previewIv);
previewIv.animate().alpha(1.0f).setDuration(100).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
previewIv.setVisibility(View.VISIBLE);
}
});
}
if (readOnlyChat) {
addOrRemoveTv.setVisibility(View.GONE);
} else {
addOrRemoveTv.setText(getResources().getString(R.string.send));
addOrRemoveTv.setVisibility(View.VISIBLE);
}
} else if (previewIv.getVisibility() == View.VISIBLE) {
previewIv.animate().alpha(0.0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
previewIv.setVisibility(View.GONE);
}
});
} else if (stickerCell.getVisibility() == View.VISIBLE) {
stickerCell.animate().alpha(0.0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
stickerCell.setVisibility(View.GONE);
}
});
}
});
viewModel.getSendMessageLiveData().observe(getViewLifecycleOwner(), structIGSticker -> {
if (listener != null) {
listener.sendMessage(structIGSticker);
dismiss();
}
});
viewModel.getAddOrRemoveProgressLiveData().observe(getViewLifecycleOwner(), visibility -> addOrRemoveProgressBar.setVisibility(visibility));
viewModel.getRetryViewLiveData().observe(getViewLifecycleOwner(), visibility -> retryView.setVisibility(visibility));
previewIv.setOnClickListener(v -> viewModel.onPreviewImageClicked());
stickerCell.setOnClickListener(v -> viewModel.onPreviewImageClicked());
viewModel.getCloseDialogMutableLiveData().observe(getViewLifecycleOwner(), close -> dismiss());
addOrRemoveTv.setOnClickListener(v -> viewModel.onAddOrRemoveStickerClicked());
retryView.setOnClickListener(v -> viewModel.onRetryViewClicked());
viewModel.getSticker();
}
use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class StickerRepository method getStickerByEmoji.
public Flowable<List<StructIGSticker>> getStickerByEmoji(String unicode) {
return DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmStickerItem.class).equalTo("name", unicode).sort("recentTime", Sort.DESCENDING).findAll().asFlowable().filter(RealmResults::isLoaded).map(realmStickers -> {
List<StructIGSticker> stickers = new ArrayList<>();
for (int i = 0; i < realmStickers.size(); i++) {
RealmStickerItem stickerItem = realmStickers.get(i);
if (stickerItem != null) {
StructIGSticker sticker = new StructIGSticker(stickerItem);
stickers.add(sticker);
}
}
return stickers;
});
});
}
use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class StickerRepository method getStickerGroupWithRecentTabForEmojiView.
public Flowable<List<StructIGStickerGroup>> getStickerGroupWithRecentTabForEmojiView() {
return DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmStickerGroup.class).findAllAsync().asFlowable().filter(RealmResults::isLoaded).map(realmStickers -> {
List<StructIGStickerGroup> structIGStickerGroups = new ArrayList<>();
for (int i = 0; i < realmStickers.size(); i++) {
StructIGStickerGroup stickerGroup = new StructIGStickerGroup(realmStickers.get(i));
structIGStickerGroups.add(stickerGroup);
}
return structIGStickerGroups;
}).map(structIGStickerGroups -> {
StructIGStickerGroup stickerGroup = new StructIGStickerGroup(StructIGStickerGroup.RECENT_GROUP);
stickerGroup.setName(G.context.getResources().getString(R.string.recently));
RealmResults<RealmStickerItem> realmStickersDetails = realm.where(RealmStickerItem.class).limit(RECENT_STICKER_LIMIT).notEqualTo("recentTime", 0).sort("recentTime", Sort.DESCENDING).findAll();
List<StructIGSticker> stickers = new ArrayList<>();
for (int i = 0; i < realmStickersDetails.size(); i++) {
RealmStickerItem stickerItem = realmStickersDetails.get(i);
if (stickerItem != null) {
stickers.add(new StructIGSticker(stickerItem));
}
}
stickerGroup.setStickers(stickers);
if (stickers.size() > 0) {
structIGStickerGroups.add(0, stickerGroup);
}
return structIGStickerGroups;
}).map(structIGStickerGroups -> {
StructIGStickerGroup favoriteStickerGroup = new StructIGStickerGroup(StructIGStickerGroup.FAVORITE_GROUP);
favoriteStickerGroup.setName(G.context.getResources().getString(R.string.beeptunesÙ€favorite_song));
RealmResults<RealmStickerItem> stickerItems = realm.where(RealmStickerItem.class).limit(FAVORITE_STICKER_LIMIT).equalTo("isFavorite", true).sort("recentTime", Sort.DESCENDING).findAll();
if (stickerItems != null) {
List<StructIGSticker> stickers = new ArrayList<>();
for (int i = 0; i < stickerItems.size(); i++) {
RealmStickerItem stickerItem = stickerItems.get(i);
if (stickerItem != null) {
stickers.add(new StructIGSticker(stickerItem));
}
}
favoriteStickerGroup.setStickers(stickers);
// boolean hasRecent = structIGStickerGroups.get(0).getGroupId().equals(StructIGStickerGroup.RECENT_GROUP);
// if (stickers.size() > 0) {
// structIGStickerGroups.add(hasRecent ? 1 : 0, favoriteStickerGroup);
// }
}
return structIGStickerGroups;
});
});
}
use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class RealmStickerGroup method getIGGroupStickers.
public List<StructIGSticker> getIGGroupStickers() {
if (getStickerItems() == null || getStickerItems().size() <= 0 || !getStickerItems().isValid())
return new ArrayList<>();
List<StructIGSticker> stickerDetails = new ArrayList<>();
for (RealmStickerItem stickerItem : getStickerItems()) {
StructIGSticker structIGSticker = new StructIGSticker(stickerItem);
stickerDetails.add(structIGSticker);
}
return stickerDetails;
}
use of net.iGap.fragments.emoji.struct.StructIGSticker in project iGap-Android by KianIranian-STDG.
the class FragmentChat method initMain.
private void initMain() {
HelperGetMessageState.clearMessageViews();
initPinedMessage();
viewMicRecorder = rootView.findViewById(R.id.layout_mic_recorde);
prgWaiting = rootView.findViewById(R.id.chl_prgWaiting);
AppUtils.setProgresColler(prgWaiting);
voiceRecord = new VoiceRecord(G.fragmentActivity, viewMicRecorder, viewAttachFile, this);
prgWaiting.setVisibility(View.VISIBLE);
txtEmptyMessages = rootView.findViewById(R.id.empty_messages);
if (isBot) {
txtEmptyMessages.setText(G.fragmentActivity.getResources().getString(R.string.empty_text_dr_bot));
txtChannelMute.setText(R.string.start);
iconChannelMute.setText("");
}
lastDateCalendar.clear();
locationManager = (LocationManager) G.fragmentActivity.getSystemService(LOCATION_SERVICE);
/**
* Hint: don't need to get info here. currently do this action in {{@link #startPageFastInitialize()}}
* Bundle extras = getArguments();
* if (extras != null) {
* mRoomId = extras.getLong("RoomId");
* isGoingFromUserLink = extras.getBoolean("GoingFromUserLink");
* isNotJoin = extras.getBoolean("ISNotJoin");
* userName = extras.getString("UserName");
* messageId = extras.getLong("MessageId");
* }
*/
/**
* get userId . use in chat set action.
*/
RealmUserInfo realmUserInfo = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmUserInfo.class).findFirst();
});
if (realmUserInfo == null) {
// finish();
finishChat();
return;
}
userId = realmUserInfo.getUserId();
managedRoom = getRoom();
if (managedRoom != null) {
// room exist
title = managedRoom.getTitle();
initialize = managedRoom.getInitials();
color = managedRoom.getColor();
isChatReadOnly = managedRoom.getReadOnly();
unreadCount = managedRoom.getUnreadCount();
savedScrollMessageId = managedRoom.getLastScrollPositionMessageId();
savedScrollDocumentId = managedRoom.getLastScrollPositionDocumentId();
firstVisiblePositionOffset = managedRoom.getLastScrollPositionOffset();
if (messageId != 0) {
savedScrollMessageId = messageId;
savedScrollDocumentId = documentId;
firstVisiblePositionOffset = 0;
}
if (chatType == CHAT) {
RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
});
if (realmRegisteredInfo != null) {
initialize = realmRegisteredInfo.getInitials();
color = realmRegisteredInfo.getColor();
phoneNumber = realmRegisteredInfo.getPhoneNumber();
if (realmRegisteredInfo.getId() == Config.drIgapPeerId) {
// if (realmRegisteredInfo.getUsername().equalsIgnoreCase("")) {
initDrBot();
}
} else {
title = managedRoom.getTitle();
initialize = managedRoom.getInitials();
color = managedRoom.getColor();
userStatus = G.fragmentActivity.getResources().getString(R.string.last_seen_recently);
}
} else if (chatType == GROUP) {
RealmGroupRoom realmGroupRoom = managedRoom.getGroupRoom();
groupRole = realmGroupRoom.getRole();
groupParticipantsCountLabel = realmGroupRoom.getParticipantsCountLabel();
} else if (chatType == CHANNEL) {
RealmChannelRoom realmChannelRoom = managedRoom.getChannelRoom();
channelRole = realmChannelRoom.getRole();
channelParticipantsCountLabel = realmChannelRoom.getParticipantsCountLabel();
}
} else {
// chatPeerId = extras.getLong("peerId");
chatType = CHAT;
RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
});
if (realmRegisteredInfo != null) {
title = realmRegisteredInfo.getDisplayName();
initialize = realmRegisteredInfo.getInitials();
color = realmRegisteredInfo.getColor();
lastSeen = realmRegisteredInfo.getLastSeen();
userStatus = realmRegisteredInfo.getStatus();
}
}
initComponent();
initAppbarSelected();
getDraft();
getUserInfo();
insertSharedData();
if (structIGSticker != null) {
G.handler.postDelayed(() -> sendStickerAsMessage(structIGSticker), 1000);
}
RealmRoomMessage rm = null;
RealmResults<RealmRoomMessage> result = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoomMessage.class).equalTo("roomId", mRoomId).findAll();
});
if (result.size() > 0) {
rm = result.last();
if (rm != null && rm.getMessage() != null) {
if (rm.getRealmAdditional() != null && (rm.getRealmAdditional().getAdditionalType() == Additional.WEB_VIEW.getAdditional())) {
String additionalData = rm.getRealmAdditional().getAdditionalData();
if (!additionalData.isEmpty())
openWebViewForSpecialUrlChat(additionalData);
}
}
}
FragmentShearedMedia.goToPositionFromShardMedia = new FragmentShearedMedia.GoToPositionFromShardMedia() {
@Override
public void goToPosition(Long messageId, long documentId) {
if (messageId != 0) {
savedScrollMessageId = messageId;
savedScrollDocumentId = documentId;
firstVisiblePositionOffset = 0;
if (goToPositionWithAnimation(savedScrollMessageId, 2000)) {
savedScrollMessageId = 0;
savedScrollDocumentId = 0;
} else {
RealmRoomMessage rm = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoomMessage.class).equalTo("messageId", messageId).findFirst();
});
rm = RealmRoomMessage.getFinalMessage(rm);
if (rm != null) {
resetMessagingValue();
savedScrollMessageId = FragmentChat.messageId = messageId;
savedScrollDocumentId = FragmentChat.documentId = documentId;
firstVisiblePositionOffset = 0;
getMessages();
}
}
}
}
};
sendChatTracker();
}
Aggregations