當前位置: 首頁>>代碼示例>>Java>>正文


Java View.addOnAttachStateChangeListener方法代碼示例

本文整理匯總了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);
}
 
開發者ID:zj565061763,項目名稱:windowmanager,代碼行數:29,代碼來源:SDWindowManager.java

示例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);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:18,代碼來源:NewVideosActionProvider.java

示例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;
}
 
開發者ID:zj565061763,項目名稱:poper,代碼行數:29,代碼來源:FPoper.java

示例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);
}
 
開發者ID:azmedien,項目名稱:kolibri-android,代碼行數:15,代碼來源:Kolibri.java

示例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);
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:12,代碼來源:IMMLeaks.java

示例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);
    }
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:41,代碼來源:IMMLeaks.java

示例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);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:29,代碼來源:BranchPopupWindow.java

示例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));

}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:28,代碼來源:ImageFolderPopupWindow.java

示例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);
}
 
開發者ID:GcsSloop,項目名稱:diycode,代碼行數:11,代碼來源:IMMLeaks.java

示例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);
  }
}
 
開發者ID:GcsSloop,項目名稱:diycode,代碼行數:41,代碼來源:IMMLeaks.java

示例12: FragmentViewHolder

import android.view.View; //導入方法依賴的package包/類
public FragmentViewHolder(View itemView) {
    super(itemView);
    itemView.addOnAttachStateChangeListener(this);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:FragmentStatePagerAdapter.java

示例13: onViewCreated

import android.view.View; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.addOnAttachStateChangeListener(this);
}
 
開發者ID:CodingCodersCode,項目名稱:EvolvingNetLib,代碼行數:6,代碼來源:CCBaseLazyRxFragment.java


注:本文中的android.view.View.addOnAttachStateChangeListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。