本文整理汇总了Java中com.squareup.otto.ThreadEnforcer类的典型用法代码示例。如果您正苦于以下问题:Java ThreadEnforcer类的具体用法?Java ThreadEnforcer怎么用?Java ThreadEnforcer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ThreadEnforcer类属于com.squareup.otto包,在下文中一共展示了ThreadEnforcer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
@Override public void onCreate() {
super.onCreate();
// create an event bus to allow our gcm intent service to notify when new messages are available
EVENT_BUS = new Bus(ThreadEnforcer.MAIN);
// create instances - typically these would be created as part of a dependency injection framework to allow for mocking, different environments, etc.
SharedPreferences gcmSharedPrefs = getSharedPreferences(GCM_SHARED_PREFS_NAME, Context.MODE_PRIVATE);
PUSH_REGISTRATION_SERVICE = new RestAdapter.Builder()
.setEndpoint(BuildConfig.PUSH_SERVER_ENDPOINT)
.setLogLevel(RestAdapter.LogLevel.FULL)
.build()
.create(ExamplePushRegistrationService.class);
PUSH_MANAGER = new ExamplePushManager(InstanceID.getInstance(this), GCM_SENDER_ID, gcmSharedPrefs, PUSH_REGISTRATION_SERVICE);
// this will register the device with GCM and retrieve a registration id for this device
PUSH_MANAGER.registerWithGCM();
}
示例2: onCreate
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
bus = new Bus(ThreadEnforcer.ANY);
list = new ArrayList<>();
StringBuffer buffer = new StringBuffer();
try (BufferedReader input = new BufferedReader(
new InputStreamReader(
openFileInput(RSS_FILE)))) {
String line;
while ((line = input.readLine()) != null) {
buffer.append(line);
}
} catch (Exception ex) {
// do nothing
}
if (buffer!=null && buffer.length()>0 )
{
Gson gson = new Gson();
Type type = new TypeToken<List<RssItem>>() {}.getType();
List<RssItem> fromJson = gson.fromJson(buffer.toString(), type);
list.addAll(fromJson);
}
}
示例3: PerfTestOtto
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
public PerfTestOtto(Context context, TestParams params) {
super(context, params);
eventBus = new Bus(ThreadEnforcer.ANY);
subscribers = new ArrayList<Object>();
eventCount = params.getEventCount();
expectedEventCount = eventCount * params.getSubscriberCount();
subscriberClass = Subscriber.class;
}
示例4: bus
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
public static Bus bus() {
Bus localInstance = instance;
if (localInstance == null) {
synchronized (AndroidBus.class) {
localInstance = instance;
if (localInstance == null) {
instance = localInstance = new AndroidBus(ThreadEnforcer.ANY);
}
}
}
return localInstance;
}
示例5: provideBus
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
/**
* 提供全局单例的event bus
*/
@Provides
@Singleton
public Bus provideBus() {
// our event bus running on any thread
return new Bus(ThreadEnforcer.ANY);
}
示例6: AndroidMiniClientOptions
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
AndroidMiniClientOptions(Application ctx) {
this.prefs=new AndroidPrefStore(PreferenceManager.getDefaultSharedPreferences(ctx));
this.configDir = ctx.getFilesDir();
this.cacheDir = ctx.getCacheDir();
this.bus = new OttoBusImpl(new Bus(ThreadEnforcer.ANY));
this.isTV = ctx.getResources().getBoolean(R.bool.istv);
this.isTOUCH = !isTV;
this.advancedAspects=true;
}
示例7: bus
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
public static Bus bus() {
Bus localInstance = instance;
if (localInstance == null) {
synchronized (Bus.class) {
localInstance = instance;
if (localInstance == null) {
instance = localInstance = new Bus(ThreadEnforcer.ANY);
}
}
}
return localInstance;
}
示例8: onCreate
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
downloadButton = (Button) findViewById(R.id.button);
notificationText = (TextView) findViewById(R.id.textView);
notificationInfo = (TextView) findViewById(R.id.textViewInfo);
downloadButton.setOnClickListener(this);
bus = new Bus (ThreadEnforcer.ANY);
bus.register(this);
downloadInformation = new RestActorSource(bus);
}
示例9: getEventBus
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
/**
* Lazy loading event bus.
*
* @return Event bus service.
*/
public Bus getEventBus() {
if (eventBus == null) {
eventBus = new Bus(ThreadEnforcer.MAIN, LOG_TAG);
}
return eventBus;
}
示例10: setUp
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
@Before public void setUp() throws Exception {
this.busWrapper = new OttoBusWrapper(new Bus(ThreadEnforcer.ANY));
Logger logger = Mockito.mock(Logger.class);
Context context = Mockito.mock(Context.class);
OnlineChecker onlineChecker = Mockito.mock(OnlineChecker.class);
this.receiver = new NetworkConnectionChangeReceiver(busWrapper, logger, context, onlineChecker);
this.connectivityChangeEvents = new ArrayList<>();
}
示例11: setUp
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
@Before public void setUp() throws Exception {
this.busWrapper = new OttoBusWrapper(new Bus(ThreadEnforcer.ANY));
Logger logger = Mockito.mock(Logger.class);
Context context = Mockito.mock(Context.class);
this.receiver = new InternetConnectionChangeReceiver(busWrapper, logger, context);
this.connectivityChangeEvents = new ArrayList<>();
}
示例12: getInstance
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
public static Bus getInstance() {
if (mInstance == null) {
mInstance = new Bus(ThreadEnforcer.ANY);
}
if (statProducer == null) {
statProducer = new UploadStatusEventProducer();
statProducer.register(mInstance);
}
return mInstance;
}
示例13: provideBus
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
/**
* Provides the event bus for the application.
*
* @return the application event bus.
*/
@Provides
Bus provideBus() {
if (mBus == null)
mBus = new Bus(ThreadEnforcer.ANY);
return mBus;
}
示例14: initialize
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
public static void initialize() {
mBus = new Bus(ThreadEnforcer.MAIN);
mHandler = new Handler();
// Activity and fragment lifecycle events make it difficult to reliably
// make register and unregister calls in a 1-to-1 way. So we're going
// to make sure that things only get registered once and unregistered if
// they're actually registered.
mRegisteredObjects = new HashSet<Object>();
}
示例15: onCreate
import com.squareup.otto.ThreadEnforcer; //导入依赖的package包/类
@Override
public void onCreate()
{
super.onCreate();
bus = new Bus(ThreadEnforcer.ANY);
Crittercism.initialize(getApplicationContext(), "527b160b8b2e3376d3000003");
}