private void updateSelection() { if (mSelectedPlanet != null && mSelectionView != null) { mSelectionView.setVisibility(View.VISIBLE); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mSelectionView.getLayoutParams(); params.width = (int) ((((mSelectedPlanet.planet.getSize() - 10.0) / 8.0) + 4.0) * 10.0) + (int) (40 * getPixelScale()); params.height = params.width; params.leftMargin = (int) (getLeft() + mSelectedPlanet.centre.x - (params.width / 2)); params.topMargin = (int) (getTop() + mSelectedPlanet.centre.y - (params.height / 2)); mSelectionView.setLayoutParams(params); } }
public void selectPlanet(int planetIndex) { for (PlanetInfo planetInfo : mPlanetInfos) { if (planetInfo.planet.getIndex() == planetIndex) { mSelectedPlanet = planetInfo; firePlanetSelected(mSelectedPlanet.planet); if (mSelectedPlanet != null && mSelectionView != null) { updateSelection(); } else if (mSelectionView != null) { mSelectionView.setVisibility(View.GONE); } } } }
public void setSelectionView(SelectionView selectionView) { mSelectionView = selectionView; if (mSelectionView != null) { mSelectionView.setVisibility(View.GONE); } }