Android Open Source - xposed-keyboard-tweaks Context Manager






From Project

Back to project page xposed-keyboard-tweaks.

License

The source code is released under:

Apache License

If you think the Android project xposed-keyboard-tweaks listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ca.spacek.gkdd.blacklist.gk;
//  w ww . j  a  va2  s .c om
import android.content.Context;

import com.google.common.base.Optional;

import ca.spacek.gkdd.CachedBlackListDictionaryWordContentObserver;
import ca.spacek.gkdd.contentprovider.DictionaryWordContentProvider;

/**
 * Created by temp on 22/04/14.
 */
public class ContextManager {
    private Optional<Context> currentContext = Optional.absent();
    private CachedBlackListDictionaryWordContentObserver contentObserver;

    public ContextManager(CachedBlackListDictionaryWordContentObserver contentObserver) {
        this.contentObserver = contentObserver;
    }

    public Optional<Context> get() {
        return currentContext;
    }

    public void update(Context context) {
        if (currentContext.isPresent()) {
            unregisterContentObserver(currentContext.get());
        }
        this.currentContext = Optional.of(context);
        registerContentObserver(context);
    }

    private void registerContentObserver(Context context) {
        context.getContentResolver().registerContentObserver(DictionaryWordContentProvider.CONTENT_URI, false, contentObserver);
    }

    private void unregisterContentObserver(Context context) {
        context.getContentResolver().unregisterContentObserver(contentObserver);
    }

    public void clear() {
        currentContext = Optional.absent();
    }
}




Java Source Code List

ca.spacek.gkdd.BlackList.java
ca.spacek.gkdd.CachedBlackListDictionaryWordContentObserver.java
ca.spacek.gkdd.CachedBlackList.java
ca.spacek.gkdd.DictionaryWordsListActivity.java
ca.spacek.gkdd.Initialize.java
ca.spacek.gkdd.Injector.java
ca.spacek.gkdd.blacklist.AddToBlackListHook.java
ca.spacek.gkdd.blacklist.ContextChangeHook.java
ca.spacek.gkdd.blacklist.GetSuggestedWordsHook.java
ca.spacek.gkdd.blacklist.ReflectionException.java
ca.spacek.gkdd.blacklist.SuggestionBlackLister.java
ca.spacek.gkdd.blacklist.gk.ContextManager.java
ca.spacek.gkdd.blacklist.gk.CurrentGoogleKeyboardInjector.java
ca.spacek.gkdd.blacklist.gk.LongPressReplacementMethod.java
ca.spacek.gkdd.blacklist.gk.OnSuggestedWordCallbackHandler.java
ca.spacek.gkdd.blacklist.gk.OnSuggestedWordCallbackProxyFactory.java
ca.spacek.gkdd.blacklist.gk.PackageReflection.java
ca.spacek.gkdd.blacklist.gk.SuggestedWordInfoTransform.java
ca.spacek.gkdd.blacklist.gk.hook.ProfileAddToBlackListHook.java
ca.spacek.gkdd.blacklist.gk.hook.ProfileContextChangeHook.java
ca.spacek.gkdd.blacklist.gk.hook.ProfileGetSuggestedWordsHook.java
ca.spacek.gkdd.contentprovider.DictionaryWordContentProvider.java
ca.spacek.gkdd.data.DictionaryWordDatabaseHelper.java
ca.spacek.gkdd.data.DictionaryWordTable.java