Android Open Source - InfuseFactory Infuse Creator






From Project

Back to project page InfuseFactory.

License

The source code is released under:

/** * Copyright (c) 2014 Lazu Ioan-Bogdan * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from ...

If you think the Android project InfuseFactory 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 com.factory.infuse;
//from www .java 2 s  .  co  m
import java.util.Map;
import java.util.WeakHashMap;

import android.content.Context;

import com.factory.infuse.internal.InfuserGlobal;
import com.factory.infuse.internal.InfuserScoped;
import com.factory.infuse.internal.scope.ScopeFactory;

public class InfuseCreator {  
  private Map<Object, Infuser> scopedInfusers;
  
  private Infuser globalInfuser;  
  private Scope scopeGlobal;
  private Context context;
  
  public InfuseCreator() {
    scopedInfusers = new WeakHashMap<Object, Infuser>();
    
    globalInfuser = InfuserGlobal.getInfuserInstance();
    scopeGlobal = ScopeFactory.getGlobalScope();
  }
  
  // Clear and populate the global scope
  public void clearGlobalInstances() {
    scopeGlobal.clearScope();
    scopeGlobal.markScoped(Context.class, context);
  }
  
  // Set the context and populate the global scope
  public void setContext(Context context) {
    this.context = context; 
    clearGlobalInstances();
  }
  
  public Infuser obtainScopedInfuser(Object key) {
    if(scopedInfusers.containsKey(key)) {
      return scopedInfusers.get(key);
    } else {
      Infuser infuser = new InfuserScoped();
      scopedInfusers.put(key, infuser);
      
      return infuser;
    }
  }
  
//  public void deleteScopedInfuser(Object key) {
//    if(scopedInfusers.containsKey(key)) {
//      scopedInfusers.remove(key);
//    }
//  }
  
  public Infuser obtainGlobalInfuser() {
    return globalInfuser;
  }
}




Java Source Code List

com.example.infuseexample.ExampleApplication.java
com.example.infuseexample.MainActivity.java
com.example.infuseexample.MainFragmentActivity.java
com.example.other.mock.DatabaseAdapter.java
com.example.other.mock.NetworkingAdapter.java
com.example.other.mock.PreferencesAdapter.java
com.example.other.ui.adapter.TestListAdapter.java
com.example.other.ui.listener.HideListener.java
com.example.other.ui.listener.ListListener.java
com.factory.InfuseFactory.java
com.factory.android.InfuseActivityActionBar.java
com.factory.android.InfuseActivity.java
com.factory.android.InfuseApplication.java
com.factory.android.InfuseFragment.java
com.factory.infuse.InfuseCreator.java
com.factory.infuse.Infuser.java
com.factory.infuse.Scope.java
com.factory.infuse.annotation.InfuseView.java
com.factory.infuse.annotation.Infuse.java
com.factory.infuse.annotation.InitializeViews.java
com.factory.infuse.annotation.Initialize.java
com.factory.infuse.annotation.Instantiate.java
com.factory.infuse.annotation.ScopedSingleton.java
com.factory.infuse.annotation.Singleton.java
com.factory.infuse.annotation.bindings.BindAdapter.java
com.factory.infuse.annotation.bindings.BindOnClick.java
com.factory.infuse.annotation.bindings.BindOnItemClick.java
com.factory.infuse.annotation.bindings.BindOnItemLongClick.java
com.factory.infuse.annotation.bindings.BindOnScroll.java
com.factory.infuse.annotation.bindings.BindOnText.java
com.factory.infuse.annotation.bindings.BindOnTouch.java
com.factory.infuse.internal.InfuseReflection.java
com.factory.infuse.internal.InfuserGlobal.java
com.factory.infuse.internal.InfuserScoped.java
com.factory.infuse.internal.ViewResolver.java
com.factory.infuse.internal.base.AbsInfuser.java
com.factory.infuse.internal.lock.SharedLock.java
com.factory.infuse.internal.scope.GlobalScope.java
com.factory.infuse.internal.scope.LocalScope.java
com.factory.infuse.internal.scope.ScopeFactory.java
com.factory.java.InfuseObject.java