Search in sources :

Example 1 with DispatchEventManager

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

Example 2 with DispatchEventManager

use of com.benmu.framework.manager.impl.dispatcher.DispatchEventManager in project WeexErosFramework by bmfe.

the class AbstractWeexActivity method debugLayerClick.

private void debugLayerClick() {
    android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(mAct);
    builder.setItems(mDebugOptions, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == 0) {
                Intent intent = new Intent(mAct, DebugActivity.class);
                startActivity(intent);
            } else if (which == 1) {
                refresh();
            } else if (which == 2) {
                DispatchEventManager dispatchEventManager = ManagerFactory.getManagerService(DispatchEventManager.class);
                WeexEventBean eventBean = new WeexEventBean();
                eventBean.setContext(mAct);
                eventBean.setKey(WXConstant.WXEventCenter.EVENT_CAMERA);
                dispatchEventManager.getBus().post(eventBean);
            // connectionDebugService(BMWXEnvironment.mPlatformConfig.getUrl()
            // .getDebugServer());
            }
        }
    });
    builder.create().show();
}
Also used : DialogInterface(android.content.DialogInterface) WeexEventBean(com.benmu.framework.model.WeexEventBean) Intent(android.content.Intent) DispatchEventManager(com.benmu.framework.manager.impl.dispatcher.DispatchEventManager)

Aggregations

DispatchEventManager (com.benmu.framework.manager.impl.dispatcher.DispatchEventManager)2 ContentResolver (android.content.ContentResolver)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 AxiosResultBean (com.benmu.framework.model.AxiosResultBean)1 WeexEventBean (com.benmu.framework.model.WeexEventBean)1