Permalink
Browse files

Added onClick to user profile photo, small performance improvements f…

…or FeedAdapter
  • Loading branch information...
frogermcs committed Jan 21, 2015
1 parent 97dc05b commit 5942df826b14355ddc6fe7dc6dfbce98a9eb02e4
@@ -52,7 +52,13 @@ public FeedAdapter(Context context) {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(context).inflate(R.layout.item_feed, parent, false);
- return new CellFeedViewHolder(view);
+ final CellFeedViewHolder cellFeedViewHolder = new CellFeedViewHolder(view);
+ cellFeedViewHolder.btnComments.setOnClickListener(this);
+ cellFeedViewHolder.btnMore.setOnClickListener(this);
+ cellFeedViewHolder.ivFeedCenter.setOnClickListener(this);
+ cellFeedViewHolder.btnLike.setOnClickListener(this);
+ cellFeedViewHolder.ivUserProfile.setOnClickListener(this);
+ return cellFeedViewHolder;
}
private void runEnterAnimation(View view, int position) {
@@ -85,15 +91,12 @@ public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
updateLikesCounter(holder, false);
updateHeartButton(holder, false);
- holder.btnComments.setOnClickListener(this);
holder.btnComments.setTag(position);
- holder.btnMore.setOnClickListener(this);
holder.btnMore.setTag(position);
- holder.ivFeedCenter.setOnClickListener(this);
holder.ivFeedCenter.setTag(holder);
- holder.btnLike.setOnClickListener(this);
holder.btnLike.setTag(holder);
+
if (likeAnimations.containsKey(holder)) {
likeAnimations.get(holder).cancel();
}
@@ -191,6 +194,10 @@ public void onClick(View view) {
animatePhotoLike(holder);
updateHeartButton(holder, false);
}
+ } else if (viewId == R.id.ivUserProfile) {
+ if (onFeedItemClickListener != null) {
+ onFeedItemClickListener.onProfileClick(view);
+ }
}
}
@@ -286,6 +293,8 @@ public void setOnFeedItemClickListener(OnFeedItemClickListener onFeedItemClickLi
ImageView ivLike;
@InjectView(R.id.tsLikesCounter)
TextSwitcher tsLikesCounter;
+ @InjectView(R.id.ivUserProfile)
+ ImageView ivUserProfile;
public CellFeedViewHolder(View view) {
super(view);
@@ -297,5 +306,7 @@ public CellFeedViewHolder(View view) {
public void onCommentsClick(View v, int position);
public void onMoreClick(View v, int position);
+
+ public void onProfileClick(View v);
}
}
@@ -127,6 +127,10 @@ public void onMoreClick(View v, int itemPosition) {
FeedContextMenuManager.getInstance().toggleContextMenuFromView(v, itemPosition, this);
}
+ @Override
+ public void onProfileClick(View v) {
+ }
+
@Override
public void onReportClick(int feedItem) {
FeedContextMenuManager.getInstance().hideContextMenu();

0 comments on commit 5942df8

Please sign in to comment.