@Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   mActivityGraph =
       ((Application) getApplication()).getApplicationGraph().plus(new ActivityModule(this));
   mActivityGraph.inject(this);
 }
  /** {@inheritDoc} */
  @Override
  public void inject(Object target) {
    // ensure object graph has been created
    buildGraph();

    activityGraph.inject(target);
  }
 @Override
 public void onCreate() {
   super.onCreate();
   ActiveAndroid.initialize(this);
   mObjectGraph = ObjectGraph.create();
   mObjectGraph.inject(this);
 }
 public void inject(final Object object) {
   if (graph == null) {
     injectList.add(object);
   } else {
     graph.inject(object);
   }
 }
  public void onCreate(Context context, List<Object> modules) {
    DaggerApplication application = (DaggerApplication) context.getApplicationContext();
    mObjectGraph = application.getObjectGraph().plus(modules.toArray());

    // Inject ourselves so subclasses will have dependencies fulfilled when this method returns.
    mObjectGraph.inject(context);
  }
Exemple #6
0
  private void inject() {
    // ObjectGraph.creat()方法需要一个Module类,作用是让ObjectGraph对象知道哪些类需要注入
    ObjectGraph objectGraph = ObjectGraph.create(getModules().toArray());
    objectGraph.inject(this);

    System.out.print("");
  }
Exemple #7
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   activityGraph =
       ((MainApplication) getActivity().getApplication())
           .createScopedGraph(getModules().toArray());
   activityGraph.inject(this);
 }
  @Override
  public void onCreate() {
    super.onCreate();

    applicationGraph = ObjectGraph.create(getModules().toArray());

    applicationGraph.inject(this);
  }
 @Override
 public void onCreate() {
   super.onCreate();
   initData();
   initJPush();
   applicationGraph = ObjectGraph.create(new AndroidModule(this));
   applicationGraph.inject(this);
   notificationEventManager.register();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MyWeatherReporter myWeatherReporter = (MyWeatherReporter) getApplication();
    activityGraph = myWeatherReporter.getApplicationGraph().plus(getModules().toArray());

    activityGraph.inject(this);
  }
  private void buildGraph() {
    if (activityGraph == null) {
      final ApplicationExtension application = (ApplicationExtension) getApplication();
      final List<Object> modules = CollectionUtils.newList();

      // Create the activity graph by .plus-ing our modules onto the application graph.
      modules.add(new ActivityModule(this));
      modules.addAll(getActivityModules());

      activityGraph = application.getObjectGraph().plus(modules.toArray());

      // Inject ourselves so subclasses will have dependencies fulfilled when this method returns.
      activityGraph.inject(this);
    }
  }
  @Override
  public void onCreate() {
    super.onCreate();

    applicationGraph = ObjectGraph.create(getModules().toArray());

    applicationGraph.inject(this);

    userProvider.fetch();

    /*UserProvider.get(new MemoryUserDataSource(
        Arrays.asList(new User[]{
            new User.Builder()
                    .setFirstName("John")
                    .setLastName("Brunton")
                    .getInstance()})
    )).fetch();*/
  }
Exemple #13
0
  @Override
  public void onCreate() {
    super.onCreate();

    System.out.println(
        "JCC: APP STARTED ----------------------------------------------------------------------------------------------------");

    objectGraph = ObjectGraph.create(new ApplicationModule(this));
    objectGraph =
        objectGraph.plus(
            new PojoEventBusModule(),
            new DomainEventBusModule(this),
            new LoginEventBusModule(this));

    objectGraph.inject(this);

    UIComponentCache = new UIComponentCache();
  }
  @Override
  public void onCreate() {
    super.onCreate();
    // Parse.initialize(this, "64LrLB3jNDJQq8sSApLLHUWbjv2wmiACyemSLfN3",
    // "u1rLwcDJzwZuNYa06M0ODtsMqmNbYU9MPKwnjG3E");

    mPlusClient =
        new GoogleApiClient.Builder(this)
            .addApi(Plus.API, null)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .build();
    mPlusClient.connect();

    graph = ObjectGraph.create(getModules().toArray());
    for (final Object obj : injectList) {
      graph.inject(obj);
    }
    injectList.clear();
  }
  @Override
  public void onCreate() {
    super.onCreate();
    AndroidThreeTen.init(this);
    LeakCanary.install(this);

    if (BuildConfig.DEBUG) {
      Timber.plant(new DebugTree());
    } else {
      // TODO Crashlytics.start(this);
      // TODO Timber.plant(new CrashlyticsTree());
    }

    objectGraph = ObjectGraph.create(Modules.list(this));
    objectGraph.inject(this);

    lumberYard.cleanUp();
    Timber.plant(lumberYard.tree());

    registerActivityLifecycleCallbacks(activityHierarchyServer);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    BaseApp app = (BaseApp) getApplication();

    List<Object> modules = new ArrayList<>();
    addModules(modules);

    mActivityObjectGraph = app.getObjectGraph().plus(modules.toArray());
    if (isRequiringInject(getClass())) {
      mActivityObjectGraph.inject(this);
    }

    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
      toRunWhenVisible = savedInstanceState.getParcelableArrayList(KEY_MESSAGE_LIST);
    }

    if (toRunWhenVisible == null) {
      toRunWhenVisible = new ArrayList<>();
    }
  }
 public void inject(Object object) {
   mActivityObjectGraph.inject(object);
 }
 @Override
 public void inject(Object o) {
   objectGraph.inject(o);
 }
 public <T> T inject(T obj) {
   return mObjectGraph.inject(obj);
 }
 private void injectModules(MVPDaggerApp application) {
   activityGraph = application.getApplicationGraph().plus(getCombinedModules().toArray());
   activityGraph.inject(this);
 }
 private void buildObjectGraphAndInject() {
   objectGraph = ObjectGraph.create(Modules.list(this));
   objectGraph.inject(this);
 }
 public void inject(Object target) {
   objectGraph.inject(target);
 }
 @Override
 public void inject(Object object) {
   mObjectGraph.inject(object);
 }
 @Override
 public void inject(Object object) {
   mActivityGraph.inject(object);
 }
 /**
  * Used for injecting dependencies
  *
  * @param object object that needs dependencies injected
  */
 public void inject(Object object) {
   mGraph.inject(object);
 }
 public MusicVisualizer() {
   ObjectGraph objectGraph = ObjectGraph.create(new DaggerModule(this));
   objectGraph.inject(this);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ObjectGraph objectGraph = ObjectGraph.create(new KwikShopModule(getActivity()));
    locationViewModel = objectGraph.get(LocationViewModel.class);
    objectGraph.inject(this);

    context = getActivity().getApplicationContext();

    View rootView = inflater.inflate(R.layout.fragment_setting, container, false);
    ListView listView = (ListView) rootView.findViewById(android.R.id.list);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            // local change
            if (settingsList.get(position).equals(localeSetting)) changeLocalOption();

            // delete history of autocompletion
            if (settingsList.get(position).equals(autoCompletionDeletionSetting))
              deleteAutoCompletionHistoryOption();

            // manage units
            if (settingsList.get(position).equals(manageUnitsSetting)) manageUnits();

            // set API endpoint
            if (settingsList.get(position).equals(apiEndpointSetting)) setApiEndpoint();

            // location permission
            if (settingsList.get(position).equals(locationPermissionSetting)) {
              setLocationPermission(position);
            }

            // Item deletion
            if (settingsList.get(position).equals(itemDeletionSetting)) {
              setItemDeletionSetting(position);
            }

            // Shopping List deletion
            if (settingsList.get(position).equals(slDeletionSetting)) {
              setShoppingListDeletionSetting(position);
            }

            // Recipe deletion
            if (settingsList.get(position).equals(recipeDeletionSetting)) {
              setRecipeDeletionSetting(position);
            }

            // Default recipes
            if (settingsList.get(position).equals(recipeAddDefaultSetting)) {
              setRecipeAddDefaultSetting(position);
            }

            // Parser separator word
            if (settingsList.get(position).equals(parserSeparatorWordSetting)) {
              setParserSeparatorWord();
            }

            if (settingsList.get(position).equals(loginSetting)) {
              startLoginActivity();
            }

            if (settingsList.get(position).equals(syncNowSetting)) {
              SyncingActivity.requestSync();
            }

            if (settingsList.get(position).equals(enableSyncSetting)) {
              setEnableSynchronization(position);
            }

            if (settingsList.get(position).equals(syncIntervalSetting)) {
              selectSyncInterval();
            }

            if (settingsList.get(position).equals(placeTypeSetting)) {
              locationViewModel.setContext(context);
              locationViewModel.selectPlaceType();
            }

            if (settingsList.get(position).equals(askForLocalizationPermissionSetting)) {
              setAskForLocationPermission(position);
            }
          }
        });

    // set title for actionbar
    getActivity().setTitle(R.string.title_activity_settings);

    // Locale Setting
    localeSetting = new Setting(context);
    localeSetting.setName(R.string.settings_option_2_setlocale);
    localeSetting.setCaption(R.string.settings_option_2_desc);

    // Autocompletion deletion
    autoCompletionDeletionSetting = new Setting(context);
    autoCompletionDeletionSetting.setName(R.string.settings_option_3_deleteHistory);
    autoCompletionDeletionSetting.setCaption(R.string.settings_option_3_desc);

    // manage units
    manageUnitsSetting = new Setting(context);
    manageUnitsSetting.setName(R.string.settings_option_3_manageUnits);
    manageUnitsSetting.setCaption(R.string.settings_option_3_desc2);

    // API endpoint settings
    apiEndpointSetting = new Setting(context);
    apiEndpointSetting.setName(R.string.settings_option_4_APIEndPoint_Title);
    apiEndpointSetting.setCaption(R.string.settings_option_4_APIEndPoint_Desc);

    // permission for location tracking
    locationPermissionSetting = new Setting(context);
    locationPermissionSetting.setName(R.string.settings_option_5_location_permission_title);
    locationPermissionSetting.setCaption(R.string.settings_option_5_location_permission_desc);
    locationPermissionSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.LOCATION_PERMISSION, false, getActivity()));
    locationPermissionSetting.setViewVisibility(View.VISIBLE);

    // Show Dialog when deleting an item
    itemDeletionSetting = new Setting(context);
    itemDeletionSetting.setName(R.string.settings_option_6_item_deletion_name);
    itemDeletionSetting.setCaption(R.string.settings_option_6_item_deletion_descr);
    itemDeletionSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.ITEM_DELETION_SHOW_AGAIN_MSG, false, getActivity()));
    itemDeletionSetting.setViewVisibility(View.VISIBLE);

    // Show Dialog when deleting a Shopping List
    slDeletionSetting = new Setting(context);
    slDeletionSetting.setName(R.string.settings_options_delete_shoppinglist_name);
    slDeletionSetting.setCaption(R.string.settings_options_delete_shoppinglist_descr);
    slDeletionSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.SL_DELETION_SHOW_AGAIN_MSG, false, getActivity()));
    slDeletionSetting.setViewVisibility(View.VISIBLE);

    // Show Dialog when deleting a recipe
    recipeDeletionSetting = new Setting(context);
    recipeDeletionSetting.setName(R.string.settings_options_delete_recipe_name);
    recipeDeletionSetting.setCaption(R.string.settings_options_delete_recipe_descr);
    recipeDeletionSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.RECIPE_DELETION_SHOW_AGAIN_MSG, false, getActivity()));
    recipeDeletionSetting.setViewVisibility(View.VISIBLE);

    // Ask to add default recipes when the user has no recipes
    recipeAddDefaultSetting = new Setting(context);
    recipeAddDefaultSetting.setName(R.string.settings_options_add_default_recipes_name);
    recipeAddDefaultSetting.setCaption(R.string.settings_options_add_default_recipes_descr);
    recipeAddDefaultSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.ASK_TO_ADD_DEFAULT_RECIPES, false, getActivity()));
    recipeAddDefaultSetting.setViewVisibility(View.VISIBLE);

    // Choose separator word for the parser
    parserSeparatorWordSetting = new Setting(context);
    parserSeparatorWordSetting.setName(R.string.settings_option_7_parser_separate_word_name);
    parserSeparatorWordSetting.setCaption(R.string.settings_option_7_parser_separate_word_descr);

    // LoginActivity
    loginSetting = new Setting(context);
    loginSetting.setName(R.string.settings_option_8_login_name);
    loginSetting.setCaption(R.string.settings_option_8_login_descr);

    // Ask for Localization Permission
    askForLocalizationPermissionSetting = new Setting(context);
    askForLocalizationPermissionSetting.setName(R.string.setting_permission_for_localization_title);
    askForLocalizationPermissionSetting.setCaption(
        R.string.setting_permission_for_localization_desc);
    askForLocalizationPermissionSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.LOCATION_PERMISSION_SHOW_AGAIN_MSG, false, getActivity()));
    askForLocalizationPermissionSetting.setViewVisibility(View.VISIBLE);

    enableSyncSetting = new Setting(context);
    enableSyncSetting.setName(R.string.settings_option_enableSync_name);
    enableSyncSetting.setCaption(R.string.settings_option_enableSync_descr);
    enableSyncSetting.setChecked(
        SharedPreferencesHelper.loadBoolean(
            SharedPreferencesHelper.ENABLE_SYNCHRONIZATION, true, context));
    enableSyncSetting.setViewVisibility(View.VISIBLE);

    syncNowSetting = new Setting(context);
    syncNowSetting.setName(R.string.settings_option_sync_name);
    syncNowSetting.setCaption(R.string.settings_option_sync_descr);

    syncIntervalSetting = new Setting(context);
    syncIntervalSetting.setName(R.string.settings_options_syncInterval_name);
    syncIntervalSetting.setCaption(R.string.settings_options_syncInterval_descr);

    // Change Place Request Type
    placeTypeSetting = new Setting(context);
    placeTypeSetting.setName(R.string.localization_store_types_dialog_title);
    placeTypeSetting.setCaption(R.string.localization_store_types_dialog_caption);

    // headers
    Setting locationHeaderSetting;
    Setting generalHeaderSetting;
    Setting accountHeaderSetting;
    Setting synchronizationHeaderSetting;
    Setting otherHeaderSetting;

    // localization header
    locationHeaderSetting = new Setting(context);
    locationHeaderSetting.setIsHeader(true);
    locationHeaderSetting.setName(R.string.localization);

    // general header
    generalHeaderSetting = new Setting(context);
    generalHeaderSetting.setIsHeader(true);
    generalHeaderSetting.setName(R.string.general);

    // account header
    accountHeaderSetting = new Setting(context);
    accountHeaderSetting.setIsHeader(true);
    accountHeaderSetting.setName(R.string.account);

    // synchronization header
    synchronizationHeaderSetting = new Setting(context);
    synchronizationHeaderSetting.setIsHeader(true);
    synchronizationHeaderSetting.setName(R.string.synchronization);

    // other heady
    otherHeaderSetting = new Setting(context);
    otherHeaderSetting.setIsHeader(true);
    otherHeaderSetting.setName(R.string.other);

    // list of settings
    settingsList =
        new ArrayList<>(
            Arrays.asList(
                new Setting[] {
                  accountHeaderSetting,
                  loginSetting,
                  generalHeaderSetting,
                  localeSetting,
                  autoCompletionDeletionSetting,
                  manageUnitsSetting,
                  recipeAddDefaultSetting,
                  parserSeparatorWordSetting,
                  locationHeaderSetting,
                  locationPermissionSetting,
                  askForLocalizationPermissionSetting,
                  placeTypeSetting,
                  synchronizationHeaderSetting,
                  syncNowSetting,
                  syncIntervalSetting,
                  enableSyncSetting,
                  otherHeaderSetting,
                  itemDeletionSetting,
                  slDeletionSetting,
                  recipeDeletionSetting
                }));

    if (BuildConfig.DEBUG_MODE) {
      settingsList.add(apiEndpointSetting);
    }

    // Adapter for settings view
    objAdapter = new SettingAdapter(getActivity(), R.layout.fragment_setting_row, settingsList);
    listView.setAdapter(objAdapter);
    listView.setSelector(R.drawable.list_selector);
    listView.setDividerHeight(0);

    return rootView;
  }