use of net.iGap.realm.RealmUserInfo in project iGap-Android by KianIranian-STDG.
the class FragmentNewGroup method showInitials.
private void showInitials() {
DbManager.getInstance().doRealmTask(realm -> {
RealmUserInfo realmUserInfo = realm.where(RealmUserInfo.class).findFirst();
imgProfileHelper.setVisibility(View.GONE);
imgCircleImageView.setImageBitmap(HelperImageBackColor.drawAlphabetOnPicture((int) imgCircleImageView.getContext().getResources().getDimension(R.dimen.dp100), realmUserInfo.getUserInfo().getInitials(), realmUserInfo.getUserInfo().getColor()));
});
}
use of net.iGap.realm.RealmUserInfo 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();
}
use of net.iGap.realm.RealmUserInfo in project iGap-Android by KianIranian-STDG.
the class LoginActions method login.
/**
* try login to server and do common actions
*/
public static void login() {
if (!G.ISRealmOK) {
return;
}
G.onUserLogin = new OnUserLogin() {
@Override
public void onLogin() {
G.handler.post(new Runnable() {
@Override
public void run() {
if (firstEnter) {
firstEnter = false;
new RequestUserContactsGetBlockedList().userContactsGetBlockedList();
importContact();
}
getUserInfo();
if (G.isAppInFg) {
UserStatusController.getInstance().setOnline();
}
if (AndroidUtils.isAppOnForeground(G.context)) {
GPSTracker.getGpsTrackerInstance().checkLocation();
}
// sendWaitingRequestWrappers();
HelperCheckInternetConnection.detectConnectionTypeForDownload();
}
});
}
@Override
public void onLoginError(int majorCode, int minorCode) {
}
};
if (RequestManager.getInstance(AccountManager.selectedAccount).isSecure()) {
DbManager.getInstance().doRealmTask(realm -> {
RealmUserInfo userInfo = realm.where(RealmUserInfo.class).findFirst();
if (!RequestManager.getInstance(AccountManager.selectedAccount).isUserLogin()) {
if (userInfo != null) {
if (userInfo.getUserRegistrationState()) {
Log.wtf(LoginActions.class.getName(), "LoginActions.login: RequestUserLogin().userLogin");
new RequestUserLogin().userLogin(userInfo.getToken());
} else {
Log.wtf(LoginActions.class.getName(), "LoginActions.login:getUserRegistrationState" + userInfo.getUserRegistrationState());
}
} else {
Log.wtf(LoginActions.class.getName(), "LoginActions.login:userInfo != null");
}
} else {
Log.wtf(LoginActions.class.getName(), "LoginActions.login:else");
}
});
} else {
login();
}
}
use of net.iGap.realm.RealmUserInfo in project iGap-Android by KianIranian-STDG.
the class UserIVandGetScoreResponse method handler.
@Override
public void handler() {
super.handler();
ProtoUserIVandGetScore.UserIVandGetScoreResponse.Builder builder = (ProtoUserIVandGetScore.UserIVandGetScoreResponse.Builder) message;
DbManager.getInstance().doRealmTransaction(realm -> {
RealmUserInfo user = realm.where(RealmUserInfo.class).findFirst();
if (user != null) {
user.setIvandScore(builder.getScore());
}
});
if (identity instanceof OnUserIVandGetScore) {
((OnUserIVandGetScore) identity).getScore(builder);
}
}
use of net.iGap.realm.RealmUserInfo in project iGap-Android by KianIranian-STDG.
the class UserLoginResponse method handler.
@Override
public void handler() {
super.handler();
HelperConnectionState.connectionState(ConnectionState.IGAP);
ProtoUserLogin.UserLoginResponse.Builder builder = (ProtoUserLogin.UserLoginResponse.Builder) message;
G.serverHashContact = builder.getContactHash();
if (builder.getUpdateAvailable() && !isUpdateAvailable) {
new android.os.Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if (G.onVersionCallBack != null) {
G.onVersionCallBack.isUpdateAvailable();
isUpdateAvailable = true;
}
}
}, 1000);
}
if (builder.getDeprecatedClient() && !isDeprecated) {
new android.os.Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if (G.onVersionCallBack != null) {
G.onVersionCallBack.isDeprecated();
isDeprecated = true;
G.isDepricatedApp = true;
}
}
}, 1000);
} else {
G.isDepricatedApp = false;
}
G.isNeedToCheckProfileWallpaper = true;
G.currentServerTime = builder.getResponse().getTimestamp();
G.bothChatDeleteTime = builder.getChatDeleteMessageForBothPeriod() * 1000;
RequestManager.getInstance(AccountManager.selectedAccount).setUserLogin(true);
TokenContainer.getInstance().updateToken(builder.getAccessToken(), false);
if (BuildConfig.SHOW_RATE_DIALOG_PERIOD_HOURE != 0 && sharedPreferences.getLong(SHP_SETTING.KEY_LOGIN_TIME_STAMP, 0) == 0) {
sharedPreferences.edit().putLong(SHP_SETTING.KEY_LOGIN_TIME_STAMP, new Date().getTime()).apply();
}
/**
* get Signaling Configuration
* (( hint : call following request after set G.userLogin=true ))
*/
DbManager.getInstance().doRealmTask(realm -> {
if (realm.where(RealmCallConfig.class).findFirst() == null) {
new RequestSignalingGetConfiguration().signalingGetConfiguration();
}
});
new Thread(() -> {
G.clientConditionGlobal = RealmClientCondition.computeClientCondition(null);
new RequestClientGetRoomList().clientGetRoomList(0, Config.LIMIT_LOAD_ROOM, "0");
}).start();
G.onUserLogin.onLogin();
boolean doUserNeedFcmToken = builder.getNeedFcmToken();
if (doUserNeedFcmToken) {
RealmUserInfo.sendPushNotificationToServer();
}
DbManager.getInstance().doRealmTransaction(realm -> {
RealmUserInfo realmUserInfo = realm.where(RealmUserInfo.class).findFirst();
contactCount = realm.where(RealmContacts.class).findAll().size();
if (realmUserInfo != null) {
realmUserInfo.setWalletActive(builder.getWalletActive());
realmUserInfo.setMplActive(builder.getMplActive());
realmUserInfo.setWalletRegister(builder.getWalletAgreementAccepted());
realmUserInfo.setAccessToken(builder.getAccessToken());
}
});
if (!isFetched) {
MessageController.getInstance(AccountManager.selectedAccount).getStories(contactCount);
}
}
Aggregations