List of usage examples for android.view View removeOnLayoutChangeListener
public void removeOnLayoutChangeListener(OnLayoutChangeListener listener)
From source file:com.simas.vc.nav_drawer.NavDrawerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerList = (HeadlessListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false); final View header = createHeader(inflater, mDrawerList); // When available, fetch the item width and height if (MainActivity.sPreviewSize == 0) { header.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override/* w w w .jav a 2s .c o m*/ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int width = header.getWidth(), height = header.getHeight(); if (width > 0 && height > 0) { header.removeOnLayoutChangeListener(this); MainActivity.sPreviewSize = (width > height) ? width : height; } } }); } getListView().addHeaderView(header); return mDrawerList; }
From source file:com.heinrichreimersoftware.materialintro.app.IntroActivity.java
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); activityCreated = true;/*from w ww. ja v a2s . co m*/ updateTaskDescription(); updateButtonNextDrawable(); updateButtonBackDrawable(); updateScrollPositions(); miFrame.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { updateScrollPositions(); v.removeOnLayoutChangeListener(this); } }); }
From source file:com.simas.vc.editor.EditorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { View root = inflater.inflate(R.layout.fragment_editor, container, false); // Overlay a ProgressBar when preparing the PlayerFragment for the first time mProgressOverlay = root.findViewById(R.id.editor_progress_overlay); mPlayerFragment = (PlayerFragment) getChildFragmentManager().findFragmentById(R.id.player_fragment); // Queue container modifications until it's measured final View playerContainer = mPlayerFragment.getContainer(); final Runnable playerResize = new Runnable() { @Override/*from w w w . j a v a 2 s .co m*/ public void run() { ViewGroup.LayoutParams params = playerContainer.getLayoutParams(); params.width = MainActivity.sPlayerContainerSize; params.height = MainActivity.sPlayerContainerSize; playerContainer.setLayoutParams(params); playerContainer.post(new Runnable() { @Override public void run() { modifyProgressOverlayStates(true, ProgressStates.PLAYER_CONTAINER_DRAWN); } }); } }; if (MainActivity.sPlayerContainerSize != 0) { playerResize.run(); } else { playerContainer.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int size = Math.max(playerContainer.getWidth(), playerContainer.getHeight()); if (size <= 0) return; MainActivity.sPlayerContainerSize = size; playerContainer.removeOnLayoutChangeListener(this); playerResize.run(); } }); } mDelayedHandler.resume(); View actions = root.findViewById(R.id.editor_actions); mDataMap.put(Data.ACTIONS, actions); mDataMap.put(Data.FILENAME, actions.findViewById(R.id.filename_value)); mDataMap.put(Data.SIZE, actions.findViewById(R.id.size_value)); mDataMap.put(Data.DURATION, actions.findViewById(R.id.duration_value)); mDataMap.put(Data.STREAM_TREE, actions.findViewById(R.id.tree_view)); if (savedState != null) { NavItem previousItem = savedState.getParcelable(STATE_PREVIOUS_ITEM); if (previousItem != null) { setItem(previousItem); } } return root; }