<commit_before>package im.actor.messenger.app;

import com.droidkit.actors.typed.TypedActor;

import im.actor.messenger.app.util.Logger;
import im.actor.model.AuthState;

/**
 * Created by ex3ndr on 06.09.14.
 */
public class AppStateBroker extends TypedActor<AppStateInterface> implements AppStateInterface {

    private static final TypedActorHolder<AppStateInterface> HOLDER = new TypedActorHolder<AppStateInterface>(AppStateInterface.class,
            AppStateBroker.class, "app_state");

    public static AppStateInterface stateBroker() {
        return HOLDER.get();
    }

    private static final int CLOSE_TIMEOUT = 300;

    private boolean isAppOpen = false;
    private int activityCount = 0;

    private static final String TAG = "AppStateBroker";

    public AppStateBroker() {
        super(AppStateInterface.class);
    }

    @Override
    public void onReceive(Object message) {
        super.onReceive(message);
        if (message instanceof CloseApp) {
            if (isAppOpen) {
                isAppOpen = false;
                onAppClosed();
            }
        }
    }

    @Override
    public void onActivityOpen() {
        Logger.d(TAG, "Activity open");
        activityCount++;
        if (!isAppOpen) {
            isAppOpen = true;
            onAppOpened();
        }
        self().sendOnce(new CloseApp(), 24 * 60 * 60 * 1000); // Far away
    }

    @Override
    public void onActivityClose() {
        Logger.d(TAG, "Activity close");
        activityCount--;
        if (isAppOpen) {
            if (activityCount == 0) {
                self().sendOnce(new CloseApp(), CLOSE_TIMEOUT);
            }
        }
    }

    private void onAppOpened() {
        Logger.d(TAG, "App open");
        if (Core.messenger().getAuthState() == AuthState.LOGGED_IN) {
            Core.messenger().onAppVisible();
        }
    }

    private void onAppClosed() {
        Logger.d(TAG, "App closed");
        if (Core.messenger().getAuthState() == AuthState.LOGGED_IN) {
            Core.messenger().onAppHidden();
        }
    }

    private static class CloseApp {

    }
}<commit_msg>fix(android): Online timeout<commit_after>package im.actor.messenger.app;

import com.droidkit.actors.typed.TypedActor;

import im.actor.messenger.app.util.Logger;
import im.actor.model.AuthState;

/**
 * Created by ex3ndr on 06.09.14.
 */
public class AppStateBroker extends TypedActor<AppStateInterface> implements AppStateInterface {

    private static final TypedActorHolder<AppStateInterface> HOLDER = new TypedActorHolder<AppStateInterface>(AppStateInterface.class,
            AppStateBroker.class, "app_state");

    public static AppStateInterface stateBroker() {
        return HOLDER.get();
    }

    private static final int CLOSE_TIMEOUT = 1000;

    private boolean isAppOpen = false;
    private int activityCount = 0;

    private static final String TAG = "AppStateBroker";

    public AppStateBroker() {
        super(AppStateInterface.class);
    }

    @Override
    public void onReceive(Object message) {
        super.onReceive(message);
        if (message instanceof CloseApp) {
            if (isAppOpen) {
                isAppOpen = false;
                onAppClosed();
            }
        }
    }

    @Override
    public void onActivityOpen() {
        Logger.d(TAG, "Activity open");
        activityCount++;
        if (!isAppOpen) {
            isAppOpen = true;
            onAppOpened();
        }
        self().sendOnce(new CloseApp(), 24 * 60 * 60 * 1000); // Far away
    }

    @Override
    public void onActivityClose() {
        Logger.d(TAG, "Activity close");
        activityCount--;
        if (isAppOpen) {
            if (activityCount == 0) {
                self().sendOnce(new CloseApp(), CLOSE_TIMEOUT);
            }
        }
    }

    private void onAppOpened() {
        Logger.d(TAG, "App open");
        if (Core.messenger().getAuthState() == AuthState.LOGGED_IN) {
            Core.messenger().onAppVisible();
        }
    }

    private void onAppClosed() {
        Logger.d(TAG, "App closed");
        if (Core.messenger().getAuthState() == AuthState.LOGGED_IN) {
            Core.messenger().onAppHidden();
        }
    }

    private static class CloseApp {

    }
}
{'fraction_non_alphanumeric': 0.11051149694978883, 'fraction_numerical': 0.01055842327545753, 'mean_word_length': 2.2369020501138954, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2499525', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1220, 'n_words': 270}