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

The following examples show how to use android.view.View#equals() . 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 check out the related API usage on the sidebar.
Example 1
Source File: BasicUITests.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 6 votes vote down vote up
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 File: MainActivity.java    From FragmentMixViewPager with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: EditPage.java    From MyHearts with 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 4
Source File: DayNightModeTest.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
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 File: AddCustomFermentableActivity.java    From biermacht with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: FriendListPage.java    From LiuAGeAndroid with 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 7
Source File: MySwipeRefreshLayout.java    From Cotable with 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 8
Source File: PhoneNumberActivity.java    From identity-samples with Apache License 2.0 5 votes vote down vote up
@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 File: WearSettingFragment.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@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 10
Source File: MainActivity.java    From astrobee_android with 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 11
Source File: ViewAssembleManager.java    From AndroidMathKeyboard with Apache License 2.0 4 votes vote down vote up
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 12
Source File: EmojiPagerAdapter.java    From Emoji with 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 13
Source File: Waiter.java    From AndroidRipper with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * 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 14
Source File: IntroActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object)
{
    return view.equals(object);
}
 
Example 15
Source File: ArchiveHintCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isViewFromObject(View view, Object object) {
    return view.equals(object);
}
 
Example 16
Source File: BooksAdapter.java    From document-viewer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isViewFromObject(final View arg0, final Object arg1) {
    return arg0.equals(arg1);
}
 
Example 17
Source File: BaldViewAdapter.java    From BaldPhone with 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 18
Source File: ViewUtil.java    From ViewInspector with Apache License 2.0 4 votes vote down vote up
public static boolean isViewRoot(View view) {
  return view.equals(ViewInspector.viewRoot);
}
 
Example 19
Source File: ImageViewerActivity.java    From android-project-wo2b with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isViewFromObject(View view, Object object)
{
	return view.equals(object);
}
 
Example 20
Source File: ItemAdapter.java    From Camera-Roll-Android-App with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
    return view.equals(object);
}