Skip to content

Instantly share code, notes, and snippets.

View davidtcdeveloper's full-sized avatar

David Tiago Conceição davidtcdeveloper

  • Microsoft
  • Florianópolis, SC
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="5dp"
android:orientation="vertical"
app:cardCornerRadius="4dp">
<TextView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="100dp"
android:layout_margin="5dp"
android:orientation="vertical"
app:cardCornerRadius="4dp">
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView 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/main_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layoutManager="LinearLayoutManager"
tools:listitem="@layout/row_person" />
@davidtcdeveloper
davidtcdeveloper / activity_main.xml
Created March 13, 2016 16:00
Layout for an activity that holds an image and extracts it's color to set two labels.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_background"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/main_image"
android:layout_width="@dimen/image_size"
android:layout_height="@dimen/image_size"
@davidtcdeveloper
davidtcdeveloper / build.gradle
Last active March 16, 2016 12:24
Snippet for compile project with support, palette and picasso support.
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:palette-v7:23.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
@davidtcdeveloper
davidtcdeveloper / MainActivity.java
Last active March 16, 2016 12:25
Loading random image with picasso.
Picasso.with(MainActivity.this)
.load("https://source.unsplash.com/random")
.centerCrop()
.into(imageView);
@davidtcdeveloper
davidtcdeveloper / MainActivity.java
Last active March 16, 2016 12:26
Loading random image into a custom target with picasso.
Picasso.with(MainActivity.this)
.load("https://source.unsplash.com/random")
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
@davidtcdeveloper
davidtcdeveloper / MainActivity.java
Last active March 16, 2016 12:27
Loading fixed size image into a custom target with picasso.
int imageDimension =
(int) getResources().getDimension(R.dimen.image_size);
Picasso.with(MainActivity.this)
.load("https://source.unsplash.com/random")
.resize(imageDimension, imageDimension)
.centerCrop()
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
@davidtcdeveloper
davidtcdeveloper / MainActivity.java
Last active March 16, 2016 12:28
Extracting colors with Palette in a custom target image loaded with picasso.
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
assert imageView != null;
imageView.setImageBitmap(bitmap);
Palette.from(bitmap)
.generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch textSwatch = palette.getVibrantSwatch();
if (textSwatch == null) {