List of usage examples for android.widget ImageView setColorFilter
public void setColorFilter(ColorFilter cf)
From source file:com.google.samples.apps.sergio.ui.BaseActivity.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) { if (isSeparator(itemId)) { // not applicable return;/*from w w w . java2 s.co m*/ } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); if (selected) { view.setBackgroundResource(R.drawable.selected_navdrawer_item_background); } // configure its appearance according to whether or not it's selected titleView.setTextColor(selected ? getResources().getColor(R.color.navdrawer_text_color_selected) : getResources().getColor(R.color.navdrawer_text_color)); iconView.setColorFilter(selected ? getResources().getColor(R.color.navdrawer_icon_tint_selected) : getResources().getColor(R.color.navdrawer_icon_tint)); }
From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) { if (isSeparator(itemId)) { // not applicable return;//from w ww .ja v a2 s. co m } ImageView iconView = (ImageView) view.findViewById(com.saarang.samples.apps.iosched.R.id.icon); TextView titleView = (TextView) view.findViewById(com.saarang.samples.apps.iosched.R.id.title); // configure its appearance according to whether or not it's selected titleView.setTextColor(selected ? getResources().getColor(com.saarang.samples.apps.iosched.R.color.navdrawer_text_color_selected) : getResources().getColor(com.saarang.samples.apps.iosched.R.color.navdrawer_text_color)); iconView.setColorFilter(selected ? getResources().getColor(com.saarang.samples.apps.iosched.R.color.navdrawer_icon_tint_selected) : getResources().getColor(com.saarang.samples.apps.iosched.R.color.navdrawer_icon_tint)); }
From source file:com.example.ray.firstapp.bottombar.BottomBar.java
private void updateItems(final BottomBarItemBase[] bottomBarItems) { if (mItemContainer == null) { initializeViews();//w w w . ja v a 2s.co m } int index = 0; int biggestWidth = 0; mIsShiftingMode = MAX_FIXED_TAB_COUNT < bottomBarItems.length; if (!mIsDarkTheme && !mIgnoreNightMode && MiscUtils.isNightMode(mContext)) { mIsDarkTheme = true; } if (!mIsTabletMode && mIsShiftingMode) { mDefaultBackgroundColor = mCurrentBackgroundColor = mPrimaryColor; mBackgroundView.setBackgroundColor(mDefaultBackgroundColor); if (mContext instanceof Activity) { navBarMagic((Activity) mContext, this); } } else if (mIsDarkTheme) { darkThemeMagic(); } View[] viewsToAdd = new View[bottomBarItems.length]; for (BottomBarItemBase bottomBarItemBase : bottomBarItems) { int layoutResource; if (mIsShiftingMode && !mIsTabletMode) { layoutResource = R.layout.bb_bottom_bar_item_shifting; } else { layoutResource = mIsTabletMode ? R.layout.bb_bottom_bar_item_fixed_tablet : R.layout.bb_bottom_bar_item_fixed; } View bottomBarTab = View.inflate(mContext, layoutResource, null); ImageView icon = (ImageView) bottomBarTab.findViewById(R.id.bb_bottom_bar_icon); icon.setImageDrawable(bottomBarItemBase.getIcon(mContext)); if (!mIsTabletMode) { TextView title = (TextView) bottomBarTab.findViewById(R.id.bb_bottom_bar_title); title.setText(bottomBarItemBase.getTitle(mContext)); if (mPendingTextAppearance != -1) { MiscUtils.setTextAppearance(title, mPendingTextAppearance); } if (mPendingTypeface != null) { title.setTypeface(mPendingTypeface); } } if (mIsDarkTheme || (!mIsTabletMode && mIsShiftingMode)) { icon.setColorFilter(mWhiteColor); } if (bottomBarItemBase instanceof BottomBarTab) { bottomBarTab.setId(((BottomBarTab) bottomBarItemBase).id); } if (index == mCurrentTabPosition) { selectTab(bottomBarTab, false); } else { unselectTab(bottomBarTab, false); } if (!mIsTabletMode) { if (bottomBarTab.getWidth() > biggestWidth) { biggestWidth = bottomBarTab.getWidth(); } viewsToAdd[index] = bottomBarTab; } else { mItemContainer.addView(bottomBarTab); } bottomBarTab.setOnClickListener(this); bottomBarTab.setOnLongClickListener(this); index++; } if (!mIsTabletMode) { int proposedItemWidth = Math.min(MiscUtils.dpToPixel(mContext, mScreenWidth / bottomBarItems.length), mMaxFixedItemWidth); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(proposedItemWidth, LinearLayout.LayoutParams.WRAP_CONTENT); for (View bottomBarView : viewsToAdd) { bottomBarView.setLayoutParams(params); mItemContainer.addView(bottomBarView); } } if (mPendingTextAppearance != -1) { mPendingTextAppearance = -1; } if (mPendingTypeface != null) { mPendingTypeface = null; } }
From source file:com.harlan.jxust.ui.view.bottombar.BottomBar.java
private void updateItems(final BottomBarItemBase[] bottomBarItems) { if (mItemContainer == null) { initializeViews();// ww w. j a v a 2s .c o m } int index = 0; int biggestWidth = 0; mIsShiftingMode = MAX_FIXED_TAB_COUNT < bottomBarItems.length; if (!mIsDarkTheme && !mIgnoreNightMode && MiscUtils.isNightMode(mContext)) { mIsDarkTheme = true; } if (mIsDarkTheme) { darkThemeMagic(); } else if (!mIsTabletMode && mIsShiftingMode) { mDefaultBackgroundColor = mCurrentBackgroundColor = mPrimaryColor; mBackgroundView.setBackgroundColor(mDefaultBackgroundColor); if (mContext instanceof Activity) { navBarMagic((Activity) mContext, this); } } View[] viewsToAdd = new View[bottomBarItems.length]; for (BottomBarItemBase bottomBarItemBase : bottomBarItems) { int layoutResource; if (mIsShiftingMode && !mIsTabletMode) { layoutResource = R.layout.bb_bottom_bar_item_shifting; } else { layoutResource = mIsTabletMode ? R.layout.bb_bottom_bar_item_fixed_tablet : R.layout.bb_bottom_bar_item_fixed; } View bottomBarTab = View.inflate(mContext, layoutResource, null); ImageView icon = (ImageView) bottomBarTab.findViewById(R.id.bb_bottom_bar_icon); icon.setImageDrawable(bottomBarItemBase.getIcon(mContext)); if (!mIsTabletMode) { TextView title = (TextView) bottomBarTab.findViewById(R.id.bb_bottom_bar_title); title.setText(bottomBarItemBase.getTitle(mContext)); if (mPendingTextAppearance != -1) { MiscUtils.setTextAppearance(title, mPendingTextAppearance); } if (mPendingTypeface != null) { title.setTypeface(mPendingTypeface); } } if (mIsDarkTheme || (!mIsTabletMode && mIsShiftingMode)) { icon.setColorFilter(mWhiteColor); } if (bottomBarItemBase instanceof BottomBarTab) { bottomBarTab.setId(((BottomBarTab) bottomBarItemBase).id); } if (index == mCurrentTabPosition) { selectTab(bottomBarTab, false); } else { unselectTab(bottomBarTab, false); } if (!mIsTabletMode) { if (bottomBarTab.getWidth() > biggestWidth) { biggestWidth = bottomBarTab.getWidth(); } viewsToAdd[index] = bottomBarTab; } else { mItemContainer.addView(bottomBarTab); } bottomBarTab.setOnClickListener(this); bottomBarTab.setOnLongClickListener(this); index++; } if (!mIsTabletMode) { int proposedItemWidth = Math.min(MiscUtils.dpToPixel(mContext, mScreenWidth / bottomBarItems.length), mMaxFixedItemWidth); mInActiveShiftingItemWidth = (int) (proposedItemWidth * 0.9); mActiveShiftingItemWidth = (int) (proposedItemWidth + (proposedItemWidth * (bottomBarItems.length * 0.1))); for (View bottomBarView : viewsToAdd) { LinearLayout.LayoutParams params; if (mIsShiftingMode && !mIgnoreShiftingResize) { if (TAG_BOTTOM_BAR_VIEW_ACTIVE.equals(bottomBarView.getTag())) { params = new LinearLayout.LayoutParams(mActiveShiftingItemWidth, LinearLayout.LayoutParams.WRAP_CONTENT); } else { params = new LinearLayout.LayoutParams(mInActiveShiftingItemWidth, LinearLayout.LayoutParams.WRAP_CONTENT); } } else { params = new LinearLayout.LayoutParams(proposedItemWidth, LinearLayout.LayoutParams.WRAP_CONTENT); } bottomBarView.setLayoutParams(params); mItemContainer.addView(bottomBarView); } } if (mPendingTextAppearance != -1) { mPendingTextAppearance = -1; } if (mPendingTypeface != null) { mPendingTypeface = null; } }
From source file:com.filemanager.free.adapters.DrawerAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (values.get(position).isSection()) { ImageView view = new ImageView(context); if (m.theme1 == 0) view.setImageResource(R.color.divider); else//from ww w.j a v a2s . c o m view.setImageResource(R.color.divider_dark); view.setClickable(false); view.setFocusable(false); if (m.theme1 == 0) view.setBackgroundColor(Color.WHITE); else view.setBackgroundResource(R.color.background_material_dark); view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17))); view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8)); return view; } else { View view = inflater.inflate(R.layout.drawerrow, parent, false); final TextView txtTitle = (TextView) view.findViewById(R.id.firstline); final ImageView imageView = (ImageView) view.findViewById(R.id.icon); if (m.theme1 == 0) { view.setBackgroundResource(R.drawable.safr_ripple_white); } else { view.setBackgroundResource(R.drawable.safr_ripple_black); } view.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { m.selectItem(position); } // TODO: Implement this method }); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!getItem(position).isSection()) // not to remove the first bookmark (storage) and permanent bookmarks if (position > m.storage_count && position < values.size() - 7) { EntryItem item = (EntryItem) getItem(position); String path = (item).getPath(); if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) { m.renameBookmark((item).getTitle(), path); } else if (path.startsWith("smb:/")) { m.showSMBDialog(item.getTitle(), path, true); } } else if (position < m.storage_count) { String path = ((EntryItem) getItem(position)).getPath(); if (!path.equals("/")) new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m, m.theme1); } // return true to denote no further processing return true; } }); txtTitle.setText(((EntryItem) (values.get(position))).getTitle()); imageView.setImageDrawable(getDrawable(position)); imageView.clearColorFilter(); if (myChecked.get(position)) { if (m.theme1 == 0) view.setBackgroundColor(Color.parseColor("#ffeeeeee")); else view.setBackgroundColor(Color.parseColor("#ff424242")); imageView.setColorFilter(fabskin); txtTitle.setTextColor(Color.parseColor(m.fabskin)); } else { if (m.theme1 == 0) { imageView.setColorFilter(Color.parseColor("#666666")); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black)); } else { imageView.setColorFilter(Color.WHITE); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); } } return view; } }
From source file:com.google.samples.apps.iosched.ui.BaseActivity.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that * shows which account the user is logged in as, and lets them switch accounts. It also * shows the user's Google+ cover photo as background. *//*from w w w . jav a 2 s . c om*/ private void setupAccountBox() { mAccountListContainer = (LinearLayout) findViewById(R.id.account_list); if (mAccountListContainer == null) { //This activity does not have an account box return; } final View chosenAccountView = findViewById(R.id.chosen_account_view); Account chosenAccount = AccountUtils.getActiveAccount(this); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); mAccountListContainer.setVisibility(View.INVISIBLE); } AccountManager am = AccountManager.get(this); Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE); List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray)); accounts.remove(chosenAccount); ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text); TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text); mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator); String name = AccountUtils.getPlusName(this); if (name == null) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setVisibility(View.VISIBLE); nameTextView.setText(name); } String imageUrl = AccountUtils.getPlusImageUrl(this); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(this); if (coverImageUrl != null) { findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.GONE); coverImageView.setVisibility(View.VISIBLE); coverImageView.setContentDescription( getResources().getString(R.string.navview_header_user_image_content_description)); mImageLoader.loadImage(coverImageUrl, coverImageView); coverImageView.setColorFilter(getResources().getColor(R.color.light_content_scrim)); } email.setText(chosenAccount.name); if (accounts.isEmpty()) { // There's only one account on the device, so no need for a switcher. mExpandAccountBoxIndicator.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); chosenAccountView.setEnabled(false); return; } chosenAccountView.setEnabled(true); mExpandAccountBoxIndicator.setVisibility(View.VISIBLE); chosenAccountView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountBoxExpanded = !mAccountBoxExpanded; setupAccountBoxToggle(); } }); setupAccountBoxToggle(); populateAccountList(accounts); }
From source file:fr.shywim.antoinedaniel.ui.fragment.VideoDetailsFragment.java
private void bindSound(View view, Cursor cursor) { AppState appState = AppState.getInstance(); final View card = view; final View downloadFrame = view.findViewById(R.id.sound_download_frame); final TextView tv = (TextView) view.findViewById(R.id.grid_text); final SquareImageView siv = (SquareImageView) view.findViewById(R.id.grid_image); final ImageView star = (ImageView) view.findViewById(R.id.ic_sound_fav); final ImageView menu = (ImageView) view.findViewById(R.id.ic_sound_menu); final String soundName = cursor .getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_SOUND_NAME)); String imgId = cursor.getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_IMAGE_NAME)); final String description = cursor.getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_DESC)); final boolean favorite = appState.favSounds.contains(soundName) || cursor.getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_FAVORITE)) == 1; final boolean widget = appState.widgetSounds.contains(soundName) || cursor.getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_WIDGET)) == 1; final boolean downloaded = cursor .getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_DOWNLOADED)) != 0; new Handler().post(new Runnable() { @Override//from w w w . j a va 2 s.c om public void run() { ContentValues cv = new ContentValues(); File sndFile = new File(mContext.getExternalFilesDir(null) + "/snd/" + soundName + ".ogg"); if (downloaded && !sndFile.exists()) { cv.put(ProviderContract.SoundEntry.COLUMN_DOWNLOADED, 0); mContext.getContentResolver().update( Uri.withAppendedPath(ProviderConstants.SOUND_DOWNLOAD_NOTIFY_URI, soundName), cv, null, null); } } }); final View.OnClickListener playSound = new View.OnClickListener() { @Override public void onClick(View v) { String category = mContext.getString(R.string.ana_cat_sound); String action = mContext.getString(R.string.ana_act_play); Bundle extras = new Bundle(); extras.putString(SoundFragment.SOUND_TO_PLAY, soundName); extras.putBoolean(SoundFragment.LOOP, SoundUtils.isLoopingSet()); Intent intent = new Intent(mContext, SoundService.class); intent.putExtras(extras); mContext.startService(intent); AnalyticsUtils.sendEvent(category, action, soundName); } }; final View.OnClickListener downloadSound = new View.OnClickListener() { @Override public void onClick(View v) { card.setOnClickListener(null); RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new BounceInterpolator()); animation.setFillAfter(true); animation.setFillEnabled(true); animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); downloadFrame.findViewById(R.id.sound_download_icon).startAnimation(animation); DownloadService.startActionDownloadSound(mContext, soundName, new SoundUtils.DownloadResultReceiver(new Handler(), downloadFrame, playSound, this)); } }; if (downloaded) { downloadFrame.setVisibility(View.GONE); downloadFrame.findViewById(R.id.sound_download_icon).clearAnimation(); card.setOnClickListener(playSound); } else { downloadFrame.setAlpha(1); downloadFrame.findViewById(R.id.sound_download_icon).setScaleX(1); downloadFrame.findViewById(R.id.sound_download_icon).setScaleY(1); downloadFrame.setVisibility(View.VISIBLE); card.setOnClickListener(downloadSound); } menu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final ImageView menuIc = (ImageView) v; PopupMenu popup = new PopupMenu(mContext, menuIc); Menu menu = popup.getMenu(); popup.getMenuInflater().inflate(R.menu.sound_menu, menu); if (favorite) menu.findItem(R.id.action_sound_fav).setTitle("Retirer des favoris"); if (widget) menu.findItem(R.id.action_sound_wid).setTitle("Retirer du widget"); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_sound_fav: SoundUtils.addRemoveFavorite(mContext, soundName); return true; case R.id.action_sound_wid: SoundUtils.addRemoveWidget(mContext, soundName); return true; /*case R.id.action_sound_add: return true;*/ case R.id.action_sound_ring: SoundUtils.addRingtone(mContext, soundName, description); return true; case R.id.action_sound_share: AnalyticsUtils.sendEvent(mContext.getString(R.string.ana_cat_soundcontext), mContext.getString(R.string.ana_act_weblink), soundName); ClipboardManager clipboard = (ClipboardManager) mContext .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("BAD link", "http://bad.shywim.fr/" + soundName); clipboard.setPrimaryClip(clip); Toast.makeText(mContext, R.string.toast_link_copied, Toast.LENGTH_LONG).show(); return true; case R.id.action_sound_delete: SoundUtils.delete(mContext, soundName); return true; default: return false; } } }); popup.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { menuIc.setColorFilter(mContext.getResources().getColor(R.color.text_caption_dark)); } }); menuIc.setColorFilter(mContext.getResources().getColor(R.color.black)); popup.show(); } }); tv.setText(description); siv.setTag(imgId); if (appState.favSounds.contains(soundName)) { star.setVisibility(View.VISIBLE); } else if (favorite) { star.setVisibility(View.VISIBLE); appState.favSounds.add(soundName); } else { star.setVisibility(View.INVISIBLE); } File file = new File(mContext.getExternalFilesDir(null) + "/img/" + imgId + ".jpg"); Picasso.with(mContext).load(file).placeholder(R.drawable.noimg).fit().into(siv); }
From source file:com.genesys.pokemaps.MapActivity.java
public void startPokemoonLoop() { new Timer().schedule(new TimerTask() { @Override/*ww w . j a v a2 s . com*/ 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); }