Java Code Examples for android.view.View.OnLayoutChangeListener

The following are top voted examples for showing how to use android.view.View.OnLayoutChangeListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: CustomTabBottomBarDelegate.java   View source code 6 votes vote down vote up
private void hideBottomBar() {
    if (mBottomBarView == null) return;
    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.BOTTOM;
    final ViewGroup compositorView = mActivity.getCompositorViewHolder();
    compositorView.addView(mBottomBarView, lp);
    compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            compositorView.removeOnLayoutChangeListener(this);
            mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight())
                    .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
                    .setDuration(SLIDE_ANIMATION_DURATION_MS)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
                            mBottomBarView = null;
                        }
                    }).start();
        }
    });
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: FocusAnimator.java   View source code 6 votes vote down vote up
/**
 * Constructs the {@link FocusAnimator}.
 *
 * To get the correct values to animate between, this should be called immediately before the
 * children of the layout are remeasured.
 *
 * @param layout       Layout being animated.
 * @param focusedChild Child being focused, or null if none is being focused.
 * @param callback     Callback to run when children are in the correct places.
 */
public FocusAnimator(
        LinearLayout layout, @Nullable View focusedChild, final Runnable callback) {
    mLayout = layout;
    mFocusedChild = focusedChild;
    mInitialNumberOfChildren = mLayout.getChildCount();
    mInitialTops = calculateChildTops();

    // Add a listener to know when Android has done another measurement pass.  The listener
    // automatically removes itself to prevent triggering the animation multiple times.
    mLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mLayout.removeOnLayoutChangeListener(this);
            startAnimator(callback);
        }
    });
}
 
Example 3
Project: AndroidChromium   File: CustomTabBottomBarDelegate.java   View source code 6 votes vote down vote up
private void hideBottomBar() {
    if (mBottomBarView == null) return;
    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.BOTTOM;
    final ViewGroup compositorView = mActivity.getCompositorViewHolder();
    compositorView.addView(mBottomBarView, lp);
    compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            compositorView.removeOnLayoutChangeListener(this);
            mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight())
                    .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
                    .setDuration(SLIDE_ANIMATION_DURATION_MS)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
                            mBottomBarView = null;
                        }
                    }).start();
        }
    });
}
 
Example 4
Project: AndroidChromium   File: FocusAnimator.java   View source code 6 votes vote down vote up
/**
 * Constructs the {@link FocusAnimator}.
 *
 * To get the correct values to animate between, this should be called immediately before the
 * children of the layout are remeasured.
 *
 * @param layout       Layout being animated.
 * @param focusedChild Child being focused, or null if none is being focused.
 * @param callback     Callback to run when children are in the correct places.
 */
public FocusAnimator(
        LinearLayout layout, @Nullable View focusedChild, final Runnable callback) {
    mLayout = layout;
    mFocusedChild = focusedChild;
    mInitialNumberOfChildren = mLayout.getChildCount();
    mInitialTops = calculateChildTops();

    // Add a listener to know when Android has done another measurement pass.  The listener
    // automatically removes itself to prevent triggering the animation multiple times.
    mLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mLayout.removeOnLayoutChangeListener(this);
            startAnimator(callback);
        }
    });
}
 
Example 5
Project: 365browser   File: CustomTabBottomBarDelegate.java   View source code 6 votes vote down vote up
private void showRemoteViews(RemoteViews remoteViews) {
    final View inflatedView = remoteViews.apply(mActivity, getBottomBarView());
    if (mClickableIDs != null && mClickPendingIntent != null) {
        for (int id: mClickableIDs) {
            if (id < 0) return;
            View view = inflatedView.findViewById(id);
            if (view != null) view.setOnClickListener(mBottomBarClickListener);
        }
    }
    getBottomBarView().addView(inflatedView, 1);
    inflatedView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            inflatedView.removeOnLayoutChangeListener(this);
            mFullscreenManager.setBottomControlsHeight(v.getHeight());
        }
    });
}
 
Example 6
Project: 365browser   File: FocusAnimator.java   View source code 6 votes vote down vote up
/**
 * Constructs the {@link FocusAnimator}.
 *
 * To get the correct values to animate between, this should be called immediately before the
 * children of the layout are remeasured.
 *
 * @param layout       Layout being animated.
 * @param focusedChild Child being focused, or null if none is being focused.
 * @param callback     Callback to run when children are in the correct places.
 */
public FocusAnimator(
        LinearLayout layout, @Nullable View focusedChild, final Runnable callback) {
    mLayout = layout;
    mFocusedChild = focusedChild;
    mInitialNumberOfChildren = mLayout.getChildCount();
    mInitialTops = calculateChildTops();

    // Add a listener to know when Android has done another measurement pass.  The listener
    // automatically removes itself to prevent triggering the animation multiple times.
    mLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mLayout.removeOnLayoutChangeListener(this);
            startAnimator(callback);
        }
    });
}
 
Example 7
Project: android-wear-gestures-recognition   File: testActivity.java   View source code 6 votes vote down vote up
/**
 * Initialises the chart and sets the correct radio button.  This is 
 * called from onCreate() as well as from onRadioButtonClicked().
 *
 */
private void initChart()
{
    final ChartSurfaceView csv
            = (ChartSurfaceView) findViewById(R.id.chartView);
    Chart3D chart = null;
    chart = Charts.createDemoScatterChart(-1.0, -1.0, -1.0);
    csv.setChart(chart);

    // here we add a listener that will zoom-to-fit the new chart when
    // the layout changes...
    csv.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right,
                                   int bottom, int oldLeft, int oldTop, int oldRight,
                                   int oldBottom) {
            csv.zoomToFit(right - left, bottom - top);
        }
    });

}
 
Example 8
Project: SpunkyCharts   File: TraditionalChartFragment.java   View source code 6 votes vote down vote up
private void 
_setPriceAxisOnLayoutChangeListener(){            
    _pAxisLayoutChngLstnr = new OnLayoutChangeListener(){        
                                @Override
                                public void 
                                onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, 
                                        int oldTop, int oldRight, int oldBottom){     
                                    for( BaseChartFragmentA tmp = getTopOfStack(); 
                                         tmp != getBaseOfStack();     
                                         tmp = tmp.getLastLinkOfStack())
                                         {                    
                                             tmp.getView()
                                                .findViewById(R.id.chart_right_panel_spacer)
                                                .setLayoutParams( new LinearLayout.LayoutParams(right-left, 
                                                    LinearLayout.LayoutParams.MATCH_PARENT) );
                                         }                
                                }    
                            };
                            
    ((LinearLayout)(_myViewGroup.findViewById(R.id.chart_right_panel_holder)))
        .addOnLayoutChangeListener(_pAxisLayoutChngLstnr);
}
 
Example 9
Project: SpunkyCharts   File: TraditionalChartFragment.java   View source code 6 votes vote down vote up
private void 
_syncPanels(){
    final TextView tv = (TextView)_rightPanel.findViewById(R.id.xAxis_mirror);        
    final int innerHeight = getResources().getDimensionPixelSize(R.dimen.chart_frag_trad_inner_axis_height);
            
    _xAxis.addOnLayoutChangeListener( new OnLayoutChangeListener(){ 
                                          /* synch X-Axis heights */
                                          @Override
                                          public void 
                                          onLayoutChange(View v, int left, int top, int right, int bottom, 
                                                  int oldLeft, int oldTop, int oldRight, int oldBottom){
                                              tv.setLayoutParams( new LinearLayout.LayoutParams(
                                                  LinearLayout.LayoutParams.WRAP_CONTENT, 
                                                  (int)((bottom-top)+ innerHeight) ) );
                                              _rightPanel.invalidate();                    
                                          }                
                                      } );     
}
 
Example 10
Project: SpunkyCharts   File: PriceByVolumeChartFragment.java   View source code 6 votes vote down vote up
private void 
_syncPanels(){
    final TextView tv = (TextView)_rightPanel.findViewById(R.id.xAxis_mirror);
    
    _xAxis.addOnLayoutChangeListener(
        new OnLayoutChangeListener(){ /* synch X-Axis heights */
            @Override
            public void 
            onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, 
                int oldRight, int oldBottom){
                    tv.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, 
                        (int)(bottom-top)) );                    
                    _rightPanel.invalidate();                    
            }                
        } 
    );     
}
 
Example 11
Project: co_nomad   File: PanAndZoomListener.java   View source code 6 votes vote down vote up
PanZoomCalculator(View container, View child, int anchor) {
	// Initialize class fields
	currentPan = new PointF(0, 0);
	currentZoom = 1f;
	;
	this.window = container;
	this.child = child;
	matrix = new Matrix();
	this.anchor = anchor;
	onPanZoomChanged();
	this.child.addOnLayoutChangeListener(new OnLayoutChangeListener() {
		// This catches when the image bitmap changes, for some reason
		// it doesn't recurse

		public void onLayoutChange(View v, int left, int top,
				int right, int bottom, int oldLeft, int oldTop,
				int oldRight, int oldBottom) {
			onPanZoomChanged();
		}
	});
}
 
Example 12
Project: q-mail   File: SecurityInfoDialog.java   View source code 5 votes vote down vote up
private void prepareIconAnimation() {
    authenticationText.setAlpha(0.0f);
    trustText.setAlpha(0.0f);

    dialogView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
            float halfVerticalPixelDifference = (trustIconFrame.getY() - authenticationIconFrame.getY()) / 2.0f;
            authenticationIconFrame.setTranslationY(halfVerticalPixelDifference);
            trustIconFrame.setTranslationY(-halfVerticalPixelDifference);

            authenticationIconFrame.animate().translationY(0)
                    .setStartDelay(ICON_ANIM_DELAY)
                    .setDuration(ICON_ANIM_DURATION)
                    .setInterpolator(new AccelerateDecelerateInterpolator())
                    .start();
            trustIconFrame.animate().translationY(0)
                    .setStartDelay(ICON_ANIM_DELAY)
                    .setDuration(ICON_ANIM_DURATION)
                    .setInterpolator(new AccelerateDecelerateInterpolator())
                    .start();
            authenticationText.animate().alpha(1.0f).setStartDelay(ICON_ANIM_DELAY + ICON_ANIM_DURATION).start();
            trustText.animate().alpha(1.0f).setStartDelay(ICON_ANIM_DELAY + ICON_ANIM_DURATION).start();

            view.removeOnLayoutChangeListener(this);
        }
    });
}
 
Example 13
Project: chromium-for-android-56-debug-video   File: SnackbarView.java   View source code 5 votes vote down vote up
void show() {
    addToParent();
    mView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mView.removeOnLayoutChangeListener(this);
            mView.setTranslationY(mView.getHeight() + getLayoutParams().bottomMargin);
            Animator animator = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, 0);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.setDuration(mAnimationDuration);
            startAnimatorOnSurfaceView(animator);
        }
    });
}
 
Example 14
Project: boohee_v5.6   File: SearchView.java   View source code 5 votes vote down vote up
@TargetApi(11)
private void addOnLayoutChangeListenerToDropDownAnchorSDK11() {
    this.mDropDownAnchor.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            SearchView.this.adjustDropDownSizeAndPosition();
        }
    });
}
 
Example 15
Project: K9-MailClient   File: CryptoInfoDialog.java   View source code 5 votes vote down vote up
private void prepareIconAnimation() {
    topText.setAlpha(0.0f);
    bottomText.setAlpha(0.0f);

    dialogView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
            float halfVerticalPixelDifference = (bottomIconFrame.getY() - topIconFrame.getY()) / 2.0f;
            topIconFrame.setTranslationY(halfVerticalPixelDifference);
            bottomIconFrame.setTranslationY(-halfVerticalPixelDifference);

            topIconFrame.animate().translationY(0)
                    .setStartDelay(ICON_ANIM_DELAY)
                    .setDuration(ICON_ANIM_DURATION)
                    .setInterpolator(new AccelerateDecelerateInterpolator())
                    .start();
            bottomIconFrame.animate().translationY(0)
                    .setStartDelay(ICON_ANIM_DELAY)
                    .setDuration(ICON_ANIM_DURATION)
                    .setInterpolator(new AccelerateDecelerateInterpolator())
                    .start();
            topText.animate().alpha(1.0f).setStartDelay(ICON_ANIM_DELAY + ICON_ANIM_DURATION).start();
            bottomText.animate().alpha(1.0f).setStartDelay(ICON_ANIM_DELAY + ICON_ANIM_DURATION).start();

            view.removeOnLayoutChangeListener(this);
        }
    });
}
 
Example 16
Project: AndroidChromium   File: SnackbarView.java   View source code 5 votes vote down vote up
void show() {
    addToParent();
    mView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mView.removeOnLayoutChangeListener(this);
            mView.setTranslationY(mView.getHeight() + getLayoutParams().bottomMargin);
            Animator animator = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, 0);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.setDuration(mAnimationDuration);
            startAnimatorOnSurfaceView(animator);
        }
    });
}
 
Example 17
Project: intellij-ce-playground   File: NotificationStudioActivity.java   View source code 5 votes vote down vote up
private void initPreviewScroller() {

        MaxHeightScrollView preview = (MaxHeightScrollView) findViewById(R.id.preview_scroller);
        if (preview == null)
            return;
        final int margin = ((ViewGroup.MarginLayoutParams) preview.getLayoutParams()).bottomMargin;
        preview.addOnLayoutChangeListener(new OnLayoutChangeListener(){
            public void onLayoutChange(View v, int left, int top, int right, int bottom,
                    int oldLeft, int oldTop, int oldRight, int oldBottom) {
                // animate preview height changes
                if (oldBottom != bottom) {
                    final View e = findViewById(R.id.editors);
                    final int y = bottom + margin;
                    e.animate()
                        .translationY(y - oldBottom)
                        .setListener(new AnimatorListenerAdapter() {
                            public void onAnimationEnd(Animator animation) {
                                FrameLayout.LayoutParams lp = (LayoutParams) e.getLayoutParams();
                                lp.topMargin = y;
                                e.setTranslationY(0);
                                e.setLayoutParams(lp);
                            }
                        });
                }
            }});

        // limit the max height for preview, leave room for editors + soft keyboard
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        float actualHeight = dm.heightPixels / dm.ydpi;
        float pct = actualHeight < 3.5 ? .32f :
                    actualHeight < 4 ? .35f :
                    .38f;
        preview.setMaxHeight((int)(dm.heightPixels * pct));
    }
 
Example 18
Project: FMTech   File: SearchView.java   View source code 5 votes vote down vote up
@TargetApi(11)
private void addOnLayoutChangeListenerToDropDownAnchorSDK11()
{
  this.mDropDownAnchor.addOnLayoutChangeListener(new View.OnLayoutChangeListener()
  {
    public final void onLayoutChange(View paramAnonymousView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3, int paramAnonymousInt4, int paramAnonymousInt5, int paramAnonymousInt6, int paramAnonymousInt7, int paramAnonymousInt8)
    {
      SearchView.this.adjustDropDownSizeAndPosition();
    }
  });
}
 
Example 19
Project: 365browser   File: SnackbarView.java   View source code 5 votes vote down vote up
void show() {
    addToParent();
    mView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mView.removeOnLayoutChangeListener(this);
            mView.setTranslationY(mView.getHeight() + getLayoutParams().bottomMargin);
            Animator animator = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, 0);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.setDuration(mAnimationDuration);
            startAnimatorOnSurfaceView(animator);
        }
    });
}
 
Example 20
Project: 365browser   File: DropdownPopupWindow.java   View source code 5 votes vote down vote up
/**
 * Creates an DropdownPopupWindow with specified parameters.
 * @param context Application context.
 * @param anchorView Popup view to be anchored.
 */
public DropdownPopupWindow(Context context, View anchorView) {
    super(context, null, 0, R.style.DropdownPopupWindow);
    mContext = context;
    mAnchorView = anchorView;

    mAnchorView.setId(R.id.dropdown_popup_window);
    mAnchorView.setTag(this);

    mLayoutChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (v == mAnchorView) DropdownPopupWindow.this.show();
        }
    };
    mAnchorView.addOnLayoutChangeListener(mLayoutChangeListener);

    super.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (mOnDismissListener != null) {
                mOnDismissListener.onDismiss();
            }
            mAnchorView.removeOnLayoutChangeListener(mLayoutChangeListener);
            mAnchorView.setTag(null);
        }
    });

    setAnchorView(mAnchorView);
    Rect originalPadding = new Rect();
    getBackground().getPadding(originalPadding);
    setVerticalOffset(-originalPadding.top);
}
 
Example 21
Project: oschina-app   File: CommonDialog.java   View source code 5 votes vote down vote up
@SuppressLint("InflateParams")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void init(final Context context) {
	setCancelable(false);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	content = LayoutInflater.from(context).inflate(
			R.layout.v2_dialog_common, null);
	headerVw = (DialogTitleView) content.findViewById(R.id.dialog_header);
	container = (FrameLayout) content.findViewById(R.id.content_container);
	barDivider = content.findViewById(R.id.button_bar_divider);
	buttonDivider = content.findViewById(R.id.button_divder);
	positiveBt = (Button) content.findViewById(R.id.positive_bt);
	negativeBt = (Button) content.findViewById(R.id.negative_bt);
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
		// TODO Check content view height and change height
	} else {
		content.addOnLayoutChangeListener(new OnLayoutChangeListener() {

			@Override
			public void onLayoutChange(View v, int left, int top,
					int right, int bottom, int oldLeft, int oldTop,
					int oldRight, int oldBottom) {
				int height = v.getHeight();
				int contentHeight = container.getHeight();
				int winHeight = BaseApplication.getDisplaySize()[1];
				int needHeight = height - winHeight * 8 / 10;
				if (needHeight > 0) {
					container
							.setLayoutParams(new LinearLayout.LayoutParams(
									LayoutParams.MATCH_PARENT,
									contentHeight - needHeight));
				}
			}
		});
	}
	super.setContentView(content);
}
 
Example 22
Project: testApp1_android   File: DKaraoke.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.actions, menu);
	mSearchView = (SearchView) MenuItemCompat.getActionView(menu
			.findItem(R.id.action_search));
	mSearchView.setOnQueryTextListener(mOnQueryTextListener);
	mSearchView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

		@Override
		public void onLayoutChange(View v, int left, int top, int right,
				int bottom, int oldLeft, int oldTop, int oldRight,
				int oldBottom) {
			SearchView searchView = (SearchView) v;
			if (searchView.isIconfiedByDefault()
					&& !searchView.isIconified()) {
				// search got expanded from icon to search box, hide tabs to
				// make space
				getActionBar().getCustomView().setVisibility(View.GONE);
			} else {
				getActionBar().getCustomView().setVisibility(View.VISIBLE);
			}
		}

	});
	return true;
}
 
Example 23
Project: ima_intellj   File: CommonDialog.java   View source code 5 votes vote down vote up
@SuppressLint("InflateParams")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void init(final Context context) {
	setCancelable(false);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	content = LayoutInflater.from(context).inflate(
			R.layout.v2_dialog_common, null);
	headerVw = (DialogTitleView) content.findViewById(R.id.dialog_header);
	container = (FrameLayout) content.findViewById(R.id.content_container);
	barDivider = content.findViewById(R.id.button_bar_divider);
	buttonDivider = content.findViewById(R.id.button_divder);
	positiveBt = (Button) content.findViewById(R.id.positive_bt);
	negativeBt = (Button) content.findViewById(R.id.negative_bt);
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
		// TODO Check content view height and change height

	} else {
		content.addOnLayoutChangeListener(new OnLayoutChangeListener() {

			@Override
			public void onLayoutChange(View v, int left, int top,
					int right, int bottom, int oldLeft, int oldTop,
					int oldRight, int oldBottom) {
				int height = v.getHeight();
				int contentHeight = container.getHeight();
				int winHeight = BaseApplication.getDisplaySize()[1];
				int needHeight = height - winHeight * 8 / 10;
				if (needHeight > 0) {
					container
							.setLayoutParams(new LinearLayout.LayoutParams(
									LayoutParams.MATCH_PARENT,
									contentHeight - needHeight));
				}
			}
		});
	}
	super.setContentView(content);
}
 
Example 24
Project: android-chromium-view   File: AutofillPopup.java   View source code 5 votes vote down vote up
/**
 * Creates an AutofillWindow with specified parameters.
 * @param context Application context.
 * @param viewAndroidDelegate View delegate used to add and remove views.
 * @param autofillCallback A object that handles the calls to the native AutofillPopupView.
 */
public AutofillPopup(Context context, ViewAndroidDelegate viewAndroidDelegate,
        AutofillPopupDelegate autofillCallback) {
    super(context, null, 0, R.style.AutofillPopupWindow);
    mContext = context;
    mViewAndroidDelegate = viewAndroidDelegate ;
    mAutofillCallback = autofillCallback;

    setOnItemClickListener(this);

    mAnchorView = mViewAndroidDelegate.acquireAnchorView();
    mAnchorView.setId(R.id.autofill_popup_window);
    mAnchorView.setTag(this);

    mViewAndroidDelegate.setAnchorViewPosition(mAnchorView, mAnchorX, mAnchorY, mAnchorWidth,
            mAnchorHeight);

    mLayoutChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (v == mAnchorView) AutofillPopup.this.show();
        }
    };

    mAnchorView.addOnLayoutChangeListener(mLayoutChangeListener);
    setAnchorView(mAnchorView);
}
 
Example 25
Project: android-chromium   File: AutofillPopup.java   View source code 5 votes vote down vote up
/**
 * Creates an AutofillWindow with specified parameters.
 * @param context Application context.
 * @param viewAndroidDelegate View delegate used to add and remove views.
 * @param autofillCallback A object that handles the calls to the native AutofillPopupView.
 */
public AutofillPopup(Context context, ViewAndroidDelegate viewAndroidDelegate,
        AutofillPopupDelegate autofillCallback) {
    super(context, null, 0, R.style.AutofillPopupWindow);
    mContext = context;
    mViewAndroidDelegate = viewAndroidDelegate ;
    mAutofillCallback = autofillCallback;

    setOnItemClickListener(this);

    mAnchorView = mViewAndroidDelegate.acquireAnchorView();
    mAnchorView.setId(R.id.autofill_popup_window);
    mAnchorView.setTag(this);

    mViewAndroidDelegate.setAnchorViewPosition(mAnchorView, mAnchorX, mAnchorY, mAnchorWidth,
            mAnchorHeight);

    mLayoutChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (v == mAnchorView) AutofillPopup.this.show();
        }
    };

    mAnchorView.addOnLayoutChangeListener(mLayoutChangeListener);
    setAnchorView(mAnchorView);
}
 
Example 26
Project: chromium_webview   File: AutofillPopup.java   View source code 5 votes vote down vote up
/**
 * Creates an AutofillWindow with specified parameters.
 * @param context Application context.
 * @param viewAndroidDelegate View delegate used to add and remove views.
 * @param autofillCallback A object that handles the calls to the native AutofillPopupView.
 */
public AutofillPopup(Context context, ViewAndroidDelegate viewAndroidDelegate,
        AutofillPopupDelegate autofillCallback) {
    super(context, null, 0, R.style.AutofillPopupWindow);
    mContext = context;
    mViewAndroidDelegate = viewAndroidDelegate;
    mAutofillCallback = autofillCallback;

    setOnItemClickListener(this);

    mAnchorView = mViewAndroidDelegate.acquireAnchorView();
    mAnchorView.setId(R.id.autofill_popup_window);
    mAnchorView.setTag(this);

    mViewAndroidDelegate.setAnchorViewPosition(mAnchorView, mAnchorX, mAnchorY, mAnchorWidth,
            mAnchorHeight);

    mLayoutChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (v == mAnchorView) AutofillPopup.this.show();
        }
    };

    mAnchorView.addOnLayoutChangeListener(mLayoutChangeListener);
    setAnchorView(mAnchorView);
}
 
Example 27
Project: cordova-android-chromium   File: AutofillPopup.java   View source code 5 votes vote down vote up
/**
 * Creates an AutofillWindow with specified parameters.
 * @param context Application context.
 * @param viewAndroidDelegate View delegate used to add and remove views.
 * @param autofillCallback A object that handles the calls to the native AutofillPopupView.
 */
public AutofillPopup(Context context, ViewAndroidDelegate viewAndroidDelegate,
        AutofillPopupDelegate autofillCallback) {
    super(context, null, 0, R.style.AutofillPopupWindow);
    mContext = context;
    mViewAndroidDelegate = viewAndroidDelegate ;
    mAutofillCallback = autofillCallback;

    setOnItemClickListener(this);

    mAnchorView = mViewAndroidDelegate.acquireAnchorView();
    mAnchorView.setId(R.id.autofill_popup_window);
    mAnchorView.setTag(this);

    mViewAndroidDelegate.setAnchorViewPosition(mAnchorView, mAnchorX, mAnchorY, mAnchorWidth,
            mAnchorHeight);

    mLayoutChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (v == mAnchorView) AutofillPopup.this.show();
        }
    };

    mAnchorView.addOnLayoutChangeListener(mLayoutChangeListener);
    setAnchorView(mAnchorView);
}
 
Example 28
Project: AndroidViewHelper   File: ViewWrapper.java   View source code 4 votes vote down vote up
/**
* @see View#addOnLayoutChangeListener(OnLayoutChangeListener)
*/
 public W addOnLayoutChangeListener(OnLayoutChangeListener listener) {
     mView.addOnLayoutChangeListener(listener);
     return (W)this;
 }
 
Example 29
Project: AndroidViewHelper   File: ViewWrapper.java   View source code 4 votes vote down vote up
/**
* @see View#removeOnLayoutChangeListener(OnLayoutChangeListener)
*/
 public W removeOnLayoutChangeListener(OnLayoutChangeListener listener) {
     mView.removeOnLayoutChangeListener(listener);
     return (W)this;
 }
 
Example 30
Project: AbacusUtil   File: Observer.java   View source code 4 votes vote down vote up
public Disposable onLayoutChange(final OnLayoutChangeListener onNext) {
    return onLayoutChange(onNext, Fu.ON_ERROR_MISSING);
}
 
Example 31
Project: AbacusUtil   File: Observer.java   View source code 4 votes vote down vote up
public Disposable onLayoutChange(final OnLayoutChangeListener onNext, final Consumer<? super Exception> onError) {
    return onLayoutChange(onNext, onError, Fu.EMPTY_ACTION);
}
 
Example 32
Project: AbacusUtil   File: Observer.java   View source code 4 votes vote down vote up
public Disposable onLayoutChange(final OnLayoutChangeListener onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            final Tuple9<View, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> tmp = (Tuple9<View, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>) param;

            if (Fu.isUiThread()) {
                onNext.onLayoutChange(tmp._1, tmp._2, tmp._3, tmp._4, tmp._5, tmp._6, tmp._7, tmp._8, tmp._9);
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        onNext.onLayoutChange(tmp._1, tmp._2, tmp._3, tmp._4, tmp._5, tmp._6, tmp._7, tmp._8, tmp._9);
                    }
                });
            }
        }
    });

    final OnLayoutChangeListener onAttachStateChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            dispatcher.onNext(Tuple.of(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom));
        };
    };

    _view.addOnLayoutChangeListener(onAttachStateChangeListener);

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.removeOnLayoutChangeListener(onAttachStateChangeListener);
        }
    });

    return this;
}
 
Example 33
Project: AbacusUtil   File: Observer.java   View source code 4 votes vote down vote up
public Disposable onLayoutChange(final Consumer<? super Tuple9<View, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>> onNext,
        final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            final Tuple9<View, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> tmp = (Tuple9<View, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>) param;

            if (Fu.isUiThread()) {
                onNext.accept(tmp);
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        onNext.accept(tmp);
                    }
                });
            }
        }
    });

    final OnLayoutChangeListener onAttachStateChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            dispatcher.onNext(Tuple.of(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom));
        };
    };

    _view.addOnLayoutChangeListener(onAttachStateChangeListener);

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.removeOnLayoutChangeListener(onAttachStateChangeListener);
        }
    });

    return this;
}
 
Example 34
Project: vlc_android_win   File: VideoPlayerActivity.java   View source code 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startPlayback() {
    /* start playback only when audio service and both surfaces are ready */
    if (mPlaybackStarted || mService == null)
        return;

    LibVLC().setOnHardwareAccelerationError(this);
    final IVLCVout vlcVout = mService.getVLCVout();
    if (mPresentation == null) {
        vlcVout.setVideoView(mSurfaceView);
        if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
            vlcVout.setSubtitlesView(mSubtitlesSurfaceView);
    } else {
        vlcVout.setVideoView(mPresentation.mSurfaceView);
        if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
            vlcVout.setSubtitlesView(mPresentation.mSubtitlesSurfaceView);
    }
    vlcVout.addCallback(this);
    vlcVout.attachViews();

    mPlaybackStarted = true;

    if (AndroidUtil.isHoneycombOrLater()) {
        if (mOnLayoutChangeListener == null) {
            mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
                private final Runnable mRunnable = new Runnable() {
                    @Override
                    public void run() {
                        changeSurfaceLayout();
                    }
                };
                @Override
                public void onLayoutChange(View v, int left, int top, int right,
                                           int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
                        /* changeSurfaceLayout need to be called after the layout changed */
                        mHandler.removeCallbacks(mRunnable);
                        mHandler.post(mRunnable);
                    }
                }
            };
        }
        mSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
    }
    changeSurfaceLayout();

    if (mMediaRouter != null) {
        // Listen for changes to media routes.
        mediaRouterAddCallback(true);
    }

    loadMedia();

    mSurfaceView.setKeepScreenOn(true);

    // Add any selected subtitle file from the file picker
    if(mSubtitleSelectedFiles.size() > 0) {
        for(String file : mSubtitleSelectedFiles) {
            Log.i(TAG, "Adding user-selected subtitle " + file);
            mService.addSubtitleTrack(file);
        }
    }

    // Set user playback speed
    mService.setRate(mSettings.getFloat(PreferencesActivity.VIDEO_SPEED, 1));
}
 
Example 35
Project: Camera2   File: TextureViewHelper.java   View source code 4 votes vote down vote up
public void setOnLayoutChangeListener(OnLayoutChangeListener listener) {
    mOnLayoutChangeListener = listener;
}
 
Example 36
Project: vlc-android   File: VideoPlayerActivity.java   View source code 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startPlayback() {
    /* start playback only when audio service and both surfaces are ready */
    if (mPlaybackStarted || mService == null)
        return;

    LibVLC().setOnHardwareAccelerationError(this);
    final IVLCVout vlcVout = mService.getVLCVout();
    if (mPresentation == null) {
        vlcVout.setVideoView(mSurfaceView);
        if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
            vlcVout.setSubtitlesView(mSubtitlesSurfaceView);
    } else {
        vlcVout.setVideoView(mPresentation.mSurfaceView);
        if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
            vlcVout.setSubtitlesView(mPresentation.mSubtitlesSurfaceView);
    }
    vlcVout.addCallback(this);
    vlcVout.attachViews();

    mPlaybackStarted = true;

    if (AndroidUtil.isHoneycombOrLater()) {
        if (mOnLayoutChangeListener == null) {
            mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
                private final Runnable mRunnable = new Runnable() {
                    @Override
                    public void run() {
                        changeSurfaceLayout();
                    }
                };
                @Override
                public void onLayoutChange(View v, int left, int top, int right,
                                           int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
                        /* changeSurfaceLayout need to be called after the layout changed */
                        mHandler.removeCallbacks(mRunnable);
                        mHandler.post(mRunnable);
                    }
                }
            };
        }
        mSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
    }
    changeSurfaceLayout();

    if (mMediaRouter != null) {
        // Listen for changes to media routes.
        mediaRouterAddCallback(true);
    }

    loadMedia();

    mSurfaceView.setKeepScreenOn(true);

    // Add any selected subtitle file from the file picker
    if(mSubtitleSelectedFiles.size() > 0) {
        for(String file : mSubtitleSelectedFiles) {
            Log.i(TAG, "Adding user-selected subtitle " + file);
            mService.addSubtitleTrack(file);
        }
    }

    // Set user playback speed
    mService.setRate(mSettings.getFloat(PreferencesActivity.VIDEO_SPEED, 1));
}
 
Example 37
Project: twenty48   File: MainActivity.java   View source code 4 votes vote down vote up
@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      won = false;
      setTitle("2048");
      setContentView(R.layout.activity_main);
      SharedPreferences data =
          getSharedPreferences("com.jbapps.twenty48", MODE_PRIVATE);
      highScore = data.getInt("highScore", 0);
      model = new Model();
      textView1 = (TextView)findViewById(R.id.textView1);
      textView2 = (TextView)findViewById(R.id.textView2);
      textView3 = (TextView)findViewById(R.id.textView3);
      textView4 = (TextView)findViewById(R.id.textView4);
      textView5 = (TextView)findViewById(R.id.textView5);
      textView6 = (TextView)findViewById(R.id.textView6);
      textView7 = (TextView)findViewById(R.id.textView7);
      textView8 = (TextView)findViewById(R.id.textView8);
      textView9 = (TextView)findViewById(R.id.textView9);
      textView10 = (TextView)findViewById(R.id.textView10);
      textView11 = (TextView)findViewById(R.id.textView11);
      textView12 = (TextView)findViewById(R.id.textView12);
      textView13 = (TextView)findViewById(R.id.textView13);
      textView14 = (TextView)findViewById(R.id.textView14);
      textView15 = (TextView)findViewById(R.id.textView15);
      textView16 = (TextView)findViewById(R.id.textView16);
      scoreView = (TextView)findViewById(R.id.textView17);
      highScoreView = (TextView)findViewById(R.id.textView18);
      textViews = new ArrayList<TextView>();
      textViews.add(textView1);
      textViews.add(textView2);
      textViews.add(textView3);
      textViews.add(textView4);
      textViews.add(textView5);
      textViews.add(textView6);
      textViews.add(textView7);
      textViews.add(textView8);
      textViews.add(textView9);
      textViews.add(textView10);
      textViews.add(textView11);
      textViews.add(textView12);
      textViews.add(textView13);
      textViews.add(textView14);
      textViews.add(textView15);
      textViews.add(textView16);
      mDetector = new GestureDetectorCompat(this, this);
      mDetector.setOnDoubleTapListener(this);
      GridLayout gridLayout = (GridLayout) findViewById(R.id.gridLayout1);
      gridLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() {
	@Override
	public void onLayoutChange(View view, int arg1, int arg2, int arg3,
			int arg4, int arg5, int arg6, int arg7, int arg8) {
		int sideLength;
		if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
			sideLength = view.getWidth() / 4;
		} else {
			sideLength = view.getHeight() / 4;
		}
		for (TextView text : textViews)
        {
            text.setWidth(sideLength);
            text.setHeight(sideLength);
            text.setGravity(Gravity.CENTER);
        }
	}
});
      update();
  }
 
Example 38
Project: rpgpack-android   File: MapActivity.java   View source code 4 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {

	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_game_toolbox_map);
	mapView = (MapView) findViewById(R.id.map);
	mapView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

		@Override
		public void onLayoutChange(View v, int left, int top, int right,
				int bottom, int oldLeft, int oldTop, int oldRight,
				int oldBottom) {
			// its possible that the layout is not complete in which case
			// we will get all zero values for the positions, so ignore the
			// event
			if (left == 0 && top == 0 && right == 0 && bottom == 0) {
				return;
			}

			if (first) {
				initTest();
				createCells();
				first = false;
			}

		}
	});
	Intent intent = getIntent();
	final String[] characterAbsPaths = intent
			.getStringArrayExtra(EXTRA_CHARACTER_ABS_PATH);
	if (savedInstanceState != null) {
		characterSheets = (CharacterSheet[]) savedInstanceState
				.getParcelableArray("characterSheets");
	} else {
		characterSheets = new CharacterSheet[characterAbsPaths.length];
		if (characterAbsPaths != null) {
			Log.d("ToolboxMap", "characterAbsPath != null");
			try {
				int index = 0;
				for (String onePath : characterAbsPaths) {
					characterSheets[index++] = JacksonInterface
							.loadCharacterSheet(new File(onePath), false);
				}

			} catch (Throwable e) {
				e.printStackTrace();
			}
		}
	}
	mapView.setOnTouchListener(mapView);
	paintLayout = (LinearLayout) findViewById(R.id.paint_colors);
	currPaint = (ImageButton) paintLayout.getChildAt(0);
	currPaint.setImageDrawable(getResources().getDrawable(
			R.drawable.paint_pressed));

}