Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17142]: Modify section methods to be synchronous. #5807

Merged
merged 1 commit into from
Aug 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,33 @@ public boolean handleMessage(final Message msg) {
return true;
}
case MSG_APPEND_SECTION: {
handleAppendSection(msg.obj);
AsyncResult result = (AsyncResult)msg.obj;
handleAppendSection(result.getArg());
result.setResult(null);
return true;
}
case MSG_DELETE_SECTION_AT: {
handleDeleteSectionAt(TiConvert.toInt(msg.obj));
AsyncResult result = (AsyncResult)msg.obj;
handleDeleteSectionAt(TiConvert.toInt(result.getArg()));
result.setResult(null);
return true;
}
case MSG_INSERT_SECTION_AT: {
KrollDict data = (KrollDict) msg.obj;
AsyncResult result = (AsyncResult)msg.obj;
KrollDict data = (KrollDict) result.getArg();
int index = data.getInt("index");
Object section = data.get("section");
handleInsertSectionAt(index, section);
result.setResult(null);
return true;
}
case MSG_REPLACE_SECTION_AT: {
KrollDict data = (KrollDict) msg.obj;
AsyncResult result = (AsyncResult)msg.obj;
KrollDict data = (KrollDict) result.getArg();
int index = data.getInt("index");
Object section = data.get("section");
handleReplaceSectionAt(index, section);
result.setResult(null);
return true;
}

Expand All @@ -246,8 +254,7 @@ public void appendSection(Object section) {
if (TiApplication.isUIThread()) {
handleAppendSection(section);
} else {
Handler handler = getMainHandler();
handler.sendMessage(handler.obtainMessage(MSG_APPEND_SECTION, section));
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_APPEND_SECTION), section);
}
}

Expand All @@ -266,8 +273,7 @@ public void deleteSectionAt(int index) {
if (TiApplication.isUIThread()) {
handleDeleteSectionAt(index);
} else {
Handler handler = getMainHandler();
handler.sendMessage(handler.obtainMessage(MSG_DELETE_SECTION_AT, index));
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_DELETE_SECTION_AT), index);
}
}

Expand Down Expand Up @@ -295,11 +301,10 @@ public void insertSectionAt(int index, Object section) {
}

private void sendInsertSectionMessage(int index, Object section) {
Handler handler = getMainHandler();
KrollDict data = new KrollDict();
data.put("index", index);
data.put("section", section);
handler.sendMessage(handler.obtainMessage(MSG_INSERT_SECTION_AT, data));
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_INSERT_SECTION_AT), data);
}

private void handleInsertSectionAt(int index, Object section) {
Expand All @@ -326,11 +331,10 @@ public void replaceSectionAt(int index, Object section) {
}

private void sendReplaceSectionMessage(int index, Object section) {
Handler handler = getMainHandler();
KrollDict data = new KrollDict();
data.put("index", index);
data.put("section", section);
handler.sendMessage(handler.obtainMessage(MSG_REPLACE_SECTION_AT, data));
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_REPLACE_SECTION_AT), data);
}

private void handleReplaceSectionAt(int index, Object section) {
Expand Down