ml-opensource / CutoutViewIndicator

Android indicator for ViewPagers and so forth
Apache License 2.0
21 stars 3 forks source link

Reshape StateProxy interface #30

Closed Cliabhach closed 7 years ago

Cliabhach commented 8 years ago

Currently, the resendPositionInfo doesn't provide an instance of CutoutViewIndicator - this should be resolved.

Also, take a look at seeing how getCurrentPosition could potentially be implemented using MigratoryRanges and perhaps define a standard interaction pattern thereon.

Cliabhach commented 8 years ago

The first half is covered by #18 and 200fcbc - I'm now investigating potential integration options for the second.

Cliabhach commented 8 years ago

I think I need more layouts and sample integration usages before I can properly assess a way forward with MigratoryRanges. The second part will have to wait until #7 is complete.

Cliabhach commented 7 years ago

All right, over the past week I've investigated how MigratoryRanges, Spans, and RecyclerViews should work within a CVI-style relationship.

Here are my findings:

  1. Span:
    • The location of the span will always need start and end positions
    • Length of a span is heavily linked to the covered content thereof
  2. MigratoryRange:
    • MigratoryRange represents 2 numbers - a start and an end. These live in only 1-dimension.
    • A simple int is insufficient and unwieldy for representing full 2-dimensional orientations
    • Floating-point "fractional" ranges are hard to define - usually they depend heavily on whatever they currently represent.
    • Floating-point ranges need to be grounded to integers at some point before displaying to the user
  3. RecyclerView:
    • Our existing API limits the data which can be transmitted to LayeredView instances - only one int and one float can be passed from showOffsetIndicator to offsetImageBy at a time
    • Practical experience suggests that passing a RecyclerView.ViewHolder to showOffsetIndicator would lessen the complexity of methods in e.g. CVIScrollListener, while complicating such calls in OnViewPagerChangeListener. There must be a middle ground.
    • The indicator appearance should have some way of directly copying the appearance of the source material

And my conclusions:

  1. LayeredTextViewHolder and other length-based LayeredViews need different parameters to their offsetImageBy methods.
    • Recommendation: rename offsetImageBy to offsetContentBy
    • Recommendation: change parameters from (int, float) to (PointF)
  2. Offset positions often depend on other concrete classes not exposed by StateProxy
    • Recommendation: deprecate usage of the term percentage within CutoutViewIndicator and LayeredView
    • Recommendation: somehow pass source View information directly to the LayeredView which is representing it
    • Discuss: should we formalize the implicit 1:1 correlation of indicator views to source views?
  3. MigratorySpan::getCoverage() should be more grounded
    • Recommendation: return range of integer values, to be clamped then passed into the spannable method directly
    • Recommendation: add parameter consisting of the text that this span will be placed among