当前位置: 首页 > news >正文

怎么把做网站发给别人wordpress评论点赞怎么实现

怎么把做网站发给别人,wordpress评论点赞怎么实现,购物网站需要做的功能,团购鲜花的网站建设继续承接上一篇文章----Fragment.OnPause的事情#xff0c;我们知道onPause之后进入的是onStop生命周期方法#xff0c;那Fragment的onStop方法又干了些什么呢#xff1f; 还是从Activity入手#xff0c;相应的入口代码如下#xff1a; //FragmentActivity.java/*** Disp…        继续承接上一篇文章----Fragment.OnPause的事情我们知道onPause之后进入的是onStop生命周期方法那Fragment的onStop方法又干了些什么呢 还是从Activity入手相应的入口代码如下 //FragmentActivity.java/*** Dispatch onStop() to all fragments.*/Overrideprotected void onStop() {super.onStop();mStopped true;markFragmentsCreated();mHandler.sendEmptyMessage(MSG_REALLY_STOPPED);mFragments.dispatchStop();} 这里主要做了3个事情首先调用markFragmentsCreated标记相应fragment的LifecycleRegistry状态这里不是重点不关注其次发送了消息MSG_REALLY_STOPPED最后调用mFragments.dispatchStop()分发activity的生命周期这里关注dispatchStop代码如下 //FragmentManager.java public void dispatchStop() {mStopped true;dispatchStateChange(Fragment.STOPPED);}private void dispatchStateChange(int nextState) {try {mExecutingActions true;moveToState(nextState, false);} finally {mExecutingActions false;}execPendingActions();}/*** Changes the state of the fragment manager to {code newState}. If the fragment manager* changes state or {code always} is {code true}, any fragments within it have their* states updated as well.** param newState The new state for the fragment manager* param always If {code true}, all fragments update their state, even* if {code newState} matches the current fragment managers state.*/void moveToState(int newState, boolean always) {if (mHost null newState ! Fragment.INITIALIZING) {throw new IllegalStateException(No activity);}if (!always newState mCurState) {return;}mCurState newState;if (mActive ! null) {// Must add them in the proper order. mActive fragments may be out of orderfinal int numAdded mAdded.size();for (int i 0; i numAdded; i) {Fragment f mAdded.get(i);moveFragmentToExpectedState(f);//这里这里}// Now iterate through all active fragments. These will include those that are removed// and detached.final int numActive mActive.size();for (int i 0; i numActive; i) {Fragment f mActive.valueAt(i);if (f ! null (f.mRemoving || f.mDetached) !f.mIsNewlyAdded) {moveFragmentToExpectedState(f);}}startPendingDeferredFragments();if (mNeedMenuInvalidate mHost ! null mCurState Fragment.RESUMED) {mHost.onSupportInvalidateOptionsMenu();mNeedMenuInvalidate false;}}}/*** Moves a fragment to its expected final state or the fragment managers state, depending* on whether the fragment managers state is raised properly.** param f The fragment to change.*/void moveFragmentToExpectedState(Fragment f) {if (f null) {return;}int nextState mCurState;if (f.mRemoving) {if (f.isInBackStack()) {nextState Math.min(nextState, Fragment.CREATED);} else {nextState Math.min(nextState, Fragment.INITIALIZING);}}moveToState(f, nextState, f.getNextTransition(), f.getNextTransitionStyle(), false);if (f.mView ! null) {// Move the view if it is out of orderFragment underFragment findFragmentUnder(f);if (underFragment ! null) {final View underView underFragment.mView;// make sure this fragment is in the right order.final ViewGroup container f.mContainer;int underIndex container.indexOfChild(underView);int viewIndex container.indexOfChild(f.mView);if (viewIndex underIndex) {container.removeViewAt(viewIndex);container.addView(f.mView, underIndex);}}if (f.mIsNewlyAdded f.mContainer ! null) {// Make it visible and run the animationsif (f.mPostponedAlpha 0f) {f.mView.setAlpha(f.mPostponedAlpha);}f.mPostponedAlpha 0f;f.mIsNewlyAdded false;// run animations:AnimationOrAnimator anim loadAnimation(f, f.getNextTransition(), true,f.getNextTransitionStyle());if (anim ! null) {setHWLayerAnimListenerIfAlpha(f.mView, anim);if (anim.animation ! null) {f.mView.startAnimation(anim.animation);} else {anim.animator.setTarget(f.mView);anim.animator.start();}}}}if (f.mHiddenChanged) {completeShowHideFragment(f);}} 调用链与上一篇文章一致这里关注调用moveToState时的参数其中newState为Fragment.STOPPED3always为false将newState保存到mCurState中然后调用moveFragmentToExpectedState进行fragment的状态转移该方法最后调用5个参数的moveToState代码如下 SuppressWarnings(ReferenceEquality)void moveToState(Fragment f, int newState, int transit, int transitionStyle,boolean keepActive) {// Fragments that are not currently added will sit in the onCreate() state.if ((!f.mAdded || f.mDetached) newState Fragment.CREATED) {newState Fragment.CREATED;}if (f.mRemoving newState f.mState) {if (f.mState Fragment.INITIALIZING f.isInBackStack()) {// Allow the fragment to be created so that it can be saved later.newState Fragment.CREATED;} else {// While removing a fragment, we cant change it to a higher state.newState f.mState;}}// Defer start if requested; dont allow it to move to STARTED or higher// if its not already started.if (f.mDeferStart f.mState Fragment.STARTED newState Fragment.STOPPED) {newState Fragment.STOPPED;}if (f.mState newState) {// For fragments that are created from a layout, when restoring from// state we dont want to allow them to be created until they are// being reloaded from the layout.//该分支表示生命周期转换 create - start - resume} else if (f.mState newState) {//该分支表示生命周期转换 pause - stop - destoryView - destory - detachswitch (f.mState) {case Fragment.RESUMED:if (newState Fragment.RESUMED) {if (DEBUG) Log.v(TAG, movefrom RESUMED: f);f.performPause();dispatchOnFragmentPaused(f, false);}// fall throughcase Fragment.STARTED://走到这里if (newState Fragment.STARTED) {if (DEBUG) Log.v(TAG, movefrom STARTED: f);f.performStop();dispatchOnFragmentStopped(f, false);}// fall throughcase Fragment.STOPPED:if (newState Fragment.STOPPED) {if (DEBUG) Log.v(TAG, movefrom STOPPED: f);f.performReallyStop();}// fall throughcase Fragment.ACTIVITY_CREATED:if (newState Fragment.ACTIVITY_CREATED) {if (DEBUG) Log.v(TAG, movefrom ACTIVITY_CREATED: f);if (f.mView ! null) {// Need to save the current view state if not// done already.if (mHost.onShouldSaveFragmentState(f) f.mSavedViewState null) {saveFragmentViewState(f);}}f.performDestroyView();dispatchOnFragmentViewDestroyed(f, false);if (f.mView ! null f.mContainer ! null) {// Stop any current animations:f.mContainer.endViewTransition(f.mView);f.mView.clearAnimation();AnimationOrAnimator anim null;if (mCurState Fragment.INITIALIZING !mDestroyed f.mView.getVisibility() View.VISIBLE f.mPostponedAlpha 0) {anim loadAnimation(f, transit, false,transitionStyle);}f.mPostponedAlpha 0;if (anim ! null) {animateRemoveFragment(f, anim, newState);}f.mContainer.removeView(f.mView);}f.mContainer null;f.mView null;f.mInnerView null;f.mInLayout false;}// fall throughcase Fragment.CREATED:if (newState Fragment.CREATED) {if (mDestroyed) {// The fragments containing activity is// being destroyed, but this fragment is// currently animating away. Stop the// animation right now -- it is not needed,// and we cant wait any more on destroying// the fragment.if (f.getAnimatingAway() ! null) {View v f.getAnimatingAway();f.setAnimatingAway(null);v.clearAnimation();} else if (f.getAnimator() ! null) {Animator animator f.getAnimator();f.setAnimator(null);animator.cancel();}}if (f.getAnimatingAway() ! null || f.getAnimator() ! null) {// We are waiting for the fragments view to finish// animating away. Just make a note of the state// the fragment now should move to once the animation// is done.f.setStateAfterAnimating(newState);newState Fragment.CREATED;} else {if (DEBUG) Log.v(TAG, movefrom CREATED: f);if (!f.mRetaining) {f.performDestroy();dispatchOnFragmentDestroyed(f, false);} else {f.mState Fragment.INITIALIZING;}f.performDetach();dispatchOnFragmentDetached(f, false);if (!keepActive) {if (!f.mRetaining) {makeInactive(f);} else {f.mHost null;f.mParentFragment null;f.mFragmentManager null;}}}}}}if (f.mState ! newState) {Log.w(TAG, moveToState: Fragment state for f not updated inline; expected state newState found f.mState);f.mState newState;}} 这里注意Fragment执行完onPause之后mState为STARTED4而newState为STOPPED3所以进入销毁流程的Fragment.STARTED分支即执行如下代码 case Fragment.STARTED:if (newState Fragment.STARTED) {if (DEBUG) Log.v(TAG, movefrom STARTED: f);f.performStop();dispatchOnFragmentStopped(f, false);} newState Fragment.STARTED条件为真因此进入代码块中performStop代码如下 void performStop() {mLifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP);if (mChildFragmentManager ! null) {mChildFragmentManager.dispatchStop();}mState STOPPED;mCalled false;onStop();if (!mCalled) {throw new SuperNotCalledException(Fragment this did not call through to super.onStop());}} 处理LifecycleRegistry中的回调处理子fragmet的生命周期回调分发改变当前fragment状态mState STOPPED调用当前fragment的生命周期方法onStop。回到上一步继续调用方法dispatchOnFragmentStopped代码如下 void dispatchOnFragmentStopped(Fragment f, boolean onlyRecursive) {if (mParent ! null) {FragmentManager parentManager mParent.getFragmentManager();if (parentManager instanceof FragmentManagerImpl) {((FragmentManagerImpl) parentManager).dispatchOnFragmentStopped(f, true);}}for (PairFragmentLifecycleCallbacks, Boolean p : mLifecycleCallbacks) {if (!onlyRecursive || p.second) {p.first.onFragmentStopped(this, f);}}} 处理父fragment生命周期分发处理mLifecycleCallbacks的注册回调。 onStop分支总结 1 处理mLifecycleRegistry中的回调。 2 通过mChildFragmentManager.dispatchPause()分发其子fragment的生命周期回调。 3 调用onStop执行自己的生命周期方法同时mState STOPPED。 4 如果有父framnet则分发父frament的生命周期回调。 5 执行保存在mLifecycleCallbacks中的生命周期回调比如LeakCanary的内存泄漏判断就是此时触发的。 执行完onStop之后上面的逻辑将穿透到Fragment.STOPPED分支代码如下 case Fragment.STARTED:if (newState Fragment.STARTED) {if (DEBUG) Log.v(TAG, movefrom STARTED: f);f.performStop();dispatchOnFragmentStopped(f, false);}// fall throughcase Fragment.STOPPED://走到这里if (newState Fragment.STOPPED) {if (DEBUG) Log.v(TAG, movefrom STOPPED: f);f.performReallyStop();} 然而由于此时newStateFragment.STOPPED因此将会穿透其余的分支最后跳出整个大switch代码块。 还记得开篇说的MSG_REALLY_STOPPED消息吗其对应的代码逻辑如下 final Handler mHandler new Handler() {Overridepublic void handleMessage(Message msg) {switch (msg.what) {case MSG_REALLY_STOPPED:if (mStopped) {doReallyStop(false);}break;case MSG_RESUME_PENDING:onResumeFragments();mFragments.execPendingActions();break;default:super.handleMessage(msg);}}};void doReallyStop(boolean retaining) {if (!mReallyStopped) {mReallyStopped true;mRetaining retaining;mHandler.removeMessages(MSG_REALLY_STOPPED);onReallyStop();}}/*** Pre-HC, we didnt have a way to determine whether an activity was* being stopped for a config change or not until we saw* onRetainNonConfigurationInstance() called after onStop(). However* we need to know this, to know whether to retain fragments. This will* tell us what we need to know.*/void onReallyStop() {mFragments.dispatchReallyStop();} 最后调用dispatchReallyStop方法该方法也会进入5个参数的moveToState方法中相应分支代码如下 case Fragment.STOPPED:if (newState Fragment.STOPPED) {if (DEBUG) Log.v(TAG, movefrom STOPPED: f);f.performReallyStop();} 继续调用performReallyStop方法如下 void performReallyStop() {if (mChildFragmentManager ! null) {mChildFragmentManager.dispatchReallyStop();}mState ACTIVITY_CREATED;} 首先是分发事件然后是改变fragment的状态此时fragment的mState 为 ACTIVITY_CREATED。 到这里onStop执行完成。 此时Fragment的mState为ACTIVITY_CREATED。
http://www.huolong8.cn/news/314746/

相关文章:

  • 有哪些做头像的网站中山建设企业网站
  • 高州网站开发公司怎么做360网站排名
  • 暗网网站有那些软件服务网站设计费如何做分录
  • 宁波网站推广软件哪家强网站建设兼职在哪找
  • 柳州哪家公司做网站好组工网站建设方案
  • 网站建设淘宝属于什么类目广州建设工程领域平台登录
  • pc网站建设意见大气娱乐搞笑网站源码
  • 企业网站keywords最多几个吉林做网站公司
  • 网站建设论证方案涪城网站建设
  • 如何用腾讯云做网站云南大永高速公路建设指挥部网站
  • 广州教育学会网站建设怎么注册网址免费
  • 下载网站模板怎么使用教程中国建设银行总行网站
  • 网站获利模式wordpress时间轴源码
  • 无锡免费做网站学校网站建设教程
  • 架设网站费用网站后来功能
  • 网站添加背景音乐公司网站制作费用多少
  • 建设网站与服务器产品营销网站
  • 加强网站信息建设管理品牌宣传网站有哪些
  • 漳州网站开发制作影视制作宣传片公司
  • 新余 网站建站 设计 公司建筑公司网站平台
  • 中型网站建设外包软件开发
  • 如何在百度上做公司做网站网站空间的地址
  • 全国的网站建设免费网站建设社区
  • 网站建设方案书封面wordpress 字段插件
  • 岱山县建设网站网业游戏大全
  • 什么app做网站seo关键词优化公司官网
  • 用备案的网站做违法网站wordpress 主题 设置
  • 网站底部导航制作泰安网站建设哪家强
  • 公司网站免费建立贺兰县住房和城乡建设局网站
  • 做简单网站用什么软件有哪些内容wordpress彩票