我的适配器是表面视图列表
AdptImageEffects.java
public class AdptImageEffects extends RecyclerView.Adapter<AdptImageEffects.MyViewHolder> implements GLSurfaceView.Renderer {
private static ClickListener clickListener;
private Activity activity;
private FrgImageCompose fragment;
private TextureRenderer mTexRenderer;
public AdptImageEffects(Activity activity,
FrgImageCompose fragment) {
this.fragment = fragment;
this.activity = activity;
mTexRenderer = new TextureRenderer();
}
@Override
public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
Log.d("onSurfaceCreated","triggered first");
}
@Override
public void onSurfaceChanged(GL10 gl10, int width, int height) {
Log.d("onSurfaceChanged","triggered second");
if (mTexRenderer != null) {
mTexRenderer.updateViewSize(width, height);
}
}
@Override
public void onDrawFrame(GL10 gl10) {
Log.d("onDrawFrame","triggered");
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public GLSurfaceView mEffectView;
public MyViewHolder(View view) {
super(view);
view.setOnClickListener(this);
mEffectView = (GLSurfaceView) view.findViewById(R.id.mEffectView);
mEffectView.setEGLContextClientVersion(2);
mEffectView.setRenderer(this); //////////////////---------> Not able to Set this
mEffectView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
initSurfaceView();
}
private void initSurfaceView() {
}
@Override
public void onClick(View view) {
clickListener.onItemClick(getAdapterPosition(), view);
}
}
public void setOnItemClickListener(ClickListener clickListener) {
AdptImageEffects.clickListener = clickListener;
}
public interface ClickListener {
void onItemClick(int position, View v);
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_adpt_image_effects, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return 10;
}
}
无法设置mEffectView.setRenderer(this);
答案 0 :(得分:0)
使用mEffectiveView.setRenderer(AdptImageEffects.this)