use of com.benmu.framework.model.AxiosResultBean in project WeexErosFramework by bmfe.
the class EventFetch method parseError.
private void parseError(Context context, Exception e, JSCallback callback) {
if (e instanceof CancelException) {
// request canceled
ModalManager.BmLoading.dismissLoading(context);
return;
}
AxiosResultBean bean = new AxiosResultBean();
if (e instanceof HttpException) {
HttpException httpException = (HttpException) e;
bean.status = httpException.getmErrorCode();
bean.errorMsg = httpException.getmErrorMessage();
} else if (e instanceof IrregularUrlException) {
IrregularUrlException irregularUrlException = (IrregularUrlException) e;
bean.status = 9;
bean.errorMsg = irregularUrlException.getmErrosMeeage();
}
if (callback != null) {
callback.invoke(bean);
}
}
use of com.benmu.framework.model.AxiosResultBean in project WeexErosFramework by bmfe.
the class EventFetch method parseResponse.
private void parseResponse(String response, JSCallback callBack, int code) {
try {
AxiosResultBean bean = new AxiosResultBean();
if (callBack != null && !TextUtils.isEmpty(response)) {
bean.status = code;
bean.errorMsg = "";
bean.data = JSON.parse(response);
callBack.invoke(bean);
}
} catch (Exception e) {
e.printStackTrace();
L.e("json 解析错误");
AxiosResultBean bean = new AxiosResultBean();
bean.status = -1;
bean.errorMsg = "json 解析错误";
if (callBack != null) {
callBack.invoke(bean);
}
}
}
use of com.benmu.framework.model.AxiosResultBean in project WeexErosFramework by bmfe.
the class AbstractWeexActivity method readContractResult.
private void readContractResult(Intent data) {
String username, usernumber = "";
ContentResolver reContentResolverol = getContentResolver();
// URI,每个ContentProvider定义一个唯一的公开的URI,用于指定到它的数据集
Uri contactData = data.getData();
// 查询就是输入URI等参数,其中URI是必须的,其他是可选的,如果系统能找到URI对应的ContentProvider将返回一个Cursor对象.
Cursor cursor = managedQuery(contactData, null, null, null, null);
cursor.moveToFirst();
// 获得DATA表中的名字
username = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
// 条件为联系人ID
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
// 获得DATA表中的电话号码,条件为联系人ID,因为手机号码可能会有多个
Cursor phone = reContentResolverol.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId, null, null);
while (phone.moveToNext()) {
usernumber = phone.getString(phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
String json = joinContractJson(username, usernumber);
AxiosResultBean resultBean = new AxiosResultBean();
resultBean.status = 0;
resultBean.data = json;
DispatchEventManager dispatchEventManager = ManagerFactory.getManagerService(DispatchEventManager.class);
dispatchEventManager.getBus().post(resultBean);
}
Aggregations