<commit_before># adal-application-state
Android library that let you know if the application is in foreground or background via `getter` or `callback.` 

<div align="center">
  <img src="art/adal-application-state.gif" />
</div>

### Download
Gradle:

```gradle
dependencies {
  compile 'com.massivedisaster.adal:adal-application-state:0.1.13'
}
```

### Usage
```java
public class App extends Application implements ApplicationStateManager.BackAndForegroundListener {

    private static final String TAG = App.class.getSimpleName();
    private ApplicationStateManager applicationStateManager;

    @Override
    public void onCreate() {
        super.onCreate();
        applicationStateManager = new ApplicationStateManager(this);
        registerActivityLifecycleCallbacks(applicationStateManager);
    }

    @Override
    public void onBackground() {
        Log.d(TAG, "onBackground");
    }

    @Override
    public void onForeground() {
        Log.d(TAG, "onForeground");
    }

    public boolean isBackground() {
        return applicationStateManager.isBackground();
    }

    public boolean isForeground() {
        return applicationStateManager.isForeground();
    }
}
```

### Contributing
[CONTRIBUTING](../CONTRIBUTING.md)<commit_msg>Add another sample to ActivityFragmentManager. #116<commit_after># adal-application-state
Android library that let you know if the application is in foreground or background via `getter` or `callback.` 

<div align="center">
  <img src="art/adal-application-state.gif" />
</div>

### Download
Gradle:

```gradle
dependencies {
  compile 'com.massivedisaster.adal:adal-application-state:0.1.13'
}
```

### Usage
```java
public class App extends Application implements ApplicationStateManager.BackAndForegroundListener {

    private static final String TAG = App.class.getSimpleName();
    private ApplicationStateManager applicationStateManager;

    @Override
    public void onCreate() {
        super.onCreate();
        applicationStateManager = new ApplicationStateManager(this);
        registerActivityLifecycleCallbacks(applicationStateManager);
    }

    @Override
    public void onBackground() {
        Log.d(TAG, "onBackground");
    }

    @Override
    public void onForeground() {
        Log.d(TAG, "onForeground");
    }

    public boolean isBackground() {
        return applicationStateManager.isBackground();
    }

    public boolean isForeground() {
        return applicationStateManager.isForeground();
    }
}
```

Another way of using within a `Fragment` or `Activity`.
```java
Application application = (Application) context.getApplicationContext();
application.registerActivityLifecycleCallbacks(new ApplicationStateManager() {
    @Override
    public void onActivityResumed(Activity activity) {
        doOnActivityResumed(activity);
    }

    @Override
    public void onActivityPaused(Activity activity) {
        doOnActivityPaused(activity);
    }
});
```

### Contributing
[CONTRIBUTING](../CONTRIBUTING.md)
{'fraction_non_alphanumeric': 0.10592938041305797, 'fraction_numerical': 0.0036642238507661557, 'mean_word_length': 3.906862745098039, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6413453', 'n_tokens_mistral': 839, 'n_tokens_neox': 785, 'n_words': 196}