Java Code Examples for android.view.View#equals()

The following examples show how to use android.view.View#equals() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
Example 2
Source Project: LiuAGeAndroid   File: FriendListPage.java    License: MIT License 6 votes vote down vote up
public void onClick(View v) {
	if (v.equals(tvCancel)) {
		finish();
	} else {
		ArrayList<String> selected = new ArrayList<String>();
		for (int i = 0, size = adapter.getCount(); i < size; i++) {
			if (adapter.getItem(i).checked) {
				selected.add(adapter.getItem(i).atName);
			}
		}

		HashMap<String, Object> res = new HashMap<String, Object>();
		res.put("selected", selected);
		res.put("platform", platform);
		setResult(res);
		finish();
	}
}
 
Example 3
@Override
public void onMissedClick(View v) {
  super.onMissedClick(v);
  Log.d("AddCustomFerm", "Checking views for: " + v);

  AlertDialog alert;
  if (v.equals(descriptionView)) {
    Log.d("AddCustomFerm", "Displaying descriptionView edit alert");
    alert = alertBuilder.editTextMultilineStringAlert(descriptionViewText, descriptionViewTitle).create();
  }
  else {
    Log.d("AddCustomFerm", "View not found: " + v);
    return;
  }

  // Force keyboard open and show popup
  alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  alert.show();
}
 
Example 4
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup)parent).getChildAt(position));
        }
    };
}
 
Example 5
Source Project: MyHearts   File: EditPage.java    License: Apache License 2.0 6 votes vote down vote up
public void onClick(View v) {
	if (v.equals(tvCancel)) {
		cancelAndFinish();
	} else if (v.equals(tvShare)) {
		sp.setText(etContent.getText().toString().trim());
		shareAndFinish();
	} else if (v.equals(aivThumb)) {
		showThumb(thumb);
	} else if (v.equals(xvRemove)) {
		maxBodyHeight = 0;
		rlThumb.setVisibility(View.GONE);
		llPage.measure(0, 0);
		onTextChanged(etContent.getText(), 0, 0, 0);
		removeThumb();
	} else if (v.equals(tvAt)) {
		showFriendList();
	}
}
 
Example 6
@Override
public boolean onTouch(View v, MotionEvent event) {
	super.onTouchEvent(event);
	boolean consumed = false;
	// use getTabHost().getCurrentTabView to decide if the current tab is
	// touched again
	if (event.getAction() == MotionEvent.ACTION_DOWN
			&& v.equals(mTabHost.getCurrentTabView())) {
		// use getTabHost().getCurrentView() to get a handle to the view
		// which is displayed in the tab - and to get this views context
		Fragment currentFragment = getCurrentFragment();
		if (currentFragment != null
				&& currentFragment instanceof OnTabReselectListener) {
			OnTabReselectListener listener = (OnTabReselectListener) currentFragment;
			listener.onTabReselect();
			consumed = true;
		}
	}
	return consumed;
}
 
Example 7
Source Project: astrobee_android   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if(v.equals(mBtnBind)) {
        doBindService();
    } else if(v.equals(mBtnUnbid)) {
        doUnbindService();
    }
}
 
Example 8
@Override
public void onClick(View view) {
    if (view.equals(submit)) {
        doSubmit(getPhoneNumber());
    }
    if (view.equals(phoneField)) {
        phoneField.setEnabled(true);
        phoneField.requestFocus();
        if (TextUtils.isEmpty(getPhoneNumber())) {
            showHint();
        }
    }
}
 
Example 9
Source Project: Cotable   File: MySwipeRefreshLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void ensureTarget() {
    // Don't bother getting the parent height if the parent hasn't been laid
    // out yet.
    if (mTarget == null) {
        for (int i = 0; i < getChildCount(); i++) {
            View child = getChildAt(i);
            if (!child.equals(mCircleView)) {
                mTarget = child;
                break;
            }
        }
    }
}
 
Example 10
@Override
public void onClick(final View v) {
    if (v.equals(mImageView)) {
        Uri uri = Uri.parse("market://details?id=com.google.android.wearable.app");
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }
}
 
Example 11
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
    return view.equals(object);
}
 
Example 12
/**
 * Waits for a given view.
 * 
 * @param view the view to wait for
 * @param timeout the amount of time in milliseconds to wait
 * @param scroll {@code true} if scrolling should be performed
 * @param checkIsShown {@code true} if view.isShown() should be used
 * @return {@code true} if view is shown and {@code false} if it is not shown before the timeout
 */

public View waitForView(View view, int timeout, boolean scroll, boolean checkIsShown){
	long endTime = SystemClock.uptimeMillis() + timeout;
	int retry = 0;
	
	if(view == null)
		return null;

	while (SystemClock.uptimeMillis() < endTime) {

		final boolean foundAnyMatchingView = searcher.searchFor(view);

		if(checkIsShown && foundAnyMatchingView && !view.isShown()){
			sleeper.sleepMini();
			retry++;
		
			View identicalView = viewFetcher.getIdenticalView(view);
			if(identicalView != null && !view.equals(identicalView)){
				view = identicalView;
			}

			if(retry > 5){
				return view;
			}
			continue;
		}

		if (foundAnyMatchingView){
			return view;
		}

		if(scroll) {
			scroller.scrollDown();
		}

		sleeper.sleep();

	}
	return view;
}
 
Example 13
public void addSimpleSymbol(SimpleSymbolView symbolView) {
    if (symbolView == null) {
        Log.e(TAG ,"symbolView 为 null");
        return;
    }

    if (selectedStruct == null) {
        Log.e(TAG ,"select struct为null,请检查代码,查明原因");
        return;
    }

    String sLatexViewName = selectedStruct.getSelectedLatexView();
    String sClickViewName = selectedStruct.getSelectedClickView();
    int sIndex = selectedStruct.getIndex();
    boolean isRootSelected = selectedStruct.isRootSelected();

    if (sLatexViewName != null && !sLatexViewName.isEmpty()
            && sClickViewName != null && !sClickViewName.isEmpty()) {
        if (formulaViews.containsKey(sLatexViewName)) {
            FormulaView formulaView = formulaViews.get(sLatexViewName);
            //在没有光标情况下
            if (sIndex == -1) {
                //在根布局被选中情况下,则查找其父布局,将新公式添加后该公式后面
                if (isRootSelected) {
                    String pLatexName = formulaView.getParentFormulaViewName();
                    String pClickName = formulaView.getParentClickViewName();
                    if (pLatexName == null) {
                        if(getRootView()!=null){
                            for (int i = 0; i < getRootView().getChildCount(); ++i) {
                                View view = getRootView().getChildAt(i);
                                if (view.equals(formulaView)) {
                                    getRootView().addView(symbolView, i + 1);
                                    addLine(pLatexName, pClickName, i + 2, formulaView.getLevel());
                                    break;
                                }
                            }
                        }

                    } else {
                        FormulaView pFormulaView = formulaViews.get(pLatexName);
                        if (pFormulaView != null) {
                            int index = pFormulaView.getChildViewIndex(pClickName, formulaView.getLatexView());
                            pFormulaView.addChildView(pClickName, index + 1, symbolView);
                            addLine(pLatexName, pClickName, index + 2, pFormulaView.getLevel());
                        } else {
                            Log.e(TAG ,"有选中数据,在整体布局中没有,请查找代码问题");
                        }
                    }
                } else {
                    //在某元素被选中状态时,插入符号类型,则直接插入
                    formulaView.addChildView(sClickViewName, -1, symbolView);
                    if (isSpecial(formulaView, sClickViewName)) {
                        addLine(sLatexViewName, sClickViewName, -1, formulaView.getLevel());
                    } else {
                        addLine(sLatexViewName, sClickViewName, -1, formulaView.getLevel() + 1);
                    }
                }
            } else {
                //存在光标
                formulaView.addChildView(sClickViewName, sIndex, symbolView);
                selectedStruct.setIndex(sIndex + 1);
            }
        } else {
            Log.e(TAG ,"没有找到对应公式:" + sLatexViewName);
        }
    } else {
        //在根节点的光标处,添加公式
        if (sIndex != -1) {
            //添加符号后,光标后移一位
            ViewGroup viewGroup = getRootView();
            if (viewGroup != null) {
                viewGroup.addView(symbolView, sIndex);
            }
            changeDoneViewState(true);
            selectedStruct.setIndex(sIndex + 1);
        } else {
            Log.e(TAG ,"在没有选中元素的情况下,必然会有光标,请检查代码");
        }
    }
    moveCoordinate();
}
 
Example 14
Source Project: Emoji   File: EmojiPagerAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override public boolean isViewFromObject(final View view, final Object object) {
  return view.equals(object);
}
 
Example 15
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object)
{
    return view.equals(object);
}
 
Example 16
@Override
public boolean isViewFromObject(View view, Object object) {
    return view.equals(object);
}
 
Example 17
@Override
public boolean isViewFromObject(final View arg0, final Object arg1) {
    return arg0.equals(arg1);
}
 
Example 18
Source Project: BaldPhone   File: BaldViewAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
    return view.equals(object);
}
 
Example 19
Source Project: ViewInspector   File: ViewUtil.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean isViewRoot(View view) {
  return view.equals(ViewInspector.viewRoot);
}
 
Example 20
@Override
public boolean isViewFromObject(View view, Object object)
{
	return view.equals(object);
}