-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
266 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ public class Episode { | |
public String duration; | ||
public String id; | ||
|
||
public WatchProgress watch_progress; | ||
} |
10 changes: 10 additions & 0 deletions
10
common/src/main/java/com/sqrtf/common/model/WatchProgress.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sqrtf.common.model; | ||
|
||
/** | ||
* Created by roya on 2017/6/23. | ||
*/ | ||
|
||
public class WatchProgress { | ||
public Float percentage; | ||
public Double last_watch_time; | ||
} |
76 changes: 76 additions & 0 deletions
76
common/src/main/java/com/sqrtf/common/view/ProgressCoverView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.sqrtf.common.view; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.support.annotation.Nullable; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
import com.sqrtf.common.R; | ||
|
||
/** | ||
* Created by roya on 2017/6/23. | ||
*/ | ||
|
||
public class ProgressCoverView extends View { | ||
|
||
private float progress = 0f; | ||
private Paint colorPaint; | ||
private Paint colorSecondaryPaint; | ||
|
||
public ProgressCoverView(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public ProgressCoverView(Context context, @Nullable AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public ProgressCoverView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
|
||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressCoverView); | ||
progress = a.getFloat(R.styleable.ProgressCoverView_progress, 0f); | ||
int color = a.getColor(R.styleable.ProgressCoverView_color, 0); | ||
int colorSecondary = a.getColor(R.styleable.ProgressCoverView_colorSecondary, 0); | ||
a.recycle(); | ||
|
||
colorPaint = new Paint(); | ||
colorPaint.setColor(color); | ||
|
||
colorSecondaryPaint = new Paint(); | ||
colorSecondaryPaint.setColor(colorSecondary); | ||
} | ||
|
||
public void setColor(int color) { | ||
colorPaint = new Paint(); | ||
colorPaint.setColor(color); | ||
postInvalidate(); | ||
} | ||
|
||
public void setColorSecondary(int colorSecondary) { | ||
colorSecondaryPaint = new Paint(); | ||
colorSecondaryPaint.setColor(colorSecondary); | ||
postInvalidate(); | ||
} | ||
|
||
public void setProgress(float progress) { | ||
this.progress = progress; | ||
postInvalidate(); | ||
} | ||
|
||
@Override | ||
protected void onSizeChanged(int w, int h, int oldw, int oldh) { | ||
super.onSizeChanged(w, h, oldw, oldh); | ||
} | ||
|
||
@Override | ||
protected void onDraw(Canvas canvas) { | ||
super.onDraw(canvas); | ||
int r1 = (int) (getMeasuredWidth() * progress); | ||
canvas.drawRect(0, 0, r1, getMeasuredHeight(), colorPaint); | ||
canvas.drawRect(r1, 0, getMeasuredWidth(), getMeasuredHeight(), colorSecondaryPaint); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
common/src/main/java/com/sqrtf/common/view/ScrollStartLayoutManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.sqrtf.common.view; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.LinearSmoothScroller; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.AttributeSet; | ||
|
||
public class ScrollStartLayoutManager extends LinearLayoutManager { | ||
|
||
public ScrollStartLayoutManager(Context context) { | ||
super(context); | ||
} | ||
|
||
public ScrollStartLayoutManager(Context context, int orientation, boolean reverseLayout) { | ||
super(context, orientation, reverseLayout); | ||
} | ||
|
||
public ScrollStartLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
@Override | ||
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { | ||
RecyclerView.SmoothScroller smoothScroller = new CenterSmoothScroller(recyclerView.getContext()); | ||
smoothScroller.setTargetPosition(position); | ||
startSmoothScroll(smoothScroller); | ||
} | ||
|
||
private static class CenterSmoothScroller extends LinearSmoothScroller { | ||
|
||
CenterSmoothScroller(Context context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) { | ||
return boxStart - viewStart; | ||
} | ||
|
||
@Override | ||
protected int calculateTimeForScrolling(int dx) { | ||
return super.calculateTimeForScrolling(dx) * 3; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.