-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from wordpress-mobile/feature/Android_on_forma…
…ts_active_event Android - Add event to RCTAztecView to propagate format changes
- Loading branch information
Showing
5 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
.../src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecFormattingChangeEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.wordpress.mobile.ReactNativeAztec; | ||
|
||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.bridge.WritableArray; | ||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.uimanager.events.Event; | ||
import com.facebook.react.uimanager.events.RCTEventEmitter; | ||
|
||
/** | ||
* Event emitted by Aztec native view when it receives focus. | ||
*/ | ||
class ReactAztecFormattingChangeEvent extends Event<ReactAztecFormattingChangeEvent> { | ||
|
||
private static final String EVENT_NAME = "topFormatsChanges"; | ||
|
||
private String[] mFormats; | ||
|
||
public ReactAztecFormattingChangeEvent(int viewId, String[] formats) { | ||
super(viewId); | ||
this.mFormats = formats; | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
public boolean canCoalesce() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void dispatch(RCTEventEmitter rctEventEmitter) { | ||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); | ||
} | ||
|
||
private WritableMap serializeEventData() { | ||
WritableMap eventData = Arguments.createMap(); | ||
eventData.putInt("target", getViewTag()); | ||
WritableArray newFormats = Arguments.fromArray(mFormats); | ||
eventData.putArray("formats", newFormats); | ||
return eventData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters