All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.shipdream.lib.android.mvc.manager.BaseManagerImpl Maven / Gradle / Ivy

/*
 * Copyright 2016 Kejun Xia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.shipdream.lib.android.mvc.manager;

import com.shipdream.lib.android.mvc.MvcBean;
import com.shipdream.lib.android.mvc.event.BaseEventC;
import com.shipdream.lib.android.mvc.event.bus.EventBus;
import com.shipdream.lib.android.mvc.event.bus.annotation.EventBusC;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;

/**
 * Abstract manager with model that needs to be managed. A manager can be shared by multiple
 * controllers. A LoginManager is an good example that manages the state of logged in user.
 *
 * 

* Managers should only be serving controllers and not visible to views. Managers can post events * to controllers to notify the state change in the shared manager. *

*/ public abstract class BaseManagerImpl extends MvcBean { protected Logger logger = LoggerFactory.getLogger(getClass()); @Inject @EventBusC private EventBus eventBus2C; /** * Post an event to other controllers. Event will be posted on the same thread as the caller. * * @param event event to controllers */ protected void postControllerEvent(final BaseEventC event) { if (eventBus2C != null) { eventBus2C.post(event); } else { logger.warn("Trying to post event {} to EventBusC which is null", event.getClass().getName()); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy