Closed gagan50 closed 6 years ago
in branch #12 add CurrentItemCallback
in class CircleRecyclerView
, in CircularViewRTLMode
can't get selected value and scoll list on click to next item, you can add setCurrentItemCallback
, get the center selected value, and if you want get other item value when click, you can add
itemView.setOnClickListener(yourListener)
in onBindViewHolder
, and CurrentItemCallback#onItemInCenter
will also called
this branch not merge to master, you can watch the sample Issue12Activity.java and CircleRecyclerView.java in branch #12
and if you want other item support click, do not add setOnCenterItemClickListener
Hell sir/ma'am
Please provide code for get selected value
is there anyway to get value that has been set after scroll the wheel in circularRTL becuase i'am using that one
@gagan50 this commit is the code how to get select value
pls watch the branch
is there any way to get selected value in curcularViewRTLMode?
@gagan50 get selected value not dependence the child class of ItemViewMode
,
and I write the CurrentItemCallback
is in the CircleRecyclerView
, it's adapted all of ItemViewMode
i have an arraylist
ArrayList
mCircleRecyclerView.setCurrentItemCallback(new CurrentItemCallback() {
@Override
public void onItemInCenter(View centerItem) {
Log.e("onItemInCenter", "onItemInCenter:>>center" );
int position = (int) centerItem.getTag(R.string.item_position);
position = position % arrayList.size();
Log.e("LENGTH_SHORT", "onItemInCenter:>>>>>>>"+position);
}
});
while run it's crash java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
pls watch my whole commit
you need holder.itemView.setTag(R.string.item_position, position);
in onBindViewHolder
at first
Hello sir/ma'm
Thank you so much for such patience and guideline. Successfully its working
may i know that how i can start scroll list from first position
@gagan50 in current version not support scroll from first position, because, it's conflict with findViewAtCenter
but you can write like this after recyclerView.setAdapter()
mCircleRecyclerView.post(new Runnable() {
@Override
public void run() {
mCircleRecyclerView.scrollBy(0, -mCircleRecyclerView.getHeight()/2 + mCircleRecyclerView.getChildAt(0).getHeight()/2);
}
});
and this is a hack method
i have write after set adapter it's send exception i.e
java.lang.NullPointerException: Attempt to invoke virtual method 'int
android.view.View.getHeight()' on a null object reference
you need must ensure the adapter have datas, and you have to use mCircleRecyclerView.post()
to ensure the itemView is display on screen before execute mCircleRecyclerView.scrollBy
,
also, if you know the itemView height, you can write the fixed value to replace mCircleRecyclerView.getChildAt(0).getHeight()
I have implemented below code please review
ArrayList
mCircleRecyclerView.setAdapter(new A(arrayList));
mCircleRecyclerView.post(new Runnable() {
@Override
public void run() {
mCircleRecyclerView.scrollBy(0,
-mCircleRecyclerView.getHeight()/2 + mCircleRecyclerView.getChildAt(0).getHeight()/2); } });
@gagan50 yes i thought it works
but sir it through exception
you can test your code in my sample menu item NOLOOPBUTCENTER
, i test it works
ok let me know that how i can change color of selected item
@gagan50 this commit is the code how to get select value
pls watch the branch
作者你好,这个回调会触发多次,怎么解决?
Please let us know how i can get selected value and scoll list on click to next item and code below of CircularViewRTLMode.
@Override public void applyToView(View v, RecyclerView parent) { float halfHeight = v.getHeight() 0.5f; float parentHalfHeight = parent.getHeight() 0.5f; float y = v.getY(); float rot = parentHalfHeight - halfHeight - y; Log.e("paent", "applyToView:>>"+parent.getChildAdapterPosition(v) ); ViewCompat.setPivotX(v, v.getWidth()); ViewCompat.setPivotY(v, halfHeight); ViewCompat.setRotation(v, -1 rot 0.05f); ViewCompat.setTranslationX(v, -1 (float) (-Math.cos(rot mTranslationRatio mDegToRad) + 1) mCircleOffset);