|
|
@@ -7,7 +7,6 @@ import android.graphics.Paint;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.util.AttributeSet;
|
|
|
-import android.util.Log;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
|
|
|
@@ -50,6 +49,7 @@ public class CustomIndicator extends View {
|
|
|
private float indicatorTotalWidth;
|
|
|
private float indicatorStartX;
|
|
|
private int itemCount;
|
|
|
+ private boolean isDispose;
|
|
|
|
|
|
private static final float DP = Resources.getSystem().getDisplayMetrics().density;
|
|
|
private final int mIndicatorHeight = (int) (DP * 16);
|
|
|
@@ -71,8 +71,8 @@ public class CustomIndicator extends View {
|
|
|
}
|
|
|
|
|
|
public void onChangedIndex(int firstVisibleItemPosition) {
|
|
|
- this.activePosition = firstVisibleItemPosition;
|
|
|
- this.invalidate();
|
|
|
+ activePosition = firstVisibleItemPosition;
|
|
|
+ invalidate();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -80,7 +80,6 @@ public class CustomIndicator extends View {
|
|
|
if (null == recyclerView || null == recyclerView.getAdapter()) {
|
|
|
return;
|
|
|
}
|
|
|
- Log.e("APP# CustomIndicator | onDraw", "|");
|
|
|
|
|
|
itemCount = recyclerView.getAdapter().getItemCount();
|
|
|
totalLength = mIndicatorItemLength * itemCount;
|
|
|
@@ -127,21 +126,17 @@ public class CustomIndicator extends View {
|
|
|
|
|
|
@Override
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
- Log.e("APP# CustomIndicator | onTouchEvent", "|" + "==== > ");
|
|
|
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
else if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
|
|
float itemWidth = mIndicatorItemLength + mIndicatorItemPadding;
|
|
|
- Log.e("APP# CustomIndicator | onTouchEvent", "|" + itemWidth + " , " + indicatorStartX); //48, 516 (index 1) // 48 , 0
|
|
|
int index = (int) Math.floor((event.getX() - indicatorStartX) / itemWidth); //인디케이터 안에서 찍힌 x 좌표
|
|
|
- Log.e("APP# CustomIndicator | onTouchEvent", "index |" + index);
|
|
|
if (index >= 0 && index < itemCount) {
|
|
|
listener.onEvent(new Event.Builder(Event.CLICK).index((int) index).build());
|
|
|
}
|
|
|
- //return true;
|
|
|
}
|
|
|
-
|
|
|
return super.onTouchEvent(event);
|
|
|
}
|
|
|
}
|