下面列出了android.widget.ImageButton# getTag ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Animates the visibility of a tab's close button.
*
* @param viewHolder
* The view holder, which holds a reference to the close button, whose visibility should
* be animated, as an instance of the class {@link AbstractTabViewHolder}. The view
* holder may not be null
* @param show
* True, if the close button should be shown, false otherwise
*/
private void animateCloseButtonVisibility(@NonNull final AbstractTabViewHolder viewHolder,
final boolean show) {
ImageButton closeButton = viewHolder.closeButton;
Boolean visible = (Boolean) closeButton.getTag(R.id.tag_visibility);
if (visible == null || visible != show) {
closeButton.setTag(R.id.tag_visibility, show);
if (closeButton.getAnimation() != null) {
closeButton.getAnimation().cancel();
}
ViewPropertyAnimator animation = closeButton.animate();
animation.setListener(createCloseButtonVisibilityAnimationListener(viewHolder, show));
animation.alpha(show ? 1 : 0);
animation.setStartDelay(0);
animation.setDuration(closeButtonVisibilityAnimationDuration);
animation.start();
}
}
private static void setDoneState(ImageButton nextButton,
Context context,
final ClippingFrame finishButton,
FormNavigationController.NavigationDetails details,
ProgressBar progressBar) {
if (nextButton.getTag() == null) {
setFinishVisible(finishButton);
} else if (!FormEntryConstants.NAV_STATE_DONE.equals(nextButton.getTag())) {
nextButton.setTag(FormEntryConstants.NAV_STATE_DONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
expandAndShowFinishButton(context, finishButton);
} else {
setFinishVisible(finishButton);
}
}
progressBar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_full));
progressBar.setProgress(details.totalQuestions);
Log.i("Questions", "Form complete");
}
/**
* Search recursively through all children of the parent layout and checks their class.
* If they are ViewGroup classes, continues the recursion,
* if they are View classes, terminates the recursion
* <p>
* Used in {@link #hideVisibleViews(ViewGroup)} to get all the Views that should be hidden
* Used in {@link #showHiddenViews()} to get all the Views that should be shown
*
* @param parentLayout the top layout in XML file
* @return a list of all non-ViewGroup views from the parent layout except the VideoView,
* but including Toolbar
*/
private List<View> getVisibleChildViews(View parentLayout) {
if (!shouldCheckChildren(parentLayout)) {
return Collections.singletonList(parentLayout);
}
int childCount = ((ViewGroup) parentLayout).getChildCount();
List<View> children = new ArrayList<>(childCount);
for (int i = 0; i < childCount; i++) {
View view = ((ViewGroup) parentLayout).getChildAt(i);
if (shouldCheckChildren(view)) {
children.addAll(getVisibleChildViews(view));
} else {
if (view instanceof FullscreenVideoView) {
ImageButton fullscreenButton = view.findViewById(R.id.fullscreen_media_button);
String buttonTag = (String) fullscreenButton.getTag();
if (view.getVisibility() == VISIBLE &&
!Objects.equals(buttonTag, VIEW_TAG_CLICKED)) {
children.add(view);
}
} else {
if (view.getVisibility() == VISIBLE) {
children.add(view);
}
}
}
}
return children;
}
@Override public void onClick(View v){
if (v instanceof ImageButton){
ImageButton action = (ImageButton) v;
Effect effect = (Effect) action.getTag();
if (lastSelectionEffects.contains(effect)){
richEditText.applyEffect(effect, false);
setActionOff(action);
lastSelectionEffects.remove(effect);
}else{
richEditText.applyEffect(effect, true);
setActionOn(action);
lastSelectionEffects.add(effect);
}
}
}
private void tileClick(int x, int y) {
ImageButton tile = tiles[x][y];
if (tile.getTag() == STATE_HIGHLIGHTED) {
swap(swapTile[0], swapTile[1], x, y);
swapTile = new int[]{-1, -1};
incrementRound();
} else {
swapTile = new int[]{x, y};
tile.setTag(STATE_PRESSED);
tile.setEnabled(false);
tile.setBackgroundResource(R.drawable.button_game_pressed);
highlightNeighbours(x, y);
}
}
private void updateDVDButton() {
if(getView() == null) {
return;
}
ImageButton dvd = (ImageButton) getView().findViewById(R.id.button_navigation);
if(dvd != null && dvd.getTag() == null) {
dvd.setVisibility(Preferences.get(getActivity()).isHideDVDTabSet() ? View.GONE : View.VISIBLE);
}
}