Search in sources :

Example 1 with ThreadMode

use of org.greenrobot.eventbus.ThreadMode in project EventBus by greenrobot.

the class TestSetupActivity method startClick.

public void startClick(View v) {
    TestParams params = new TestParams();
    Spinner spinnerThread = findViewById(R.id.spinnerThread);
    String threadModeStr = spinnerThread.getSelectedItem().toString();
    ThreadMode threadMode = ThreadMode.valueOf(threadModeStr);
    params.setThreadMode(threadMode);
    params.setEventInheritance(((CheckBox) findViewById(R.id.checkBoxEventBusEventHierarchy)).isChecked());
    params.setIgnoreGeneratedIndex(((CheckBox) findViewById(R.id.checkBoxEventBusIgnoreGeneratedIndex)).isChecked());
    EditText editTextEvent = findViewById(R.id.editTextEvent);
    params.setEventCount(Integer.parseInt(editTextEvent.getText().toString()));
    EditText editTextSubscriber = findViewById(R.id.editTextSubscribe);
    params.setSubscriberCount(Integer.parseInt(editTextSubscriber.getText().toString()));
    Spinner spinnerTestToRun = findViewById(R.id.spinnerTestToRun);
    int testPos = spinnerTestToRun.getSelectedItemPosition();
    params.setTestNumber(testPos + 1);
    ArrayList<Class<? extends Test>> testClasses = initTestClasses(testPos);
    params.setTestClasses(testClasses);
    Intent intent = new Intent();
    intent.setClass(this, TestRunnerActivity.class);
    intent.putExtra("params", params);
    startActivity(intent);
}
Also used : ThreadMode(org.greenrobot.eventbus.ThreadMode) EditText(android.widget.EditText) Spinner(android.widget.Spinner) Intent(android.content.Intent)

Example 2 with ThreadMode

use of org.greenrobot.eventbus.ThreadMode in project PhotoNoter by yydcdut.

the class HomePresenterImpl method onCategoryDeleteEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onCategoryDeleteEvent(CategoryDeleteEvent categoryDeleteEvent) {
    mRxCategory.getAllCategories().observeOn(AndroidSchedulers.mainThread()).subscribe(categories -> {
        int beforeCategoryId = mCategoryId;
        for (Category category : categories) {
            if (category.isCheck()) {
                mCategoryId = category.getId();
                break;
            }
        }
        mHomeView.updateCategoryList(categories);
        if (mCategoryId != beforeCategoryId) {
            mHomeView.changePhotos4Category(mCategoryId);
        }
    }, (throwable -> YLog.e(throwable)));
}
Also used : Context(android.content.Context) RxPhotoNote(com.yydcdut.note.model.rx.RxPhotoNote) PhotoNoteDeleteEvent(com.yydcdut.note.bus.PhotoNoteDeleteEvent) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) RxUser(com.yydcdut.note.model.rx.RxUser) Inject(javax.inject.Inject) CategoryUpdateEvent(com.yydcdut.note.bus.CategoryUpdateEvent) UserImageEvent(com.yydcdut.note.bus.UserImageEvent) Const(com.yydcdut.note.utils.Const) Handler(android.os.Handler) ContextLife(com.yydcdut.note.injector.ContextLife) EventBus(org.greenrobot.eventbus.EventBus) Category(com.yydcdut.note.entity.Category) FilePathUtils(com.yydcdut.note.utils.FilePathUtils) SDKInitializer(com.baidu.mapapi.SDKInitializer) PermissionUtils(com.yydcdut.note.utils.PermissionUtils) RxCategory(com.yydcdut.note.model.rx.RxCategory) CategoryMoveEvent(com.yydcdut.note.bus.CategoryMoveEvent) IHomePresenter(com.yydcdut.note.presenters.home.IHomePresenter) IHomeView(com.yydcdut.note.views.home.IHomeView) PhotoNoteCreateEvent(com.yydcdut.note.bus.PhotoNoteCreateEvent) ThreadMode(org.greenrobot.eventbus.ThreadMode) CategoryEditEvent(com.yydcdut.note.bus.CategoryEditEvent) Subscribe(org.greenrobot.eventbus.Subscribe) Permission(com.yydcdut.note.utils.permission.Permission) ComparatorFactory(com.yydcdut.note.model.compare.ComparatorFactory) ImageLoaderManager(com.yydcdut.note.utils.ImageManager.ImageLoaderManager) CategoryCreateEvent(com.yydcdut.note.bus.CategoryCreateEvent) CategoryDeleteEvent(com.yydcdut.note.bus.CategoryDeleteEvent) AspectPermission(com.yydcdut.note.aspect.permission.AspectPermission) Activity(android.app.Activity) YLog(com.yydcdut.note.utils.YLog) IView(com.yydcdut.note.views.IView) Category(com.yydcdut.note.entity.Category) RxCategory(com.yydcdut.note.model.rx.RxCategory) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 3 with ThreadMode

use of org.greenrobot.eventbus.ThreadMode in project Signal-Android by WhisperSystems.

the class MainActivity method onEventMainThread.

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(@NonNull TransferStatus event) {
    TextView text = new TextView(this);
    text.setText(event.getTransferMode().toString());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    text.setLayoutParams(params);
    list.addView(text);
    if (event.getTransferMode() == TransferStatus.TransferMode.VERIFICATION_REQUIRED) {
        new AlertDialog.Builder(this).setTitle("Verification Required").setMessage("Code: " + event.getAuthenticationCode()).setPositiveButton("Yes, Same", (d, w) -> DeviceToDeviceTransferService.setAuthenticationCodeVerified(this, true)).setNegativeButton("No, different", (d, w) -> DeviceToDeviceTransferService.setAuthenticationCodeVerified(this, false)).setCancelable(false).show();
    }
}
Also used : TransferStatus(org.signal.devicetransfer.TransferStatus) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) ServerTask(org.signal.devicetransfer.ServerTask) ClientTask(org.signal.devicetransfer.ClientTask) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) Random(java.util.Random) PendingIntent(android.app.PendingIntent) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Manifest(android.Manifest) EventBus(org.greenrobot.eventbus.EventBus) NotificationChannel(android.app.NotificationChannel) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) Build(android.os.Build) Log(android.util.Log) OutputStream(java.io.OutputStream) NotificationManager(android.app.NotificationManager) DeviceToDeviceTransferService(org.signal.devicetransfer.DeviceToDeviceTransferService) TransferNotificationData(org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData) IOException(java.io.IOException) ThreadMode(org.greenrobot.eventbus.ThreadMode) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Subscribe(org.greenrobot.eventbus.Subscribe) InputStream(java.io.InputStream) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Intent (android.content.Intent)3 ThreadMode (org.greenrobot.eventbus.ThreadMode)3 Context (android.content.Context)2 EventBus (org.greenrobot.eventbus.EventBus)2 Subscribe (org.greenrobot.eventbus.Subscribe)2 Manifest (android.Manifest)1 Activity (android.app.Activity)1 NotificationChannel (android.app.NotificationChannel)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 PackageManager (android.content.pm.PackageManager)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Log (android.util.Log)1 ViewGroup (android.view.ViewGroup)1 EditText (android.widget.EditText)1 LinearLayout (android.widget.LinearLayout)1 Spinner (android.widget.Spinner)1 TextView (android.widget.TextView)1