List of usage examples for android.view View getParent
public final ViewParent getParent()
From source file:com.transitionseverywhere.Transition.java
static void addViewValues(TransitionValuesMaps transitionValuesMaps, View view, TransitionValues transitionValues) { transitionValuesMaps.viewValues.put(view, transitionValues); int id = view.getId(); if (id >= 0) { if (transitionValuesMaps.idValues.indexOfKey(id) >= 0) { // Duplicate IDs cannot match by ID. transitionValuesMaps.idValues.put(id, null); } else {// w ww. j av a 2 s . c o m transitionValuesMaps.idValues.put(id, view); } } String name = ViewUtils.getTransitionName(view); if (name != null) { if (transitionValuesMaps.nameValues.containsKey(name)) { // Duplicate transitionNames: cannot match by transitionName. transitionValuesMaps.nameValues.put(name, null); } else { transitionValuesMaps.nameValues.put(name, view); } } if (view.getParent() instanceof ListView) { ListView listview = (ListView) view.getParent(); if (listview.getAdapter().hasStableIds()) { int position = listview.getPositionForView(view); long itemId = listview.getItemIdAtPosition(position); if (transitionValuesMaps.itemIdValues.indexOfKey(itemId) >= 0) { // Duplicate item IDs: cannot match by item ID. View alreadyMatched = transitionValuesMaps.itemIdValues.get(itemId); if (alreadyMatched != null) { ViewUtils.setHasTransientState(alreadyMatched, false); transitionValuesMaps.itemIdValues.put(itemId, null); } } else { ViewUtils.setHasTransientState(view, true); transitionValuesMaps.itemIdValues.put(itemId, view); } } } }
From source file:cn.ieclipse.af.view.StaggeredGridView.java
/** * Obtain a populated view from the adapter. If optScrap is non-null and is not * reused it will be placed in the recycle bin. * * @param position position to get view for * @param optScrap Optional scrap view; will be reused if possible * @return A new view, a recycled view from mRecycler, or optScrap *//*from www . j a v a 2 s . c om*/ final View obtainView(int position, View optScrap) { View view = mRecycler.getTransientStateView(position); if (view != null) { return view; } // Reuse optScrap if it's of the right type (and not null) final int optType = optScrap != null ? ((LayoutParams) optScrap.getLayoutParams()).viewType : -1; final int positionViewType = mAdapter.getItemViewType(position); final View scrap = optType == positionViewType ? optScrap : mRecycler.getScrapView(positionViewType); view = mAdapter.getView(position, scrap, this); if (view != scrap && scrap != null) { // The adapter didn't use it; put it back. mRecycler.addScrap(scrap); } ViewGroup.LayoutParams lp = view.getLayoutParams(); if (view.getParent() != this) { if (lp == null) { lp = generateDefaultLayoutParams(); } else if (!checkLayoutParams(lp)) { lp = generateLayoutParams(lp); } } final LayoutParams sglp = (LayoutParams) lp; sglp.position = position; sglp.viewType = positionViewType; return view; }
From source file:com.wjs.myapplication.view.VerticalPager.VerticalViewPager.java
@Nullable ItemInfo infoForAnyChild(View child) { ViewParent parent;/*w w w.j a v a2 s . c om*/ while ((parent = child.getParent()) != this) { if (parent == null || !(parent instanceof View)) { return null; } /* end of if */ child = (View) parent; } /* end of while */ return infoForChild(child); }
From source file:administrator.example.com.myscrollview.VerticalViewPager.java
ItemInfo infoForAnyChild(View child) { ViewParent parent;/*from w ww . j ava2s . c o m*/ while ((parent = child.getParent()) != this) { if (parent == null || !(parent instanceof View)) { return null; } /* end of if */ child = (View) parent; } /* end of while */ return infoForChild(child); }
From source file:com.tencent.tws.assistant.support.v4.view.ViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null;/* ww w.j a v a2 s . c o m*/ boolean handled = false; // tws-start::modify this view must be descendant 20141230 if (currentFocused != null) { ViewParent mParent = currentFocused.getParent(); if (mParent == null) { return handled; } } // tws-end::modify this view must be descendant 20141230 View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public void highlightbutton(View arg0) { try {// w ww .j a va2s . co m RelativeLayout parent = ((RelativeLayout) arg0.getParent()); for (int child = 0; child < parent.getChildCount(); child++) { parent.getChildAt(child).setBackgroundColor(Color.TRANSPARENT); } } catch (Throwable e) { LinearLayout parent = ((LinearLayout) arg0.getParent()); for (int child = 0; child < parent.getChildCount(); child++) { parent.getChildAt(child).setBackgroundColor(Color.TRANSPARENT); } } arg0.setBackgroundColor(Color.parseColor("#501BADA9")); }
From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java
@SuppressWarnings({ "deprecation", "ResourceAsColor" }) @Override// w w w. jav a 2 s . c o m public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { View tutorialLayout = mActivity.findViewById(R.id.tutorial_layout); ArgbEvaluator evaluator = new ArgbEvaluator(); Object background = position < getCount() - 1 ? evaluator.evaluate(positionOffset, mActivity.getResources().getColor(colors[position]), mActivity.getResources().getColor(colors[position + 1])) : mActivity.getResources().getColor(colors[position]); tutorialLayout.setBackgroundColor((int) background); MainActivity.setNavBarColor(mActivity.getWindow(), mActivity.getTheme(), (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background)); MainActivity.setStatusBarColor(mActivity.getWindow(), mActivity.getTheme(), (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background)); View bigFab = tutorialLayout.findViewById(R.id.big_fab); View handImage = tutorialLayout.findViewById(R.id.musicid_demo_hand_image); View soundImage = tutorialLayout.findViewById(R.id.musicid_demo_sound_image); View redKey = tutorialLayout.findViewById(R.id.intro_4_red_key); View yellowKey = tutorialLayout.findViewById(R.id.intro_4_yellow_key); View gearA = tutorialLayout.findViewById(R.id.redGear); View gearB = tutorialLayout.findViewById(R.id.blueGear); BubblePopImageView tableImageView = (BubblePopImageView) tutorialLayout.findViewById(R.id.table); position = rightToLeft ? getCount() - 1 - position : position; if (rightToLeft && positionOffset > 0.0) { position -= 1; positionOffset = 1f - positionOffset; positionOffsetPixels = (int) (positionOffset * mPager.getWidth()); } switch (position) { case 0: if (tableImageView != null) { tableImageView.setProgress(positionOffset); tableImageView.setTranslationX((rightToLeft ? -1f : 1f) * (1f - positionOffset) * (tableImageView.getMeasuredWidth() / 3f)); } break; case 1: if (tableImageView != null) { tableImageView.setProgress(1f); tableImageView.setTranslationX((rightToLeft ? 0.15f : -0.4f) * positionOffsetPixels); } if (bigFab != null) { bigFab.setTranslationX( (rightToLeft ? -1f : 1f) * (1f - positionOffset) * (bigFab.getMeasuredWidth() / 3f)); if (mCurrentPage == 1 ^ rightToLeft) bigFab.setRotation(positionOffset * 360f); else bigFab.setRotation((1f - positionOffset) * 360f); } break; case 2: if (bigFab != null) ((View) bigFab.getParent()).setTranslationX((!rightToLeft ? -0.4f : 0.4f) * positionOffsetPixels); if (soundImage != null && handImage != null) { soundImage.setTranslationX(300f - 300f * positionOffset); handImage.setTranslationX(-400f + 400f * positionOffset); } break; case 3: if (redKey != null && yellowKey != null) { if (redKey.getMeasuredHeight() < redKey.getResources().getDimensionPixelSize(R.dimen.dp) * 15) { redKey.setVisibility(View.INVISIBLE); yellowKey.setVisibility(View.INVISIBLE); break; } else { redKey.setVisibility(View.VISIBLE); yellowKey.setVisibility(View.VISIBLE); } redKey.setTranslationY(330f * (1 - positionOffset)); yellowKey.setTranslationY(290f * Math.min(1.3f * (1 - positionOffset), 1.0f)); yellowKey.setTranslationX(105f * Math.min(1.3f * (1 - positionOffset), 1.0f)); } if (3 == count - 2 && gearA != null && gearB != null) { gearA.setRotation(-180f * positionOffset); gearB.setRotation(180f * positionOffset); } break; case 4: if (gearA != null && gearB != null) { gearA.setRotation(-180f * positionOffset); gearB.setRotation(180f * positionOffset); } break; } }
From source file:com.android.calendar.EventInfoFragment.java
@Override public void onClick(View view) { // This must be a click on one of the "remove reminder" buttons LinearLayout reminderItem = (LinearLayout) view.getParent(); LinearLayout parent = (LinearLayout) reminderItem.getParent(); parent.removeView(reminderItem);/*from w ww.j a v a 2s .co m*/ mReminderViews.remove(reminderItem); mUserModifiedReminders = true; EventViewUtils.updateAddReminderButton(mView, mReminderViews, mMaxReminders); }
From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java
private void removeCling(int id) { setPagingEnabled(true);//from w w w.java 2s . c o m clingActive = false; final View cling = findViewById(id); if (cling != null) { final ViewGroup parent = (ViewGroup) cling.getParent(); parent.post(new Runnable() { @Override public void run() { parent.removeView(cling); } }); } }
From source file:com.app.blockydemo.ui.adapter.BrickAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (draggedBrick != null && dragTargetPosition == position) { return insertionView; }//from w w w . ja va 2 s . c o m listItemCount = position + 1; Object item = getItem(position); if (item instanceof ScriptBrick && (!initInsertedBrick || position != positionOfInsertedBrick)) { View scriptBrickView = ((Brick) item).getView(context, position, this); if (draggedBrick == null) { scriptBrickView.setOnClickListener(this); } return scriptBrickView; } View currentBrickView; // dirty HACK // without the footer, position can be 0, and list.get(-1) caused an Indexoutofboundsexception // no clean solution was found if (position == 0) { if (item instanceof AllowedAfterDeadEndBrick && brickList.get(position) instanceof DeadEndBrick) { currentBrickView = ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this); } else { currentBrickView = ((Brick) item).getView(context, position, this); } } else { if (item instanceof AllowedAfterDeadEndBrick && brickList.get(position - 1) instanceof DeadEndBrick) { currentBrickView = ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this); } else { currentBrickView = ((Brick) item).getView(context, position, this); } } // this one is working but causes null pointer exceptions on movement and control bricks?! // currentBrickView.setOnLongClickListener(longClickListener); // Hack!!! // if wrapper isn't used the longClick event won't be triggered ViewGroup wrapper = (ViewGroup) View.inflate(context, R.layout.brick_wrapper, null); if (currentBrickView.getParent() != null) { ((ViewGroup) currentBrickView.getParent()).removeView(currentBrickView); } wrapper.addView(currentBrickView); if (draggedBrick == null) { if ((selectMode == ListView.CHOICE_MODE_NONE)) { wrapper.setOnClickListener(this); if (!(item instanceof DeadEndBrick)) { wrapper.setOnLongClickListener(dragAndDropListView); } } } if (position == positionOfInsertedBrick && initInsertedBrick && (selectMode == ListView.CHOICE_MODE_NONE)) { initInsertedBrick = false; addingNewBrick = true; dragAndDropListView.setInsertedBrick(position); dragAndDropListView.setDraggingNewBrick(); dragAndDropListView.onLongClick(currentBrickView); return insertionView; } if (animatedBricks.contains(brickList.get(position))) { Animation animation = AnimationUtils.loadAnimation(context, R.anim.blink); wrapper.startAnimation(animation); animatedBricks.remove(brickList.get(position)); } return wrapper; }