Skip to content

Commit

Permalink
Merge branch 'release/v0.7.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 14, 2016
2 parents da8cbdb + 13d2ecb commit 26f7234
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Beside being blazing fast, minimizing the code you need to write, it is also rea
#Include in your project
##Using Maven
```javascript
compile('com.mikepenz:fastadapter:0.7.3@aar') {
compile('com.mikepenz:fastadapter:0.7.5@aar') {
transitive = true
}
```
Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 73
versionName '0.7.3'
versionCode 75
versionName '0.7.5'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down Expand Up @@ -52,16 +52,16 @@ dependencies {

//used to generate the drawer on the left
//https://github.com/mikepenz/MaterialDrawer
compile('com.mikepenz:materialdrawer:5.0.0.fastAdapter.b6-SNAPSHOT@aar') {
compile('com.mikepenz:materialdrawer:5.0.0.fastAdapter.b9-SNAPSHOT@aar') {
transitive = true
exclude module: "fastadapter"
}
//used to provide different itemAnimators for the RecyclerView
//https://github.com/mikepenz/ItemAnimators
compile 'com.mikepenz:itemanimators:0.1.0-SNAPSHOT@aar'
compile 'com.mikepenz:itemanimators:0.2.0-SNAPSHOT@aar'
//used to generate the Open Source section
//https://github.com/mikepenz/AboutLibraries
compile('com.mikepenz:aboutlibraries:5.3.4@aar') {
compile('com.mikepenz:aboutlibraries:5.3.6@aar') {
transitive = true
}
//used to display the icons in the drawer
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ org.gradle.daemon=true
org.gradle.parallel=true

# Maven stuff
VERSION_NAME=0.7.3
VERSION_CODE=73
VERSION_NAME=0.7.5
VERSION_CODE=75
GROUP=com.mikepenz

POM_DESCRIPTION=FastAdapter Library
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 73
versionName '0.7.3'
versionCode 75
versionName '0.7.5'
}
buildTypes {
release {
Expand Down
2 changes: 1 addition & 1 deletion library/gradle-jcenter-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish {
bintrayKey = project.hasProperty('bintray.apikey') ? project.property('bintray.apikey') : System.getenv('BINTRAY_API_KEY')
userOrg = project.property("POM_DEVELOPER_ID")
groupId = project.property("GROUP")
artifactId = project.property("GROUP") + ":" + project.property("POM_ARTIFACT_ID")
artifactId = project.property("POM_ARTIFACT_ID")
publishVersion = project.property("VERSION_NAME")
desc = project.property("POM_DESCRIPTION")
website = project.property("POM_URL")
Expand Down
82 changes: 79 additions & 3 deletions library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public class FastAdapter<Item extends IItem> extends RecyclerView.Adapter<Recycl
private OnLongClickListener<Item> mOnLongClickListener;
private OnTouchListener<Item> mOnTouchListener;

//the listeners for onCreateViewHolder or onBindViewHolder
private OnCreateViewHolderListener mOnCreateViewHolderListener = new OnCreateViewHolderListenerImpl();
private OnBindViewHolderListener mOnBindViewHolderListener = new OnBindViewHolderListenerImpl();

/**
* default CTOR
*/
Expand Down Expand Up @@ -217,7 +221,7 @@ public void registerTypeInstance(Item item) {
*/
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final RecyclerView.ViewHolder holder = mTypeInstances.get(viewType).getViewHolder(parent);
final RecyclerView.ViewHolder holder = mOnCreateViewHolderListener.onPreCreateViewHolder(parent, viewType);

//handle click behavior
holder.itemView.setOnClickListener(new View.OnClickListener() {
Expand All @@ -240,6 +244,7 @@ public void onClick(View v) {
}
});

//handle long click behavior
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Expand All @@ -262,6 +267,7 @@ public boolean onLongClick(View v) {
}
});

//handle touch behavior
holder.itemView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Expand All @@ -276,7 +282,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
});

return holder;
return mOnCreateViewHolderListener.onPostCreateViewHolder(holder);
}

/**
Expand All @@ -287,7 +293,7 @@ public boolean onTouch(View v, MotionEvent event) {
*/
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
getItem(position).bindView(holder);
mOnBindViewHolderListener.onBindViewHolder(holder, position);
}

/**
Expand Down Expand Up @@ -997,6 +1003,76 @@ public interface OnLongClickListener<Item extends IItem> {
boolean onLongClick(View v, IAdapter<Item> adapter, Item item, int position);
}

public interface OnCreateViewHolderListener {
/**
* is called inside the onCreateViewHolder method and creates the viewHolder based on the provided viewTyp
*
* @param parent the parent which will host the View
* @param viewType the type of the ViewHolder we want to create
* @return the generated ViewHolder based on the given viewType
*/
RecyclerView.ViewHolder onPreCreateViewHolder(ViewGroup parent, int viewType);

/**
* is called after the viewHolder was created and the default listeners were added
*
* @param viewHolder the created viewHolder after all listeners were set
* @return the viewHolder given as param
*/
RecyclerView.ViewHolder onPostCreateViewHolder(RecyclerView.ViewHolder viewHolder);
}

/**
* default implementation of the OnCreateViewHolderListener
*/
public class OnCreateViewHolderListenerImpl implements OnCreateViewHolderListener {
/**
* is called inside the onCreateViewHolder method and creates the viewHolder based on the provided viewTyp
*
* @param parent the parent which will host the View
* @param viewType the type of the ViewHolder we want to create
* @return the generated ViewHolder based on the given viewType
*/
@Override
public RecyclerView.ViewHolder onPreCreateViewHolder(ViewGroup parent, int viewType) {
return mTypeInstances.get(viewType).getViewHolder(parent);
}

/**
* is called after the viewHolder was created and the default listeners were added
*
* @param viewHolder the created viewHolder after all listeners were set
* @return the viewHolder given as param
*/
@Override
public RecyclerView.ViewHolder onPostCreateViewHolder(RecyclerView.ViewHolder viewHolder) {
return viewHolder;
}
}

public interface OnBindViewHolderListener {
/**
* is called in onBindViewHolder to bind the data on the ViewHolder
*
* @param viewHolder the viewHolder for the type at this position
* @param position the position of thsi viewHolder
*/
void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position);
}

public class OnBindViewHolderListenerImpl implements OnBindViewHolderListener {
/**
* is called in onBindViewHolder to bind the data on the ViewHolder
*
* @param viewHolder the viewHolder for the type at this position
* @param position the position of thsi viewHolder
*/
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
getItem(position).bindView(viewHolder);
}
}

/**
* an internal class to return the IItem and relativePosition and it's adapter at once. used to save one iteration inside the getInternalItem method
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;

import com.mikepenz.fastadapter.R;

/**
* Created by mikepenz on 28.12.15.
*/
Expand All @@ -17,7 +19,7 @@ public class FastAdapterUIUtils {
*
* @param ctx the context
* @param selected_color the selected color
* @param animate true if you want to fade over the states (only animates if >= Build.VERSION_CODES.HONEYCOMB)
* @param animate true if you want to fade over the states (only animates if API newer than Build.VERSION_CODES.HONEYCOMB)
* @return the StateListDrawable
*/
public static StateListDrawable getSelectableBackground(Context ctx, int selected_color, boolean animate) {
Expand All @@ -42,7 +44,7 @@ public static StateListDrawable getSelectableBackground(Context ctx, int selecte
* @param ctx the context
* @param selected_color the selected color
* @param pressed_alpha 0-255
* @param animate true if you want to fade over the states (only animates if >= Build.VERSION_CODES.HONEYCOMB)
* @param animate true if you want to fade over the states (only animates if API newer than Build.VERSION_CODES.HONEYCOMB)
* @return the StateListDrawable
*/
public static StateListDrawable getSelectablePressedBackground(Context ctx, int selected_color, int pressed_alpha, boolean animate) {
Expand Down Expand Up @@ -74,7 +76,8 @@ public static int getSelectableBackground(Context ctx) {
// If we're running on Honeycomb or newer, then we can use the Theme's
// selectableItemBackground to ensure that the View has a pressed state
TypedValue outValue = new TypedValue();
ctx.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
//it is important here to not use the android.R because this wouldn't add the latest drawable
ctx.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true);
return outValue.resourceId;
} else {
TypedValue outValue = new TypedValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<b>FastAdapter</b>, the bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
]]>
</string>
<string name="library_fastadapter_libraryVersion">0.7.3</string>
<string name="library_fastadapter_libraryVersion">0.7.5</string>
<string name="library_fastadapter_libraryWebsite">https://github.com/mikepenz/FastAdapter</string>
<string name="library_fastadapter_licenseId">apache_2_0</string>
<string name="library_fastadapter_isOpenSource">true</string>
Expand Down

0 comments on commit 26f7234

Please sign in to comment.