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
public class SampleViewModel { | |
private String buttonTitle = "Click me!"; | |
private Context context; | |
public static interface ISampleViewModelEventListener { | |
void onClickButton(); | |
} | |
private ISampleViewModelEventListener listener; | |
public SampleViewModel(Context context, ISampleViewModelEventListener listener) { |
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
public class SampleViewModel { | |
private String buttonTitle = "Click me!"; | |
private Context context; | |
public SampleViewModel(Context context) { | |
this.context = context; | |
} | |
public String getButtonTitle() { | |
return buttonTitle; |
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
package com.rickyngk.databinding.sample1; | |
/** | |
* Created by duynk on 4/4/16. | |
* | |
*/ | |
public class SampleViewModel { | |
private String text = "This is a sample"; | |
public String getText() { |
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
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 23 | |
buildToolsVersion "23.0.1" | |
defaultConfig { | |
applicationId "com.rickyngk.databinding.sample1" | |
minSdkVersion 8 | |
targetSdkVersion 23 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.r</groupId> | |
<artifactId>try_graphaware</artifactId> | |
<version>1.0-SNAPSHOT</version> |
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
public class Person extends EntityX { | |
public Person() {super();} | |
@BindField("username") String name; | |
@BindField("age") int age; | |
@BindField("address") Address userAddress; | |
@BindField("wishListItems") ArrayList<int> wishList; | |
@BindField("phones") ArrayList<Phone> phones; | |
} |
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
public void importFromJson(JSONObject input) throws Exception{ | |
for (Field field : this.getClass().getDeclaredFields()) { | |
String fieldName = field.getName(); | |
if (fields.containsKey(fieldName)) { | |
field.setAccessible(true); | |
EntityMetaData t = fields.get(fieldName); | |
if (input.has(t.key)) { | |
if (t.isArray) { | |
JSONArray array = null; | |
try { |
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
public JSONObject exportToJson() throws Exception{ | |
JSONObject outputJsonObject = new JSONObject(); | |
for (Field field : this.getClass().getDeclaredFields()) { | |
String fieldName = field.getName(); | |
if (fields.containsKey(fieldName)) { | |
field.setAccessible(true); | |
EntityMetaData t = fields.get(fieldName); | |
Object fieldValue = field.get(this); | |
if (fieldValue != null) { |
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
public abstract class EntityX { | |
static class EntityMetaData { | |
String key; | |
Class entityType; | |
Class<?> collectionType; | |
boolean isArray = false; | |
boolean isDerivedFromEntity; | |
EntityMetaData(String key, Class entityType, Class collectionType) { | |
this.key = key; | |
this.entityType = entityType; |
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
public class LauncherActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
hideSystemUI(); | |
setContentView(R.layout.activity_launcher); | |
} | |
private void hideSystemUI() { |