Java Code Examples for rx.functions.Action2#call()
The following examples show how to use
rx.functions.Action2#call() .
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: DeviceListAdapter.java From openwebnet-android with MIT License | 6 votes |
private void updateEnergyValues(EnergyViewHolder holder, EnergyModel energy) { holder.linearLayoutEnergyValues.setVisibility(View.VISIBLE); holder.imageViewCardAlert.setVisibility(View.INVISIBLE); if (energy.getInstantaneousPower() == null && energy.getDailyPower() == null && energy.getMonthlyPower() == null) { log.warn("energy values are null or invalid: unable to update"); holder.linearLayoutEnergyValues.setVisibility(View.GONE); holder.imageViewCardAlert.setVisibility(View.VISIBLE); return; } Action2<TextView, String> updateEnergy = (textView, value) -> textView.setText(TextUtils.isEmpty(value) ? utilityService.getString(R.string.energy_none) : value + " " + utilityService.getString(R.string.energy_power_unit)); updateEnergy.call(holder.textViewEnergyInstantaneousPower, energy.getInstantaneousPower()); updateEnergy.call(holder.textViewEnergyDailyPower, energy.getDailyPower()); updateEnergy.call(holder.textViewEnergyMonthlyPower, energy.getMonthlyPower()); }
Example 2
Source File: AwsObservableExt.java From titus-control-plane with Apache License 2.0 | 5 votes |
public <REQ extends AmazonWebServiceRequest, RES> AsyncHandler<REQ, RES> handler(Action2<REQ, RES> onSuccessAction, Action1<Exception> onErrorAction) { return new AsyncHandler<REQ, RES>() { @Override public void onError(Exception exception) { onErrorAction.call(exception); subscriber.onError(exception); } @Override public void onSuccess(REQ request, RES result) { onSuccessAction.call(request, result); subscriber.onCompleted(); } }; }
Example 3
Source File: DeliveryTest.java From FlowGeek with GNU General Public License v2.0 | 5 votes |
private void testWithOnNextOnError(Action2<Action2, Action2> test) { Action2 onNext = mock(Action2.class); Action2 onError = mock(Action2.class); test.call(onNext, onError); verifyNoMoreInteractions(onNext); verifyNoMoreInteractions(onError); }
Example 4
Source File: EndpointFactoryMock.java From couchbase-jvm-core with Apache License 2.0 | 5 votes |
@Override public Endpoint create(String hostname, String bucket, String username, String password, int port, CoreContext ctx) { final BehaviorSubject<LifecycleState> state = BehaviorSubject.create(LifecycleState.DISCONNECTED); final Endpoint endpoint = mock(Endpoint.class); when(endpoint.states()).thenReturn(state); for (Action2<Endpoint, BehaviorSubject<LifecycleState>> action : createActions) { action.call(endpoint, state); } endpoints.add(endpoint); endpointStates.add(state); return endpoint; }
Example 5
Source File: DeliveryTest.java From nucleus with MIT License | 5 votes |
private void testWithOnNextOnError(Action2<Action2, Action2> test) { Action2 onNext = mock(Action2.class); Action2 onError = mock(Action2.class); test.call(onNext, onError); verifyNoMoreInteractions(onNext); verifyNoMoreInteractions(onError); }
Example 6
Source File: Delivery.java From FlowGeek with GNU General Public License v2.0 | 4 votes |
public void split(Action2<View, T> onNext, @Nullable Action2<View, Throwable> onError) { if (notification.getKind() == Notification.Kind.OnNext) onNext.call(view, notification.getValue()); else if (onError != null && notification.getKind() == Notification.Kind.OnError) onError.call(view, notification.getThrowable()); }
Example 7
Source File: Delivery.java From nucleus with MIT License | 4 votes |
public void split(Action2<View, T> onNext, @Nullable Action2<View, Throwable> onError) { if (notification.getKind() == Notification.Kind.OnNext) onNext.call(view, notification.getValue()); else if (onError != null && notification.getKind() == Notification.Kind.OnError) onError.call(view, notification.getThrowable()); }
Example 8
Source File: EntityToMapConverterTest.java From usergrid with Apache License 2.0 | 3 votes |
/** * Test the single field in our root level */ public <T> void testSingleField( final Field<T> field, Action2<Field, EntityField> assertFunction ) { Entity entity = new Entity( "test" ); entity.setField( field ); final UUID version = UUIDGenerator.newTimeUUID(); EntityUtils.setVersion( entity, version ); final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) ); final IndexEdge indexEdge = new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 ); final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, entity ); final Set<EntityField> fieldSet = ( Set<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS ); final List<EntityField> fields = new ArrayList<>(); fields.addAll(fieldSet); assertEquals( 1, fields.size() ); final EntityField esField = fields.get( 0 ); //always test the lower case arrays final String fieldName = field.getName().toLowerCase(); assertEquals( fieldName, esField.get( IndexingUtils.FIELD_NAME ) ); assertFunction.call( field, esField ); }
Example 9
Source File: EntityToMapConverterTest.java From usergrid with Apache License 2.0 | 2 votes |
/** * Test primitive arrays in the root of an object * * @param storedField The field stored on the nested object * @param assertFunction The function */ private <T> void testNestedField( final Field<T> storedField, Action2<Field, EntityField> assertFunction ) { EntityObject leafEntity = new EntityObject(); leafEntity.setField( storedField ); final EntityObjectField nested2Field = new EntityObjectField( "nested2", leafEntity ); final EntityObject nested2 = new EntityObject(); nested2.setField( nested2Field ); final EntityObjectField nested1Field = new EntityObjectField( "nested1", nested2 ); Entity rootEntity = new Entity( "test" ); rootEntity.setField( nested1Field ); final UUID version = UUIDGenerator.newTimeUUID(); EntityUtils.setVersion( rootEntity, version ); final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) ); final IndexEdge indexEdge = new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 ); final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity ); final Set<EntityField> fieldSet = ( Set<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS ); final List<EntityField> fields = new ArrayList<>(); fields.addAll(fieldSet); assertEquals( 1, fields.size() ); for ( int i = 0; i < fields.size(); i++ ) { final EntityField field = fields.get( i ); final String path = "nested1.nested2." + storedField.getName(); assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) ); assertFunction.call( storedField, field ); } }
Example 10
Source File: EntityToMapConverterTest.java From usergrid with Apache License 2.0 | 2 votes |
/** * Test primitive arrays in the root of an object * * @param storedField The field stored on the nested object * @param assertFunction The function */ private <T> void testNestedFieldArraySubObject( final Field<T> storedField, Action2<Field, EntityField> assertFunction ) { EntityObject leafEntity = new EntityObject(); leafEntity.setField( storedField ); final EntityObjectField nested2Field = new EntityObjectField( "nested2", leafEntity ); final EntityObject nested2 = new EntityObject(); nested2.setField( nested2Field ); final EntityObjectField nested1Field = new EntityObjectField( "nested1", nested2 ); final EntityObject nested1 = new EntityObject(); nested1.setField( nested1Field ); final ArrayField<EntityObject> array = new ArrayField<>( "array" ); array.add( nested1 ); Entity rootEntity = new Entity( "test" ); rootEntity.setField( array ); final UUID version = UUIDGenerator.newTimeUUID(); EntityUtils.setVersion( rootEntity, version ); final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) ); final IndexEdge indexEdge = new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 ); final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity ); final Set<EntityField> fieldSet = ( Set<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS ); final List<EntityField> fields = new ArrayList<>(); fields.addAll(fieldSet); assertEquals( 1, fields.size() ); for ( int i = 0; i < fields.size(); i++ ) { final EntityField field = fields.get( i ); final String path = "array.nested1.nested2." + storedField.getName(); assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) ); assertFunction.call( storedField, field ); } }