Fix an exception error; we forgot to remember the updated handle.

This commit is contained in:
B. Petersen
2016-11-19 02:49:27 +01:00
parent effef5f8ad
commit aa4fb45888
4 changed files with 29 additions and 21 deletions
@@ -147,9 +147,6 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
if( MrMailbox.MrMailboxDeleteContact(MrMailbox.hMailbox, selectedUserId) == 0 ) {
Toast.makeText(getParentActivity(), LocaleController.getString("CannotDeleteContact", R.string.CannotDeleteContact), Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getParentActivity(), LocaleController.getString("ContactDeleted", R.string.ContactDeleted), Toast.LENGTH_LONG).show();
}
}
}
});
@@ -317,6 +317,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
{
super.finalize();
MrMailbox.MrChatUnref(m_hChat);
m_hChat = 0;
}
RecyclerListView.OnItemLongClickListener onItemLongClickListener = new RecyclerListView.OnItemLongClickListener() {
@@ -3986,7 +3987,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (id == NotificationCenter.updateInterfaces) {
int updateMask = (Integer) args[0];
if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
if (currentChat != null) {
/*if (currentChat != null) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(currentChat.id);
if (chat != null) {
currentChat = chat;
@@ -3996,7 +3997,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (user != null) {
currentUser = user;
}
}
}*/
int back_id = MrMailbox.MrChatGetId(m_hChat);
MrMailbox.MrChatUnref(m_hChat);
m_hChat = MrMailbox.MrMailboxGetChat(MrMailbox.hMailbox, back_id);
updateTitle();
}
boolean updateSubtitle = false;
@@ -4305,7 +4310,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (id == NotificationCenter.messagesSentOrRead) {
int back_id = MrMailbox.MrChatGetId(m_hChat);
MrMailbox.MrChatUnref(m_hChat);
MrMailbox.MrMailboxGetChat(MrMailbox.hMailbox, back_id);
m_hChat = MrMailbox.MrMailboxGetChat(MrMailbox.hMailbox, back_id);
int evt_read = (int)args[0];
int evt_chat_id = (int)args[1];
@@ -94,12 +94,16 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (do_what==CREATE_CONTACT) {
actionBar.setTitle(LocaleController.getString("NewContactTitle", R.string.NewContactTitle));
} else {
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user_id);
nameToSet = MrMailbox.MrContactGetDisplayName(hContact);
MrMailbox.MrContactUnref(hContact);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@@ -108,20 +112,25 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
if (id == -1) {
finishFragment();
} else if (id == done_button) {
String name = nameTextView.getText().toString();
String addr = "";
if (do_what==CREATE_CONTACT) {
String name = nameTextView.getText().toString();
String addr = emailTextView.getText().toString();
if( MrMailbox.MrMailboxCreateContact(MrMailbox.hMailbox, name, addr)==0 ) {
Toast.makeText(getParentActivity(), LocaleController.getString("BadEmailAddress", R.string.BadEmailAddress), Toast.LENGTH_LONG).show();
return;
}
else {
Toast.makeText(getParentActivity(), LocaleController.getString("ContactCreated", R.string.ContactCreated), Toast.LENGTH_LONG).show();
}
addr = emailTextView.getText().toString();
}
else {
long hContact = MrMailbox.MrMailboxGetContact(MrMailbox.hMailbox, user_id);
addr = MrMailbox.MrContactGetAddr(hContact);
MrMailbox.MrContactUnref(hContact);
}
else if(do_what == EDIT_NAME) {
if( MrMailbox.MrMailboxCreateContact(MrMailbox.hMailbox, name, addr)==0 ) {
Toast.makeText(getParentActivity(), LocaleController.getString("BadEmailAddress", R.string.BadEmailAddress), Toast.LENGTH_LONG).show();
return;
}
else if (do_what==CREATE_CONTACT) {
Toast.makeText(getParentActivity(), LocaleController.getString("ContactCreated", R.string.ContactCreated), Toast.LENGTH_LONG).show();
}
finishFragment();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
}
@@ -145,7 +154,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
avatarImage = new BackupImageView(context);
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable.setInfoByName("?");
avatarDrawable.setInfoByName(nameToSet!=null? nameToSet : "?");
avatarImage.setImageDrawable(avatarDrawable);
frameLayout.addView(avatarImage);
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
@@ -198,7 +207,6 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
nameTextView.setHint(LocaleController.getString("Name", R.string.Name));
if (nameToSet != null) {
nameTextView.setText(nameToSet);
nameToSet = null;
}
nameTextView.setMaxLines(4);
nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
@@ -263,6 +271,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
emailTextView.setLayoutParams(layoutParams2);
}
nameToSet = null;
return fragmentView;
}
@@ -460,9 +460,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if( MrMailbox.MrMailboxDeleteContact(MrMailbox.hMailbox, user.id) == 0 ) {
Toast.makeText(getParentActivity(), LocaleController.getString("CannotDeleteContact", R.string.CannotDeleteContact), Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getParentActivity(), LocaleController.getString("ContactDeleted", R.string.ContactDeleted), Toast.LENGTH_LONG).show();
}
}
}
});