• 每日日报2021.2.18


    今天完成内容:

    1.学习android

    2.3.1 LinearLayoutManager#onLayoutChildren

      public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
        ...
        //1. 寻找填充的锚点
        updateAnchorInfoForLayout(recycler, state, mAnchorInfo);
        
        ...
        //2. 移除屏幕上的Views
        detachAndScrapAttachedViews(recycler);
        
        ...
        //3. 从锚点处从上往下填充
        updateLayoutStateToFillEnd(mAnchorInfo);
        mLayoutState.mExtraFillSpace = extraForEnd;
        fill(recycler, mLayoutState, state, false);
        
        ...
        //4. 从锚点处从下往上填充
        // fill towards start
        updateLayoutStateToFillStart(mAnchorInfo);
        mLayoutState.mExtraFillSpace = extraForStart;
        mLayoutState.mCurrentPosition += mLayoutState.mItemDirection;
        fill(recycler, mLayoutState, state, false);
        
        ...
        //5. 如果还有多余的空间,继续填充
        if (mLayoutState.mAvailable > 0) {
            extraForEnd = mLayoutState.mAvailable;
            // start could not consume all it should. add more items towards end
            updateLayoutStateToFillEnd(lastElement, endOffset);
            mLayoutState.mExtraFillSpace = extraForEnd;
            fill(recycler, mLayoutState, state, false);
            endOffset = mLayoutState.mOffset;
        }
      }
        ...
        //6. 非预布局,将scrapList中多余的ViewHolder填充
        layoutForPredictiveAnimations(recycler, state, startOffset, endOffset);
        ...

    2.3.2 LinearLayoutManager#layoutForPredictiveAnimations

     private void layoutForPredictiveAnimations(RecyclerView.Recycler recycler,
                RecyclerView.State state, int startOffset,
                int endOffset) {
            //判断是否满足条件,如果是预布局直接返回
            if (!state.willRunPredictiveAnimations() ||  getChildCount() == 0 || state.isPreLayout()
                    || !supportsPredictiveItemAnimations()) {
                return;
            }
            // 遍历scrapList,步骤2中屏幕中被移除的View
            int scrapExtraStart = 0, scrapExtraEnd = 0;
            final List<RecyclerView.ViewHolder> scrapList = recycler.getScrapList();
            final int scrapSize = scrapList.size();
            final int firstChildPos = getPosition(getChildAt(0));
            for (int i = 0; i < scrapSize; i++) {
                RecyclerView.ViewHolder scrap = scrapList.get(i);
                //如果被remove掉了,跳过
                if (scrap.isRemoved()) {
                    continue;
                }
                //计算额外的控件
                    scrapExtraEnd += mOrientationHelper.getDecoratedMeasurement(scrap.itemView);

            }

            mLayoutState.mScrapList = scrapList;
            ...
            // 步骤6 继续填充
            if (scrapExtraEnd > 0) {
                View anchor = getChildClosestToEnd();
                updateLayoutStateToFillEnd(getPosition(anchor), endOffset);
                mLayoutState.mExtraFillSpace = scrapExtraEnd;
                mLayoutState.mAvailable = 0;
                mLayoutState.assignPositionFromScrapList();
                fill(recycler, mLayoutState, state, false);
            }
            mLayoutState.mScrapList = null;
        }

    2.看书

    3.看视频

    遇到问题:

    明日目标:

    学习Android studio的开发

  • 相关阅读:
    [BZOJ1657] [Usaco2006 Mar] Mooo 奶牛的歌声 (单调栈)
    [BZOJ1016] [JSOI2008] 最小生成树计数 (Kruskal)
    [BZOJ1015] [JSOI2008] 星球大战starwar (并查集)
    [BZOJ1007] [HNOI2008] 水平可见直线 (凸包)
    [BZOJ1061] [Noi2008] 志愿者招募 (费用流)
    [BZOJ1051] [HAOI2006] 受欢迎的牛 (强联通分量)
    BZOJ2299: [HAOI2011]向量
    BZOJ2783: [JLOI2012]树
    BZOJ3521: [Poi2014]Salad Bar
    BZOJ2429: [HAOI2006]聪明的猴子
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14906621.html
Copyright © 2020-2023  润新知