Skip to content

Instantly share code, notes, and snippets.

View Sottti's full-sized avatar
🏠
Remote

Pablo Costa Sottti

🏠
Remote
View GitHub Profile
@Sottti
Sottti / MainActivity.java
Last active November 7, 2019 09:20
Navigation Drawer Sizing according to Material Design
{...}
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
@Sottti
Sottti / ApiCalls.java
Created October 18, 2015 02:43
Retrofit set up
public class ApiCalls
{
public static Call<DummyObject> getDummyObjectCall()
{
return ApiServices
.getDummyService()
.getDummyObject();
}
public static Call<List<DummyObject>> getDummyObjectListCall()
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class AdaptiveTabLayout extends TabLayout
{
private boolean mGravityAndModeSeUpNeeded = true;
@Sottti
Sottti / MyFragment.java
Last active June 25, 2017 10:14
Allow Android Map to scroll when within an scrollable container
(...)
mSupportMapFragment = (OnScrollableContainerMapFragment) getChildFragmentManager()
.findFragmentById(R.id.fragment_map);
mSupportMapFragment
.setOnTouchListener(new OnScrollableContainerMapFragment.OnTouchListener() {
@Override
public void onStartScrollingMap() {
mScrollView.requestDisallowInterceptTouchEvent(true);
}
@Sottti
Sottti / MyActivity.java
Last active January 18, 2021 09:29
Handles clicks on a EditText right drawable
[...]
mEditText.setOnTouchListener(
new OnEditTextRightDrawableTouchListener(mEditText) {
@Override
public void OnDrawableClick() {
// The right drawable was clicked. Your action goes here.
}
});
[...]
@Sottti
Sottti / User.java
Last active September 22, 2018 08:02
public class User {
private String name;
private int age;
public User(String name, int age) {
this.name = name;
this.age = age;
}
val steveJobs= User("Steve Jobs", 56)
fun print() {
val (name, age) = steveJobs
println("$name, $age years of age") // prints "Steve Jobs, 56 years of age"
steveJobs.component1() // name
steveJobs.component2() // age
}
data class User(val name: String, val age: Int) {
var address : String = ""
}
@Sottti
Sottti / Copy.kt
Last active September 22, 2018 07:56
val steveJobs= User("Steve Jobs", 56)
val steveJobsToday= steveJobs.copy(age = 63)
@Entity(tableName = "Users")
data class UserRM(
@PrimaryKey
@ColumnInfo(name = "id")
val id: Int,
@ColumnInfo(name = "name")
val name: String,