zoukankan      html  css  js  c++  java
  • 每日日报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的开发

  • 相关阅读:
    Dubbo使用
    JVM内存分配及GC简述
    深入理解ThreadLocal
    Java的Timer定时器
    https与http的区别
    SpringBoot微服务
    Java的BIO,NIO,AIO
    Java常量池
    Java中的值传递与引用传递
    面向对象三大特征及代码优化七大原则
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14906621.html
Copyright © 2011-2022 走看看