本文整理汇总了Java中android.view.View.addOnAttachStateChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.addOnAttachStateChangeListener方法的具体用法?Java View.addOnAttachStateChangeListener怎么用?Java View.addOnAttachStateChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.addOnAttachStateChangeListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addView
import android.view.View; //导入方法依赖的package包/类
/**
* 添加view到Window
*
* @param view
* @param params
*/
public void addView(View view, ViewGroup.LayoutParams params)
{
if (view == null)
{
return;
}
init(view);
if (containsView(view))
{
return;
}
if (params == null)
{
params = newLayoutParams();
}
getWindowManager().addView(view, params);
view.removeOnAttachStateChangeListener(mInternalOnAttachStateChangeListener);
view.addOnAttachStateChangeListener(mInternalOnAttachStateChangeListener);
mMapView.put(view, 0);
}
示例2: DropDownWindow
import android.view.View; //导入方法依赖的package包/类
public DropDownWindow(View anchor, View contentView) {
super(anchor.getContext());
mAnchor = anchor;
final Resources r = anchor.getResources();
setBackgroundDrawable(r.getDrawable(R.drawable.dialog_full_holo_dark));
setWidth(r.getDimensionPixelSize(R.dimen.new_videos_action_dropdown_width)); // Takes too much space on tablets when using LayoutParams.WRAP_CONTENT
setHeight(LayoutParams.WRAP_CONTENT);
setContentView(contentView);
setTouchable(true);
setFocusable(true);
// listen to anchor getting removed (e.g. activity destroyed)
// -> dismiss() self so we don't keep this window open
anchor.addOnAttachStateChangeListener(this);
}
示例3: setTarget
import android.view.View; //导入方法依赖的package包/类
/**
* 设置目标view
*
* @param target
*/
public FPoper setTarget(View target)
{
final View old = getTarget();
if (old != target)
{
if (old != null)
{
old.removeOnAttachStateChangeListener(mOnAttachStateChangeListenerTarget);
}
if (target != null)
{
mTarget = new WeakReference<>(target);
target.removeOnAttachStateChangeListener(mOnAttachStateChangeListenerTarget);
target.addOnAttachStateChangeListener(mOnAttachStateChangeListenerTarget);
} else
{
mTarget = null;
removeUpdateListener();
}
}
return this;
}
示例4: bind
import android.view.View; //导入方法依赖的package包/类
@UiThread
public static void bind(View view, KolibriProvider provider) {
final KolibriCoordinator coordinator = provider.provideCoordinator(view);
if (coordinator == null) {
return;
}
View.OnAttachStateChangeListener binding = new Binding(view, coordinator);
view.addOnAttachStateChangeListener(binding);
// Sometimes we missed the first attach because the child's already been added.
// Sometimes we didn't. The binding keeps track to avoid double attachment of the Coordinator,
// and to guard against attachment to two different views simultaneously.
binding.onViewAttachedToWindow(view);
}
示例5: onGlobalFocusChanged
import android.view.View; //导入方法依赖的package包/类
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (newFocus == null) {
return;
}
if (oldFocus != null) {
oldFocus.removeOnAttachStateChangeListener(this);
}
Looper.myQueue().removeIdleHandler(this);
newFocus.addOnAttachStateChangeListener(this);
}
示例6: clearInputMethodManagerLeak
import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
try {
Object lock = mHField.get(inputMethodManager);
// This is highly dependent on the InputMethodManager implementation.
synchronized (lock) {
View servedView = (View) mServedViewField.get(inputMethodManager);
if (servedView != null) {
boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;
if (servedViewAttached) {
// The view held by the IMM was replaced without a global focus change. Let's make
// sure we get notified when that view detaches.
// Avoid double registration.
servedView.removeOnAttachStateChangeListener(this);
servedView.addOnAttachStateChangeListener(this);
} else {
// servedView is not attached. InputMethodManager is being stupid!
Activity activity = extractActivity(servedView.getContext());
if (activity == null || activity.getWindow() == null) {
// Unlikely case. Let's finish the input anyways.
finishInputLockedMethod.invoke(inputMethodManager);
} else {
View decorView = activity.getWindow().peekDecorView();
boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
if (!windowAttached) {
finishInputLockedMethod.invoke(inputMethodManager);
} else {
decorView.requestFocusFromTouch();
}
}
}
}
}
} catch (IllegalAccessException | InvocationTargetException unexpected) {
Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
}
}
示例7: DisplayStyleObserverAdapter
import android.view.View; //导入方法依赖的package包/类
/**
* @param view the view whose lifecycle is tracked to determine when to not fire the
* observer.
* @param config the {@link UiConfig} object to subscribe to.
* @param observer the observer to adapt. It's {#onDisplayStyleChanged} will be called when
* the configuration changes, provided that {@code view} is attached to the
* window.
*/
public DisplayStyleObserverAdapter(View view, UiConfig config, DisplayStyleObserver observer) {
mObserver = observer;
// TODO(dgn): getParent() is not a good way to test that, but isAttachedToWindow()
// requires API 19.
mIsViewAttached = view.getParent() != null;
view.addOnAttachStateChangeListener(this);
// This call will also assign the initial value to |mCurrentDisplayStyle|
config.addObserver(this);
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:DisplayStyleObserverAdapter.java
示例8: BranchPopupWindow
import android.view.View; //导入方法依赖的package包/类
@SuppressLint("InflateParams")
public BranchPopupWindow(Context context, long mProjectId, Callback callback) {
super(LayoutInflater.from(context).inflate(R.layout.popup_window_branch, null),
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mCallback = callback;
this.mProjectId = mProjectId;
setAnimationStyle(R.style.popup_anim_style_alpha);
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setOutsideTouchable(true);
setFocusable(true);
View content = getContentView();
content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
content.addOnAttachStateChangeListener(this);
RecyclerView mRecyclerView = (RecyclerView) content.findViewById(R.id.rv_branch);
mAdapter = new BranchAdapter(context);
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(this);
mPresenter = new BranchPresenter(this);
mPresenter.getBranches(mProjectId);
}
示例9: ImageFolderPopupWindow
import android.view.View; //导入方法依赖的package包/类
@SuppressLint("InflateParams")
ImageFolderPopupWindow(Context context, Callback callback) {
super(LayoutInflater.from(context).inflate(R.layout.popup_window_folder, null),
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mCallback = callback;
// init
setAnimationStyle(R.style.popup_anim_style_alpha);
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setOutsideTouchable(true);
setFocusable(true);
// content
View content = getContentView();
content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
content.addOnAttachStateChangeListener(this);
mFolderView = (RecyclerView) content.findViewById(R.id.rv_popup_folder);
mFolderView.setLayoutManager(new LinearLayoutManager(context));
}
示例10: onGlobalFocusChanged
import android.view.View; //导入方法依赖的package包/类
@Override public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (newFocus == null) {
return;
}
if (oldFocus != null) {
oldFocus.removeOnAttachStateChangeListener(this);
}
Looper.myQueue().removeIdleHandler(this);
newFocus.addOnAttachStateChangeListener(this);
}
示例11: clearInputMethodManagerLeak
import android.view.View; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
try {
Object lock = mHField.get(inputMethodManager);
// This is highly dependent on the InputMethodManager implementation.
synchronized (lock) {
View servedView = (View) mServedViewField.get(inputMethodManager);
if (servedView != null) {
boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;
if (servedViewAttached) {
// The view held by the IMM was replaced without a global focus change. Let's make
// sure we get notified when that view detaches.
// Avoid double registration.
servedView.removeOnAttachStateChangeListener(this);
servedView.addOnAttachStateChangeListener(this);
} else {
// servedView is not attached. InputMethodManager is being stupid!
Activity activity = extractActivity(servedView.getContext());
if (activity == null || activity.getWindow() == null) {
// Unlikely case. Let's finish the input anyways.
finishInputLockedMethod.invoke(inputMethodManager);
} else {
View decorView = activity.getWindow().peekDecorView();
boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
if (!windowAttached) {
finishInputLockedMethod.invoke(inputMethodManager);
} else {
decorView.requestFocusFromTouch();
}
}
}
}
}
} catch (IllegalAccessException | InvocationTargetException unexpected) {
Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
}
}
示例12: FragmentViewHolder
import android.view.View; //导入方法依赖的package包/类
public FragmentViewHolder(View itemView) {
super(itemView);
itemView.addOnAttachStateChangeListener(this);
}
示例13: onViewCreated
import android.view.View; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.addOnAttachStateChangeListener(this);
}