Skip to content

Instantly share code, notes, and snippets.

View yenerm's full-sized avatar

Murat Yener yenerm

  • Google
  • San Francisco
View GitHub Profile
@yenerm
yenerm / fragment_home.xml
Last active April 12, 2020 17:42
Starter
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@yenerm
yenerm / activity_main.xml
Last active April 12, 2020 17:42
Starter
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@yenerm
yenerm / activity_main.xml
Last active April 12, 2020 17:42
Final code
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
package com.android.examples.myawesomeapp.ui.home
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
@yenerm
yenerm / Singleton.java
Created April 17, 2020 19:22
Naive singleton implementation
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
public class Singleton{
private static Singleton INSTANCE;
private Singleton(){}
public static Singleton getInstance(){
if (INSTANCE == null){
INSTANCE = new Singleton();
}
@yenerm
yenerm / Singleton.kt
Created April 17, 2020 19:30
Singleton via object
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
object Singleton {
private var count: Int = 0
fun count() {
count++
}
}
@yenerm
yenerm / Singleton.java
Created April 17, 2020 19:32
Kotlin object decompiled to Java
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
public final class Singleton {
private static int count;
public static final Singleton INSTANCE;
public final int getCount() {return count;}
public final void setCount(int var1) {count = var1;}
public final int count() {
int var1 = count++;
@yenerm
yenerm / Anonymous.kt
Created April 17, 2020 19:36
anonymous object
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
val tempValues = object : {
var value = 2
var anotherValue = 3
var someOtherValue = 4
}
tempValues.value += tempValues.anotherValue
@yenerm
yenerm / Anonymous.java
Created April 17, 2020 19:37
anonymous object decompiled to java
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<undefinedtype> tempValues = new Object() {
private int value = 2;
private int anotherValue = 3;
private int someOtherValue = 4;
// getters and setters for x, y, z
//...