Skip to content

Instantly share code, notes, and snippets.

View tarek360's full-sized avatar
💭
I'm Fluttering!

Ahmed Tarek tarek360

💭
I'm Fluttering!
View GitHub Profile
@tarek360
tarek360 / Car.java
Last active June 8, 2017 09:19
Car to JSON
public class Car {
long modelNumber;
int maxSpeed;
String color;
String manufacturer;
String style;
String price;
}
JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("modelNumber", modelNumber);
jsonObject.put("maxSpeed", maxSpeed);
jsonObject.put("color", color);
jsonObject.put("manufacturer", manufacturer);
jsonObject.put("style", style);
jsonObject.put("price", price);
} catch (JSONException e) {
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("modelNumber", modelNumber);
jsonObject.put("maxSpeed", maxSpeed);
jsonObject.put("color", color);
jsonObject.put("manufacturer", manufacturer);
jsonObject.put("style", style);
jsonObject.put("price", price);
} catch (JSONException e) {
@tarek360
tarek360 / EasyJSON.kt
Created June 8, 2017 11:14
annotation in Kotlin
@Target(AnnotationTarget.CLASS)
annotation class EasyJSON
import com.google.auto.service.AutoService
import com.tarek30.annotation.EasyJSON
import javax.annotation.processing.AbstractProcessor
import javax.annotation.processing.ProcessingEnvironment
import javax.annotation.processing.Processor
import javax.annotation.processing.RoundEnvironment
import javax.lang.model.SourceVersion
import javax.lang.model.element.TypeElement
@AutoService(Processor::class)
@tarek360
tarek360 / Car.java
Last active June 8, 2017 18:48
Car.java annotated with @easyjson
import com.tarek30.annotation.EasyJSON;
import org.json.JSONObject;
@EasyJSON
public class Car {
long modelNumber;
int maxSpeed;
String color;
String manufacturer;
String style;
val VariableElements = typeElement.enclosedElements
.filterIsInstance<VariableElement>()
final RichPath richPath = imageView.findFirstRichPath();
richPath.setStrokeColor(Color.BLACK);
richPath.setStrokeWidth(1f);
RichPathAnimator
.animate(richPath)
.pathData(elephantPathData)
.fillColor(elephantFillColor)
.duration(600)
final KyrieDrawable kyrieDrawable =
KyrieDrawable.builder()
.viewport(409, 280)
.child(
PathNode.builder()
.strokeColor(Color.BLACK)
.strokeWidth(1f)
.fillColor(
Animation.ofArgb(hippoFillColor, elephantFillColor).duration(300),
Animation.ofArgb(buffaloFillColor).startDelay(600).duration(300),
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="218dp"
android:height="64dp"
android:viewportHeight="40"
android:viewportWidth="136">
<path
android:fillColor="#FFFFFF"
android:pathData="M136,38c0,1.1-0.9,2-2,2H2c-1.1,0-2-0.9-2-2V2c0-1.1,0.9-2,2-2h132c1.1,0,2,0.9,2,2V38z" />