Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

private void refreshAnnotationNumber(ViewGroup viewGroup) {
    if (viewGroup != null) {
        for (int i = 0; i < viewGroup.getChildCount(); ++i) {
            View child = viewGroup.getChildAt(i);
            if (child instanceof TextAnnotationView) {
                TextView textView = (((TextAnnotationView) child).getAnnotationNumberView());
                String newAnnotationNumber = Integer
                        .toString(Integer.valueOf(textView.getText().toString()) - 1);
                if (Integer.valueOf(newAnnotationNumber) != 0) {
                    textView.setText(newAnnotationNumber);
                }// w  w w. j  a v a  2  s  .c  o m
            }
        }
    }
}

From source file:com.gome.haoyuangong.views.SwipeRefreshLayout.java

private void disableSubControls(View view) {
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View v = viewGroup.getChildAt(i);
            if (v instanceof ViewGroup) {
                if (v instanceof Spinner) {
                    v.setPressed(false);
                } else if (v instanceof ListView) {
                    removeListTapCallback((ListView) v);
                } else {
                    removeViewTapCallback(v);
                    disableSubControls((ViewGroup) v);
                }/*from w ww.j  av  a2s  . c  om*/
            } else {
                removeViewTapCallback(v);
            }
        }
    } else {
        removeViewTapCallback(view);
    }
}

From source file:com.mfh.framework.uikit.widget.SideSlidingTabStrip.java

/**
 * ?TAB/*from  ww w. ja v  a  2  s . c o m*/
 */
public void selectedTab(int currentSelectedTabPosition) {
    ViewGroup tabsLayout = getTabsLayout();
    if (currentSelectedTabPosition > -1 && tabsLayout != null
            && currentSelectedTabPosition < tabsLayout.getChildCount()) {
        if (currentSelectedTabView != null) {
            currentSelectedTabView.setSelected(false);
        }
        currentSelectedTabView = tabsLayout.getChildAt(currentSelectedTabPosition);
        if (currentSelectedTabView != null) {
            currentSelectedTabView.setSelected(true);
        }
    }
}

From source file:me.xiaopan.psts.PagerSlidingTabStrip.java

private void setTabClickEvent() {
    ViewGroup tabViewGroup = getTabsLayout();
    if (tabViewGroup != null && tabViewGroup.getChildCount() > 0) {
        //?tab?Pager
        for (int w = 0; w < tabViewGroup.getChildCount(); w++) {
            View itemView = tabViewGroup.getChildAt(w);
            itemView.setTag(w);/*from   ww w .  j a v a  2 s .c  om*/
            itemView.setOnClickListener(tabViewClickListener);
            itemView.setOnTouchListener(tabViewDoubleClickGestureDetector);
        }
    }
}

From source file:com.android.tv.settings.accessories.AddAccessoryActivity.java

@Override
protected void onStart() {
    super.onStart();

    if (DEBUG) {/*from   w ww.  j a  v  a2s. c om*/
        Log.d(TAG, "onStart() mPairingInBackground = " + mPairingInBackground);
    }

    // Only do the following if we are not coming back to this activity from
    // the Secure Pairing activity.
    if (!mPairingInBackground) {
        if (mAnimateOnStart) {
            mAnimateOnStart = false;
            ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content);
            mTopLayout = (FrameLayout) contentView.getChildAt(0);

            // Fade out the old activity, and fade in the new activity.
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

            // Set the activity background
            int bgColor = getResources().getColor(R.color.dialog_activity_background);
            getBackgroundDrawable().setColor(bgColor);
            mTopLayout.setBackground(getBackgroundDrawable());

            // Delay the rest of the changes until the first layout event
            mTopLayout.getViewTreeObserver()
                    .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                        @Override
                        public void onGlobalLayout() {
                            mTopLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);

                            // set the Action and Content fragments to their start offsets
                            mActionView = findViewById(R.id.action_fragment);
                            mContentView = findViewById(R.id.content_fragment);
                            if (mActionView != null) {
                                mViewOffset = mActionView.getMeasuredWidth();
                                int offset = (ViewCompat
                                        .getLayoutDirection(mActionView) == View.LAYOUT_DIRECTION_RTL)
                                                ? -mViewOffset
                                                : mViewOffset;
                                mActionView.setTranslationX(offset);
                                mContentView.setTranslationX(offset / 2);
                            }
                            mAutoPairText = (TextView) findViewById(R.id.autopair_message);
                            if (mAutoPairText != null) {
                                mAutoPairText.setVisibility(View.GONE);
                            }
                            updateView();
                        }
                    });
        }

        startBluetoothPairer();

        mStartTime = SystemClock.elapsedRealtime();
    }

    mPairingInBackground = false;
}

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

private void hideAllControlItems(ViewGroup viewGroup) {
    // Hide all control items
    if (viewGroup != null) {
        for (int i = 0; i < viewGroup.getChildCount(); ++i) {
            View child = viewGroup.getChildAt(i);
            if (child instanceof StickerAnnotationView) {
                ((StickerAnnotationView) child).setControlItemsHidden(true);
            } else if (child instanceof TextAnnotationView) {
                ((TextAnnotationView) child).setControlItemsHidden(true);
            }/*w  w  w  .j  a va2s . c om*/
        }
    }
}

From source file:com.ayuget.redface.ui.activity.ReplyActivity.java

private void styleToolbarButtons(ViewGroup toolbar) {
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        View childView = toolbar.getChildAt(i);

        if (childView instanceof ImageButton) {
            ImageButton imageButton = (ImageButton) childView;
            UiUtils.setDrawableColor(imageButton.getDrawable(), UiUtils.getReplyToolbarIconsColor(this));
        } else if (childView instanceof HorizontalScrollView || childView instanceof LinearLayout) {
            styleToolbarButtons((ViewGroup) childView);
        }//from   w  ww . j  ava  2s.  co  m
    }
}

From source file:com.genesys.pokemaps.MapActivity.java

public void startPokemoonLoop() {
    new Timer().schedule(new TimerTask() {
        @Override//  w  w  w.jav a 2  s  . c  o m
        public void run() {
            if (gameManager != null && (location != null)) {
                long startTime = System.currentTimeMillis();
                try {
                    // Updates our game location to match our real location.
                    gameManager.setPlayerLocation(location);

                    // Update our pokestops and add a marker on our map at its location.
                    // TODO: Add a map marker for pokestops.
                    // gameManager.updatePokestops();

                    // Cycles through our pokestops and loots them if the option is available.
                    for (PokestopLootResult lootResult : gameManager.lootPokestops()) {
                        switch (lootResult.getResult()) {
                        case SUCCESS:
                            showSnackBar("Pokestop was successfully looted. Gained "
                                    + lootResult.getExperience() + " XP");
                            Log.i(TAG, "Pokestop was successfully looted. Gained" + lootResult.getExperience()
                                    + " XP and " + lootResult.getItemsAwarded().size() + " items.");
                            Utils.vibrate(Constants.POKESTOP_VIBRATION_PATTERN, vibrator);
                            break;
                        case INVENTORY_FULL:
                            String invMsg = "Inventory too full to loot Pokestop";
                            showSnackBar(invMsg);
                            Log.i(TAG, invMsg);
                            break;
                        case IN_COOLDOWN_PERIOD:
                            String coolMsg = "Pokestop is currently in cooldown";
                            showSnackBar(coolMsg);
                            Log.i(TAG, coolMsg);
                            break;
                        default:
                            String errMsg = "Couldn't loot pokestop due to error "
                                    + lootResult.getResult().name();
                            showSnackBar(errMsg);
                            Log.i(TAG, errMsg);
                        }
                    }

                    final List<NearbyPokemon> nearbyPokemon = gameManager.getNearbyPokemon();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            for (int i = 0; i < nearbyContainer.getChildCount(); i++) {
                                View child = nearbyContainer.getChildAt(i);
                                if (child.getId() != R.id.no_nearby_text_view
                                        && child.getParent() == nearbyContainer) {
                                    nearbyContainer.removeViewAt(i--);
                                }
                            }

                            if (nearbyPokemon.size() > 0) {
                                // There are nearby Pokemon!
                                // Set our TextView visibility to gone.
                                nearbyTextView.setVisibility(View.GONE);
                                for (NearbyPokemon pokemon : nearbyPokemon) {
                                    Log.i(TAG, pokemon.getPokemonId().name() + " is nearby.");

                                    ViewGroup nearbyPokemonLayout = (ViewGroup) getLayoutInflater()
                                            .inflate(R.layout.nearby_pokemon, null);

                                    ImageView pokemonImage = (ImageView) nearbyPokemonLayout.getChildAt(1);
                                    ImageView pokemonBackground = (ImageView) nearbyPokemonLayout.getChildAt(0);

                                    int id = getResources().getIdentifier(
                                            pokemon.getPokemonId().name().toLowerCase(), "drawable",
                                            getPackageName());
                                    pokemonImage.setImageResource(id);

                                    int backgroundColor;
                                    switch (PokemonMetaRegistry.getMeta(pokemon.getPokemonId())
                                            .getPokemonClass()) {
                                    case VERY_COMMON:
                                        backgroundColor = Utils.getColor(MapActivity.this,
                                                R.color.veryCommonColor);
                                        break;
                                    case COMMON:
                                        backgroundColor = Utils.getColor(MapActivity.this, R.color.commonColor);
                                        break;
                                    case UNCOMMON:
                                        backgroundColor = Utils.getColor(MapActivity.this,
                                                R.color.uncommonColor);
                                        break;
                                    case RARE:
                                        backgroundColor = Utils.getColor(MapActivity.this, R.color.rareColor);
                                        break;
                                    case VERY_RARE:
                                        backgroundColor = Utils.getColor(MapActivity.this,
                                                R.color.veryRareColor);
                                        break;
                                    case EPIC:
                                        backgroundColor = Utils.getColor(MapActivity.this, R.color.epicColor);
                                        break;
                                    case LEGENDARY:
                                        backgroundColor = Utils.getColor(MapActivity.this,
                                                R.color.legendaryColor);
                                        break;
                                    case MYTHIC:
                                        backgroundColor = Utils.getColor(MapActivity.this, R.color.mythicColor);
                                        break;
                                    default:
                                        backgroundColor = Color.WHITE;
                                    }

                                    pokemonBackground.setColorFilter(backgroundColor);

                                    nearbyContainer.addView(nearbyPokemonLayout);
                                }
                            } else {
                                nearbyTextView.setVisibility(View.VISIBLE);
                            }
                        }
                    });

                    // Update our pokemon and add a marker on the map at its location.
                    // TODO: Add a map marker for catchable pokemon.
                    //gameManager.updateCatchablePokemon();

                    GameManager.Catch catchResult = gameManager.catchPokemon();
                    if (catchResult != null) {
                        String pokemon = PokeDictionary.getDisplayName(
                                catchResult.getCatchablePokemon().getPokemonId().getNumber(), Locale.ENGLISH);
                        String message;
                        switch (catchResult.getCatchResult().getStatus()) {
                        case CATCH_SUCCESS:
                            message = pokemon + " successfully captured";
                            Utils.vibrate(Constants.POKEMON_VIBRATION_PATTERN, vibrator);
                            break;
                        case CATCH_FLEE:
                            message = pokemon + " fled";
                            break;
                        case CATCH_MISSED:
                            message = pokemon + " missed";
                            break;
                        default:
                            message = "Unable to catch " + pokemon;
                        }
                        showSnackBar(message);
                        Log.i(TAG, message);
                    }

                    gameManager.updateGyms();

                } catch (LoginFailedException e) {
                    showSnackBar("Login failed. Credentials changed");
                } catch (RemoteServerException e) {
                    showSnackBar("Login failed. Servers may be down");
                } catch (NoSuchItemException e) {
                    showSnackBar("Not enough pokeballs to catch pokemon");
                } catch (AsyncPokemonGoException e) {
                    String username = preferences.getString(getString(R.string.username_preference_key), null);
                    String password = preferences.getString(getString(R.string.password_preference_key), null);
                    if (username != null || password != null) {
                        gameManager.loginPTC(username, password);
                    }
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                double scanTimeSeconds = (double) (System.currentTimeMillis() - startTime) / 1000;
                Log.i(TAG, "World scanning completed in " + scanTimeSeconds + " seconds.");
            }
        }
    }, 0, GAME_REFRESH_RATE);
}

From source file:loon.LGame.java

public void safeguardAndroidADView(android.view.View view) {
    try {//ww  w  . jav a  2 s  . com
        final android.view.ViewGroup vgp = (android.view.ViewGroup) view.getParent().getParent();
        if (vgp.getChildAt(1) != null) {
            vgp.removeViewAt(1);
        }
    } catch (Exception ex) {
    }
}