当前位置: 首页>>代码示例>>Java>>正文


Java MXSession.getDataHandler方法代码示例

本文整理汇总了Java中org.matrix.androidsdk.MXSession.getDataHandler方法的典型用法代码示例。如果您正苦于以下问题:Java MXSession.getDataHandler方法的具体用法?Java MXSession.getDataHandler怎么用?Java MXSession.getDataHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.matrix.androidsdk.MXSession的用法示例。


在下文中一共展示了MXSession.getDataHandler方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: specificUpdateBadgeUnreadCount

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 * Refresh the badge count for specific configurations.<br>
 * The refresh is only effective if the device is:
 * <ul><li>offline</li><li>does not support GCM</li>
 * <li>GCM registration failed</li>
 * <br>Notifications rooms are parsed to track the notification count value.
 *
 * @param aSession session value
 * @param aContext App context
 */
public static void specificUpdateBadgeUnreadCount(MXSession aSession, Context aContext) {
    MXDataHandler dataHandler;

    // sanity check
    if ((null == aContext) || (null == aSession)) {
        Log.w(LOG_TAG, "## specificUpdateBadgeUnreadCount(): invalid input null values");
    } else if ((null == (dataHandler = aSession.getDataHandler()))) {
        Log.w(LOG_TAG, "## specificUpdateBadgeUnreadCount(): invalid DataHandler instance");
    } else {
        if (aSession.isAlive()) {
            boolean isRefreshRequired;
            GcmRegistrationManager gcmMgr = Matrix.getInstance(aContext).getSharedGCMRegistrationManager();

            // update the badge count if the device is offline, GCM is not supported or GCM registration failed
            isRefreshRequired = !Matrix.getInstance(aContext).isConnected();
            isRefreshRequired |= (null != gcmMgr) && (!gcmMgr.useGCM() || !gcmMgr.hasRegistrationToken());

            if (isRefreshRequired) {
                updateBadgeCount(aContext, dataHandler);
            }
        }
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:34,代码来源:CommonActivityUtils.java

示例2: hasValidSessions

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 *
 * @return true if the matrix client instance defines a valid session
 */
public static Boolean hasValidSessions() {
    if (null == instance) {
        Log.e(LOG_TAG, "hasValidSessions : has no instance");
        return false;
    }

    Boolean res;

    synchronized (instance) {
        res = (null != instance.mMXSessions) && (instance.mMXSessions.size() > 0);

        if (!res) {
            Log.e(LOG_TAG, "hasValidSessions : has no session");
        } else {
            for(MXSession session : instance.mMXSessions) {
                // some GA issues reported that the data handler can be null
                // so assume the application should be restarted
                res &= (null != session.getDataHandler());
            }

            if (!res) {
                Log.e(LOG_TAG, "hasValidSessions : one sesssion has no valid data hanlder");
            }
        }
    }

    return res;
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:33,代码来源:Matrix.java

示例3: refreshPushRules

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 * Refresh the sessions push rules.
 */
public void refreshPushRules() {
    ArrayList<MXSession> sessions = null;

    synchronized (this) {
        sessions = getSessions();
    }

    for(MXSession session : sessions) {
        if (null != session.getDataHandler()) {
            session.getDataHandler().refreshPushRules();
        }
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:17,代码来源:Matrix.java

示例4: hasValidSessions

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 * @return true if the matrix client instance defines a valid session
 */
public static boolean hasValidSessions() {
    if (null == instance) {
        Log.e(LOG_TAG, "hasValidSessions : has no instance");
        return false;
    }

    boolean res;

    synchronized (LOG_TAG) {
        res = (null != instance.mMXSessions) && (instance.mMXSessions.size() > 0);

        if (!res) {
            Log.e(LOG_TAG, "hasValidSessions : has no session");
        } else {
            for (MXSession session : instance.mMXSessions) {
                // some GA issues reported that the data handler can be null
                // so assume the application should be restarted
                res &= session.isAlive() && (null != session.getDataHandler());
            }

            if (!res) {
                Log.e(LOG_TAG, "hasValidSessions : one sesssion has no valid data handler");
            }
        }
    }

    return res;
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:32,代码来源:Matrix.java

示例5: refreshPushRules

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 * Refresh the sessions push rules.
 */
public void refreshPushRules() {
    ArrayList<MXSession> sessions;

    synchronized (this) {
        sessions = getSessions();
    }

    for (MXSession session : sessions) {
        if (null != session.getDataHandler()) {
            session.getDataHandler().refreshPushRules();
        }
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:17,代码来源:Matrix.java

示例6: startEventStreamService

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 * Start the events stream service.
 *
 * @param context the context.
 */
public static void startEventStreamService(Context context) {
    // the events stream service is launched
    // either the application has never be launched
    // or the service has been killed on low memory
    if (EventStreamService.isStopped()) {
        ArrayList<String> matrixIds = new ArrayList<>();
        Collection<MXSession> sessions = Matrix.getInstance(context.getApplicationContext()).getSessions();

        if ((null != sessions) && (sessions.size() > 0)) {
            GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(context).getSharedGCMRegistrationManager();
            Log.e(LOG_TAG, "## startEventStreamService() : restart EventStreamService");

            for (MXSession session : sessions) {
                // reported by GA
                if ((null != session.getDataHandler()) && (null != session.getDataHandler().getStore())) {
                    boolean isSessionReady = session.getDataHandler().getStore().isReady();

                    if (!isSessionReady) {
                        Log.e(LOG_TAG, "## startEventStreamService() : the session " + session.getMyUserId() + " is not opened");
                        session.getDataHandler().getStore().open();
                    } else {
                        // it seems that the crypto is not always restarted properly after a crash
                        Log.e(LOG_TAG, "## startEventStreamService() : check if the crypto of the session " + session.getMyUserId());
                        session.checkCrypto();
                    }

                    session.setSyncDelay(gcmRegistrationManager.isBackgroundSyncAllowed() ? gcmRegistrationManager.getBackgroundSyncDelay() : 0);
                    session.setSyncTimeout(gcmRegistrationManager.getBackgroundSyncTimeOut());

                    // session to activate
                    matrixIds.add(session.getCredentials().userId);
                }
            }

            // check size
            if (matrixIds.size() > 0) {
                Intent intent = new Intent(context, EventStreamService.class);
                intent.putExtra(EventStreamService.EXTRA_MATRIX_IDS, matrixIds.toArray(new String[matrixIds.size()]));
                intent.putExtra(EventStreamService.EXTRA_STREAM_ACTION, EventStreamService.StreamAction.START.ordinal());
                context.startService(intent);
            }
        }
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:50,代码来源:CommonActivityUtils.java


注:本文中的org.matrix.androidsdk.MXSession.getDataHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。