Java Code Examples for android.view.View#setAccessibilityDelegate()

The following examples show how to use android.view.View#setAccessibilityDelegate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void cleanup() {
    for (final Map.Entry<View, TrackingAccessibilityDelegate> entry :
            mWatching.entrySet()) {
        final View v = entry.getKey();
        final TrackingAccessibilityDelegate toCleanup = entry.getValue();
        final View.AccessibilityDelegate currentViewDelegate = getOldDelegate(v);
        if (currentViewDelegate == toCleanup) {
            v.setAccessibilityDelegate(toCleanup.getRealDelegate());
        } else if (currentViewDelegate instanceof TrackingAccessibilityDelegate) {
            final TrackingAccessibilityDelegate newChain =
                    (TrackingAccessibilityDelegate) currentViewDelegate;
            newChain.removeFromDelegateChain(toCleanup);
        } else {
            // Assume we've been replaced, zeroed out, or for some other reason we're
            // already gone.
            // (This isn't too weird, for example, it's expected when views get recycled)
        }
    }
    mWatching.clear();
}
 
Example 2
Source File: DrawerLayout.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
	super.addView(child, index, params);

	final View openDrawer = findOpenDrawer();
	if (openDrawer != null || isDrawerView(child)) {
		// A drawer is already open or the new view is a drawer, so the
		// new view should start out hidden.
		child.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
	} else {
		// Otherwise this is a content view and no drawer is open, so the
		// new view should start out visible.
		child.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
	}

	// We only need a delegate here if the framework doesn't understand
	// NO_HIDE_DESCENDANTS importance.
	if (!CAN_HIDE_DESCENDANTS) {
		child.setAccessibilityDelegate(mChildAccessibilityDelegate);
	}
}
 
Example 3
Source File: AbsHListView.java    From letv with Apache License 2.0 6 votes vote down vote up
@SuppressLint({"NewApi"})
public void reclaimViews(List<View> views) {
    int childCount = getChildCount();
    RecyclerListener listener = RecycleBin.access$2200(this.mRecycler);
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (lp != null && this.mRecycler.shouldRecycleViewType(lp.viewType)) {
            views.add(child);
            if (VERSION.SDK_INT >= 14) {
                child.setAccessibilityDelegate(null);
            }
            if (listener != null) {
                listener.onMovedToScrapHeap(child);
            }
        }
    }
    this.mRecycler.reclaimScrapViews(views);
    removeAllViewsInLayout();
}
 
Example 4
Source File: RecycleBin.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** Move all views remaining in activeViews to scrapViews. */
void scrapActiveViews() {
    final View[] activeViews = this.activeViews;
    final int[] activeViewTypes = this.activeViewTypes;
    final boolean multipleScraps = viewTypeCount > 1;

    SparseArray<View> scrapViews = currentScrapViews;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            int whichScrap = activeViewTypes[i];

            activeViews[i] = null;
            activeViewTypes[i] = -1;

            if (!shouldRecycleViewType(whichScrap)) {
                continue;
            }

            if (multipleScraps) {
                scrapViews = this.scrapViews[whichScrap];
            }
            scrapViews.put(i, victim);

            victim.setAccessibilityDelegate(null);
        }
    }

    pruneScrapViews();
}
 
Example 5
Source File: RecycleBin.java    From COCOFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position, int viewType) {
    if (viewTypeCount == 1) {
        currentScrapViews.put(position, scrap);
    } else {
        scrapViews[viewType].put(position, scrap);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        scrap.setAccessibilityDelegate(null);
    }
}
 
Example 6
Source File: RecycleBin.java    From tubatu-viewpager with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position, int viewType) {
    if (viewTypeCount == 1) {
        currentScrapViews.put(position, scrap);
    } else {
        scrapViews[viewType].put(position, scrap);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        scrap.setAccessibilityDelegate(null);
    }
}
 
Example 7
Source File: Recycler.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 * 
 * @param scrap
 *            The view to add
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void addScrapView(View scrap, int position, int viewType) {
	// create a new Scrap
	Scrap item = new Scrap(scrap, true);
	
	if (viewTypeCount == 1) {
		currentScraps.put(position, item);
	} else {
		scraps[viewType].put(position, item);
	}
	if (Build.VERSION.SDK_INT >= 14) {
		scrap.setAccessibilityDelegate(null);
	}
}
 
Example 8
Source File: RecycleBin.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** Move all views remaining in activeViews to scrapViews. */
void scrapActiveViews() {
    final View[] activeViews = this.activeViews;
    final int[] activeViewTypes = this.activeViewTypes;
    final boolean multipleScraps = viewTypeCount > 1;

    SparseArray<View> scrapViews = currentScrapViews;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            int whichScrap = activeViewTypes[i];

            activeViews[i] = null;
            activeViewTypes[i] = -1;

            if (!shouldRecycleViewType(whichScrap)) {
                continue;
            }

            if (multipleScraps) {
                scrapViews = this.scrapViews[whichScrap];
            }
            scrapViews.put(i, victim);

            victim.setAccessibilityDelegate(null);
        }
    }

    pruneScrapViews();
}
 
Example 9
Source File: RecycleBin.java    From InfiniteViewPager with MIT License 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position, int viewType) {
  if (viewTypeCount == 1) {
    currentScrapViews.put(position, scrap);
  } else {
    scrapViews[viewType].put(position, scrap);
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    scrap.setAccessibilityDelegate(null);
  }
}
 
Example 10
Source File: RecycleBin.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/** Move all views remaining in activeViews to scrapViews. */
@SuppressLint("NewApi")
void scrapActiveViews() {
	final View[] activeViews = this.activeViews;
	final int[] activeViewTypes = this.activeViewTypes;
	final boolean multipleScraps = viewTypeCount > 1;

	SparseArray<View> scrapViews = currentScrapViews;
	final int count = activeViews.length;
	for (int i = count - 1; i >= 0; i--) {
		final View victim = activeViews[i];
		if (victim != null) {
			int whichScrap = activeViewTypes[i];

			activeViews[i] = null;
			activeViewTypes[i] = -1;

			if (!shouldRecycleViewType(whichScrap)) {
				continue;
			}

			if (multipleScraps) {
				scrapViews = this.scrapViews[whichScrap];
			}
			scrapViews.put(i, victim);

			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
				victim.setAccessibilityDelegate(null);
			}
		}
	}

	pruneScrapViews();
}
 
Example 11
Source File: RecycleBin.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 * 
 * @param scrap
 *            The view to add
 */
@SuppressLint("NewApi")
void addScrapView(View scrap, int position, int viewType) {
	if (viewTypeCount == 1) {
		currentScrapViews.put(position, scrap);
	} else {
		scrapViews[viewType].put(position, scrap);
	}

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
		scrap.setAccessibilityDelegate(null);
	}
}
 
Example 12
Source File: Recycler.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 * 
 * @param scrap
 *            The view to add
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void addScrapView(View scrap, int position, int viewType) {
	// create a new Scrap
	Scrap item = new Scrap(scrap, true);
	
	if (viewTypeCount == 1) {
		currentScraps.put(position, item);
	} else {
		scraps[viewType].put(position, item);
	}
	if (Build.VERSION.SDK_INT >= 14) {
		scrap.setAccessibilityDelegate(null);
	}
}
 
Example 13
Source File: RecycleBin.java    From ParallaxViewPager with Apache License 2.0 5 votes vote down vote up
/** Move all views remaining in activeViews to scrapViews. */
void scrapActiveViews() {
  final View[] activeViews = this.activeViews;
  final int[] activeViewTypes = this.activeViewTypes;
  final boolean multipleScraps = viewTypeCount > 1;

  SparseArray<View> scrapViews = currentScrapViews;
  final int count = activeViews.length;
  for (int i = count - 1; i >= 0; i--) {
    final View victim = activeViews[i];
    if (victim != null) {
      int whichScrap = activeViewTypes[i];

      activeViews[i] = null;
      activeViewTypes[i] = -1;

      if (!shouldRecycleViewType(whichScrap)) {
        continue;
      }

      if (multipleScraps) {
        scrapViews = this.scrapViews[whichScrap];
      }
      scrapViews.put(i, victim);

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        victim.setAccessibilityDelegate(null);
      }
    }
  }

  pruneScrapViews();
}
 
Example 14
Source File: RecycleBin.java    From ParallaxViewPager with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position, int viewType) {
  if (viewTypeCount == 1) {
    currentScrapViews.put(position, scrap);
  } else {
    scrapViews[viewType].put(position, scrap);
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    scrap.setAccessibilityDelegate(null);
  }
}
 
Example 15
Source File: RecycleBin.java    From salvage with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position, int viewType) {
  if (viewTypeCount == 1) {
    currentScrapViews.put(position, scrap);
  } else {
    scrapViews[viewType].put(position, scrap);
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    scrap.setAccessibilityDelegate(null);
  }
}
 
Example 16
Source File: RecycleBin.java    From tubatu-viewpager with Apache License 2.0 5 votes vote down vote up
/**
 * Move all views remaining in activeViews to scrapViews.
 */
void scrapActiveViews() {
    final View[] activeViews = this.activeViews;
    final int[] activeViewTypes = this.activeViewTypes;
    final boolean multipleScraps = viewTypeCount > 1;

    SparseArray<View> scrapViews = currentScrapViews;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            int whichScrap = activeViewTypes[i];

            activeViews[i] = null;
            activeViewTypes[i] = -1;

            if (!shouldRecycleViewType(whichScrap)) {
                continue;
            }

            if (multipleScraps) {
                scrapViews = this.scrapViews[whichScrap];
            }
            scrapViews.put(i, victim);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                victim.setAccessibilityDelegate(null);
            }
        }
    }

    pruneScrapViews();
}
 
Example 17
Source File: Recycler.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 * 
 * @param scrap
 *            The view to add
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void addScrapView(View scrap, int position, int viewType) {
	// create a new Scrap
	Scrap item = new Scrap(scrap, true);
	
	if (viewTypeCount == 1) {
		currentScraps.put(position, item);
	} else {
		scraps[viewType].put(position, item);
	}
	if (Build.VERSION.SDK_INT >= 14) {
		scrap.setAccessibilityDelegate(null);
	}
}
 
Example 18
Source File: ViewCompatICS.java    From guideshow with MIT License 4 votes vote down vote up
public static void setAccessibilityDelegate(View v, Object delegate) {
    v.setAccessibilityDelegate((AccessibilityDelegate) delegate);
}
 
Example 19
Source File: al.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static void a(View view, Object obj)
{
    view.setAccessibilityDelegate((android.view.View.AccessibilityDelegate)obj);
}
 
Example 20
Source File: ViewCompatICS.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void setAccessibilityDelegate(View v, Object delegate) {
    v.setAccessibilityDelegate((AccessibilityDelegate) delegate);
}