下面列出了怎么用android.support.annotation.CallSuper的API类实例代码及写法,或者点击链接到github查看源代码。
/** Called when the user has accepted (or denied) our permission request. */
@CallSuper
@Override
public void onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQUEST_CODE_REQUIRED_PERMISSIONS) {
for (int grantResult : grantResults) {
if (grantResult == PackageManager.PERMISSION_DENIED) {
Toast.makeText(this, R.string.error_missing_permissions, Toast.LENGTH_LONG).show();
finish();
return;
}
}
recreate();
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@CallSuper
@Override
public void onBindViewHolder(@NonNull VH holder, int position) {
holder.addOnItemClickListener(onItemClickListener == null ? null : getDefaultItemClickListener());
holder.addOnItemLongClickListener(onItemLongClickListener == null ? null : getDefaultItemLongClickListener());
switch (getItemViewType(position)) {
case TYPE_HEADER:
onBindHeaderViewHolder(holder, position, getHeaderAt(position));
break;
case TYPE_DATA:
onBindDataViewHolder(holder, position, getDataAt(position));
break;
case TYPE_FOOTER:
onBindFooterViewHolder(holder, position, getFooterAt(position));
break;
case TYPE_EMPTY:
onBindEmptyViewHolder(holder, position, getEmptyAt(position));
break;
case UNKNOWN:
break;
}
}
@CallSuper
@Override
protected void releaseCodec() {
try {
super.releaseCodec();
} finally {
buffersInCodecCount = 0;
if (dummySurface != null) {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
}
}
}
/**
* 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);
}
}
@CallSuper
public synchronized void show() {
if (mInflate == null)
throw new IllegalStateException("FloatView can not be null");
if (mAdded) {
mInflate.setVisibility(View.VISIBLE);
return;
}
getLayoutParam(mViewMode);
mInflate.setVisibility(View.VISIBLE);
try {
mWindowManager.addView(mInflate, mLayoutParams);
mAdded = true;
} catch (Exception e) {
Log.e(TAG, "添加悬浮窗失败!!!!!!请检查悬浮窗权限");
// Toast.makeText(mContext, "添加悬浮窗失败!!!!!!请检查悬浮窗权限", Toast.LENGTH_SHORT).show();
onAddWindowFailed(e);
}
}
@CallSuper
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStatusBar();
setContentView();
initPaddingTop();
Bundle extras = getIntent().getExtras();
activity = this;
presenter = createPresenter();
if (presenter != null) {
presenter.register(this);
}
AppManager.getAppManager().addActivity(this);
Bundle bundle = getIntent().getExtras();
// 设置bundle传值注入
if (bundle != null) {
new BundleUtils().setBundleField(this, bundle);
}
initView(savedInstanceState);
loadData();
}
@CallSuper
@Override
protected void onDestroy() {
// 避免WebView引起内存泄漏
if (mWebView != null) {
/* WebView中包含一个ZoomButtonsController,当使用web.getSettings().setBuiltInZoomControls(true);
启用该设置后,用户一旦触摸屏幕,就会出现缩放控制图标,这个图标过上几秒会自动消失.
但在3.0系统以上上,如果图标自动消失前退出当前Activity的话,就会发生ZoomButton找不到依附的Window而造成程序崩溃,
解决办法很简单就是在Activity的ondestory方法中调用web.setVisibility(View.GONE);方法,手动将其隐藏,就不会崩溃了。
在3.0一下系统上不会出现该崩溃问题 */
mWebView.setVisibility(View.GONE);
mWebView.stopLoading();
mWebView.clearHistory();
ViewGroup webParent = (ViewGroup) mWebView.getParent();
if (webParent != null) {
webParent.removeView(mWebView);
}
mWebView.removeAllViews();
mWebView.destroy();
mWebView = null;
}
super.onDestroy();
}
/**
* 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);
}
}
@CallSuper
public synchronized void show() {
if (mInflate == null)
throw new IllegalStateException("FloatView can not be null");
if (mAdded) {
mInflate.setVisibility(View.VISIBLE);
return;
}
getLayoutParam(mViewMode);
mInflate.setVisibility(View.VISIBLE);
try {
mWindowManager.addView(mInflate, mLayoutParams);
mAdded = true;
} catch (Exception e) {
Log.e(TAG, "添加悬浮窗失败!!!!!!请检查悬浮窗权限");
// Toast.makeText(mContext, "添加悬浮窗失败!!!!!!请检查悬浮窗权限", Toast.LENGTH_SHORT).show();
onAddWindowFailed(e);
}
}
@Override
@CallSuper
public void onRenderSuccess(WXSDKInstance instance, int width, int height) {
if(mWxAnalyzerDelegate != null){
mWxAnalyzerDelegate.onWeexRenderSuccess(instance);
}
}
@Override
@CallSuper
public void onException(WXSDKInstance instance, String errCode, String msg) {
if(mWxAnalyzerDelegate != null){
mWxAnalyzerDelegate.onException(instance,errCode,msg);
}
}
@CallSuper
public void captureValue(@NonNull View fromView, @NonNull View toView, @NonNull View animationView) {
if (animationView == null) {
throw new IllegalArgumentException("animationView cant be null");
}
this.mFromView = fromView;
this.mToView = toView;
this.mAnimationView = animationView;
}
@CallSuper
public void captureValue(@NonNull View view, @NonNull ViewGroup rootView) {
this.mView = view;
this.mRootView = rootView;
if (this.mPropagation != null) {
this.mTransitionPropagationResult = mPropagation.captureValues(view, rootView);
}
}
@CallSuper
public void remove() {
if (mInflate != null && mWindowManager != null) {
if (mInflate.isAttachedToWindow()) {
mWindowManager.removeView(mInflate);
}
mAdded = false;
}
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
}
@Override
@CallSuper
public void prepareSourceInternal(
ExoPlayer player,
boolean isTopLevelSource,
@Nullable TransferListener mediaTransferListener) {
this.player = player;
this.mediaTransferListener = mediaTransferListener;
eventHandler = new Handler();
}
@Override
@CallSuper
public void maybeThrowSourceInfoRefreshError() throws IOException {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.maybeThrowSourceInfoRefreshError();
}
}
@Override
@CallSuper
public void releaseSourceInternal() {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.releaseSource(childSource.listener);
childSource.mediaSource.removeEventListener(childSource.eventListener);
}
childSources.clear();
player = null;
}
/**
* Called immediately before an input buffer is queued into the codec.
*
* @param buffer The buffer to be queued.
*/
@CallSuper
@Override
protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
buffersInCodecCount++;
lastInputTimeUs = Math.max(buffer.timeUs, lastInputTimeUs);
if (Util.SDK_INT < 23 && tunneling) {
maybeNotifyRenderedFirstFrame();
}
}
@CallSuper
public void remove() {
if (mInflate != null && mWindowManager != null) {
if (mInflate.isAttachedToWindow()) {
mWindowManager.removeView(mInflate);
}
mAdded = false;
}
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
}
@CallSuper
public void mkdirs() {
if (!dirRoot.exists()) dirRoot.mkdirs();
if (!dirProject.exists()) dirProject.mkdirs();
if (!dirLibs.exists()) dirLibs.mkdirs();
if (!dirSrcMain.exists()) dirSrcMain.mkdirs();
if (!dirJava.exists()) dirJava.mkdirs();
if (!dirBuildClasses.exists()) dirBuildClasses.mkdirs();
if (!dirGenerated.exists()) dirGenerated.mkdirs();
if (!dirGeneratedSource.exists()) dirGeneratedSource.mkdirs();
}
@CallSuper
public void clean() {
try {
com.android.utils.FileUtils.emptyFolder(dirBuildClasses);
} catch (IOException e) {
e.printStackTrace();
}
}
@CallSuper
@Override
protected void onDestroy() {
super.onDestroy();
if (presenter != null) {
presenter.unRegister();
}
AppManager.getAppManager().finishActivity(this);
}
@CallSuper
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
presenter = createPresenter();
if (presenter != null) {
presenter.register(this);
}
return inflater.inflate(getLayout(), container, false);
}
@CallSuper
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
this.rootView = view;
initHideBoard(view);
if (getArguments() != null) {
getBundle(getArguments());
new BundleUtils().setBundleField(this,getArguments());
}
initView(savedInstanceState);
loadData();
}
@CallSuper
@Override
public void onDestroyView() {
super.onDestroyView();
if (presenter != null) {
presenter.unRegister();
}
}
@CallSuper
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (hidden) {
onHide();
} else {
onShow();
}
}
@CallSuper
@Override
public int getItemCount() {
if (emptyModle == EMPTY_MODLE_NOMAL) {
if (data.isEmpty() && data.size() == 0 && emptyView != null && headerList.isEmpty() && footerList.isEmpty()) {
return 1;
}
} else {
if (data.isEmpty() && data.size() == 0 && emptyView != null) {
return 1;
}
}
return data.size() + getHeaderCount() + getFooterCount();
}
@CallSuper
@Override
protected void initView(@Nullable Bundle savedInstanceState) {
titleView = findViewById(R.id.toobar_title);
if (titleView != null && !TextUtils.isEmpty(getTooBarTitle())) {
titleView.setText(getTooBarTitle());
findViewById(R.id.bar_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
@Override @CallSuper
public void onDestroy() {
if (mDaemonStarted) {
mDaemonStarted = false;
final boolean stoppedSuccessfully = NDCrash.stopOutOfProcessDaemon();
Log.i(TAG, "Out-of-process daemon " + (stoppedSuccessfully ? "is successfully stopped." : "failed to stop."));
}
super.onDestroy();
}
@CallSuper
@Override
public void onPause() {
super.onPause();
if (mWebView != null) {
mWebView.onPause();
}
}