use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.
the class FragmentChat method inflateReplayLayoutIntoStub.
@SuppressLint("RestrictedApi")
private void inflateReplayLayoutIntoStub(MessageObject messageObject, boolean isEdit) {
// TODO: 12/28/20 refactor message
if (rootView.findViewById(R.id.replayLayoutAboveEditText) == null) {
ViewStubCompat stubView = rootView.findViewById(R.id.replayLayoutStub);
stubView.setInflatedId(R.id.replayLayoutAboveEditText);
stubView.setLayoutResource(R.layout.layout_chat_reply);
stubView.inflate();
inflateReplayLayoutIntoStub(messageObject, isEdit);
} else {
mReplayLayout = rootView.findViewById(R.id.replayLayoutAboveEditText);
mReplayLayout.setVisibility(View.VISIBLE);
TextView replayTo = mReplayLayout.findViewById(R.id.replayTo);
replayTo.setTypeface(ResourcesCompat.getFont(mReplayLayout.getContext(), R.font.main_font));
TextView replayFrom = mReplayLayout.findViewById(R.id.replyFrom);
replayFrom.setTypeface(ResourcesCompat.getFont(mReplayLayout.getContext(), R.font.main_font));
FontIconTextView replayIcon = rootView.findViewById(R.id.lcr_imv_replay);
if (isEdit)
replayIcon.setText(getString(R.string.icon_new_conversation));
else
replayIcon.setText(getString(R.string.icon_reply));
ImageView thumbnail = mReplayLayout.findViewById(R.id.thumbnail);
thumbnail.setImageResource(android.R.color.transparent);
TextView closeReplay = mReplayLayout.findViewById(R.id.cancelIcon);
closeReplay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isEdit)
removeEditedMessage();
else
clearReplyView();
}
});
thumbnail.setVisibility(View.VISIBLE);
if (messageObject.isForwarded()) {
AppUtils.rightFileThumbnailIcon(thumbnail, messageObject.forwardedMessage.messageType, messageObject.forwardedMessage);
String _text = AppUtils.conversionMessageType(messageObject.forwardedMessage.messageType);
if (_text != null && _text.length() > 0) {
ReplySetText(replayTo, _text);
} else {
ReplySetText(replayTo, messageObject.forwardedMessage.message);
}
} else {
AppUtils.rightFileThumbnailIcon(thumbnail, messageObject.messageType, messageObject);
String _text = AppUtils.conversionMessageType(messageObject.messageType);
if (_text != null && _text.length() > 0) {
ReplySetText(replayTo, _text);
} else {
ReplySetText(replayTo, messageObject.message);
}
}
if (!isEdit) {
if (chatType == CHANNEL) {
RealmRoom realmRoom = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoom.class).equalTo("id", messageObject.roomId).findFirst();
});
if (realmRoom != null) {
replayFrom.setText(EmojiManager.getInstance().replaceEmoji(realmRoom.getTitle(), replayFrom.getPaint().getFontMetricsInt()));
}
} else {
RealmRegisteredInfo userInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, messageObject.userId);
});
if (userInfo != null) {
replayFrom.setText(EmojiManager.getInstance().replaceEmoji(userInfo.getDisplayName(), replayFrom.getPaint().getFontMetricsInt()));
}
}
} else {
replayFrom.setText(getString(R.string.edit));
}
// I set tag to retrieve it later when sending message
mReplayLayout.setTag(messageObject);
}
}
use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.
the class FragmentGroupProfileViewModel method onGroupAddMemberCallback.
private void onGroupAddMemberCallback() {
G.onGroupAddMember = new OnGroupAddMember() {
@Override
public void onGroupAddMember(final Long roomIdUser, final Long userId) {
G.handler.post(new Runnable() {
@Override
public void run() {
setMemberCount(roomIdUser);
RealmRegisteredInfo realmRegistered = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, userId);
});
if (realmRegistered == null) {
if (roomIdUser == roomId) {
new RequestUserInfo().userInfo(userId, roomId + "");
}
}
}
});
}
@Override
public void onError(int majorCode, int minorCode) {
}
};
}
use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.
the class UserContactsGetBlockedListResponse method handler.
@Override
public void handler() {
super.handler();
ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.Builder builder = (ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.Builder) message;
List<ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.User> list = builder.getUserList();
DbManager.getInstance().doRealmTask(realm -> {
/**
* reset blocked user in RealmRegisteredInfo and realm contact
*/
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
RealmResults<RealmRegisteredInfo> results = realm.where(RealmRegisteredInfo.class).equalTo("blockUser", true).findAll();
for (RealmRegisteredInfo item : results) {
item.setBlockUser(false);
}
RealmResults<RealmContacts> resultsContacts = realm.where(RealmContacts.class).equalTo("blockUser", true).findAll();
for (RealmContacts item : resultsContacts) {
item.setBlockUser(false);
}
}
});
for (ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.User user : list) {
RealmRegisteredInfo.getRegistrationInfo(user.getUserId(), user.getCacheId(), realm, new OnInfo() {
@Override
public void onInfo(Long registeredId) {
RealmRegisteredInfo.updateBlock(registeredId, true);
RealmContacts.updateBlock(registeredId, true);
}
});
}
});
}
use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.
the class FragmentMap method initComponent.
private void initComponent(View view, int type, long roomId, String senderId) {
SupportMapFragment mapFragment = new SupportMapFragment();
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), mapFragment).setReplace(false).setAddToBackStack(false).setResourceContainer(mf_fragment_map_view).load();
}
mapFragment.getMapAsync(FragmentMap.this);
rvSendPosition = view.findViewById(R.id.mf_rv_send_position);
rvSendPosition.setBackgroundColor(new Theme().getPrimaryColor(getContext()));
if (mode == Mode.sendPosition) {
fabOpenMap.hide();
rvSendPosition.setVisibility(View.VISIBLE);
rvSeePosition.setVisibility(View.GONE);
rvSendPosition.setOnClickListener(this);
} else if (mode == Mode.seePosition) {
rvSeePosition.setVisibility(View.VISIBLE);
fabOpenMap.show();
rvSendPosition.setVisibility(View.GONE);
fabOpenMap.setOnClickListener(this);
DbManager.getInstance().doRealmTask(realm -> {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fabOpenMap.getLayoutParams();
if (HelperCalander.isPersianUnicode) {
// params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params.anchorGravity = Gravity.LEFT | Gravity.BOTTOM;
txtUserName.setGravity(Gravity.RIGHT);
((RelativeLayout.LayoutParams) txtUserName.getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else {
// params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.anchorGravity = Gravity.RIGHT | Gravity.BOTTOM;
txtUserName.setGravity(Gravity.LEFT);
((RelativeLayout.LayoutParams) txtUserName.getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_LEFT);
}
if (type == ProtoGlobal.Room.Type.CHAT.getNumber() || type == ProtoGlobal.Room.Type.GROUP.getNumber()) {
RealmRegisteredInfo realmRegisteredInfo = realm.where(RealmRegisteredInfo.class).equalTo("id", Long.parseLong(senderId)).findFirst();
txtUserName.setText(realmRegisteredInfo.getDisplayName());
setAvatar(Long.parseLong(senderId));
} else {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
txtUserName.setText(realmRoom.getTitle());
setAvatar(roomId);
}
});
}
}
use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.
the class FragmentiGapMap method getInitials.
private static Bitmap getInitials(Realm realm, long userId) {
String initials = "";
String color = "";
RealmRegisteredInfo realmRegisteredInfo = RealmRegisteredInfo.getRegistrationInfo(realm, userId);
if (realmRegisteredInfo != null) {
initials = realmRegisteredInfo.getInitials();
color = realmRegisteredInfo.getColor();
}
return HelperImageBackColor.drawAlphabetOnPicture((int) G.context.getResources().getDimension(R.dimen.dp60), initials, color);
}
Aggregations