下面列出了怎么用androidx.annotation.CallSuper的API类实例代码及写法,或者点击链接到github查看源代码。
@CallSuper
protected void onStatusBarTranslucentChanged(boolean translucent) {
AwesomeToolbar toolbar = getAwesomeToolbar();
if (toolbar != null) {
if (translucent) {
appendStatusBarPadding(toolbar);
} else {
removeStatusBarPadding(toolbar);
}
}
if (getView() != null) {
fixKeyboardBugAtKitkat(getView(), translucent);
}
List<AwesomeFragment> children = getChildFragmentsAtAddedList();
for (int i = 0, size = children.size(); i < size; i++) {
AwesomeFragment child = children.get(i);
child.onStatusBarTranslucentChanged(translucent);
}
}
/**
* Called when an output buffer is successfully processed.
*
* @param presentationTimeUs The timestamp associated with the output buffer.
*/
@CallSuper
@Override
protected void onProcessedOutputBuffer(long presentationTimeUs) {
buffersInCodecCount--;
while (pendingOutputStreamOffsetCount != 0
&& presentationTimeUs >= pendingOutputStreamSwitchTimesUs[0]) {
outputStreamOffsetUs = pendingOutputStreamOffsetsUs[0];
pendingOutputStreamOffsetCount--;
System.arraycopy(
pendingOutputStreamOffsetsUs,
/* srcPos= */ 1,
pendingOutputStreamOffsetsUs,
/* destPos= */ 0,
pendingOutputStreamOffsetCount);
System.arraycopy(
pendingOutputStreamSwitchTimesUs,
/* srcPos= */ 1,
pendingOutputStreamSwitchTimesUs,
/* destPos= */ 0,
pendingOutputStreamOffsetCount);
clearRenderedFirstFrame();
}
}
/**
* Flushes the decoder.
*
* @throws ExoPlaybackException If an error occurs reinitializing a decoder.
*/
@CallSuper
protected void flushDecoder() throws ExoPlaybackException {
waitingForKeys = false;
buffersInCodecCount = 0;
if (decoderReinitializationState != REINITIALIZATION_STATE_NONE) {
releaseDecoder();
maybeInitDecoder();
} else {
inputBuffer = null;
if (outputBuffer != null) {
outputBuffer.release();
outputBuffer = null;
}
decoder.flush();
decoderReceivedBuffers = false;
}
}
@CallSuper
@Override
public void updateUiElements() {
super.updateUiElements();
//TODO: MUST BE FIXED
toolbar.setPopupTheme(getPopupToolbarStyle());
toolbar.setBackgroundColor(getPrimaryColor());
/**** SWIPE TO REFRESH ****/
setStatusBarColor();
setNavBarColor();
fab.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
fab.setVisibility(Hawk.get(getString(R.string.preference_show_fab), false) ? View.VISIBLE : View.GONE);
mainLayout.setBackgroundColor(getBackgroundColor());
setScrollViewColor(navigationDrawerView);
setAllScrollbarsColor();
navigationDrawerView.setTheme(getPrimaryColor(), getBackgroundColor(), getTextColor(), getIconColor());
// TODO Calvin: This performs a NO-OP. Find out what this is used for
setRecentApp(getString(R.string.app_name));
}
@CallSuper
@Override
public void updateUiElements() {
super.updateUiElements();
toolbar.setBackgroundColor(getPrimaryColor());
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
setStatusBarColor();
setNavBarColor();
setRecentApp(getString(R.string.palette));
findViewById(R.id.palette_background).setBackgroundColor(getBackgroundColor());
((CardView) findViewById(R.id.palette_colors_card)).setCardBackgroundColor(getCardBackgroundColor());
((CardView) findViewById(R.id.palette_image_card)).setCardBackgroundColor(getCardBackgroundColor());
((TextView) findViewById(R.id.palette_image_title)).setTextColor(getTextColor());
((TextView) findViewById(R.id.palette_image_caption)).setTextColor(getSubTextColor());
}
@CallSuper
@Override
public void stopScan(boolean quietly) {
mainHandler.removeCallbacks(stopScanRunnable);
int size = proxyBluetoothProfiles.size();
for (int i = 0; i < size; i++) {
try {
bluetoothAdapter.closeProfileProxy(proxyBluetoothProfiles.keyAt(i), proxyBluetoothProfiles.valueAt(i));
} catch (Exception ignore) {
}
}
proxyBluetoothProfiles.clear();
if (isBtEnabled()) {
performStopScan();
}
if (getType() != ScannerType.CLASSIC) {
synchronized (this) {
if (isScanning) {
isScanning = false;
if (!quietly) {
handleScanCallback(false, null, false, -1, "");
}
}
}
}
}
/**
* Called by {@link Room} when it is initialized.
*
* @param configuration The database configuration.
*/
@CallSuper
public void init(@NonNull DatabaseConfiguration configuration) {
mOpenHelper = createOpenHelper(configuration);
if (mOpenHelper instanceof SQLiteCopyOpenHelper) {
SQLiteCopyOpenHelper copyOpenHelper = (SQLiteCopyOpenHelper) mOpenHelper;
copyOpenHelper.setDatabaseConfiguration(configuration);
}
boolean wal = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
wal = configuration.journalMode == JournalMode.WRITE_AHEAD_LOGGING;
mOpenHelper.setWriteAheadLoggingEnabled(wal);
}
mCallbacks = configuration.callbacks;
mQueryExecutor = configuration.queryExecutor;
mTransactionExecutor = new TransactionExecutor(configuration.transactionExecutor);
mAllowMainThreadQueries = configuration.allowMainThreadQueries;
mWriteAheadLoggingEnabled = wal;
if (configuration.multiInstanceInvalidation) {
mInvalidationTracker.startMultiInstanceInvalidation(configuration.context,
configuration.name);
}
}
@CallSuper
void bind(@NonNull WebRtcAudioOutput audioOutput, @Nullable WebRtcAudioOutput selected) {
textView.setText(audioOutput.getLabelRes());
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(audioOutput.getIconRes(), 0, 0, 0);
radioButton.setOnCheckedChangeListener(null);
radioButton.setChecked(audioOutput == selected);
radioButton.setOnCheckedChangeListener(this);
}
@CallSuper
@Override
public void onViewRecycled(@NonNull ViewHolder holder) {
int adapterPosition = holder.getAdapterPosition();
if (adapterPosition == RecyclerView.NO_POSITION)
return;
//onViewRecycled calls seem to be batched after onBindViewHolder calls, that will lead to clearing an actually required key without this check
if (mRecycler.findViewHolderForAdapterPosition(adapterPosition) == null) {
Key key = mPositionToKey.remove(adapterPosition);
if (key != null)
mKeyToPosition.remove(key);
}
}
@CallSuper
@Override
public void seek(long position, long timeUs) {
clusterTimecodeUs = C.TIME_UNSET;
blockState = BLOCK_STATE_START;
reader.reset();
varintReader.reset();
resetWriteSampleData();
for (int i = 0; i < tracks.size(); i++) {
tracks.valueAt(i).reset();
}
}
@CallSuper
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Key key = getKeyForPosition(position);
mKeyToPosition.put(key, position);
mPositionToKey.put(position, key);
}
@Override
@CallSuper
public void maybeThrowSourceInfoRefreshError() throws IOException {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.maybeThrowSourceInfoRefreshError();
}
}
@Override
@CallSuper
protected void enableInternal() {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.enable(childSource.caller);
}
}
@Override
@CallSuper
protected void disableInternal() {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.disable(childSource.caller);
}
}
@Override
@CallSuper
protected void releaseSourceInternal() {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.releaseSource(childSource.caller);
childSource.mediaSource.removeEventListener(childSource.eventListener);
}
childSources.clear();
}
@CallSuper
@Override
public void release() {
synchronized (lock) {
released = true;
lock.notify();
}
try {
decodeThread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
@CallSuper
@Override
public void onAnimationRepeated(Animator animation) {
super.onAnimationRepeated(animation);
if(mAnimatorListenerAdapter != null) {
mAnimatorListenerAdapter.onAnimationRepeated(animation);
}
}
@CallSuper
@Override
public ByteBuffer getOutput() {
ByteBuffer outputBuffer = this.outputBuffer;
this.outputBuffer = EMPTY_BUFFER;
return outputBuffer;
}
@CallSuper
@Override
protected void releaseCodec() {
try {
super.releaseCodec();
} finally {
buffersInCodecCount = 0;
}
}
@CallSuper
@Override
protected boolean flushOrReleaseCodec() {
try {
return super.flushOrReleaseCodec();
} finally {
buffersInCodecCount = 0;
}
}
@CallSuper
public void init(int w, int h, PageView view, OnPageChangeListener listener) {
mViewWidth = w;
mViewHeight = h;
mView = view;
mListener = listener;
mScroller = new Scroller(mView.getContext(), new FastOutLinearInInterpolator());
}
/**
* Called when a new format is read from the upstream source.
*
* @param formatHolder A {@link FormatHolder} that holds the new {@link Format}.
* @throws ExoPlaybackException If an error occurs (re-)initializing the decoder.
*/
@CallSuper
@SuppressWarnings("unchecked")
protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
waitingForFirstSampleInFormat = true;
Format newFormat = Assertions.checkNotNull(formatHolder.format);
if (formatHolder.includesDrmSession) {
setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession);
} else {
sourceDrmSession =
getUpdatedSourceDrmSession(inputFormat, newFormat, drmSessionManager, sourceDrmSession);
}
inputFormat = newFormat;
if (sourceDrmSession != decoderDrmSession) {
if (decoderReceivedBuffers) {
// Signal end of stream and wait for any final output buffers before re-initialization.
decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM;
} else {
// There aren't any final output buffers, so release the decoder immediately.
releaseDecoder();
maybeInitDecoder();
}
}
eventDispatcher.inputFormatChanged(inputFormat);
}
@CallSuper @Override protected void onSubsystemLoaded(ModelAddedEvent event) {
SubsystemModel careSubsystem = getModel();
if (careSubsystem == null) {
return;
}
CareBehaviorTemplateProvider.instance().setSubsystemAddress(careSubsystem.getAddress());
CareBehaviorsProvider.instance().setSubsystemAddress(careSubsystem.getAddress());
super.onSubsystemLoaded(event);
}
@CallSuper
@Override
public void onAnimationStarted(Animator animation) {
super.onAnimationStarted(animation);
if(mAnimatorListenerAdapter != null) {
mAnimatorListenerAdapter.onAnimationStarted(animation);
}
}
@Override
@CallSuper
protected void onStart() {
super.onStart();
ButterKnife.bind(this);
// Set text
mTextTitle.setText(getTitle());
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("");
}
@CallSuper
@Override
protected void onActive() {
for (Map.Entry<LiveData<?>, Source<?>> source : mSources) {
source.getValue().plug();
}
}
@CallSuper
@Override
protected void onInactive() {
for (Map.Entry<LiveData<?>, Source<?>> source : mSources) {
source.getValue().unplug();
}
}
@CallSuper
public void initialise() {
iconView.setSelected(false);
if (icon != null && unselectedIcon != null) {
StateListDrawable states = new StateListDrawable();
states.addState(new int[]{android.R.attr.state_selected},
icon);
states.addState(new int[]{-android.R.attr.state_selected},
unselectedIcon);
states.addState(new int[]{},
unselectedIcon);
iconView.setImageDrawable(states);
} else if (icon != null) {
DrawableCompat.setTintList(icon, new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_selected}, //1
new int[]{-android.R.attr.state_selected}, //2
new int[]{}
},
new int[]{
selectedColor, //1
unselectedColor, //2
unselectedColor //3
}
));
iconView.setImageDrawable(icon);
}
if (badgeText != null) {
showTextBadge(badgeText);
}
if (showDotBadge) {
showDotBadge();
}
}
@Override
@CallSuper
protected void loadData() {
if(mPresenter != null){
mPresenter.subscribeEvent();
}
}
@CallSuper
@Override
public void updateUiElements() {
super.updateUiElements();
toolbar.setBackgroundColor(getPrimaryColor());
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
toolbar.setNavigationOnClickListener(v -> onBackPressed());
setScrollViewColor(aboutScrollView);
setStatusBarColor();
setNavBarColor();
specialThanksPatryk.setLinkTextColor(getAccentColor());
}