use of androidx.annotation.CallSuper in project ExoPlayer by google.
the class PlaybackException method toBundle.
@CallSuper
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(keyForField(FIELD_INT_ERROR_CODE), errorCode);
bundle.putLong(keyForField(FIELD_LONG_TIMESTAMP_MS), timestampMs);
bundle.putString(keyForField(FIELD_STRING_MESSAGE), getMessage());
@Nullable Throwable cause = getCause();
if (cause != null) {
bundle.putString(keyForField(FIELD_STRING_CAUSE_CLASS_NAME), cause.getClass().getName());
bundle.putString(keyForField(FIELD_STRING_CAUSE_MESSAGE), cause.getMessage());
}
return bundle;
}
use of androidx.annotation.CallSuper in project ExoPlayer by google.
the class MediaCodecRenderer method onInputFormatChanged.
/**
* Called when a new {@link Format} is read from the upstream {@link MediaPeriod}.
*
* @param formatHolder A {@link FormatHolder} that holds the new {@link Format}.
* @throws ExoPlaybackException If an error occurs re-initializing the {@link MediaCodec}.
* @return The result of the evaluation to determine whether the existing decoder instance can be
* reused for the new format, or {@code null} if the renderer did not have a decoder.
*/
@CallSuper
@Nullable
protected DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
waitingForFirstSampleInFormat = true;
Format newFormat = checkNotNull(formatHolder.format);
if (newFormat.sampleMimeType == null) {
throw createRendererException(new IllegalArgumentException(), newFormat, PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
}
setSourceDrmSession(formatHolder.drmSession);
inputFormat = newFormat;
if (bypassEnabled) {
bypassDrainAndReinitialize = true;
// Need to drain batch buffer first.
return null;
}
if (codec == null) {
availableCodecInfos = null;
maybeInitCodecOrBypass();
return null;
}
// We have an existing codec that we may need to reconfigure, re-initialize, or release to
// switch to bypass. If the existing codec instance is kept then its operating rate and DRM
// session may need to be updated.
// Copy the current codec and codecInfo to local variables so they remain accessible if the
// member variables are updated during the logic below.
MediaCodecAdapter codec = this.codec;
MediaCodecInfo codecInfo = this.codecInfo;
Format oldFormat = codecInputFormat;
if (drmNeedsCodecReinitialization(codecInfo, newFormat, codecDrmSession, sourceDrmSession)) {
drainAndReinitializeCodec();
return new DecoderReuseEvaluation(codecInfo.name, oldFormat, newFormat, REUSE_RESULT_NO, DISCARD_REASON_DRM_SESSION_CHANGED);
}
boolean drainAndUpdateCodecDrmSession = sourceDrmSession != codecDrmSession;
Assertions.checkState(!drainAndUpdateCodecDrmSession || Util.SDK_INT >= 23);
DecoderReuseEvaluation evaluation = canReuseCodec(codecInfo, oldFormat, newFormat);
@DecoderDiscardReasons int overridingDiscardReasons = 0;
switch(evaluation.result) {
case REUSE_RESULT_NO:
drainAndReinitializeCodec();
break;
case REUSE_RESULT_YES_WITH_FLUSH:
if (!updateCodecOperatingRate(newFormat)) {
overridingDiscardReasons |= DISCARD_REASON_OPERATING_RATE_CHANGED;
} else {
codecInputFormat = newFormat;
if (drainAndUpdateCodecDrmSession) {
if (!drainAndUpdateCodecDrmSessionV23()) {
overridingDiscardReasons |= DISCARD_REASON_WORKAROUND;
}
} else if (!drainAndFlushCodec()) {
overridingDiscardReasons |= DISCARD_REASON_WORKAROUND;
}
}
break;
case REUSE_RESULT_YES_WITH_RECONFIGURATION:
if (!updateCodecOperatingRate(newFormat)) {
overridingDiscardReasons |= DISCARD_REASON_OPERATING_RATE_CHANGED;
} else {
codecReconfigured = true;
codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
codecNeedsAdaptationWorkaroundBuffer = codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_ALWAYS || (codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION && newFormat.width == oldFormat.width && newFormat.height == oldFormat.height);
codecInputFormat = newFormat;
if (drainAndUpdateCodecDrmSession && !drainAndUpdateCodecDrmSessionV23()) {
overridingDiscardReasons |= DISCARD_REASON_WORKAROUND;
}
}
break;
case REUSE_RESULT_YES_WITHOUT_RECONFIGURATION:
if (!updateCodecOperatingRate(newFormat)) {
overridingDiscardReasons |= DISCARD_REASON_OPERATING_RATE_CHANGED;
} else {
codecInputFormat = newFormat;
if (drainAndUpdateCodecDrmSession && !drainAndUpdateCodecDrmSessionV23()) {
overridingDiscardReasons |= DISCARD_REASON_WORKAROUND;
}
}
break;
default:
// Never happens.
throw new IllegalStateException();
}
if (evaluation.result != REUSE_RESULT_NO && (this.codec != codec || codecDrainAction == DRAIN_ACTION_REINITIALIZE)) {
// The reasons are indicated by overridingDiscardReasons.
return new DecoderReuseEvaluation(codecInfo.name, oldFormat, newFormat, REUSE_RESULT_NO, overridingDiscardReasons);
}
return evaluation;
}
use of androidx.annotation.CallSuper in project wire-android by wireapp.
the class GlyphProgressView method init.
@CallSuper
protected void init() {
strokeWidth = ViewUtils.toPx(getContext(), DEFAULT_STROKE_WIDTH_DP);
progressPaint = new Paint();
progressPaint.setStrokeWidth(strokeWidth);
progressPaint.setAntiAlias(true);
progressPaint.setStyle(Paint.Style.STROKE);
updateRectF();
startAngle = DEFAULT_START_ANGLE;
setGravity(Gravity.CENTER);
}
use of androidx.annotation.CallSuper in project FlexibleAdapter by davideas.
the class FlexibleAdapter method removeListener.
/**
* Removes one listener from this Adapter.
* <p><b>Warning:</b>
* <ul><li>In case of <i>Click</i> and <i>LongClick</i> events, it will remove also the callback
* from all bound ViewHolders too. To restore these 2 events on the current bound ViewHolders,
* call {@link #addListener(Object)} providing the instance of the desired listener.</li>
* <li>To remove a specific listener you have to provide the either the instance or the Class
* type of the listener, example:
* <pre>
* removeListener(mUpdateListener);
* removeListener(FlexibleAdapter.OnItemLongClickListener.class);</pre></li></ul></p>
*
* @param listener the listener instance or Class type to remove from this Adapter and/or from all bound ViewHolders
* @return this Adapter, so the call can be chained
* @see #addListener(Object)
* @since 5.0.0-rc3
*/
@CallSuper
public FlexibleAdapter<T> removeListener(Object listener) {
if (listener == null) {
log.e("No listener class to remove!");
return this;
}
String className = getClassName(listener);
if (listener instanceof OnItemClickListener || listener == OnItemClickListener.class) {
mItemClickListener = null;
log.i("Removed %s as OnItemClickListener", className);
for (FlexibleViewHolder holder : getAllBoundViewHolders()) {
holder.getContentView().setOnClickListener(null);
}
}
if (listener instanceof OnItemLongClickListener || listener == OnItemLongClickListener.class) {
mItemLongClickListener = null;
log.i("Removed %s as OnItemLongClickListener", className);
for (FlexibleViewHolder holder : getAllBoundViewHolders()) {
holder.getContentView().setOnLongClickListener(null);
}
}
if (listener instanceof OnItemMoveListener || listener == OnItemMoveListener.class) {
mItemMoveListener = null;
log.i("Removed %s as OnItemMoveListener", className);
}
if (listener instanceof OnItemSwipeListener || listener == OnItemSwipeListener.class) {
mItemSwipeListener = null;
log.i("Removed %s as OnItemSwipeListener", className);
}
if (listener instanceof OnDeleteCompleteListener || listener == OnDeleteCompleteListener.class) {
mDeleteCompleteListener = null;
log.i("Removed %s as OnDeleteCompleteListener", className);
}
if (listener instanceof OnStickyHeaderChangeListener || listener == OnStickyHeaderChangeListener.class) {
mStickyHeaderChangeListener = null;
log.i("Removed %s as OnStickyHeaderChangeListener", className);
}
if (listener instanceof OnUpdateListener || listener == OnUpdateListener.class) {
mUpdateListener = null;
log.i("Removed %s as OnUpdateListener", className);
}
if (listener instanceof OnFilterListener || listener == OnFilterListener.class) {
mFilterListener = null;
log.i("Removed %s as OnFilterListener", className);
}
return this;
}
use of androidx.annotation.CallSuper in project FlexibleAdapter by davideas.
the class FlexibleAdapter method addListener.
/**
* Initializes the listener(s) of this Adapter.
* <p>This method is automatically called from the Constructor.</p>
*
* @param listener the object(s) instance(s) of any listener
* @return this Adapter, so the call can be chained
* @see #removeListener(Object)
* @since 5.0.0-b6
*/
@CallSuper
public FlexibleAdapter<T> addListener(Object listener) {
if (listener == null) {
log.e("Invalid listener class: null");
return this;
}
log.i("Adding listener class %s as:", getClassName(listener));
if (listener instanceof OnItemClickListener) {
log.i("- OnItemClickListener");
mItemClickListener = (OnItemClickListener) listener;
for (FlexibleViewHolder holder : getAllBoundViewHolders()) {
holder.getContentView().setOnClickListener(holder);
}
}
if (listener instanceof OnItemLongClickListener) {
log.i("- OnItemLongClickListener");
mItemLongClickListener = (OnItemLongClickListener) listener;
// Restore the event
for (FlexibleViewHolder holder : getAllBoundViewHolders()) {
holder.getContentView().setOnLongClickListener(holder);
}
}
if (listener instanceof OnItemMoveListener) {
log.i("- OnItemMoveListener");
mItemMoveListener = (OnItemMoveListener) listener;
}
if (listener instanceof OnItemSwipeListener) {
log.i("- OnItemSwipeListener");
mItemSwipeListener = (OnItemSwipeListener) listener;
}
if (listener instanceof OnDeleteCompleteListener) {
log.i("- OnDeleteCompleteListener");
mDeleteCompleteListener = (OnDeleteCompleteListener) listener;
}
if (listener instanceof OnStickyHeaderChangeListener) {
log.i("- OnStickyHeaderChangeListener");
mStickyHeaderChangeListener = (OnStickyHeaderChangeListener) listener;
}
if (listener instanceof OnUpdateListener) {
log.i("- OnUpdateListener");
mUpdateListener = (OnUpdateListener) listener;
mUpdateListener.onUpdateEmptyView(getMainItemCount());
}
if (listener instanceof OnFilterListener) {
log.i("- OnFilterListener");
mFilterListener = (OnFilterListener) listener;
}
return this;
}
Aggregations