Search in sources :

Example 6 with AfFragment

use of com.andframe.fragment.AfFragment in project AndFrameWorks by scwang90.

the class AfActivity method onKeyUp.

/**
 * 转发 onKeyUp 事件给 AfFragment
 */
@Override
@SuppressLint("NewApi")
public boolean onKeyUp(int keyCode, KeyEvent event) {
    boolean isHandled = false;
    List<Fragment> fragments = getSupportFragmentManager().getFragments();
    fragments = fragments == null ? new ArrayList<>() : fragments;
    for (Fragment fragment : fragments) {
        if (fragment != null && fragment.getUserVisibleHint() && fragment instanceof AfFragment) {
            AfFragment afment = (AfFragment) fragment;
            isHandled = afment.onKeyUp(keyCode, event) || isHandled;
        }
    }
    return isHandled || super.onKeyUp(keyCode, event);
}
Also used : AfFragment(com.andframe.fragment.AfFragment) ArrayList(java.util.ArrayList) Fragment(android.support.v4.app.Fragment) AfFragment(com.andframe.fragment.AfFragment) SuppressLint(android.annotation.SuppressLint)

Example 7 with AfFragment

use of com.andframe.fragment.AfFragment in project AndFrameWorks by scwang90.

the class AfActivity method onKeyShortcut.

/**
 * 转发 onKeyShortcut 事件给 AfFragment
 */
@Override
@SuppressLint("NewApi")
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
    boolean isHandled = false;
    List<Fragment> fragments = getSupportFragmentManager().getFragments();
    fragments = fragments == null ? new ArrayList<>() : fragments;
    for (Fragment fragment : fragments) {
        if (fragment != null && fragment.getUserVisibleHint() && fragment instanceof AfFragment) {
            AfFragment afment = (AfFragment) fragment;
            isHandled = afment.onKeyShortcut(keyCode, event) || isHandled;
        }
    }
    return isHandled || super.onKeyShortcut(keyCode, event);
}
Also used : AfFragment(com.andframe.fragment.AfFragment) ArrayList(java.util.ArrayList) Fragment(android.support.v4.app.Fragment) AfFragment(com.andframe.fragment.AfFragment) SuppressLint(android.annotation.SuppressLint)

Aggregations

Fragment (android.support.v4.app.Fragment)7 AfFragment (com.andframe.fragment.AfFragment)7 ArrayList (java.util.ArrayList)7 SuppressLint (android.annotation.SuppressLint)2