🧙♂️
This file contains hidden or 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 MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> { | |
// Edit your onCreateViewHolder method to use different layouts for each view type | |
@Override | |
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
MessageType type = MessageType.values()[viewType]; | |
LayoutInflater inflater = LayoutInflater.from(parent.getContext()); |
This file contains hidden or 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 MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> { | |
// ... | |
@Override | |
public int getItemViewType(int position) { | |
return messages.get(position).type.ordinal(); | |
} | |
// ... |
This file contains hidden or 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
// As an enum | |
public enum MessageViewType { | |
Text, Image, Location | |
} | |
// Or as a list of integers, if you prefer | |
public static final int MESSAGE_VIEW_TYPE_TEXT = 0; | |
public static final int MESSAGE_VIEW_TYPE_IMAGE = 1; | |
public static final int MESSAGE_VIEW_TYPE_LOCATION = 2; |
This file contains hidden or 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
/** | |
* An adapter to display a list of Messages. | |
*/ | |
public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> { | |
private List<Message> messages; | |
@Override | |
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
This file contains hidden or 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
/** | |
* Example data structure for a simple message | |
*/ | |
public class Message { | |
public MessageType type; | |
public String text; | |
public Drawable image; | |
public Location location; | |
This file contains hidden or 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
// required to use RecyclerViews | |
compile 'com.android.support:recyclerview-v7:23.2.1' | |
// probably a good idea to have too | |
compile 'com.android.support:appcompat-v7:23.3.0' | |
compile 'com.android.support:cardview-v7:23.2.1' |
This file contains hidden or 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
<android.support.v7.widget.RecyclerView | |
android:id="@+id/recycler" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
android:clipToPadding="false" /> |
This file contains hidden or 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.nathanrjones.messenger; | |
import android.location.Location; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ImageView; | |
import android.widget.TextView; |
This file contains hidden or 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
Verifying that +nathanjones is my Bitcoin username. You can send me #bitcoin here: https://onename.io/nathanjones |
This file contains hidden or 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
{ | |
"configuration":{ | |
"idle_screen_app":"00000000-0000-0000-0000-000000000000" | |
}, | |
"applications":[ | |
{ | |
"app_name":"TicTacToe", | |
"url":"http://www.gstatic.com/eureka/sample/tictactoe/tictactoe.html", | |
"use_channel":true, |