Search in sources :

Example 1 with AxiosResultBean

use of com.eros.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();
    } else {
        bean.status = 9;
        bean.errorMsg = e.getMessage();
    }
    if (callback != null) {
        callback.invoke(bean);
    }
}
Also used : AxiosResultBean(com.eros.framework.model.AxiosResultBean) IrregularUrlException(com.eros.framework.http.okhttp.exception.IrregularUrlException) HttpException(com.eros.framework.http.okhttp.exception.HttpException) CancelException(com.eros.framework.http.okhttp.exception.CancelException)

Example 2 with AxiosResultBean

use of com.eros.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);
}
Also used : AxiosResultBean(com.eros.framework.model.AxiosResultBean) Cursor(android.database.Cursor) Uri(android.net.Uri) DispatchEventManager(com.eros.framework.manager.impl.dispatcher.DispatchEventManager) ContentResolver(android.content.ContentResolver)

Aggregations

AxiosResultBean (com.eros.framework.model.AxiosResultBean)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 CancelException (com.eros.framework.http.okhttp.exception.CancelException)1 HttpException (com.eros.framework.http.okhttp.exception.HttpException)1 IrregularUrlException (com.eros.framework.http.okhttp.exception.IrregularUrlException)1 DispatchEventManager (com.eros.framework.manager.impl.dispatcher.DispatchEventManager)1