Add setter method to child data holder of abstract concatenated timeline.

Prevents that we forget to set variables.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159939180
This commit is contained in:
tonihei 2017-06-23 05:09:01 -07:00 committed by Oliver Woodman
parent 499f9370a2
commit 6cde8335ff
3 changed files with 21 additions and 9 deletions

View file

@ -28,7 +28,7 @@ import com.google.android.exoplayer2.Timeline;
/**
* Meta data of a child timeline.
*/
protected static class ChildDataHolder {
protected static final class ChildDataHolder {
/**
* Child timeline.
@ -50,6 +50,22 @@ import com.google.android.exoplayer2.Timeline;
*/
public Object uid;
/**
* Set child holder data.
*
* @param timeline Child timeline.
* @param firstPeriodIndexInChild First period index belonging to the child timeline.
* @param firstWindowIndexInChild First window index belonging to the child timeline.
* @param uid UID of child timeline.
*/
public void setData(Timeline timeline, int firstPeriodIndexInChild, int firstWindowIndexInChild,
Object uid) {
this.timeline = timeline;
this.firstPeriodIndexInChild = firstPeriodIndexInChild;
this.firstWindowIndexInChild = firstWindowIndexInChild;
this.uid = uid;
}
}
private final ChildDataHolder childDataHolder;

View file

@ -231,10 +231,8 @@ public final class ConcatenatingMediaSource implements MediaSource {
}
private void getChildDataByChildIndex(int childIndex, ChildDataHolder childData) {
childData.timeline = timelines[childIndex];
childData.firstPeriodIndexInChild = getFirstPeriodIndexInChild(childIndex);
childData.firstWindowIndexInChild = getFirstWindowIndexInChild(childIndex);
childData.uid = childIndex;
childData.setData(timelines[childIndex], getFirstPeriodIndexInChild(childIndex),
getFirstWindowIndexInChild(childIndex), childIndex);
}
private int getChildIndexByPeriodIndex(int periodIndex) {

View file

@ -141,10 +141,8 @@ public final class LoopingMediaSource implements MediaSource {
}
private void getChildDataByChildIndex(int childIndex, ChildDataHolder childData) {
childData.timeline = childTimeline;
childData.firstPeriodIndexInChild = childIndex * childPeriodCount;
childData.firstWindowIndexInChild = childIndex * childWindowCount;
childData.uid = childIndex;
childData.setData(childTimeline, childIndex * childPeriodCount, childIndex * childWindowCount,
childIndex);
}
}