Skip to content

Instantly share code, notes, and snippets.

View nutchy's full-sized avatar
:octocat:

Chayanon Thongpila nutchy

:octocat:
View GitHub Profile
@nutchy
nutchy / LazyInstagramAdapter_Full.java
Created October 16, 2017 17:44
[MyLazyInstagram] - LazyInstagramAdapter
public class LazyInstagramAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<Layout> layouts;
private UserProfile userProfile;
private Boolean isGrid = true;
public ImageButton gridBtn, listBtn;
public LazyInstagramAdapter(Context context, List<Layout> layouts) {
this.context = context;
@nutchy
nutchy / MainActivity.java
Created October 16, 2017 17:23
[MyLazyInstagram] - MainActivity.java - 2
public class LazyInstagramAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<Layout> layouts;
private UserProfile userProfile;
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(context);
@nutchy
nutchy / MainActivity.java
Created October 16, 2017 16:56
[MyLazyInstagram] - MainActivity.java
public class MainActivity extends AppCompatActivity {
public OkHttpClient client;
public Retrofit retrofit;
public LazyInstagramApi lazyInstagramApi;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lazyinstagram_main);
@nutchy
nutchy / PostAdapter.java
Created October 16, 2017 13:58
[MyLazyInstagram] - PostAdapter.java
public class PostAdapter extends RecyclerView.Adapter<PostItemHolder> {
private List<Post> posts;
private Context context;
public PostAdapter(Context context, List<Post> posts) {
this.context = context;
this.posts = posts;
}
@nutchy
nutchy / PostItemHolder.java
Created October 16, 2017 13:57
[MyLazyInstagram] - PostItemHolder.java
public class PostItemHolder extends RecyclerView.ViewHolder {
public ImageView imageView;
public TextView like;
public TextView comment;
public PostItemHolder(View itemView) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.imageView);
like = (TextView) itemView.findViewById(R.id.tvLike);
comment = (TextView) itemView.findViewById(R.id.tvComment);
@nutchy
nutchy / adapter_implement.java
Created October 16, 2017 09:28
[MyLazyIntagram] - Implement Method (from Adapter)
@Override
public int getItemCount() {
return 0;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
return null;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
@nutchy
nutchy / UserDetailAdapter.java
Last active October 16, 2017 13:26
[MyLazyInstagram] - UserDetailAdapter.java
public class UserDetailAdapter extends RecyclerView.Adapter<UserDetailHolder> {
private Context context;
private UserProfile userProfile;
public UserDetailAdapter(Context context, UserProfile userProfile) {
this.context = context;
this.userProfile = userProfile;
}
@nutchy
nutchy / UserDetailHolder.java
Created October 16, 2017 09:15
[MyLazyInstagram] - UserDetailHolder.java
public class UserDetailHolder extends RecyclerView.ViewHolder {
private TextView tvId, tvPost, tvFollowing, tvFollower, tvBio;
private ImageView avatar;
public UserDetailHolder(View itemView) {
super(itemView);
tvId = (TextView) itemView.findViewById(R.id.user_id);
tvPost = (TextView) itemView.findViewById(R.id.post);
tvFollowing = (TextView) itemView.findViewById(R.id.following);
tvFollower = (TextView) itemView.findViewById(R.id.follower);
@nutchy
nutchy / LazyInstagramAdapter.java
Created October 16, 2017 08:51
[MyLazyInstagram] - LazyInstagramAdapter.java - 1
public class LazyInstagramAdapter {
public class PostsViewHolder extends RecyclerView.ViewHolder {
RecyclerView recyclerView;
public PostsViewHolder(View itemView) {
super(itemView);
recyclerView = (RecyclerView) itemView.findViewById(R.id.rc_post);
}
@nutchy
nutchy / lazyinstagram_main.xml
Created October 16, 2017 04:12
[MyLazyInstagram] - lazyinstagram_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/main_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>