com.jakewharton.rxrelay.PublishRelay Java Examples

The following examples show how to use com.jakewharton.rxrelay.PublishRelay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Singleton @Provides RootInstallationRetryHandler provideRootInstallationRetryHandler(
    InstallManager installManager) {

  Intent retryActionIntent = new Intent(application, RootInstallNotificationEventReceiver.class);
  retryActionIntent.setAction(RootInstallNotificationEventReceiver.ROOT_INSTALL_RETRY_ACTION);

  PendingIntent retryPendingIntent = PendingIntent.getBroadcast(application, 2, retryActionIntent,
      PendingIntent.FLAG_UPDATE_CURRENT);

  NotificationCompat.Action action =
      new NotificationCompat.Action(R.drawable.ic_refresh_action_black,
          application.getString(R.string.generalscreen_short_root_install_timeout_error_action),
          retryPendingIntent);

  PendingIntent deleteAction = PendingIntent.getBroadcast(application, 3,
      retryActionIntent.setAction(
          RootInstallNotificationEventReceiver.ROOT_INSTALL_DISMISS_ACTION),
      PendingIntent.FLAG_UPDATE_CURRENT);

  int notificationId = 230498;
  return new RootInstallationRetryHandler(notificationId,
      application.getSystemNotificationShower(), installManager, PublishRelay.create(), 0,
      application, new RootInstallErrorNotificationFactory(notificationId,
      BitmapFactory.decodeResource(application.getResources(), R.mipmap.ic_launcher), action,
      deleteAction));
}
 
Example #2
Source File: AccountNavigator.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
public AccountNavigator(BottomNavigationNavigator bottomNavigationNavigator,
    FragmentNavigator fragmentNavigator, AptoideAccountManager accountManager,
    ActivityNavigator activityNavigator, LoginManager facebookLoginManager,
    CallbackManager callbackManager, GoogleApiClient client,
    PublishRelay<FacebookLoginResult> facebookLoginSubject, String recoverPasswordUrl,
    AccountAnalytics accountAnalytics, ThemeManager themeManager) {
  this.bottomNavigationNavigator = bottomNavigationNavigator;
  this.fragmentNavigator = fragmentNavigator;
  this.accountManager = accountManager;
  this.activityNavigator = activityNavigator;
  this.facebookLoginManager = facebookLoginManager;
  this.callbackManager = callbackManager;
  this.client = client;
  this.facebookLoginSubject = facebookLoginSubject;
  this.recoverPasswordUrl = recoverPasswordUrl;
  this.accountAnalytics = accountAnalytics;
  this.themeManager = themeManager;
}
 
Example #3
Source File: ManageStoreFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
public void setupThemeSelector() {

    themeSelectorView.setLayoutManager(
        new LinearLayoutManager(getActivity(), RecyclerView.HORIZONTAL, false));
    PublishRelay<StoreTheme> storeThemePublishRelay = PublishRelay.create();
    themeSelectorAdapter =
        new ThemeSelectorViewAdapter(storeThemePublishRelay, StoreTheme.getThemesFromVersion(8),
            themeManager);
    themeSelectorView.setAdapter(themeSelectorAdapter);

    themeSelectorAdapter.storeThemeSelection()
        .doOnNext(storeTheme -> currentModel.setStoreTheme(storeTheme))
        .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
        .subscribe();

    themeSelectorView.addItemDecoration(new DividerItemDecoration(getContext(), 8,
        DividerItemDecoration.LEFT | DividerItemDecoration.RIGHT));

    themeSelectorAdapter.selectTheme(currentModel.getStoreTheme());
  }
 
Example #4
Source File: AptoideAccountManagerTest.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Before public void before() {
  credentialsValidatorMock = mock(CredentialsValidator.class);
  dataPersistMock = mock(AccountPersistence.class);
  serviceMock = mock(AccountService.class);
  storeManager = mock(StoreManager.class);
  accountRelayMock = mock(PublishRelay.class);
  adultContent = mock(AdultContent.class);
  accountManager =
      new AptoideAccountManager.Builder().setCredentialsValidator(credentialsValidatorMock)
          .setAccountPersistence(dataPersistMock)
          .setAccountService(serviceMock)
          .setAccountRelay(accountRelayMock)
          .setAdultService(adultContent)
          .setStoreManager(storeManager)
          .build();
}
 
Example #5
Source File: MainActivity.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getActivityComponent().inject(this);
  final AptoideApplication application = (AptoideApplication) getApplicationContext();
  MoPub.onCreate(this);
  installManager = application.getInstallManager();
  snackBarLayout = findViewById(R.id.snackbar_layout);
  installErrorsDismissEvent = PublishRelay.create();
  authenticationSubject = PublishSubject.create();
  themeAnalytics.setDarkThemeUserProperty(themeManager.getDarkThemeMode());
  progressDialog = GenericDialogs.createGenericPleaseWaitDialog(this,
      themeManager.getAttributeForTheme(R.attr.dialogsTheme).resourceId);

  setupUpdatesNotification();

  attachPresenter(presenter);
  handleAuthenticationIntent(getIntent());
}
 
Example #6
Source File: ActivityModule.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@ActivityScope @Provides Presenter provideMainPresenter(
    RootInstallationRetryHandler rootInstallationRetryHandler, ApkFy apkFy,
    InstallManager installManager, @Named("default") SharedPreferences sharedPreferences,
    @Named("secureShared") SharedPreferences secureSharedPreferences,
    @Named("main-fragment-navigator") FragmentNavigator fragmentNavigator,
    DeepLinkManager deepLinkManager, BottomNavigationNavigator bottomNavigationNavigator,
    UpdatesManager updatesManager, AutoUpdateManager autoUpdateManager,
    RootAvailabilityManager rootAvailabilityManager, AppsNameExperiment appsNameExperiment,
    BottomNavigationMapper bottomNavigationMapper, AptoideAccountManager accountManager,
    AccountNavigator accountNavigator, AgentPersistence agentPersistence) {
  return new MainPresenter((MainView) view, installManager, rootInstallationRetryHandler,
      CrashReport.getInstance(), apkFy, new ContentPuller(activity), notificationSyncScheduler,
      new InstallCompletedNotifier(PublishRelay.create(), installManager,
          CrashReport.getInstance()), sharedPreferences, secureSharedPreferences,
      fragmentNavigator, deepLinkManager, firstCreated, (AptoideBottomNavigator) activity,
      AndroidSchedulers.mainThread(), Schedulers.io(), bottomNavigationNavigator, updatesManager,
      autoUpdateManager, (PermissionService) activity, rootAvailabilityManager,
      appsNameExperiment, bottomNavigationMapper, accountManager, accountNavigator,
      agentPersistence);
}
 
Example #7
Source File: SearchResultViewHolder.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public SearchResultViewHolder(View itemView, PublishRelay<SearchAppResultWrapper> onItemViewClick,
    String query) {
  super(itemView);
  subscriptions = new CompositeSubscription();
  this.onItemViewClick = onItemViewClick;
  this.query = query;
  appInfoViewHolder = new AppSecondaryInfoViewHolder(itemView, new DecimalFormat("0.0"));
  bindViews(itemView);
}
 
Example #8
Source File: SearchResultAdViewHolder.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public SearchResultAdViewHolder(View itemView,
    PublishRelay<SearchAdResultWrapper> onItemViewClickRelay, DecimalFormat oneDecimalFormatter) {
  super(itemView);
  this.onItemViewClickRelay = onItemViewClickRelay;
  this.oneDecimalFormatter = oneDecimalFormatter;
  bind(itemView);
}
 
Example #9
Source File: SearchResultAdapter.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public SearchResultAdapter(PublishRelay<SearchAdResultWrapper> onAdClickRelay,
    PublishRelay<SearchAppResultWrapper> onItemViewClick, List<SearchAppResult> searchResults,
    List<SearchAdResult> searchAdResults, CrashReport crashReport,
    DecimalFormat decimalFormatter) {
  this.onAdClickRelay = onAdClickRelay;
  this.onItemViewClick = onItemViewClick;
  this.searchResults = searchResults;
  this.searchAdResults = searchAdResults;
  this.crashReport = crashReport;
  this.oneDecimalFormatter = decimalFormatter;
}
 
Example #10
Source File: RxAlertDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public RxAlertDialog build() {
  final AlertDialog dialog = builder.create();
  final CancelEvent cancelEvent = new CancelEvent(PublishRelay.create());
  final DismissEvent dismissEvent = new DismissEvent(PublishRelay.create());
  dialog.setOnCancelListener(cancelEvent);
  dialog.setOnDismissListener(dismissEvent);
  return new RxAlertDialog(dialog, view, positiveClick, negativeClick, cancelEvent,
      dismissEvent);
}
 
Example #11
Source File: ActivityModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@ActivityScope @Provides AccountNavigator provideAccountNavigator(
    @Named("main-fragment-navigator") FragmentNavigator fragmentNavigator,
    AptoideAccountManager accountManager, CallbackManager callbackManager,
    GoogleApiClient googleApiClient, AccountAnalytics accountAnalytics,
    BottomNavigationNavigator bottomNavigationNavigator, ThemeManager themeManager) {
  return new AccountNavigator(bottomNavigationNavigator, fragmentNavigator, accountManager,
      ((ActivityNavigator) activity), LoginManager.getInstance(), callbackManager,
      googleApiClient, PublishRelay.create(), "http://m.aptoide.com/account/password-recovery",
      accountAnalytics, themeManager);
}
 
Example #12
Source File: RootInstallationRetryHandler.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public RootInstallationRetryHandler(int notificationId,
    SystemNotificationShower systemNotificationShower, InstallManager installManager,
    PublishRelay<List<Install>> handler, int initialCount, Context context,
    RootInstallErrorNotificationFactory rootInstallErrorNotificationFactory) {
  this.notificationId = notificationId;
  this.systemNotificationShower = systemNotificationShower;
  this.installManager = installManager;
  this.handler = handler;
  this.count = initialCount;
  this.context = context;
  this.rootInstallErrorNotificationFactory = rootInstallErrorNotificationFactory;
}
 
Example #13
Source File: AptoideAccountManager.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public AptoideAccountManager build() {

      if (accountPersistence == null) {
        throw new IllegalArgumentException("AccountDataPersist is mandatory.");
      }

      if (accountService == null) {
        throw new IllegalArgumentException("AccountManagerService is mandatory.");
      }

      if (storeManager == null) {
        throw new IllegalArgumentException("StoreManager is mandatory.");
      }

      if (credentialsValidator == null) {
        credentialsValidator = new CredentialsValidator();
      }

      if (accountRelay == null) {
        accountRelay = PublishRelay.create();
      }

      final SignUpAdapterRegistry adapterRegistry =
          new SignUpAdapterRegistry(adapters, accountService);

      adapterRegistry.register(APTOIDE_SIGN_UP_TYPE,
          new AptoideSignUpAdapter(credentialsValidator));

      return new AptoideAccountManager(credentialsValidator, accountPersistence, accountService,
          accountRelay, adapterRegistry, storeManager, adultContent);
    }
 
Example #14
Source File: InstallCompletedNotifier.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public InstallCompletedNotifier(PublishRelay<Void> watcher, InstallManager installManager,
    CrashReport crashReport) {
  this.crashReport = crashReport;
  this.appToCheck = new ArrayList<>();
  this.watcher = watcher;
  this.installManager = installManager;
}
 
Example #15
Source File: AptoideAccountManager.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
private AptoideAccountManager(CredentialsValidator credentialsValidator,
    AccountPersistence accountPersistence, AccountService accountService,
    PublishRelay<Account> accountRelay, SignUpAdapterRegistry adapterRegistry,
    StoreManager storeManager, AdultContent adultContent) {
  this.credentialsValidator = credentialsValidator;
  this.accountPersistence = accountPersistence;
  this.accountService = accountService;
  this.accountRelay = accountRelay;
  this.adapterRegistry = adapterRegistry;
  this.storeManager = storeManager;
  this.adultContent = adultContent;
}
 
Example #16
Source File: ActivityResultNavigator.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  fragmentResultRelay = ((AptoideApplication) getApplicationContext()).getFragmentResultRelay();
  fragmentResultMap = ((AptoideApplication) getApplicationContext()).getFragmentResultMap();
  fragmentNavigator =
      new FragmentResultNavigator(getSupportFragmentManager(), R.id.fragment_placeholder,
          android.R.anim.fade_in, android.R.anim.fade_out, fragmentResultMap,
          fragmentResultRelay);
  // super.onCreate handles fragment creation using FragmentManager.
  // Make sure navigator instances are already created when fragments are created,
  // else getFragmentNavigator and getActivityNavigator will return null.
  super.onCreate(savedInstanceState);
  resultRelay = PublishRelay.create();
  getActivityComponent().inject(this);
}
 
Example #17
Source File: ThemeSelectorViewAdapter.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public ViewHolder(View itemView, PublishRelay<StoreTheme> storeThemePublishRelay) {
  super(itemView);
  this.storeThemePublishRelay = storeThemePublishRelay;
  bind(itemView);
}
 
Example #18
Source File: ThemeSelectorViewAdapter.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public ThemeSelectorViewAdapter(PublishRelay<StoreTheme> storeThemePublishRelay,
    List<StoreTheme> themes, ThemeManager themeManager) {
  this.storeThemePublishRelay = storeThemePublishRelay;
  this.themes = themes;
  this.themeManager = themeManager;
}
 
Example #19
Source File: SearchResultFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getFragmentComponent(savedInstanceState).inject(this);
  CrashReport crashReport = CrashReport.getInstance();

  if (viewModel == null && savedInstanceState != null && savedInstanceState.containsKey(
      VIEW_MODEL)) {
    viewModel = Parcels.unwrap(savedInstanceState.getParcelable(VIEW_MODEL));
  } else if (viewModel == null && getArguments().containsKey(VIEW_MODEL)) {
    viewModel = Parcels.unwrap(getArguments().getParcelable(VIEW_MODEL));
  }

  if (savedInstanceState != null && savedInstanceState.containsKey(FOCUS_IN_SEARCH)) {
    focusInSearchBar = savedInstanceState.getBoolean(FOCUS_IN_SEARCH);
  } else if (getArguments().containsKey(FOCUS_IN_SEARCH) && savedInstanceState == null) {
    focusInSearchBar = getArguments().getBoolean(FOCUS_IN_SEARCH);
  }

  if (viewModel != null) {
    currentQuery = viewModel.getSearchQueryModel()
        .getFinalQuery();
  }

  final AptoideApplication application = (AptoideApplication) getActivity().getApplication();

  noResults = false;
  networkError = false;

  onItemViewClickRelay = PublishRelay.create();
  onAdClickRelay = PublishRelay.create();
  suggestionClickedPublishSubject = PublishSubject.create();
  searchSetupPublishSubject = PublishSubject.create();
  queryTextChangedPublisher = PublishSubject.create();

  showingSearchResultsView = PublishSubject.create();
  noResultsAdultContentSubject = PublishSubject.create();
  noResultsPublishSubject = PublishSubject.create();

  final List<SearchAppResult> searchResultFollowedStores = new ArrayList<>();
  final List<SearchAdResult> searchResultAdsFollowedStores = new ArrayList<>();

  followedStoresResultAdapter =
      new SearchResultAdapter(onAdClickRelay, onItemViewClickRelay, searchResultFollowedStores,
          searchResultAdsFollowedStores, crashReport, oneDecimalFormatter);

  listItemPadding = getResources().getDimension(R.dimen.padding_tiny);

  final List<SearchAppResult> searchResultAllStores = new ArrayList<>();
  final List<SearchAdResult> searchResultAdsAllStores = new ArrayList<>();

  allStoresResultAdapter =
      new SearchResultAdapter(onAdClickRelay, onItemViewClickRelay, searchResultAllStores,
          searchResultAdsAllStores, crashReport, oneDecimalFormatter);

  searchSuggestionsAdapter =
      new SearchSuggestionsAdapter(new ArrayList<>(), suggestionClickedPublishSubject);
  searchTrendingAdapter =
      new SearchSuggestionsAdapter(new ArrayList<>(), suggestionClickedPublishSubject);

  setHasOptionsMenu(true);
}
 
Example #20
Source File: InstallCompletedNotifier.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public PublishRelay<Void> getWatcher() {
  return watcher;
}
 
Example #21
Source File: RxAlertDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public CancelEvent(PublishRelay<Void> subject) {
  this.subject = subject;
}
 
Example #22
Source File: AptoideApplication.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public PublishRelay<NotificationInfo> getNotificationsPublishRelay() {
  if (notificationsPublishRelay == null) {
    notificationsPublishRelay = PublishRelay.create();
  }
  return notificationsPublishRelay;
}
 
Example #23
Source File: RxAlertDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public DialogClick(int which, PublishRelay<Void> subject) {
  this.which = which;
  this.subject = subject;
}
 
Example #24
Source File: RxBus.java    From FriendBook with GNU General Public License v3.0 4 votes vote down vote up
public RxBus(RemoteRxBus remoteRxBus) {
    mRemoteRxBus = remoteRxBus;
    mBus =  PublishRelay.create();
    mStickyEventMap = new ConcurrentHashMap<>();
}
 
Example #25
Source File: RxAlertDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public DismissEvent(PublishRelay<Void> subject) {
  this.subject = subject;
}
 
Example #26
Source File: RxAlertDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public Builder setNegativeButton(@StringRes int textId) {
  negativeClick = new DialogClick(DialogInterface.BUTTON_NEGATIVE, PublishRelay.create());
  builder.setNegativeButton(textId, negativeClick);
  return this;
}
 
Example #27
Source File: RxAlertDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public Builder setPositiveButton(@StringRes int textId) {
  positiveClick = new DialogClick(DialogInterface.BUTTON_POSITIVE, PublishRelay.create());
  builder.setPositiveButton(textId, positiveClick);
  return this;
}
 
Example #28
Source File: PermissionProviderActivity.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  this.permissionRelay = PublishRelay.create();
  this.requestedCodeGrantedPermissions = new SparseArray<>();
}
 
Example #29
Source File: AptoideAccountManager.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public Builder setAccountRelay(PublishRelay<Account> accountRelay) {
  this.accountRelay = accountRelay;
  return this;
}
 
Example #30
Source File: RxJava1Proxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static RxJava1RelayProxy serializedPublishRelayProxy() {
    return new RxJava1RelayProxy(PublishRelay.create().toSerialized());
}