List of usage examples for android.view ViewGroup removeView
@Override public void removeView(View view)
Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.
From source file:com.taobao.weex.ui.component.WXVContainer.java
/******************************** * end hook Activity life cycle callback ********************************************************/ public @Nullable View getBoxShadowHost(boolean isClear) { if (isClear) { // Return existed host if want clear shadow return mBoxShadowHost; }/* w w w . ja va 2s . c om*/ ViewGroup hostView = getHostView(); if (hostView == null) { return null; } try { String type = getComponentType(); if (WXBasicComponentType.DIV.equals(type)) { WXLogUtils.d("BoxShadow", "Draw box-shadow with BoxShadowHost on div: " + toString()); if (mBoxShadowHost == null) { mBoxShadowHost = new BoxShadowHost(getContext()); WXViewUtils.setBackGround(mBoxShadowHost, null, this); CSSShorthand padding = this.getPadding(); CSSShorthand border = this.getBorder(); int left = (int) (padding.get(CSSShorthand.EDGE.LEFT) + border.get(CSSShorthand.EDGE.LEFT)); int top = (int) (padding.get(CSSShorthand.EDGE.TOP) + border.get(CSSShorthand.EDGE.TOP)); int right = (int) (padding.get(CSSShorthand.EDGE.RIGHT) + border.get(CSSShorthand.EDGE.RIGHT)); int bottom = (int) (padding.get(CSSShorthand.EDGE.BOTTOM) + border.get(CSSShorthand.EDGE.BOTTOM)); ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams( hostView.getLayoutParams()); layoutParams.setMargins(-left, -top, -right, -bottom); mBoxShadowHost.setLayoutParams(layoutParams); hostView.addView(mBoxShadowHost); } hostView.removeView(mBoxShadowHost); hostView.addView(mBoxShadowHost); return mBoxShadowHost; } } catch (Throwable t) { WXLogUtils.w("BoxShadow", t); } return hostView; }
From source file:com.mark.quick.ui.view.swipebacklayout.SwipeBackLayout.java
/** * Activity //from ww w. j a va 2 s . co m * * @param activity */ void attachToActivity(Activity activity) { mActivity = activity; setSliderFadeColor(Color.TRANSPARENT); ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); //view mShadowView = new SwipeBackShadowView(activity); addView(mShadowView, 0, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //??DecorViewchild ViewGroup contentView = (ViewGroup) decorView.getChildAt(0); decorView.removeView(contentView); addView(contentView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //??DecorViewchild decorView.addView(this, 0); }
From source file:com.taobao.weex.WXSDKInstance.java
/** * Move fixed view to container ,except it's already moved. * @param fixedChild//www . j a v a 2s .c o m */ public void moveFixedView(View fixedChild) { if (mRenderContainer != null) { ViewGroup parent; if ((parent = (ViewGroup) fixedChild.getParent()) != null) { if (parent != mRenderContainer) { parent.removeView(fixedChild); mRenderContainer.addView(fixedChild); } } else { mRenderContainer.addView(fixedChild); } } }
From source file:lewa.support.v7.internal.widget.ActionBarView.java
@Override public void setSplitActionBar(boolean splitActionBar) { if (mSplitActionBar != splitActionBar) { if (mMenuView != null) { final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); if (oldParent != null) { oldParent.removeView(mMenuView); }// w w w . ja v a 2 s. c o m if (splitActionBar) { if (mSplitView != null) { mSplitView.addView(mMenuView); } mMenuView.getLayoutParams().width = LayoutParams.FILL_PARENT; } else { addView(mMenuView); mMenuView.getLayoutParams().width = LayoutParams.WRAP_CONTENT; } mMenuView.requestLayout(); } if (mSplitView != null) { mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE); } if (mActionMenuPresenter != null) { if (!splitActionBar) { /// M: width limit may change when orientation changed final ActionBarPolicy abp = ActionBarPolicy.get(mContext); if (abp != null) { mActionMenuPresenter.setWidthLimit(abp.getEmbeddedMenuWidthLimit(), false); } mActionMenuPresenter.setExpandedActionViewsExclusive( getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive)); } else { mActionMenuPresenter.setExpandedActionViewsExclusive(false); // Allow full screen width in split mode. mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true); // No limit to the item count; use whatever will fit. mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); } } super.setSplitActionBar(splitActionBar); } }
From source file:lewa.support.v7.internal.widget.ActionBarView.java
public void setMenu(SupportMenu menu, MenuPresenter.Callback cb) { if (menu == mOptionsMenu) { return;// ww w .j av a2 s. c om } if (mOptionsMenu != null) { mOptionsMenu.removeMenuPresenter(mActionMenuPresenter); mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter); } MenuBuilder builder = (MenuBuilder) menu; mOptionsMenu = builder; if (mMenuView != null) { final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); if (oldParent != null) { oldParent.removeView(mMenuView); } } if (mActionMenuPresenter == null) { ///LEWA BEGIN mActionMenuPresenter = Injector.newMenuPresenter(mContext, mSplitActionBar); ///LEWA END mActionMenuPresenter.setCallback(cb); mActionMenuPresenter.setId(R.id.action_menu_presenter); mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter(); } ActionMenuView menuView; final LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.FILL_PARENT); if (!mSplitActionBar) { mActionMenuPresenter.setExpandedActionViewsExclusive( getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive)); configPresenters(builder); menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); menuView.initialize(builder); final ViewGroup oldParent = (ViewGroup) menuView.getParent(); if (oldParent != null && oldParent != this) { oldParent.removeView(menuView); } addView(menuView, layoutParams); } else { mActionMenuPresenter.setExpandedActionViewsExclusive(false); // Allow full screen width in split mode. mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true); // No limit to the item count; use whatever will fit. mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); // Span the whole width layoutParams.width = LayoutParams.FILL_PARENT; configPresenters(builder); menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); if (mSplitView != null) { final ViewGroup oldParent = (ViewGroup) menuView.getParent(); if (oldParent != null && oldParent != mSplitView) { oldParent.removeView(menuView); } menuView.setVisibility(getAnimatedVisibility()); // LEWA ADD START if (true) { // Add menu bar into ActionBar /* if (mSplitView instanceof LewaActionBarContainer) { ((LewaActionBarContainer) mSplitView) .getActionMenuBar().addView(menuView, layoutParams); } else { mSplitView.addView(menuView, layoutParams); }*/ } else { mSplitView.addView(menuView, layoutParams); } // LEWA ADD END } else { // We'll add this later if we missed it this time. menuView.setLayoutParams(layoutParams); } } mMenuView = menuView; InjectorMenu.addActionOptionMenu(this, (MenuBuilder) menu, layoutParams); }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * Called after configuration changes -> This includes also orientation change. By handling * orientation changes by ourselves, we can prevent a restart of the camera, which results in a * speedup.//from ww w .j av a 2 s . co m * @param newConfig new configuration */ @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); // Tell the camera that the orientation changed, so it can adapt the preview orientation: if (mCameraPreview != null) mCameraPreview.displayRotated(); // Change the layout dynamically: Remove the current camera_controls_layout and add a new // one, which is appropriate for the orientation (portrait or landscape xml's). ViewGroup appRoot = (ViewGroup) findViewById(R.id.main_frame_layout); if (appRoot == null) return; View f = findViewById(R.id.camera_controls_layout); if (f == null) return; appRoot.removeView(f); getLayoutInflater().inflate(R.layout.camera_controls_layout, appRoot); View view = findViewById(R.id.camera_controls_layout); view.setBackgroundColor(getResources().getColor(R.color.control_background_color_transparent)); // Initialize the newly created buttons: initButtons(); }
From source file:com.popdeem.sdk.uikit.fragment.PDUIFeedFragment.java
@Nullable @Override// w ww. j a v a 2s.co m public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Picasso.with(getActivity()).setLoggingEnabled(true); if (mView == null) { mView = inflater.inflate(R.layout.fragment_pd_feed, container, false); mNoItemsView = mView.findViewById(R.id.pd_feed_no_items_view); mSwipeRefreshLayout = (PDUISwipeRefreshLayout) mView; mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refreshFeed(); } }); final RecyclerView recyclerView = (RecyclerView) mView.findViewById(R.id.pd_feed_recycler_view); mAdapter = new PDUIFeedRecyclerViewAdapter(mFeedItems, this); mAdapter.setOnItemClickListener(new PDUIFeedRecyclerViewAdapter.OnItemClickListener() { @Override public void onItemClick(View view) { int position = recyclerView.getChildAdapterPosition(view); if (view.findViewById(R.id.pd_feed_shared_image_view).getVisibility() == View.VISIBLE && mFeedItems.get(position) != null) { Intent intent = new Intent(getActivity(), PDUIFeedImageActivity.class); intent.putExtra("userName", mFeedItems.get(position).getUserFirstName()); intent.putExtra("imageUrl", mFeedItems.get(position).getImageUrlString()); startActivity(intent); } } }); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); mSwipeRefreshLayout.addLinearLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.addItemDecoration( new PDUIDividerItemDecoration(getActivity(), R.color.pd_feed_list_divider_color)); recyclerView.setAdapter(mAdapter); loadList(); refreshFeed(); } else { container.removeView(mView); } return mView; }
From source file:com.android.deskclock.timer.TimerFullScreenFragment.java
private Animator getRevealAnimator(View source, int revealColor) { final ViewGroup containerView = (ViewGroup) source.getRootView().findViewById(android.R.id.content); final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth()); containerView.offsetDescendantRectToMyCoords(source, sourceBounds); final int centerX = sourceBounds.centerX(); final int centerY = sourceBounds.centerY(); final int xMax = Math.max(centerX, containerView.getWidth() - centerX); final int yMax = Math.max(centerY, containerView.getHeight() - centerY); final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f; final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax); final CircleView revealView = new CircleView(source.getContext()).setCenterX(centerX).setCenterY(centerY) .setFillColor(revealColor);//from w ww . j av a 2 s.co m containerView.addView(revealView); final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius, endRadius); revealAnimator.setInterpolator(PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f)); final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); fadeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { containerView.removeView(revealView); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(TimerFragment.ANIMATION_TIME_MILLIS); animatorSet.playSequentially(revealAnimator, fadeAnimator); return revealAnimator; }
From source file:com.androzic.MapActivity.java
protected void updateNavigationStatus() { boolean isNavigating = navigationService != null && navigationService.isNavigating(); boolean isNavigatingViaRoute = isNavigating && navigationService.isNavigatingViaRoute(); // waypoint panel findViewById(R.id.waypointinfo).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // route panel findViewById(R.id.routeinfo).setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); // distance//from w w w.java 2 s.co m distanceValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); findViewById(R.id.distancelt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // bearing bearingValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); findViewById(R.id.bearinglt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // turn turnValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); findViewById(R.id.turnlt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // xtk xtkValue.setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); findViewById(R.id.xtklt).setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); // we hide elevation in portrait mode due to lack of space if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { if (isNavigatingViaRoute && elevationValue.getVisibility() == View.VISIBLE) { elevationValue.setVisibility(View.GONE); findViewById(R.id.elevationlt).setVisibility(View.GONE); ViewGroup row = (ViewGroup) findViewById(R.id.movingrow); int pos = row.indexOfChild(elevationValue); View xtklt = findViewById(R.id.xtklt); row.removeView(xtkValue); row.removeView(xtklt); row.addView(xtklt, pos); row.addView(xtkValue, pos); row.getParent().requestLayout(); } else if (!isNavigatingViaRoute && elevationValue.getVisibility() == View.GONE) { elevationValue.setVisibility(View.VISIBLE); findViewById(R.id.elevationlt).setVisibility(View.VISIBLE); ViewGroup row = (ViewGroup) findViewById(R.id.movingrow); int pos = row.indexOfChild(xtkValue); View elevationlt = findViewById(R.id.elevationlt); row.removeView(elevationValue); row.removeView(elevationlt); row.addView(elevationlt, pos); row.addView(elevationValue, pos); row.getParent().requestLayout(); } } if (isNavigatingViaRoute) { routeName.setText(" " + navigationService.navRoute.name); } if (isNavigating) { waypointName.setText(" " + navigationService.navWaypoint.name); if (application.navigationOverlay == null) { application.navigationOverlay = new NavigationOverlay(this); application.navigationOverlay.onMapChanged(); } } else if (application.navigationOverlay != null) { application.navigationOverlay.onBeforeDestroy(); application.navigationOverlay = null; } updateMapViewArea(); map.update(); }
From source file:com.tct.mail.ui.ConversationViewFragment.java
@Override public void onDestroyView() { // TS: zhangchao 2015-05-26 EMAIL BUGFIX_1005432 ADD_S //NOTE : performance optimization,we want to reduce the loader work lesser for some unExpected padding happen. // So destroy the loader after the fragment destroyed, not care about the data because no fragment to show anymore. getLoaderManager().destroyLoader(MESSAGE_LOADER); // TS: zhangchao 2015-05-26 EMAIL BUGFIX_1005432 ADD_E // TS: zhangchao 2015-05-26 EMAIL BUGFIX_1046583 ADD_S //NOTE:It's good idea that after fragment destoried,we release/destory all loaders,it can reduce the asyncTasks,cause the system //only supply MAX 128. here means user do not want check this mail,just destory it. getLoaderManager().destroyLoader(LOADER_DOWNLOAD_REMAINING); // TS: zhangchao 2015-05-26 EMAIL BUGFIX_1046583 ADD_E //TS: wenggangjin 2015-01-20 EMAIL BUGFIX_906070 MOD_S //[BUGFIX]-Add-BEGIN by TSNJ Zhenhua.Fan,21/11/2014,PR 871926 + JrdApp PR 859985 // TS: xiaolin.li 2014-12-30 EMAIL BUGFIX-887553 MOD_S //TS: junwei-xu 2015-07-07 EMAIL BUGFIX_958223 MOD_S //if(ConversationViewHeader.isClickStar){ //if(initStar != mConversation.starred){ //Note: save conversation's star to database if if does not equal with it in database. //TS: zheng.zou 2015-09-01 EMAIL BUGFIX_526255 DEL_S // if (mConversation.starred != mStarInDatabase) { //TS: wenggangjin 2015-01-20 EMAIL BUGFIX_906070 MOD_E //TS: junwei-xu 2015-07-07 EMAIL BUGFIX_958223 MOD_E // final ControllableActivity activity = (ControllableActivity) getActivity(); // if (activity != null) { // //TS: zheng.zou 2015-03-03 EMAIL BUGFIX_935495 MOD_S // ContentValues values = new ContentValues(); // values.put(UIProvider.ConversationColumns.STARRED, mConversation.starred); // values.put(UIProvider.ConversationOperations.Parameters.SUPPRESS_UNDO, true); // activity.getConversationUpdater().updateConversation(Conversation.listOf(mConversation),values); //// activity.getConversationUpdater().updateConversation(Conversation.listOf(mConversation), //// UIProvider.ConversationColumns.STARRED, mConversation.starred); // //TS: zheng.zou 2015-03-03 EMAIL BUGFIX_935495 MOD_E // } // }/*w w w . j a v a 2s. c o m*/ //TS: zheng.zou 2015-09-01 EMAIL BUGFIX_526255 DEL_E ConversationViewHeader.isClickStar = false; // TS: xiaolin.li 2014-12-30 EMAIL BUGFIX-887553 MOD_E //[BUGFIX]-Add-END by TSNJ Zhenhua.Fan // TS: jin.dong 2016-02-27 EMAIL BUGFIX_1693948 ADD_S // avoid memory leak. avoid ANR ,conversationViewFrament may be dattached,destroy webview when fragment destroy. if (mWebView != null) { // TS: zheng.zou 2015-11-11 EMAIL BUGFIX_571504 ADD_S // NOTE: in 5.1 Webview, onDetachedFromWindow() will return early if the Webview is destroyed, //the mComponentCallbacks will not be unregistered, this will cause leak. // so we remove view before destroy to avoid this situation. ViewGroup parent = ((ViewGroup) mWebView.getParent()); if (parent != null) { parent.removeView(mWebView); } // TS: zheng.zou 2015-11-11 EMAIL BUGFIX_571504 ADD_E mWebView.destroy(); mWebView = null; } // TS: jin.dong 2016-02-27 EMAIL BUGFIX_1693948 ADD_E super.onDestroyView(); mConversationContainer.setOverlayAdapter(null); mAdapter = null; resetLoadWaiting(); // be sure to unregister any active load observer mViewsCreated = false; mMessageHeaderView = null; // TS: gangjin.weng 2015-04-20 EMAIL BUGFIX_940964 ADD }