android.view.View#hashCode ( )源码实例Demo

下面列出了android.view.View#hashCode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: InteractiveChart   文件: XRadioGroup.java

/**
 * 设置监听
 */
private void setListener(View child) {
  if (child instanceof RadioButton) {
    int id = child.getId();
    // generates an id if it's missing
    if (id == View.NO_ID) {
      id = child.hashCode();
      child.setId(id);
    }
    ((RadioButton) child).setOnCheckedChangeListener(
        mChildOnCheckedChangeListener);
  } else if (child instanceof ViewGroup) {
    ViewGroup view = (ViewGroup) child;
    for (int i = 0; i < view.getChildCount(); i++) {
      setListener(view.getChildAt(i));
    }
  }
}
 

/**
 * 设置监听
 *
 * @param child
 */
private void setListener(View child) {


    if (child instanceof NestedRadioLayout) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = child.hashCode();
            child.setId(id);
        }
        ((NestedRadioLayout) child).setOnCheckedChangeWidgetListener(
                mChildOnCheckedChangeListener);
    } else if (child instanceof ViewGroup) {
        ViewGroup view = (ViewGroup) child;
        for (int i = 0; i < view.getChildCount(); i++) {
            setListener(view.getChildAt(i));
        }
    }
}
 
源代码3 项目: Fishing   文件: RadioGroup.java

/**
 * {@inheritDoc}
 */
public void onChildViewAdded(View parent, View child) {
    if (parent == RadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = child.hashCode();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(
                mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
源代码4 项目: ToggleButtons   文件: ToggleGroup.java

/**
 * {@inheritDoc}
 */
public void onChildViewAdded(View parent, View child) {
    if (parent == ToggleGroup.this && child instanceof CompoundButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
         if (Build.VERSION.SDK_INT < 17)
          id = child.hashCode();
         else
             id = View.generateViewId();
            child.setId(id);
        }
        ((CompoundButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
源代码5 项目: Carbon   文件: RadioGroup.java

/**
 * {@inheritDoc}
 */
public void onChildViewAdded(View parent, View child) {
    if (parent == RadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = child.hashCode();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeWidgetListener(
                mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
源代码6 项目: ToggleButtons   文件: ToggleGroup.java

/**
 * {@inheritDoc}
 */
public void onChildViewAdded(View parent, View child) {
    if (parent == ToggleGroup.this && child instanceof CompoundButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
         if (Build.VERSION.SDK_INT < 17)
          id = child.hashCode();
         else
             id = View.generateViewId();
            child.setId(id);
        }
        ((CompoundButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 

/**
 * Generate the modified url.
 *
 * @param baseUrl  A url to be used as a base to the responsive transformation. This url can
 *                 contain any configurations and transformations. The generated responsive
 *                 transformation will be chained as the last transformation in the url.
 *                 Important: When generating using a base url, it's preferable to not include
 *                 any cropping/scaling in the original transformations.
 * @param view     The view to adapt the resource dimensions to.
 * @param callback Callback to called when the modified Url is ready.
 */
public void generate(final Url baseUrl, final View view, final Callback callback) {
    assertViewValidForResponsive(view);
    final int key = view.hashCode();

    int width = view.getWidth();
    int height = view.getHeight();

    if (conditionsAreMet(width, height)) {
        // The required dimensions are already known, build url:
        callback.onUrlReady(buildUrl(view, baseUrl));
        viewsInProgress.remove(key);
    } else {
        // save the link between the requested url and the specific view, so that
        // if in the meantime the view is assigned a new item (e.g. recycling views in a list)
        // it won't override the correct data.
        viewsInProgress.put(key, baseUrl);
        view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                view.getViewTreeObserver().removeOnPreDrawListener(this);
                if (baseUrl.equals(viewsInProgress.get(key))) {
                    callback.onUrlReady(buildUrl(view, baseUrl));
                    viewsInProgress.remove(key);
                }

                return true;
            }
        });
    }
}
 
源代码8 项目: sa-sdk-android   文件: WindowHelper.java

public int compare(View lhs, View rhs) {
    int lhsHashCode = lhs.hashCode();
    int rhsHashCode = rhs.hashCode();
    int currentHashCode = AppStateManager.getInstance().getCurrentRootWindowsHashCode();
    if (lhsHashCode == currentHashCode) {
        return -1;
    } else {
        return rhsHashCode == currentHashCode ? 1 : rhs.getWidth() * rhs.getHeight() - lhs.getWidth() * lhs.getHeight();
    }
}
 

private void cancelExistingAnimation(final View convertView) {
    int hashCode = convertView.hashCode();
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
        mAnimators.remove(hashCode);
    }
}
 
源代码10 项目: MiBandDecompiled   文件: ViewAware.java

public int getId()
{
    View view = (View)viewRef.get();
    if (view == null)
    {
        return super.hashCode();
    } else
    {
        return view.hashCode();
    }
}
 
源代码11 项目: ListViewAnimations   文件: ViewAnimator.java

/**
 * Cancels any existing animations for given View.
 */
void cancelExistingAnimation(@NonNull final View view) {
    int hashCode = view.hashCode();
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
        mAnimators.remove(hashCode);
    }
}
 
源代码12 项目: GankGirl   文件: ViewAnimator.java

/**
 * Cancels any existing animations for given View.
 */
public void cancelExistingAnimation(@NonNull final View view) {
    int hashCode = view.hashCode();
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
        mAnimators.remove(hashCode);
    }
}
 
源代码13 项目: UltimateAndroid   文件: AnimationAdapter.java

private void cancelExistingAnimation(final View convertView) {
    int hashCode = convertView.hashCode();
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
        mAnimators.remove(hashCode);
    }
}
 
源代码14 项目: AndroidUtilCode   文件: BaseItem.java

private int getViewTypeByView(@NonNull View view) {
    return view.hashCode() + getClass().hashCode();
}
 
源代码15 项目: AndroidUtilCode   文件: BaseItem.java

private int getViewTypeByView(@NonNull View view) {
    return view.hashCode() + getClass().hashCode();
}
 

@Override
public int getId() {
	View view = viewRef.get();
	return view == null ? super.hashCode() : view.hashCode();
}
 
源代码17 项目: CountDownTask   文件: ViewAware.java

public int getId() {
    View view = mViewRef.get();
    return view == null ? super.hashCode() : view.hashCode();
}
 
源代码18 项目: Dali   文件: ImageReference.java

public ImageReference(View view) {
    this.view = view;
    this.contentId = "view_" + view.hashCode();
    this.type = SourceType.VIEW;
}
 

@Override
public int getId() {
	View view = viewRef.get();
	return view == null ? super.hashCode() : view.hashCode();
}
 
源代码20 项目: Klyph   文件: KlyphAnimationAdapter.java

@Override
public final View getView(int position, View convertView, ViewGroup parent)
{
	boolean  alreadyStarted = false;

	if (!mHasParentAnimationAdapter)
	{
		if (getListView() == null)
		{
			throw new IllegalStateException("Call setListView() on this AnimationAdapter before setAdapter()!");
		}

		if (convertView != null)
		{
			int hashCode = convertView.hashCode();
			AnimationInfo animationInfo = mAnimators.get(hashCode);
			if (animationInfo != null)
			{
				if (animationInfo.position != position)
				{
					animationInfo.animator.end();
					mAnimators.remove(hashCode);
				}
				else
				{
					alreadyStarted = true;
				}
			}
		}
	}

	View itemView = super.getView(position, convertView, parent);
	
	if (nextDeactivated <= 0)
	{
		if (!mHasParentAnimationAdapter && !alreadyStarted && animationsEnabled)
		{
			animateViewIfNecessary(position, itemView, parent);
		}
	}
	else
	{
		nextDeactivated--;
	}
	
	return itemView;
}
 
 方法所在类
 同类方法