Click RecyclerView to hide exoplayer control in ViewRPANBroadcastFragment.

This commit is contained in:
Alex Ning 2021-07-07 13:19:57 +08:00
parent 2c81bb4afc
commit 44c612c6e5
2 changed files with 45 additions and 2 deletions

View File

@ -23,10 +23,12 @@ import ml.docilealligator.infinityforreddit.RPANComment;
public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private RequestManager glide; private RequestManager glide;
private ArrayList<RPANComment> rpanComments; private ArrayList<RPANComment> rpanComments;
private ItemClickListener itemClickListener;
public RPANCommentStreamRecyclerViewAdapter(Context context) { public RPANCommentStreamRecyclerViewAdapter(Context context, ItemClickListener itemClickListener) {
glide = Glide.with(context); glide = Glide.with(context);
rpanComments = new ArrayList<>(); rpanComments = new ArrayList<>();
this.itemClickListener = itemClickListener;
} }
@NonNull @NonNull
@ -78,6 +80,14 @@ public class RPANCommentStreamRecyclerViewAdapter extends RecyclerView.Adapter<R
iconImageView = itemView.findViewById(R.id.icon_image_view_item_rpan_comment); iconImageView = itemView.findViewById(R.id.icon_image_view_item_rpan_comment);
authorTextView = itemView.findViewById(R.id.author_text_view_item_rpan_comment); authorTextView = itemView.findViewById(R.id.author_text_view_item_rpan_comment);
contentTextView = itemView.findViewById(R.id.content_text_view_item_rpan_comment); contentTextView = itemView.findViewById(R.id.content_text_view_item_rpan_comment);
itemView.setOnClickListener(view -> {
itemClickListener.onClick();
});
} }
} }
public interface ItemClickListener {
void onClick();
}
} }

View File

@ -8,6 +8,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -220,7 +221,39 @@ public class ViewRPANBroadcastFragment extends Fragment {
} }
}); });
adapter = new RPANCommentStreamRecyclerViewAdapter(mActivity); recyclerView.setOnTouchListener(new View.OnTouchListener() {
float x1;
float x2;
float y1;
float y2;
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
x1 = motionEvent.getX();
y1 = motionEvent.getY();
return true;
case MotionEvent.ACTION_UP:
x2 = motionEvent.getX();
y2 = motionEvent.getY();
if (x1 == x2 && y1 == y2) {
playerView.hideController();
}
return true;
}
return false;
}
});
adapter = new RPANCommentStreamRecyclerViewAdapter(mActivity, new RPANCommentStreamRecyclerViewAdapter.ItemClickListener() {
@Override
public void onClick() {
}
});
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
handler = new Handler(); handler = new Handler();