本文整理匯總了Java中org.greenrobot.eventbus.EventBus.post方法的典型用法代碼示例。如果您正苦於以下問題:Java EventBus.post方法的具體用法?Java EventBus.post怎麽用?Java EventBus.post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.greenrobot.eventbus.EventBus
的用法示例。
在下文中一共展示了EventBus.post方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleOnClick
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
public static void handleOnClick(DialogInterface dialog, int which, Activity activity, Bundle arguments) {
if (EVENT_TYPE_ON_CLICK != null) {
Object event;
try {
event = EVENT_TYPE_ON_CLICK.newInstance();
} catch (Exception e) {
throw new RuntimeException("Event cannot be constructed", e);
}
EventBus eventBus = ErrorDialogManager.factory.config.getEventBus();
eventBus.post(event);
}
boolean finish = arguments.getBoolean(ErrorDialogManager.KEY_FINISH_AFTER_DIALOG, false);
if (finish && activity != null) {
activity.finish();
}
}
示例2: syncItems
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
private synchronized void syncItems() {
int numReceived = this.streamItems.size();
for (int i = 0; i < this.receivers.size(); i++) {
int numSent = this.numSents.get(i);
if (numSent < numReceived) {
this.numSents.set(i, numReceived);
EventBus eventBus = this.eventBuses.get(i);
int currentReceiverCount = this.receiverCount;
for (int itemId = numSent; itemId < numReceived; itemId++) {
eventBus.post(streamItems.get(itemId));
if (currentReceiverCount != this.receiverCount) break;
}
}
}
}
示例3: apply
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
public final Tout apply(UQI uqi, Tin input) {
this.uqi = uqi;
this.input = input;
this.output = this.init(uqi, input);
EventBus tempBus = new EventBus();
tempBus.register(this);
tempBus.post(new Object());
return this.output;
}
示例4: ShareTresorViewModel
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
@Inject
public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) {
this.zerokit = zerokit;
this.adminApi = adminApi;
this.inProgress = new ObservableField<>(false);
this.userId = new ObservableField<>();
this.textSummary = new ObservableField<>();
this.sharedWithUserId = new ObservableField<>("");
this.clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
shareTresor(tresorId, userId.get());
}
};
errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
@Override
public void call(ResponseZerokitError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.toString()));
}
};
errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
@Override
public void call(ResponseAdminApiError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.toString()));
}
};
}
示例5: EncryptTextViewModel
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
@Inject
public EncryptTextViewModel(Zerokit zerokit, final EventBus eventBus) {
this.zerokit = zerokit;
this.inProgressEncrypt = new ObservableField<>(false);
this.inProgressDecrypt = new ObservableField<>(false);
this.encryptClicked = new ObservableField<>(false);
this.textOriginal = new ObservableField<>();
this.textEncrypted = new ObservableField<>();
this.textSummary = new ObservableField<>();
this.textDecrypted = new ObservableField<>();
this.clickListenerEncrypt = new View.OnClickListener() {
@Override
public void onClick(View v) {
encryptClicked.set(true);
encrypt(tresorId, textOriginal.get());
}
};
this.clickListenerDecrypt = new View.OnClickListener() {
@Override
public void onClick(View v) {
decrypt(textEncrypted.get());
}
};
this.clickListenerCopy = new View.OnClickListener() {
@Override
public void onClick(View v) {
eventBus.post(new CopyEncryptedTextMessage(textEncrypted.get()));
}
};
}
示例6: CreateTresorViewModel
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
@Inject
public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) {
this.zerokit = zerokit;
this.adminApi = adminApi;
this.eventBus = eventBus;
this.inProgress = new ObservableField<>(false);
this.tresorId = new ObservableField<>("");
this.clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
createTresor();
inProgress.set(true);
}
};
errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
@Override
public void call(ResponseZerokitError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.toString()));
}
};
errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
@Override
public void call(ResponseAdminApiError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.toString()));
}
};
}
示例7: MainViewModel
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
@Inject
public MainViewModel(final EventBus eventBus) {
onNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
eventBus.post(new TabSelectMessage(item.getItemId()));
return true;
}
};
}
示例8: sendSystemEventBroadcast
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
private void sendSystemEventBroadcast(DeviceStateChange deviceStateChange, EventBus eventBus) {
cloud.sendSystemEventBroadcast(deviceStateChange);
eventBus.post(deviceStateChange);
}
示例9: RegistrationViewModel
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
@Inject
public RegistrationViewModel(final Zerokit zerokit, AdminApi adminApi, final EventBus eventBus, SharedPreferences sharedPreferences, final Resources resources) {
this.zerokit = zerokit;
this.adminApi = adminApi;
this.eventBus = eventBus;
this.sharedPreferences = sharedPreferences;
inProgress = new ObservableField<>(false);
userName = new ObservableField<>("");
passwordError = new ObservableField<>("");
passwordConfirmError = new ObservableField<>("");
userNameError = new ObservableField<>("");
passwordStrength = new ObservableInt();
seekbarColor = new ObservableField<>(resources.getDrawable(R.drawable.progress));
colorRes = new int[]{R.color.red, R.color.deep_orange, R.color.orange, R.color.light_green, R.color.green};
clickListenerRegistration = new View.OnClickListener() {
@Override
public void onClick(View view) {
attemptRegistration();
}
};
errorResponseHandlerAdmin = new Action<ResponseAdminApiError>() {
@Override
public void call(ResponseAdminApiError responseAdminApiError) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(responseAdminApiError.getMessage()));
}
};
errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
@Override
public void call(ResponseZerokitError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.getDescription()));
}
};
focusChangeListener = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
passwordError.set("");
userNameError.set("");
passwordConfirmError.set("");
}
};
passwordExporter = new PasswordEditText.PasswordExporter();
passwordExporterConfirm = new PasswordEditText.PasswordExporter();
passwordExporter.setOnChangeListener(new PasswordEditText.OnChangeListener() {
@Override
public void onChanged() {
zerokit.getPasswordStrength(passwordExporter).enqueue(new Action<ResponseZerokitPasswordStrength>() {
@Override
public void call(ResponseZerokitPasswordStrength responseZerokitPasswordStrength) {
int score = responseZerokitPasswordStrength.getScore();
passwordStrength.set((score + 1) * 20);
((LayerDrawable) seekbarColor.get()).findDrawableByLayerId(android.R.id.progress).setColorFilter(resources.getColor(colorRes[score]), PorterDuff.Mode.SRC_IN);
}
});
}
});
}
示例10: LoginViewModel
import org.greenrobot.eventbus.EventBus; //導入方法依賴的package包/類
@Inject
public LoginViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) {
this.zerokit = zerokit;
this.adminApi = adminApi;
this.eventBus = eventBus;
this.passwordExporter = new PasswordEditText.PasswordExporter();
this.clickListenerLogin = new View.OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
};
userName = new ObservableField<>("");
passwordError = new ObservableField<>("");
usernameError = new ObservableField<>("");
inProgress = new ObservableField<>(false);
errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
@Override
public void call(ResponseZerokitError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.toString()));
}
};
errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
@Override
public void call(ResponseAdminApiError errorResponse) {
inProgress.set(false);
eventBus.post(new ShowMessageMessage(errorResponse.toString()));
}
};
focusChangeListener = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
passwordError.set("");
usernameError.set("");
}
};
}