Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

[sample] add image in item to show jumping bug. #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:0.13.3+'
classpath 'com.android.tools.build:gradle:0.14.4'
}
}

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu May 01 23:00:57 BST 2014
#Fri Nov 28 15:38:23 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dependencies {
compile project(':core')
compile project(':layouts')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.squareup.picasso:picasso:2.4.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import org.lucasr.twowayview.TwoWayLayoutManager;
import org.lucasr.twowayview.widget.TwoWayView;
import org.lucasr.twowayview.widget.SpannableGridLayoutManager;
import org.lucasr.twowayview.widget.StaggeredGridLayoutManager;
import org.lucasr.twowayview.widget.TwoWayView;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -41,11 +44,13 @@ public class LayoutAdapter extends RecyclerView.Adapter<LayoutAdapter.SimpleView
private int mCurrentItemId = 0;

public static class SimpleViewHolder extends RecyclerView.ViewHolder {
public final ImageView image;
public final TextView title;

public SimpleViewHolder(View view) {
super(view);
title = (TextView) view.findViewById(R.id.title);
image = (ImageView) view.findViewById(R.id.image);
}
}

Expand Down Expand Up @@ -80,6 +85,10 @@ public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@Override
public void onBindViewHolder(SimpleViewHolder holder, int position) {
holder.title.setText(mItems.get(position).toString());
Picasso.with(holder.image.getContext().getApplicationContext())
.load("http://lorempixel.com/400/400/animals/" + (1 + position % 10))
.skipMemoryCache()
.into(holder.image);

boolean isVertical = (mRecyclerView.getOrientation() == TwoWayLayoutManager.Orientation.VERTICAL);
final View itemView = holder.itemView;
Expand Down
29 changes: 20 additions & 9 deletions sample/src/main/res/layout/item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@
limitations under the License.
-->

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="70dp"
android:layout_height="130dp"
android:gravity="center"
android:textColor="#999999"
android:textStyle="bold"
android:textSize="22sp"
android:background="@drawable/item_background"/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="70dp"
android:layout_height="130dp"
android:background="@drawable/item_background">

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>

<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#999999"
android:textSize="22sp"
android:textStyle="bold" />
</FrameLayout>