forked from syrjs/core
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
119 additions
and
13 deletions.
There are no files selected for viewing
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
21 changes: 20 additions & 1 deletion
21
android/app/src/main/java/com/example/dereanderson/syrnativeandroid/SyrEventHandler.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 |
---|---|---|
@@ -1,9 +1,28 @@ | ||
package com.example.dereanderson.syrnativeandroid; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* Syr Project | ||
* https://syr.js.org | ||
* Created by Derek Anderson on 1/8/18. | ||
*/ | ||
public class SyrEventHandler { | ||
} | ||
|
||
public SyrBridge mBridge; | ||
|
||
private static SyrEventHandler sSyrEventHandler; | ||
|
||
private SyrEventHandler(){} //private constructor. | ||
|
||
public static SyrEventHandler getInstance(){ | ||
if (sSyrEventHandler == null){ //if there is no instance available... create new one | ||
sSyrEventHandler = new SyrEventHandler(); | ||
} | ||
return sSyrEventHandler; | ||
} | ||
|
||
public void sendEvent(HashMap<String, String> event) { | ||
mBridge.sendEvent(event); | ||
} | ||
} |
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
43 changes: 42 additions & 1 deletion
43
android/app/src/main/java/com/example/dereanderson/syrnativeandroid/SyrTouchableOpacity.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 |
---|---|---|
@@ -1,8 +1,49 @@ | ||
package com.example.dereanderson.syrnativeandroid; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.widget.RelativeLayout; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* Created by dereanderson on 1/10/18. | ||
*/ | ||
|
||
public class SyrTouchableOpacity { | ||
public class SyrTouchableOpacity implements SyrBaseModule { | ||
|
||
@Override | ||
public View render(JSONObject component, Context context) { | ||
RelativeLayout layout = new RelativeLayout(context); | ||
JSONObject style = null; | ||
|
||
try { | ||
final String guid = component.getString("guid"); | ||
style = component.getJSONObject("attributes").getJSONObject("style"); | ||
|
||
layout.setOnClickListener(new View.OnClickListener() { | ||
@Override public void onClick(View v) { | ||
HashMap<String, String> eventMap = new HashMap<String, String>(); | ||
eventMap.put("type", "onPress"); | ||
eventMap.put("guid", guid); | ||
SyrEventHandler.getInstance().sendEvent(eventMap); | ||
} | ||
}); | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
layout.setLayoutParams(SyrStyler.styleLayout(style)); | ||
SyrStyler.styleView(layout, style); | ||
|
||
return layout; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "TouchableOpacity"; | ||
} | ||
} |
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