Skip to content

Commit

Permalink
SingleViewRecyclerAdapter doesn't need that ID consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
grishka committed Oct 2, 2023
1 parent d28dfe7 commit 352a548
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion appkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ dependencies {
implementation 'me.grishka.litex:collection:1.1.0'
}

version = '1.2.13'
version = '1.2.14'
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import me.grishka.appkit.FragmentStackActivity;

public class SingleViewRecyclerAdapter extends RecyclerView.Adapter<SingleViewRecyclerAdapter.ViewViewHolder>{

protected final View view;
protected final int id;
protected boolean createdViewHolder=false;

public SingleViewRecyclerAdapter(View view){
this.view=view;
if(view.getContext() instanceof FragmentStackActivity fsa)
id=fsa.generateViewId();
else
id=View.generateViewId();
id=View.generateViewId();
}

@NonNull
@Override
public ViewViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
if(createdViewHolder)
throw new IllegalStateException("Can only create one instance of the view holder. parent="+parent+", viewType="+viewType);
createdViewHolder=true;
return new ViewViewHolder(view);
}

Expand Down

0 comments on commit 352a548

Please sign in to comment.