private void listAll() {
    ViewGroup root = mList;
    root.removeAllViews();

    // 列出所有已经安装的插件
    Collection<PluginDescriptor> plugins = PluginLoader.getPlugins();
    Iterator<PluginDescriptor> itr = plugins.iterator();
    while (itr.hasNext()) {
      final PluginDescriptor pluginDescriptor = itr.next();
      Button button = new Button(this);
      button.setPadding(10, 10, 10, 10);
      button.setText("插件id:" + pluginDescriptor.getPackageName() + ",点击查看");
      button.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              Intent intent = new Intent(PluginListActivity.this, PluginDetailActivity.class);
              intent.putExtra("plugin_id", pluginDescriptor.getPackageName());
              startActivity(intent);
            }
          });

      LayoutParams layoutParam =
          new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParam.topMargin = 10;
      layoutParam.bottomMargin = 10;
      layoutParam.gravity = Gravity.LEFT;
      root.addView(button, layoutParam);
    }
  }
    @Override
    public View getChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      ViewGroup item;

      if (convertView != null && convertView.getId() == R.id.child_item) {
        // We can reuse the view
        item = (ViewGroup) convertView;
      } else {
        // We create a new View
        item = (ViewGroup) inflater.inflate(R.layout.child_item_layout, parent, false);
      }

      ChildClass child = (ChildClass) getChild(groupPosition, childPosition);

      TextView nameView = (TextView) item.findViewById(R.id.child_name);
      nameView.setText(child.getName());

      TextView sizeView = (TextView) item.findViewById(R.id.child_text);
      sizeView.setText(child.getText());

      return item;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = super.getView(position, convertView, parent);

      // Iterate on all first level children
      if (view instanceof ViewGroup) {
        ViewGroup group = ((ViewGroup) view);
        View child;
        for (int i = 0; i < group.getChildCount(); i++) {
          child = group.getChildAt(i);
          // and set text size on all TextViews found
          if (child instanceof TextView) {
            // mBrowserFontSize
            float currentSize = ((TextView) child).getTextSize();
            if (originalTextSize < 0) {
              originalTextSize = ((TextView) child).getTextSize();
            }
            // do nothing when pref is 100% and apply scaling only
            // once
            if ((fontSizeScalePcent < 99 || fontSizeScalePcent > 101)
                && (Math.abs(originalTextSize - currentSize) < 0.1)) {
              ((TextView) child)
                  .setTextSize(
                      TypedValue.COMPLEX_UNIT_SP, originalTextSize * (fontSizeScalePcent / 100.0f));
            }
          }
        }
      }

      return view;
    }
 public void setParent(android.view.ViewGroup viewgroup) {
   if (parent != null) {
     parent.removeView(this);
   }
   parent = viewgroup;
   viewgroup.addView(this, lparams);
 }
 @Test
 public void removeView_resetsParentOnlyIfViewIsInViewGroup() throws Exception {
   assertThat(root.getChildCount(), equalTo(3));
   root.removeView(child3a);
   assertThat(root.getChildCount(), equalTo(3));
   assertThat(child3a.getParent(), sameInstance((ViewParent) child3));
 }
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LinearLayout itemView = new LinearLayout(parent.getContext());

    TextView textView = new TextView(parent.getContext());
    textView.setTextSize(18);
    textView.setId(android.R.id.text1);

    RecyclerView.LayoutParams layoutParams =
        new RecyclerView.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, Converter.dp2px(itemView.getContext(), 56));

    itemView.setPadding(
        Converter.dp2px(itemView.getContext(), 16),
        0,
        Converter.dp2px(itemView.getContext(), 16),
        0);
    itemView.setGravity(Gravity.LEFT | Gravity.START | Gravity.CENTER);
    itemView.setBackgroundResource(R.drawable.touch_feedback_holo_light);
    itemView.addView(textView);
    itemView.setLayoutParams(layoutParams);
    if (this.layoutManager instanceof GridLayoutManager) {
      calculateGridItemSize(itemView);
    }

    return new ViewHolder(itemView);
  }
Beispiel #7
0
 private void setFirstViewVisibility(boolean visible) {
   if (firstView != null) {
     firstView.setVisibility(visible ? View.VISIBLE : View.GONE);
   }
   validationBar.setVisibility(visible ? View.GONE : View.VISIBLE);
   settingsContainer.setVisibility(visible ? View.GONE : View.VISIBLE);
 }
  /**
   * 设置加载界面
   *
   * @param rootView 你所要放置的加载动画的根布局
   */
  public static void setAutoLoadingView(ViewGroup rootView) {
    if (rootView != null) {
      AutoLoadingUtil.rootView = rootView;
      view =
          LayoutInflater.from(rootView.getContext()).inflate(R.layout.autoloading, rootView, false);
      saveView = new ArrayList<View>();

      ImageView image = (ImageView) view.findViewById(R.id.imageView_autoLoading);
      image.setBackgroundResource(R.anim.autoloading);
      AnimationDrawable anim = (AnimationDrawable) image.getBackground();
      anim.start();
      rootView.setOnHierarchyChangeListener(
          new OnHierarchyChangeListener() {

            @Override
            public void onChildViewRemoved(View parent, View child) {
              // TODO Auto-generated method stub
              saveView.add(child);
            }

            @Override
            public void onChildViewAdded(View parent, View child) {
              // TODO Auto-generated method stub

            }
          });
      rootView.removeAllViews();
      rootView.addView(view);
      view.bringToFront();
    }
  }
Beispiel #9
0
  public static void update(ViewGroup group, Actor actor) {
    TableLayout actorinfo_stats_table =
        (TableLayout) group.findViewById(R.id.actorinfo_stats_table);

    updateTraitsTable(
        actorinfo_stats_table,
        actor.getMoveCost(),
        actor.getAttackCost(),
        actor.getAttackChance(),
        actor.getDamagePotential(),
        actor.getCriticalSkill(),
        actor.getCriticalMultiplier(),
        actor.getBlockChance(),
        actor.getDamageResistance(),
        actor.isImmuneToCriticalHits());

    TextView actorinfo_currentconditions_title =
        (TextView) group.findViewById(R.id.actorinfo_currentconditions_title);
    ActorConditionList actorinfo_currentconditions =
        (ActorConditionList) group.findViewById(R.id.actorinfo_currentconditions);
    if (actor.conditions.isEmpty()) {
      actorinfo_currentconditions_title.setVisibility(View.GONE);
      actorinfo_currentconditions.setVisibility(View.GONE);
    } else {
      actorinfo_currentconditions_title.setVisibility(View.VISIBLE);
      actorinfo_currentconditions.setVisibility(View.VISIBLE);
      actorinfo_currentconditions.update(actor.conditions);
    }
  }
Beispiel #10
0
 /** 通讯模块,通知,聊天,球队没有数据的时候提示方法 */
 public void setEmptyView(ListView lv, View emptyView, int res) {
   ViewGroup parentView = (ViewGroup) lv.getParent();
   parentView.addView(emptyView);
   TextView warn = (TextView) emptyView.findViewById(R.id.empty_view_nearby_tv);
   warn.setText(res);
   lv.setEmptyView(emptyView);
 }
Beispiel #11
0
 public static void moveToBack(View currentView) {
   ViewGroup vg = ((ViewGroup) currentView.getParent());
   int index = vg.indexOfChild(currentView);
   for (int i = 0; i < index; i++) {
     vg.bringChildToFront(vg.getChildAt(0));
   }
 }
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
      Context context = ImageShowActivity.this;

      int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
      ImageLocation imageLocation = imageLocations.get(position);
      if (imageLocation.isLocal()) {
        ImageView imageView = new ImageView(context);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setImageURI(imageLocation.getUri());
        container.addView(imageView, 0);
        return imageView;
      } else {

        NetworkImageView imageView = new NetworkImageView(context);

        imageView.setPadding(padding, padding, padding, padding);
        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setImageUrl(
            API_IMAGE_GET + imageLocation.getId(), BaseApplication.baseApplication.mImageLoader);

        container.addView(imageView, 0);
        return imageView;
      }
    }
Beispiel #13
0
  public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache
    // License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
      callback.onCustomViewHidden();
      return;
    }

    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;

    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);

    // Hide the content view.
    this.setVisibility(View.GONE);

    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
  }
Beispiel #14
0
 private void draw() {
   try {
     mLayout.removeView(draw);
   } catch (Exception e) {
   }
   mLayout.addView(draw);
 }
Beispiel #15
0
    private void addInterestTypeView(
        InterestType interestType, LayoutInflater inflater, ViewGroup parent) {
      UserInterest[] interests = interestType != null ? interestType.getUserInterests() : null;
      if (interests == null || interests.length <= 0) {
        return;
      }

      InterestTypeProperty property = InterestUtils.getTypeProperty(interestType.getTypeId());
      View rootView = inflater.inflate(R.layout.user_info_favourite_interest, parent, false);
      ImageView typeIconView = (ImageView) rootView.findViewById(R.id.interest_icon);
      ViewGroup interestParent = (ViewGroup) rootView.findViewById(R.id.interest_content);

      typeIconView.setImageResource(property.getTypeIconResId());
      for (final UserInterest interest : interests) {
        if (interest == null) {
          continue;
        }

        TextView interestView =
            (TextView) inflater.inflate(R.layout.interest_name, interestParent, false);
        InterestUtils.setInterestColor(mContext, interestView, property);
        interestView.setText(interest.getInterestName());
        interestView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (interactListener != null) {
                  interactListener.onClick(v, new Interact(interest));
                }
              }
            });
        interestParent.addView(interestView);
      }
      parent.addView(rootView);
    }
  @Override
  public View createView(Context context, LayoutInflater inflater) {
    if (fragmentView == null) {
      fragmentView = super.createView(context, inflater);
      layoutManager = new LinearLayoutManager(getParentActivity());
      mNodeListView = (LoadMoreRecyclerView) fragmentView.findViewById(R.id.recycleview);
      mNodeListView.setLayoutManager(layoutManager);

      mEmptyContainer =
          (RelativeLayout) fragmentView.findViewById(R.id.swipe_refresh_empty_container);
      footerContainer =
          (FrameLayout) fragmentView.findViewById(R.id.swipe_refresh_footer_container);

      init();

      mNodeListView.setAdapter(mListAdapter);

      // 控制手动加载更多
      mListAdapter.setOnLoadMoreListener(this);
      // 控制自动加载更多
      mNodeListView.setOnLoadMoreListener(this);

      onRefresh();
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }

    return fragmentView;
  }
 @Override
 public PersonalData onCreateViewHolder(ViewGroup parent, int viewType) {
   View v =
       LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_layout, parent, false);
   res = parent.getContext().getResources();
   return new PersonalData(v);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {
      fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false);

      TLRPC.Chat currentChat = MessagesController.Instance.chats.get(chat_id);

      firstNameField = (EditText) fragmentView.findViewById(R.id.first_name_field);
      firstNameField.setOnEditorActionListener(
          new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
              if (i == EditorInfo.IME_ACTION_DONE) {
                doneButton.performClick();
                return true;
              }
              return false;
            }
          });
      firstNameField.setText(currentChat.title);
      firstNameField.setSelection(firstNameField.length());

      TextView headerLabel = (TextView) fragmentView.findViewById(R.id.settings_section_text);
      headerLabel.setText(getStringEntry(R.string.EnterGroupNameTitle));
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
 public void hide() {
   if (adstir != null) {
     ViewGroup topVIew = (ViewGroup) this.getActivity().findViewById(android.R.id.content);
     topVIew.removeView(adstir);
     adstir = null;
   }
 }
  private void init(LayoutInflater inflater) {
    new Thread(
            new Runnable() {

              @Override
              public void run() {
                playbackService = PlaybackService.get(getContext());
              }
            })
        .start();
    view = (ViewGroup) inflater.inflate(getLayoutId(), null);
    listView = getListView(view);
    emptyMessage = getMessageView(view);
    adapter = getAdapter(inflater.getContext());
    listView.setAdapter(adapter);
    playLastPlaylist = view.findViewById(R.id.lastPlayedPlaylist);
    createNewPlayList = view.findViewById(R.id.createNewPlaylist);
    animateListView(listView, adapter);
    initListeners();
    updatePlaylist();
    if (adapter.isEmpty()) {
      listView.setEmptyView(emptyMessage);
    }
    adapter.getCount();
  }
  @SmallTest
  public void testOnDown() {
    KeyEventButtonTouchListener keyEventButtonTouchListener =
        new KeyEventButtonTouchListener(1, 10);
    KeyEventHandler keyEventHandler = createKeyEventHandlerMock();
    keyEventButtonTouchListener.setKeyEventHandler(keyEventHandler);

    Context context = getInstrumentation().getContext();
    ViewGroup parent = new FrameLayout(context);
    parent.layout(0, 0, 100, 100);
    View view = new View(context);
    parent.addView(view);
    view.layout(0, 0, 50, 50);
    Key key = KeyEventButtonTouchListener.createKey(view, 1, 10);
    KeyEventContext keyEventContext =
        new KeyEventContext(key, 0, 0, 0, 0, 100, 100, Collections.<MetaState>emptySet());
    keyEventButtonTouchListener.keyEventContext = keyEventContext;

    // For onDown, first, cancelDelayedKeyEvent should be invoked to cancel old
    // event, then maybeStartDelayedKeyEvent and sendPress should follow.
    keyEventHandler.cancelDelayedKeyEvent(keyEventContext);
    keyEventHandler.maybeStartDelayedKeyEvent(isA(KeyEventContext.class));
    keyEventHandler.sendPress(10);
    replayAll();

    keyEventButtonTouchListener.onDown(view, 0, 0);

    verifyAll();
    assertNotSame(keyEventContext, keyEventButtonTouchListener.keyEventContext);
    assertTrue(view.isPressed());
  }
    public Object instantiateItem(ViewGroup container, int position) {
      if (girds[position] == null) {
        int pageSize = PAGE_SIZE;
        int curSize = pageSize * position;
        int listSize = platforms == null ? 0 : platforms.length;
        if (curSize + pageSize > listSize) {
          pageSize = listSize - curSize;
        }
        Platform[] gridPlatforms = new Platform[pageSize];
        for (int i = 0; i < pageSize; i++) {
          gridPlatforms[i] = platforms[curSize + i];
        }

        if (position == 0) {
          lines = gridPlatforms.length / 3;
          if (gridPlatforms.length % 3 > 0) {
            lines++;
          }
        }
        girds[position] = new GridView(container.getContext(), callback);
        girds[position].setData(lines, gridPlatforms);
      }
      container.addView(girds[position]);
      return girds[position];
    }
  @Override
  public void onHideCustomView() {
    // This method should be manually called on video end in all cases because it's not always
    // called automatically.
    // This method must be manually called on back key press (from this class' onBackPressed()
    // method).

    if (isVideoFullscreen) {
      showActionBar();
      activityNonVideoView.setVideoPlaying(false);
      // Hide the video view, remove it, and show the non-video view
      ViewGroup activityVideoView =
          ((ViewGroup) MainActivity.webLayout.findViewById(R.id.webviewholder));
      activityVideoView.removeView(videoViewContainer);
      activityNonVideoView.setVisibility(View.VISIBLE);

      // Call back (only in API level <19, because in API level 19+ with chromium webview it
      // crashes)
      if (videoViewCallback != null
          && !videoViewCallback.getClass().getName().contains(".chromium.")) {
        videoViewCallback.onCustomViewHidden();
      }

      // Reset video related variables
      isVideoFullscreen = false;
      videoViewContainer = null;
      videoViewCallback = null;

      // Notify full-screen change
      if (toggledFullscreenCallback != null) {
        toggledFullscreenCallback.toggledFullscreen(false);
      }
    }
  }
Beispiel #24
0
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    Log.i("TAG", "onActivityCreated");
    super.onActivityCreated(savedInstanceState);

    btn_steps = new Button[4];
    btn_steps[0] = (Button) getActivity().findViewById(R.id.step0);
    btn_steps[1] = (Button) getActivity().findViewById(R.id.step1);
    btn_steps[2] = (Button) getActivity().findViewById(R.id.step2);
    btn_steps[3] = (Button) getActivity().findViewById(R.id.step3);

    mMapManeger = new MapManager();

    mapLayout = new MapLayout(getActivity());
    mMapView = mapLayout.getMapView();
    mMapView.setDaumMapApiKey("c7e2c768ceb283cba77acced06e1203b");
    mMapView.setMapViewEventListener(this);
    mMapView.setPOIItemEventListener(this);
    mMapView.setMapType(MapView.MapType.Standard);
    ViewGroup mapViewContainer = (ViewGroup) getActivity().findViewById(R.id.map_view);
    mapViewContainer.addView(mapLayout);

    SharedPreferences sharedPreferences =
        getActivity().getSharedPreferences("GnBang", getContext().MODE_PRIVATE);
    CurrentZoomLevel = sharedPreferences.getInt("Zoomlevel", DEFAULT_ZOOM_LEVEL);
    CurrentLat = sharedPreferences.getFloat("Lat", (float) DEFAULT_LAT);
    CurrentLon = sharedPreferences.getFloat("Lon", (float) DEFAULT_LON);
    CurrentSelect = sharedPreferences.getInt("Select", DEFAULT_SELECT);
    mMapView.setMapCenterPointAndZoomLevel(
        MapPoint.mapPointWithGeoCoord(CurrentLat, CurrentLon), CurrentZoomLevel, true);

    mMapView = mMapManeger.CreateMarker(mMapView, CurrentZoomLevel);
    btn_steps = mMapManeger.SelectCity(CurrentSelect, btn_steps);
  }
 @Test
 public void testLayoutAnimation() {
   assertThat(root.getLayoutAnimation(), nullValue());
   LayoutAnimationController layoutAnim = new LayoutAnimationController(context, null);
   root.setLayoutAnimation(layoutAnim);
   assertThat(root.getLayoutAnimation(), sameInstance(layoutAnim));
 }
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
      mCurTransaction = mFragmentManager.beginTransaction();
    }

    final long itemId = getItemId(position);

    // Do we already have this fragment?
    String name = makeFragmentName(container.getId(), itemId);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
      if (DEBUG) Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
      mCurTransaction.attach(fragment);
    } else {
      fragment = getItem(position);
      if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
      mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
      // FragmentCompat.setMenuVisibility(fragment, false);
      // FragmentCompat.setUserVisibleHint(fragment, false);
      setMenuVisibility(fragment, false);
      setUserVisibleHint(fragment, false);
    }

    return fragment;
  }
    @Override
    protected void onCreate() {
      // inflate layout
      LayoutInflater inflater =
          (LayoutInflater)
              this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      ViewGroup root = (ViewGroup) inflater.inflate(R.layout.popup_grid_layout, null);

      // setup button events
      for (int i = 0, icount = root.getChildCount(); i < icount; i++) {
        View v = root.getChildAt(i);

        if (v instanceof TableRow) {
          TableRow row = (TableRow) v;

          for (int j = 0, jcount = row.getChildCount(); j < jcount; j++) {
            View item = row.getChildAt(j);
            if (item instanceof Button) {
              Button b = (Button) item;
              b.setOnClickListener(this);
            }
          }
        }
      }

      // set the inflated view as what we want to display
      this.setContentView(root);
    }
 @Override
 public void onHideCustomView() {
   // This method must be manually (internally) called on video end in the case of VideoView
   // (typically API level <11)
   // This method must be manually (internally) called on video end in the case of
   // HTML5VideoFullScreen (typically API level 11+) because it's not always called automatically
   // This method must be manually (internally) called on back key press (from this class'
   // onBackPressed() method)
   if (isVideoFullscreen()) {
     // Hide the video view, remove it, and show the non-video view
     activityVideoView.setVisibility(View.GONE); // 播放视频的
     activityVideoView.removeView(videoViewContainer);
     activityNonVideoView.setVisibility(View.VISIBLE);
     ((Activity) activityNonVideoView.getContext())
         .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // 强制当前页面在手机中竖屏
     // Call back
     if (videoViewCallback != null) videoViewCallback.onCustomViewHidden();
     // Reset video related variables
     isVideoFullscreen = false;
     videoViewContainer = null;
     videoViewCallback = null;
     // Notify full-screen change
     if (toggledFullscreenCallback != null) {
       toggledFullscreenCallback.toggledFullscreen(false);
     }
   }
 }
Beispiel #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_search);

    _imgDownloader = new ImageDownloader(this);
    _imgDownloader.setImageFilePrefix(AppConfig.IMAGE_CACHE_FILE_PREFIX);

    // 标题
    TextView titleTextView = (TextView) this.findViewById(R.id.textViewTitle);
    titleTextView.setText("搜索");

    _loadingLayer = (ViewGroup) findViewById(R.id.loading_layer);
    _loadingImageView = (ImageView) _loadingLayer.findViewById(R.id.imageViewLoading);
    _loadingTextView = (TextView) _loadingLayer.findViewById(R.id.textViewLoading);

    _inputBoxTextView = (TextView) this.findViewById(R.id.textViewInputBox);

    _listView = (ListView) this.findViewById(R.id.listView);
    _listView.setDividerHeight(0);
    _listView.setSelector(R.drawable.bg_download_list_selected);
    _listView.setVerticalScrollBarEnabled(true);
    _listView.setOnItemClickListener(this);

    _adapter = new MyAdapter(this);
    _listView.setAdapter(_adapter);

    buildKeyboard();

    //		HomeDataLoader.loadAllAppList(this, _allAppList);
  }
  private void measureScrapChild(
      RecyclerView.Recycler recycler,
      int position,
      int widthSpec,
      int heightSpec,
      int[] measuredDimension) {
    try {
      View view = recycler.getViewForPosition(0); // fix 动态添加时报IndexOutOfBoundsException

      if (view != null) {
        RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();

        int childWidthSpec =
            ViewGroup.getChildMeasureSpec(widthSpec, getPaddingLeft() + getPaddingRight(), p.width);

        int childHeightSpec =
            ViewGroup.getChildMeasureSpec(
                heightSpec, getPaddingTop() + getPaddingBottom(), p.height);

        view.measure(childWidthSpec, childHeightSpec);
        measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
        measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
        recycler.recycleView(view);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
    }
  }