use of android.support.v7.widget.RecyclerView.ViewHolder in project AboutLibraries by mikepenz.
the class LibraryItem method bindView.
/**
* binds the data of this item onto the viewHolder
*
* @param holder the viewHolder of this item
*/
@Override
public void bindView(final ViewHolder holder, List<Object> payloads) {
super.bindView(holder, payloads);
//ctx
final Context ctx = holder.itemView.getContext();
//Set texts
holder.libraryName.setText(library.getLibraryName());
holder.libraryCreator.setText(library.getAuthor());
if (TextUtils.isEmpty(library.getLibraryDescription())) {
holder.libraryDescription.setText(library.getLibraryDescription());
} else {
holder.libraryDescription.setText(Html.fromHtml(library.getLibraryDescription()));
}
//Set License or Version Text
if (TextUtils.isEmpty(library.getLibraryVersion()) && library.getLicense() != null && TextUtils.isEmpty(library.getLicense().getLicenseName()) || (!libsBuilder.showVersion && !libsBuilder.showLicense)) {
holder.libraryBottomDivider.setVisibility(View.GONE);
holder.libraryBottomContainer.setVisibility(View.GONE);
} else {
holder.libraryBottomDivider.setVisibility(View.VISIBLE);
holder.libraryBottomContainer.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(library.getLibraryVersion()) && libsBuilder.showVersion) {
holder.libraryVersion.setText(library.getLibraryVersion());
} else {
holder.libraryVersion.setText("");
}
if (library.getLicense() != null && !TextUtils.isEmpty(library.getLicense().getLicenseName()) && libsBuilder.showLicense) {
holder.libraryLicense.setText(library.getLicense().getLicenseName());
} else {
holder.libraryLicense.setText("");
}
}
//Define onClickListener
if (!TextUtils.isEmpty(library.getAuthorWebsite())) {
holder.libraryCreator.setOnTouchListener(rippleForegroundListener);
holder.libraryCreator.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean consumed = false;
if (LibsConfiguration.getInstance().getListener() != null) {
consumed = LibsConfiguration.getInstance().getListener().onLibraryAuthorClicked(view, library);
}
if (!consumed) {
openAuthorWebsite(ctx, library.getAuthorWebsite());
}
}
});
holder.libraryCreator.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
boolean consumed = false;
if (LibsConfiguration.getInstance().getListener() != null) {
consumed = LibsConfiguration.getInstance().getListener().onLibraryAuthorLongClicked(v, library);
}
if (!consumed) {
openAuthorWebsite(ctx, library.getAuthorWebsite());
consumed = true;
}
return consumed;
}
});
} else {
holder.libraryCreator.setOnTouchListener(null);
holder.libraryCreator.setOnClickListener(null);
holder.libraryCreator.setOnLongClickListener(null);
}
if (!TextUtils.isEmpty(library.getLibraryWebsite()) || !TextUtils.isEmpty(library.getRepositoryLink())) {
holder.libraryDescription.setOnTouchListener(rippleForegroundListener);
holder.libraryDescription.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean consumed = false;
if (LibsConfiguration.getInstance().getListener() != null) {
consumed = LibsConfiguration.getInstance().getListener().onLibraryContentClicked(v, library);
}
if (!consumed) {
openLibraryWebsite(ctx, library.getLibraryWebsite() != null ? library.getLibraryWebsite() : library.getRepositoryLink());
}
}
});
holder.libraryDescription.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
boolean consumed = false;
if (LibsConfiguration.getInstance().getListener() != null) {
consumed = LibsConfiguration.getInstance().getListener().onLibraryContentLongClicked(v, library);
}
if (!consumed) {
openLibraryWebsite(ctx, library.getLibraryWebsite() != null ? library.getLibraryWebsite() : library.getRepositoryLink());
consumed = true;
}
return consumed;
}
});
} else {
holder.libraryDescription.setOnTouchListener(null);
holder.libraryDescription.setOnClickListener(null);
holder.libraryDescription.setOnLongClickListener(null);
}
if (library.getLicense() != null && !TextUtils.isEmpty((library.getLicense().getLicenseWebsite()))) {
holder.libraryBottomContainer.setOnTouchListener(rippleForegroundListener);
holder.libraryBottomContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean consumed = false;
if (LibsConfiguration.getInstance().getListener() != null) {
consumed = LibsConfiguration.getInstance().getListener().onLibraryBottomClicked(view, library);
}
if (!consumed) {
openLicense(ctx, libsBuilder, library);
}
}
});
holder.libraryBottomContainer.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
boolean consumed = false;
if (LibsConfiguration.getInstance().getListener() != null) {
consumed = LibsConfiguration.getInstance().getListener().onLibraryBottomLongClicked(v, library);
}
if (!consumed) {
openLicense(ctx, libsBuilder, library);
consumed = true;
}
return consumed;
}
});
} else {
holder.libraryBottomContainer.setOnTouchListener(null);
holder.libraryBottomContainer.setOnClickListener(null);
holder.libraryBottomContainer.setOnLongClickListener(null);
}
//notify the libsRecyclerViewListener to allow modifications
if (LibsConfiguration.getInstance().getLibsRecyclerViewListener() != null) {
LibsConfiguration.getInstance().getLibsRecyclerViewListener().onBindViewHolder(holder);
}
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project LollipopShowcase by mikepenz.
the class ReboundItemAnimator method runPendingAnimations.
@Override
public void runPendingAnimations() {
if (!mViewHolders.isEmpty()) {
for (final RecyclerView.ViewHolder viewHolder : mViewHolders) {
SpringSystem springSystem = SpringSystem.create();
SpringConfig springConfig = new SpringConfig(70, 10);
final View target = viewHolder.itemView;
// Add a spring to the system.
Spring spring = springSystem.createSpring();
spring.setSpringConfig(springConfig);
spring.setCurrentValue(0.0f);
// Add a listener to observe the motion of the spring.
spring.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// You can observe the updates in the spring
// state by asking its current value in onSpringUpdate.
float value = (float) spring.getCurrentValue();
target.setScaleX(value);
target.setScaleY(value);
}
});
// Set the spring in motion; moving from 0 to 1
spring.setEndValue(1.0f);
}
}
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project FastDev4Android by jiangqqlmj.
the class GalleryRecyclerAdapter method onCreateViewHolder.
/**
* 创建Item View 然后使用ViewHolder来进行承载
* @param parent
* @param viewType
* @return
*/
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = mInflater.inflate(R.layout.item_gallery_recycler, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onRecyclerViewItemClickListener != null) {
onRecyclerViewItemClickListener.onItemClick(view, (int) view.getTag());
}
}
});
return viewHolder;
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project XRecyclerView by jianghejie.
the class SimpleItemTouchHelperCallback method onChildDraw.
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
// Fade out the view as it is swiped out of the parent's bounds
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
View itemView = viewHolder.itemView;
final float alpha = ALPHA_FULL - Math.abs(dX) / (float) itemView.getWidth();
itemView.setAlpha(alpha);
}
}
use of android.support.v7.widget.RecyclerView.ViewHolder in project archi by ivacf.
the class RepositoryAdapter method onCreateViewHolder.
@Override
public RepositoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_repo, parent, false);
final RepositoryViewHolder viewHolder = new RepositoryViewHolder(itemView);
viewHolder.contentLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (callback != null) {
callback.onItemClick(viewHolder.repository);
}
}
});
return viewHolder;
}
Aggregations