use of com.squareup.otto.Subscribe in project zype-android by zype.
the class PlaylistFragment method handleRetrievePlaylist.
@Subscribe
public void handleRetrievePlaylist(PlaylistEvent event) {
Logger.d("handlePlaylistEvent size=" + event.getEventData().getModelData().getResponse().size());
Playlist data = event.getEventData().getModelData();
if (data.getResponse().size() > 0) {
if (mPlaylistList == null) {
mPlaylistList = new ArrayList<>();
}
mPlaylistList.addAll(data.getResponse());
// with platform in case some palylists were deleted
if (event.getEventData().getModelData().getPagination().getCurrent() == 1) {
DataHelper.deletePlaylistsByParentId(getActivity().getContentResolver(), parentId);
}
int i = DataHelper.insertPlaylists(getActivity().getContentResolver(), data.getResponse());
Logger.d("added " + i + " playlists");
} else {
mTvEmpty.setText(R.string.videos_empty);
}
}
use of com.squareup.otto.Subscribe in project WeexErosFramework by bmfe.
the class DispatchEventCenter method onWeexEvent.
@Subscribe
public void onWeexEvent(WeexEventBean weexEventBean) {
if (weexEventBean == null)
return;
Context context = safeContext(weexEventBean.getContext());
if (context == null)
return;
String params = weexEventBean.getJsParams();
switch(weexEventBean.getKey()) {
case WXConstant.WXEventCenter.EVENT_PAYBYWECHAT:
if (TextUtils.isEmpty(params))
return;
new EventPay().pay(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_OPEN:
if (TextUtils.isEmpty(params))
return;
if (weexEventBean.getCallbacks() != null) {
new EventOpen().open(params, context, weexEventBean.getCallbacks());
} else if (weexEventBean.getJscallback() != null) {
new EventOpen().open(params, context, weexEventBean.getJscallback());
} else {
new EventOpen().open(params, context);
}
break;
case WXConstant.WXEventCenter.EVENT_GETPARAMS:
new EventGetParams().getParams(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_BACK:
new EventBack().back(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_GETBACKPARAMS:
new EventGetBackParams().getBackParams(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_REFRESH:
new EventRefresh().refresh(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_FINISH:
new EventFinish().finish(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_TOMAP:
new EventToMap().toMap(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_TOWEBVIEW:
new EventWebView().toWebView(params, context);
break;
case WXConstant.WXEventCenter.EVENT_CALL:
new EventCall().call(params, context);
break;
case WXConstant.WXEventCenter.EVENT_SETDATA:
new EventSetData().setData(context, weexEventBean.getParamsList(), weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_GETDATA:
new EventGetData().getData(context, weexEventBean.getParamsList(), weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_DELETEDATA:
new EventDeleteData().deleteData(context, weexEventBean.getParamsList(), weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_REMOVEDATA:
new EventRemoveData().removeData(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_BROWSERIMG:
if (TextUtils.isEmpty(params))
return;
new EventBrowse().open(params, context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_ALERT:
if (TextUtils.isEmpty(params))
return;
JSCallback modal_alert_callback = weexEventBean.getJscallback();
new EventAlert().alert(params, modal_alert_callback, context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_CONFIRM:
if (TextUtils.isEmpty(params))
return;
ArrayList<JSCallback> callbacks = weexEventBean.getCallbacks();
if (callbacks == null && callbacks.size() < 2)
return;
new EventConfirm().confirm(params, callbacks.get(0), callbacks.get(1), context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_SHOWLOADING:
if (TextUtils.isEmpty(params))
return;
JSCallback modal_showloading_callback = weexEventBean.getJscallback();
new EventShowLoading().showLoading(params, modal_showloading_callback, context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_TOAST:
if (TextUtils.isEmpty(params))
return;
new EventToast().toast(params, context);
break;
case WXConstant.WXEventCenter.EVENT_FETCH:
new EventFetch().fetch(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CAMERA_UPLOADIMAGE:
new EventCamera().uploadImage(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CAMERA_PATH:
new EventCamera().openCamera(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CAMERA:
JSCallback jscallback = weexEventBean.getJscallback();
new EventCamera().scan(jscallback, context);
break;
case WXConstant.WXEventCenter.EVENT_RIGHTITEM:
new EventRightItem().setRightItem(params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_LEFTITEM:
new EventLeftItem().setLeftItem(params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CENTERITEM:
new EventCenterItem().setCenterItem(params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_NAVIGATIONINFO:
new EventNavigationInfo().setNavigationInfo(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_RESIGNKEYBOARD:
new EventTool().resignKeyboard(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_ISINSTALLWXAPP:
new EventTool().isWXInstall(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_GETCID:
new EventTool().getCid(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_COPYSTRING:
new EventTool().copyString(context, params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_MODAL_DISMISSLOADING:
new EventDismissLoading().dismiss(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_SHARE:
new EventShare().share(context, params, weexEventBean.getCallbacks().get(0), weexEventBean.getCallbacks().get(1));
break;
case WXConstant.WXEventCenter.EVENT_RELAYTOFRIEND:
new EventShare().relayToFriend(context, params, weexEventBean.getCallbacks());
break;
case WXConstant.WXEventCenter.EVENT_RELAYTOCRICLE:
new EventShare().relayToCricle(context, params, weexEventBean.getCallbacks());
break;
case WXConstant.WXEventCenter.EVENT_WECHATLOGIN:
new EventAuth().wechat(context, params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_OPENBROWSER:
new EventOpenBrowser().openBrowser(context, params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_COMMUNICATION_SMS:
new EventCommunication().sms(weexEventBean.getExpand().toString(), params, context);
break;
case WXConstant.WXEventCenter.EVENT_COMMUNICATION_CONTACTS:
new EventCommunication().contacts(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_SET_HOMEPAGE:
new EventSetHomePage().setHomePage(context, params);
break;
case WXConstant.WXEventCenter.EVENT_IMAGE_PICK:
new EventImage().pick(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_IMAGE_UPLOAD:
new EventFetch().uploadImage(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_NAV:
new EventNav().nav(params, context);
break;
case WXConstant.WXEventCenter.EVENT_GEOLOCATION_GET:
reflectionClazzPerform("com.plugamap.EventGeo", context, params, weexEventBean.getJscallback(), "");
break;
default:
break;
}
}
use of com.squareup.otto.Subscribe in project open-event-android by fossasia.
the class MainActivity method errorHandlerEvent.
@Subscribe
public void errorHandlerEvent(RetrofitError error) {
String errorType;
String errorDesc;
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netinfo = connMgr != null ? connMgr.getActiveNetworkInfo() : null;
if (!(netinfo != null && netinfo.isConnected())) {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new ShowNetworkDialogEvent());
} else {
if (error.getThrowable() instanceof IOException) {
errorType = "Timeout";
errorDesc = String.valueOf(error.getThrowable().getCause());
} else if (error.getThrowable() instanceof IllegalStateException) {
errorType = "ConversionError";
errorDesc = String.valueOf(error.getThrowable().getCause());
} else {
errorType = "Other Error";
errorDesc = String.valueOf(error.getThrowable().getLocalizedMessage());
}
Timber.tag(errorType).e(errorDesc);
showErrorSnackbar(errorType, errorDesc);
}
}
use of com.squareup.otto.Subscribe in project open-event-android by fossasia.
the class MainActivity method showNetworkDialog.
@Subscribe
public void showNetworkDialog(ShowNetworkDialogEvent event) {
completeHandler.hide();
if (dialogNetworkNotification == null) {
dialogNetworkNotification = DialogFactory.createCancellableSimpleActionDialog(this, R.string.net_unavailable, R.string.turn_on, R.string.ok, R.string.cancel, (dialogInterface, button) -> {
switch(button) {
case DialogInterface.BUTTON_POSITIVE:
Intent setNetworkIntent = new Intent(Settings.ACTION_SETTINGS);
startActivity(setNetworkIntent);
break;
case DialogInterface.BUTTON_NEGATIVE:
dialogNetworkNotification.dismiss();
return;
default:
}
});
}
dialogNetworkNotification.show();
}
use of com.squareup.otto.Subscribe in project open-event-android by fossasia.
the class MainActivity method startDownloadFromNetwork.
private void startDownloadFromNetwork() {
fromServer = true;
boolean preference = SharedPreferencesUtil.getBoolean(getResources().getString(R.string.download_mode_key), true);
if (preference) {
disposable.add(NetworkUtils.haveNetworkConnectionObservable(MainActivity.this).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(isConnected -> {
if (isConnected) {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
} else {
final Snackbar snackbar = Snackbar.make(mainFrame, R.string.internet_preference_warning, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.yes, view -> downloadFromAssets());
snackbar.show();
}
}));
} else {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
}
}
Aggregations