use of net.iGap.module.downloader.Status in project iGap-Android by KianIranian-STDG.
the class StoryCell method setData.
public void setData(MainStoryObject mainStoryObject, String color, Context context, boolean needDivider, CircleStatus status, ImageLoadingView.Status imageLoadingStatus, IconClicked iconClicked) {
this.userId = mainStoryObject.userId;
this.roomId = mainStoryObject.roomId;
this.isVerified = mainStoryObject.isVerified;
initView(context, needDivider, status, imageLoadingStatus, iconClicked, mainStoryObject.storyObjects.get(0).createdAt);
circleImageLoading.setStatus(imageLoadingStatus);
if (userId == AccountManager.getInstance().getCurrentUser().getId()) {
topText.setText(context.getString(R.string.my_status));
} else {
if (roomId != 0) {
channelIconTv.setVisibility(VISIBLE);
}
if (isVerified) {
verifyIconTv.setVisibility(VISIBLE);
}
topText.setText(mainStoryObject.storyObjects.get(0).displayName != null ? mainStoryObject.storyObjects.get(0).displayName : "");
}
String name = HelperImageBackColor.getFirstAlphabetName(mainStoryObject.storyObjects.get(0).displayName != null ? mainStoryObject.storyObjects.get(0).displayName : "");
if (circleImageLoading.getStatus() == ImageLoadingView.Status.FAILED) {
bottomText.setText(context.getString(R.string.story_could_not_sent));
bottomText.setTextColor(Color.RED);
deleteIcon.setTextColor(Color.RED);
addIcon.setTextColor(Color.RED);
addIcon.setText(R.string.icon_error);
} else if (circleImageLoading.getStatus() == ImageLoadingView.Status.LOADING) {
bottomText.setText(context.getString(R.string.story_sending));
deleteIcon.setTextColor(Theme.getInstance().getTitleTextColor(context));
} else {
bottomText.setText(LastSeenTimeUtil.computeTime(context, mainStoryObject.userId, mainStoryObject.storyObjects.get(0).createdAt / 1000L, false, false));
}
AttachmentObject attachment = mainStoryObject.storyObjects.get(0).attachmentObject;
if (status == CircleStatus.LOADING_CIRCLE_IMAGE) {
if (attachment != null && (attachment.thumbnailPath != null || attachment.filePath != null)) {
try {
Glide.with(G.context).load(attachment.filePath != null ? attachment.filePath : attachment.thumbnailPath).placeholder(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
} catch (Exception e) {
Glide.with(G.context).load(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
}
} else if (attachment != null) {
Glide.with(G.context).load(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
DownloadObject object = DownloadObject.createForStory(attachment, storyId, true);
if (object != null) {
Downloader.getInstance(AccountManager.selectedAccount).download(object, arg -> {
if (arg.status == Status.SUCCESS && arg.data != null) {
String filepath = arg.data.getFilePath();
String downloadedFileToken = arg.data.getToken();
if (!(new File(filepath).exists())) {
HelperLog.getInstance().setErrorLog(new Exception("File Dont Exist After Download !!" + filepath));
}
if (arg.data.getDownloadObject().downloadId == storyId) {
DbManager.getInstance().doRealmTransaction(realm1 -> {
RealmStoryProto realmStoryProto = realm1.where(RealmStoryProto.class).equalTo("isForReply", false).equalTo("storyId", storyId).findFirst();
if (realmStoryProto != null) {
realmStoryProto.getFile().setLocalFilePath(filepath);
}
});
G.runOnUiThread(() -> Glide.with(G.context).load(filepath).placeholder(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading));
}
}
});
}
} else {
Glide.with(G.context).load(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
}
}
}
use of net.iGap.module.downloader.Status in project iGap-Android by KianIranian-STDG.
the class FragmentChat method startPageFastInitialize.
/**
* set just important item to view in onCreate and load another objects in onResume
* actions : set app color, load avatar, set background, set title, set status chat or member for group or channel
*/
private void 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");
documentId = extras.getLong("DocumentId");
chatPeerId = extras.getLong("peerId");
}
attachFile = new AttachFile(G.fragmentActivity);
RealmRoom realmRoom = getRoom();
pageSettings();
// avi = (AVLoadingIndicatorView) rootView.findViewById(R.id.avi);
verifiedIcon.setVisibility(View.GONE);
/**
* need this info for load avatar
*/
if (realmRoom != null) {
chatType = realmRoom.getType();
if (chatType == CHAT) {
chatPeerId = realmRoom.getChatRoom().getPeerId();
RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
});
if (realmRegisteredInfo != null) {
title = realmRegisteredInfo.getDisplayName();
lastSeen = realmRegisteredInfo.getLastSeen();
userStatus = realmRegisteredInfo.getStatus();
isBot = realmRegisteredInfo.isBot();
if (isBot) {
if (getMessagesCount() == 0) {
layoutMute.setVisibility(View.VISIBLE);
txtChannelMute.setText(R.string.start);
iconChannelMute.setText("");
View layoutAttach = rootView.findViewById(R.id.layout_attach_file);
layoutAttach.setVisibility(View.GONE);
layoutMute.setOnClickListener(v -> {
if (!isChatReadOnly) {
edtChat.setText("/Start");
imvSendButton.performClick();
removeStartButton();
}
});
isShowStartButton = true;
}
}
if (realmRegisteredInfo.isVerified()) {
verifiedIcon.setVisibility(View.VISIBLE);
}
} else {
/**
* when userStatus isn't EXACTLY lastSeen time not used so don't need
* this time and also this time not exist in room info
*/
title = realmRoom.getTitle();
userStatus = G.fragmentActivity.getResources().getString(R.string.last_seen_recently);
}
} else {
mRoomId = realmRoom.getId();
title = realmRoom.getTitle();
if (chatType == GROUP && realmRoom.getGroupRoom() != null) {
groupParticipantsCountLabel = realmRoom.getGroupRoom().getParticipantsCountLabel();
isPublicGroup = roomIsPublic = !realmRoom.getGroupRoom().isPrivate();
} else if (chatType == CHANNEL && realmRoom.getChannelRoom() != null) {
groupParticipantsCountLabel = realmRoom.getChannelRoom().getParticipantsCountLabel();
showVoteChannel = realmRoom.getChannelRoom().isReactionStatus();
if (realmRoom.getChannelRoom().isVerified()) {
verifiedIcon.setVisibility(View.VISIBLE);
}
roomIsPublic = !realmRoom.getChannelRoom().isPrivate();
}
}
if (chatType == CHAT) {
setUserStatus(userStatus, lastSeen);
} else if ((chatType == GROUP) || (chatType == CHANNEL)) {
if (groupParticipantsCountLabel != null) {
if (HelperString.isNumeric(groupParticipantsCountLabel) && Integer.parseInt(groupParticipantsCountLabel) == 1) {
mToolbar.setSubTitle(groupParticipantsCountLabel + " " + G.fragmentActivity.getResources().getString(R.string.one_member_chat));
} else {
mToolbar.setSubTitle(groupParticipantsCountLabel + " " + G.fragmentActivity.getResources().getString(R.string.member_chat));
}
// avi.setVisibility(View.GONE);
}
}
} else if (chatPeerId != 0) {
/**
* when user start new chat this block will be called
*/
chatType = CHAT;
RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
});
title = realmRegisteredInfo.getDisplayName();
lastSeen = realmRegisteredInfo.getLastSeen();
userStatus = realmRegisteredInfo.getStatus();
setUserStatus(userStatus, lastSeen);
}
if (title != null) {
mToolbar.setTitle(EmojiManager.getInstance().replaceEmoji(title, null));
}
/**
* change english number to persian number
*/
if (HelperCalander.isPersianUnicode) {
mToolbar.setTitle(EmojiManager.getInstance().replaceEmoji(mToolbar.getTitleTextView().getText().toString(), mToolbar.getTitleTextView().getPaint().getFontMetricsInt()));
mToolbar.setSubTitle(convertToUnicodeFarsiNumber(mToolbar.getSubTitleText()));
}
/**
* hint: don't check isCloudRoom with (( RealmRoom.isCloudRoom(mRoomId, realm); ))
* because in first time room not exist in RealmRoom and value is false always.
* so just need to check this value with chatPeerId
*/
if (chatPeerId == AccountManager.getInstance().getCurrentUser().getId()) {
isCloudRoom = true;
}
viewAttachFile = rootView.findViewById(R.id.layout_attach_file);
iconMute = mToolbar.getMuteIcon();
if (realmRoom != null) {
iconMute.setVisibility(realmRoom.getMute() ? View.VISIBLE : View.GONE);
isMuteNotification = realmRoom.getMute();
isChatReadOnly = realmRoom.getReadOnly();
}
// gone video , voice button call then if status was ok visible them
// mHelperToolbar.getSecondRightButton().setVisibility(View.GONE);
callItem.setVisibility(View.GONE);
if (isChatReadOnly) {
viewAttachFile.setVisibility(View.GONE);
(rootView.findViewById(R.id.chl_recycler_view_chat)).setPadding(0, 0, 0, 0);
} else if (chatType == CHAT && AccountManager.getInstance().getCurrentUser().getId() != chatPeerId && !isBot) {
// gone or visible view call
RealmCallConfig callConfig = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmCallConfig.class).findFirst();
});
if (callConfig != null) {
if (callConfig.isVoice_calling()) {
// mHelperToolbar.getSecondRightButton().setVisibility(View.VISIBLE);
callItem.setVisibility(View.VISIBLE);
} else {
callItem.setVisibility(View.VISIBLE);
// mHelperToolbar.getSecondRightButton().setVisibility(View.GONE);
}
} else {
new RequestSignalingGetConfiguration().signalingGetConfiguration();
}
}
createMoreItems();
manageExtraLayout();
}
use of net.iGap.module.downloader.Status in project iGap-Android by KianIranian-STDG.
the class StoryCell method setData.
public void setData(StoryObject storyObject, boolean isRoom, String displayName, String color, Context context, boolean needDivider, CircleStatus status, ImageLoadingView.Status imageLoadingStatus, IconClicked iconClicked) {
initView(context, needDivider, status, imageLoadingStatus, iconClicked, storyObject.createdAt);
this.userId = storyObject.userId;
this.roomId = storyObject.roomId;
this.isFromMyStatus = true;
String name = HelperImageBackColor.getFirstAlphabetName(storyObject.displayName != null ? storyObject.displayName : "");
if (circleImageLoading.getStatus() == ImageLoadingView.Status.FAILED) {
if (isRoom && mode == 0) {
deleteIcon.setTextColor(Color.RED);
topText.setText(storyObject.displayName);
bottomText.setText(context.getString(R.string.story_could_not_sent));
bottomText.setTextColor(Color.RED);
} else {
uploadIcon.setVisibility(VISIBLE);
deleteIcon.setVisibility(VISIBLE);
deleteIcon.setText(R.string.icon_delete);
topText.setVisibility(GONE);
bottomText.setVisibility(GONE);
middleText.setVisibility(VISIBLE);
middleText.setText(context.getString(R.string.story_could_not_sent));
middleText.setTextColor(Color.RED);
}
} else if (circleImageLoading.getStatus() == ImageLoadingView.Status.LOADING) {
if (isRoom && mode == 0) {
topText.setText(storyObject.displayName);
bottomText.setText(context.getString(R.string.story_sending));
} else {
uploadIcon.setVisibility(GONE);
deleteIcon.setVisibility(GONE);
topText.setVisibility(GONE);
middleText.setVisibility(VISIBLE);
middleText.setText(context.getString(R.string.story_sending));
middleText.setTextColor(Theme.getInstance().getTitleTextColor(context));
}
} else {
topText.setVisibility(VISIBLE);
bottomText.setVisibility(VISIBLE);
middleText.setVisibility(GONE);
uploadIcon.setVisibility(GONE);
deleteIcon.setVisibility(VISIBLE);
if (isRoom && mode == 0) {
topText.setText(storyObject.displayName);
} else {
if (G.selectedLanguage.equals("fa")) {
topText.setText(HelperCalander.convertToUnicodeFarsiNumber(String.valueOf(storyObject.viewCount)) + " " + context.getString(R.string.story_views));
} else {
topText.setText(storyObject.viewCount + " " + context.getString(R.string.story_views));
}
}
bottomText.setText(LastSeenTimeUtil.computeTime(context, storyObject.userId, storyObject.createdAt / 1000L, false, false));
}
AttachmentObject attachment = storyObject.attachmentObject;
if (attachment != null && (attachment.thumbnailPath != null || attachment.filePath != null)) {
try {
Glide.with(G.context).load(attachment.filePath != null ? attachment.filePath : attachment.thumbnailPath).placeholder(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
} catch (Exception e) {
Glide.with(G.context).load(HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color)).into(circleImageLoading);
}
} else if (attachment != null) {
Glide.with(G.context).load(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
DownloadObject object = DownloadObject.createForStory(attachment, storyObject.storyId, true);
Log.e("skfjskjfsd", "setData2: " + storyId + "/" + object.downloadId);
if (object != null) {
Downloader.getInstance(AccountManager.selectedAccount).download(object, arg -> {
if (arg.status == Status.SUCCESS && arg.data != null) {
String filepath = arg.data.getFilePath();
String downloadedFileToken = arg.data.getToken();
if (!(new File(filepath).exists())) {
HelperLog.getInstance().setErrorLog(new Exception("File Dont Exist After Download !!" + filepath));
}
if (arg.data.getDownloadObject().downloadId == storyId) {
DbManager.getInstance().doRealmTransaction(realm1 -> {
RealmStoryProto realmStoryProto = realm1.where(RealmStoryProto.class).equalTo("isForReply", false).equalTo("storyId", storyId).findFirst();
if (realmStoryProto != null) {
realmStoryProto.getFile().setLocalFilePath(filepath);
}
});
G.runOnUiThread(() -> Glide.with(G.context).load(filepath).placeholder(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading));
}
}
});
}
} else {
Glide.with(G.context).load(new BitmapDrawable(context.getResources(), HelperImageBackColor.drawAlphabetOnPicture(LayoutCreator.dp(64), name, color))).into(circleImageLoading);
}
}
Aggregations