mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Make unref-calls more clear.
This commit is contained in:
@@ -50,8 +50,9 @@ public class MrMailbox {
|
||||
public static TLRPC.TL_dialog hChatlist2dialog(long hChatlist, int index)
|
||||
{
|
||||
long hChat = MrMailbox.MrChatlistGetChatByIndex(hChatlist, index);
|
||||
TLRPC.TL_dialog dlg = hChat2dialog(hChat);
|
||||
TLRPC.TL_dialog dlg = hChat2dialog(hChat);
|
||||
MrMailbox.MrChatUnref(hChat);
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
|
||||
@@ -1082,6 +1082,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
|
||||
|
||||
MrMailbox.MrChatUnref(hChat);
|
||||
hChat = null;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class DraftQuery {
|
||||
private static void saveDraft__(long did, String message, long replyToMessageId) // message may be null
|
||||
{
|
||||
long hChat = MrMailbox.MrMailboxGetChat(MrMailbox.hMailbox, (int)did);
|
||||
MrMailbox.MrChatSetDraft(hChat, message, replyToMessageId);
|
||||
MrMailbox.MrChatSetDraft(hChat, message, replyToMessageId);
|
||||
MrMailbox.MrChatUnref(hChat);
|
||||
}
|
||||
|
||||
|
||||
@@ -3623,7 +3623,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
String cname = "";
|
||||
if(currentUser!=null && isChat) {
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, currentUser.id);
|
||||
cname = MrMailbox.MrContactGetDisplayName(hContact);
|
||||
cname = MrMailbox.MrContactGetDisplayName(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
}
|
||||
|
||||
|
||||
@@ -180,12 +180,9 @@ public class DialogCell extends BaseCell {
|
||||
currentDialogId = dialog.id;
|
||||
isDialogCell = true;
|
||||
index = i;
|
||||
//dialogsType = type;
|
||||
|
||||
// EDIT BY MR
|
||||
MrMailbox.MrChatUnref(m_hChat);
|
||||
m_hChat = MrMailbox.MrChatlistGetChatByIndex(MrMailbox.hCurrChatlist, i); // TODO: maybe this should move to update() - in general, how are updates handled?
|
||||
// /EDIT BY MR
|
||||
m_hChat = MrMailbox.MrChatlistGetChatByIndex(MrMailbox.hCurrChatlist, i);
|
||||
|
||||
update(0);
|
||||
}
|
||||
|
||||
@@ -2895,7 +2895,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
final int fromId = MrMailbox.MrMsgGetFromId(hMsg);
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, fromId);
|
||||
if( hContact==0 ) { MrMailbox.MrMsgUnref(hMsg); return; }
|
||||
String name = MrMailbox.MrContactGetNameNAddr(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
|
||||
@@ -3669,24 +3668,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
MessagesQuery.loadReplyMessagesForMessages(messArr, dialog_id);
|
||||
}
|
||||
*/
|
||||
{
|
||||
long hMsglist = MrMailbox.MrChatGetMsglist(m_hChat, 0, 100);
|
||||
|
||||
long hMsglist = MrMailbox.MrChatGetMsglist(m_hChat, 0, 100);
|
||||
int mrCount = MrMailbox.MrMsglistGetCnt(hMsglist);
|
||||
for (int a = mrCount - 1; a >= 0; a--) {
|
||||
long hMsg = MrMailbox.MrMsglistGetMsgByIndex(hMsglist, a);
|
||||
TLRPC.Message msg = MrMailbox.hMsg2Message(hMsg);
|
||||
MessageObject msgDrawObj = new MessageObject(msg, null, true);
|
||||
messages.add(0, msgDrawObj);
|
||||
messagesDict[loadIndex].put(msg.id, msgDrawObj);
|
||||
MrMailbox.MrMsgUnref(hMsg);
|
||||
}
|
||||
|
||||
int mrCount = MrMailbox.MrMsglistGetCnt(hMsglist);
|
||||
for (int a = mrCount-1; a >= 0 ; a-- ) {
|
||||
long hMsg = MrMailbox.MrMsglistGetMsgByIndex(hMsglist, a);
|
||||
TLRPC.Message msg = MrMailbox.hMsg2Message(hMsg);
|
||||
MessageObject msgDrawObj = new MessageObject(msg, null, true);
|
||||
messages.add(0, msgDrawObj);
|
||||
messagesDict[loadIndex].put(msg.id, msgDrawObj);
|
||||
MrMailbox.MrMsgUnref(hMsg);
|
||||
}
|
||||
if (MrMailbox.MrChatGetId(m_hChat) == MrMailbox.MR_CHAT_ID_STRANGERS) {
|
||||
updateBottomOverlay();
|
||||
}
|
||||
|
||||
if( MrMailbox.MrChatGetId(m_hChat)==MrMailbox.MR_CHAT_ID_STRANGERS ) {
|
||||
updateBottomOverlay();
|
||||
}
|
||||
MrMailbox.MrMsglistUnref(hMsglist);
|
||||
}
|
||||
|
||||
MrMailbox.MrMsglistUnref(hMsglist);
|
||||
|
||||
/* EDIT BY MR -- the add loop
|
||||
int approximateHeightSum = 0;
|
||||
|
||||
@@ -361,9 +361,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
return;
|
||||
}
|
||||
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user.id);
|
||||
String name = MrMailbox.MrContactGetNameNAddr(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
String name = "";
|
||||
{
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user.id);
|
||||
name = MrMailbox.MrContactGetNameNAddr(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@@ -539,9 +542,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
View textView = lf.inflate(R.layout.group_create_bubble, null);
|
||||
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
|
||||
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user.id);
|
||||
String name = MrMailbox.MrContactGetDisplayName(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
String name ="";
|
||||
{
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user.id);
|
||||
name = MrMailbox.MrContactGetDisplayName(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
}
|
||||
|
||||
|
||||
text.setText(name + ", ");
|
||||
|
||||
@@ -2702,7 +2702,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if( currentMessageObject!=null && currentMessageObject.messageOwner!=null )
|
||||
{
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, currentMessageObject.messageOwner.from_id);
|
||||
nameTextView.setText(MrMailbox.MrContactGetDisplayName(hContact));
|
||||
nameTextView.setText(MrMailbox.MrContactGetDisplayName(hContact));
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
}
|
||||
|
||||
|
||||
@@ -411,9 +411,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
return;
|
||||
}
|
||||
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user_id);
|
||||
String name = MrMailbox.MrContactGetNameNAddr(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
String name = "";
|
||||
{
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user_id);
|
||||
name = MrMailbox.MrContactGetNameNAddr(hContact);
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@@ -1191,7 +1194,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
boolean blocked = false;
|
||||
if( user_id!=0 ) {
|
||||
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user_id);
|
||||
blocked = MrMailbox.MrContactIsBlocked(hContact)!=0;
|
||||
blocked = MrMailbox.MrContactIsBlocked(hContact)!=0;
|
||||
MrMailbox.MrContactUnref(hContact);
|
||||
}
|
||||
return blocked;
|
||||
|
||||
Reference in New Issue
Block a user