List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:dev.ukanth.ufirewall.MainActivity.java
private void reloadPreferences() { getSupportActionBar().setDisplayShowHomeEnabled(true); G.reloadPrefs();/*from w w w . j a v a2 s . c o m*/ checkPreferences(); //language Api.updateLanguage(getApplicationContext(), G.locale()); if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); } //verifyMultiProfile(); refreshHeader(); updateIconStatus(); NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(Api.NOTIFICATION_ID); if (G.disableIcons()) { this.findViewById(R.id.imageHolder).setVisibility(View.GONE); } else { this.findViewById(R.id.imageHolder).setVisibility(View.VISIBLE); } if (G.showFilter()) { this.findViewById(R.id.filerOption).setVisibility(View.VISIBLE); } else { this.findViewById(R.id.filerOption).setVisibility(View.GONE); } if (G.enableMultiProfile()) { this.findViewById(R.id.profileOption).setVisibility(View.VISIBLE); } else { this.findViewById(R.id.profileOption).setVisibility(View.GONE); } if (G.enableRoam()) { addColumns(R.id.img_roam); } else { hideColumns(R.id.img_roam); } if (G.enableVPN()) { addColumns(R.id.img_vpn); } else { hideColumns(R.id.img_vpn); } if (!Api.isMobileNetworkSupported(getApplicationContext())) { ImageView view = (ImageView) this.findViewById(R.id.img_3g); view.setVisibility(View.GONE); } else { this.findViewById(R.id.img_3g).setOnClickListener(this); } if (G.enableLAN()) { addColumns(R.id.img_lan); } else { hideColumns(R.id.img_lan); } updateRadioFilter(); if (G.enableMultiProfile()) { setupMultiProfile(true); } selectFilterGroup(); }
From source file:github.daneren2005.dsub.fragments.SelectDirectoryFragment.java
private void setupButtonEvents(View header) { ImageView shareButton = (ImageView) header.findViewById(R.id.select_album_share); if (share != null || podcastId != null || !Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_SHARED, true) || Util.isOffline(context) || !UserUtil.canShare() || artistInfo != null) { shareButton.setVisibility(View.GONE); } else {/* w w w. jav a2s . c o m*/ shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createShare(SelectDirectoryFragment.this.entries); } }); } final ImageButton starButton = (ImageButton) header.findViewById(R.id.select_album_star); if (directory != null && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true) && artistInfo == null) { if (directory.isStarred()) { starButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { starButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.star_outline)); } starButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleStarred(directory, new OnStarChange() { @Override void starChange(boolean starred) { if (directory.isStarred()) { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); starButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); } } }); } }); } else { starButton.setVisibility(View.GONE); } View ratingBarWrapper = header.findViewById(R.id.select_album_rate_wrapper); final RatingBar ratingBar = (RatingBar) header.findViewById(R.id.select_album_rate); if (directory != null && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true) && !Util.isOffline(context) && artistInfo == null) { ratingBar.setRating(directory.getRating()); ratingBarWrapper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRating(directory, new OnRatingChange() { @Override void ratingChange(int rating) { ratingBar.setRating(directory.getRating()); } }); } }); } else { ratingBar.setVisibility(View.GONE); } }
From source file:im.neon.adapters.VectorMessagesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); if (null != view) { view.setBackgroundColor(Color.TRANSPARENT); }/*from w w w . j a v a 2s . co m*/ ImageView e2eIconView = (ImageView) view.findViewById(R.id.message_adapter_e2e_icon); View senderMargin = view.findViewById(R.id.e2e_sender_margin); View senderNameView = view.findViewById(R.id.messagesAdapter_sender); // GA issue if (position >= getCount()) { return view; } MessageRow row = getItem(position); final Event event = row.getEvent(); if (mE2eIconByEventId.containsKey(event.eventId)) { senderMargin.setVisibility(senderNameView.getVisibility()); e2eIconView.setVisibility(View.VISIBLE); e2eIconView.setImageResource(mE2eIconByEventId.get(event.eventId)); int type = getItemViewType(position); if ((type == ROW_TYPE_IMAGE) || (type == ROW_TYPE_VIDEO)) { View bodyLayoutView = view.findViewById(org.matrix.androidsdk.R.id.messagesAdapter_body_layout); ViewGroup.MarginLayoutParams bodyLayout = (ViewGroup.MarginLayoutParams) bodyLayoutView .getLayoutParams(); ViewGroup.MarginLayoutParams e2eIconViewLayout = (ViewGroup.MarginLayoutParams) e2eIconView .getLayoutParams(); e2eIconViewLayout.setMargins(bodyLayout.leftMargin, e2eIconViewLayout.topMargin, e2eIconViewLayout.rightMargin, e2eIconViewLayout.bottomMargin); bodyLayout.setMargins(4, bodyLayout.topMargin, bodyLayout.rightMargin, bodyLayout.bottomMargin); e2eIconView.setLayoutParams(e2eIconViewLayout); bodyLayoutView.setLayoutParams(bodyLayout); } e2eIconView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mVectorMessagesAdapterEventsListener) { mVectorMessagesAdapterEventsListener.onE2eIconClick(event, mE2eDeviceByEventId.get(event.eventId)); } } }); } else { e2eIconView.setVisibility(View.GONE); senderMargin.setVisibility(View.GONE); } return view; }
From source file:com.nadmm.airports.ActivityBase.java
public void showAirportTitle(Cursor c) { View root = findViewById(R.id.airport_title_layout); TextView tv = (TextView) root.findViewById(R.id.facility_name); String code = c.getString(c.getColumnIndex(Airports.ICAO_CODE)); if (code == null || code.length() == 0) { code = c.getString(c.getColumnIndex(Airports.FAA_CODE)); }/*from w ww .j av a2s.c om*/ String tower = c.getString(c.getColumnIndex(Airports.TOWER_ON_SITE)); int color = tower.equals("Y") ? Color.rgb(48, 96, 144) : Color.rgb(128, 72, 92); tv.setTextColor(color); String name = c.getString(c.getColumnIndex(Airports.FACILITY_NAME)); String siteNumber = c.getString(c.getColumnIndex(Airports.SITE_NUMBER)); String type = DataUtils.decodeLandingFaclityType(siteNumber); tv.setText(String.format(Locale.US, "%s %s", name, type)); tv = (TextView) root.findViewById(R.id.facility_id); tv.setTextColor(color); tv.setText(code); tv = (TextView) root.findViewById(R.id.facility_info); String city = c.getString(c.getColumnIndex(Airports.ASSOC_CITY)); String state = c.getString(c.getColumnIndex(States.STATE_NAME)); if (state == null) { state = c.getString(c.getColumnIndex(Airports.ASSOC_COUNTY)); } tv.setText(String.format(Locale.US, "%s, %s", city, state)); tv = (TextView) root.findViewById(R.id.facility_info2); int distance = c.getInt(c.getColumnIndex(Airports.DISTANCE_FROM_CITY_NM)); String dir = c.getString(c.getColumnIndex(Airports.DIRECTION_FROM_CITY)); String status = c.getString(c.getColumnIndex(Airports.STATUS_CODE)); tv.setText(String.format(Locale.US, "%s, %d miles %s of city center", DataUtils.decodeStatus(status), distance, dir)); tv = (TextView) root.findViewById(R.id.facility_info3); float elev_msl = c.getFloat(c.getColumnIndex(Airports.ELEVATION_MSL)); int tpa_agl = c.getInt(c.getColumnIndex(Airports.PATTERN_ALTITUDE_AGL)); String est = ""; if (tpa_agl == 0) { tpa_agl = 1000; est = " (est.)"; } tv.setText(String.format(Locale.US, "%s MSL elev. - %s MSL TPA %s", FormatUtils.formatFeet(elev_msl), FormatUtils.formatFeet(elev_msl + tpa_agl), est)); String s = c.getString(c.getColumnIndex(Airports.EFFECTIVE_DATE)); GregorianCalendar endDate = new GregorianCalendar(Integer.valueOf(s.substring(6)), Integer.valueOf(s.substring(3, 5)), Integer.valueOf(s.substring(0, 2))); // Calculate end date of the 56-day cycle endDate.add(GregorianCalendar.DAY_OF_MONTH, 56); Calendar now = Calendar.getInstance(); if (now.after(endDate)) { // Show the expired warning tv = (TextView) root.findViewById(R.id.expired_label); tv.setVisibility(View.VISIBLE); } CheckBox cb = (CheckBox) root.findViewById(R.id.airport_star); cb.setChecked(mDbManager.isFavoriteAirport(siteNumber)); cb.setTag(siteNumber); cb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox cb = (CheckBox) v; String siteNumber = (String) cb.getTag(); if (cb.isChecked()) { mDbManager.addToFavoriteAirports(siteNumber); Toast.makeText(ActivityBase.this, "Added to favorites list", Toast.LENGTH_LONG).show(); } else { mDbManager.removeFromFavoriteAirports(siteNumber); Toast.makeText(ActivityBase.this, "Removed from favorites list", Toast.LENGTH_LONG).show(); } } }); ImageView iv = (ImageView) root.findViewById(R.id.airport_map); String lat = c.getString(c.getColumnIndex(Airports.REF_LATTITUDE_DEGREES)); String lon = c.getString(c.getColumnIndex(Airports.REF_LONGITUDE_DEGREES)); if (lat.length() > 0 && lon.length() > 0) { iv.setTag("geo:" + lat + "," + lon + "?z=16"); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String tag = (String) v.getTag(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tag)); startActivity(intent); } }); } else { iv.setVisibility(View.GONE); } }
From source file:com.fastbootmobile.encore.app.fragments.RecognitionFragment.java
private void loadAlbumArt(final String urlString, final ImageView iv) { new Thread() { public void run() { URL url;//from w w w.j a v a 2 s.c o m try { url = new URL(urlString); } catch (MalformedURLException e) { // Too bad mHandler.post(new Runnable() { @Override public void run() { mIvArt.setImageResource(R.drawable.album_placeholder); } }); return; } Log.d(TAG, "Loading album art: " + urlString); try { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); InputStream is = conn.getInputStream(); byte[] buffer = new byte[8192]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); int read; while ((read = is.read(buffer)) > 0) { baos.write(buffer, 0, read); } final Bitmap bmp = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.size()); if (bmp != null) { mHandler.post(new Runnable() { @Override public void run() { iv.setImageBitmap(bmp); iv.setVisibility(View.VISIBLE); } }); } else { Log.e(TAG, "Null bitmap from image"); } } catch (IOException e) { Log.e(TAG, "Error downloading album art", e); mHandler.post(new Runnable() { @Override public void run() { iv.setImageResource(R.drawable.album_placeholder); iv.setVisibility(View.VISIBLE); } }); } } }.start(); }
From source file:org.ementasua.SwipeyTabFragment.java
private void buildList(LayoutInflater inflater, TableLayout tl, Menu menu, boolean what, Button lunch, Button dinner, ImageView ib) { View v = null;/* w w w.ja va2s . co m*/ boolean t = true; String tmp = ""; final String shareMsg; if (!what) { lunch.setBackgroundResource(R.drawable.table_menu_title_select); dinner.setBackgroundResource(R.drawable.table_menu_title_deselect); lunch.setClickable(false); dinner.setClickable(true); tmp = "Almo?o:\n"; } else { lunch.setBackgroundResource(R.drawable.table_menu_title_deselect); dinner.setBackgroundResource(R.drawable.table_menu_title_select); lunch.setClickable(true); dinner.setClickable(false); tmp = "Jantar:\n"; } Animation animation = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in); animation.setDuration(1000); tl.startAnimation(animation); tl.removeAllViews(); if (!menu.isDisabled()) { for (Plate p : menu.getPlates()) { if (p.getName().length() > 0 && showPlate(p)) { v = buildRow(inflater, p); if (t) v.setBackgroundResource(R.drawable.border1); else v.setBackgroundResource(R.drawable.border2); t = !t; tl.addView(v); } if (p.getType().contains("Prato") && p.getName() != "" && p.getName().length() > 0) { tmp += p.getName() + "; "; } } ib.setVisibility(View.VISIBLE); } else { v = buildRow(inflater, new Plate("", menu.getDisabledText())); v.setBackgroundResource(R.drawable.border1); tl.addView(v); ib.setVisibility(View.GONE); } shareMsg = tmp; ib.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Ementas do " + getArguments().getString("title")); String shareMessage = getArguments().getString("title") + " - " + shareMsg; shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); startActivity(Intent.createChooser(shareIntent, "Partilhar para onde:")); } }); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void initializeContentView(View content) { TextView titleView = (TextView) content.findViewById(R.id.title); TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb); TextView descriptionView = (TextView) content.findViewById(R.id.description); titleView.setText(mTitle);//from ww w . j av a2 s . com breadcrumbView.setText(mBreadcrumb); descriptionView.setText(mDescription); final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon); iconImageView.setBackgroundColor(mIconBackgroundColor); // Force text fields to be focusable when accessibility is enabled. if (AccessibilityHelper.forceFocusableViews(getActivity())) { titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); descriptionView.setFocusable(true); descriptionView.setFocusableInTouchMode(true); breadcrumbView.setFocusable(true); breadcrumbView.setFocusableInTouchMode(true); } if (mIcon != null) { iconImageView.setImageDrawable(mIcon); updateViewSize(iconImageView); } else if (mIconBitmap != null) { iconImageView.setImageBitmap(mIconBitmap); updateViewSize(iconImageView); } else if (mIconUri != null) { iconImageView.setVisibility(View.INVISIBLE); /* BitmapDownloader bitmapDownloader = BitmapDownloader.getInstance( content.getContext()); mBitmapCallBack = new BitmapCallback() { @Override public void onBitmapRetrieved(Bitmap bitmap) { if (bitmap != null) { mIconBitmap = bitmap; iconImageView.setVisibility(View.VISIBLE); iconImageView.setImageBitmap(bitmap); updateViewSize(iconImageView); } } }; bitmapDownloader.getBitmap(new BitmapWorkerOptions.Builder( content.getContext()).resource(mIconUri) .width(iconImageView.getLayoutParams().width).build(), mBitmapCallBack); */ } else { iconImageView.setVisibility(View.GONE); } content.setTag(R.id.title, titleView); content.setTag(R.id.breadcrumb, breadcrumbView); content.setTag(R.id.description, descriptionView); content.setTag(R.id.icon, iconImageView); }
From source file:com.android.incallui.CallCardFragment.java
/** * Helper method for image view to handle animations. * * @param view The image view to show or hide. * @param isVisible {@code true} if we want to show the image, {@code false} to hide it. *//* w w w . j ava2s . c o m*/ private void showImageView(ImageView view, boolean isVisible) { if (view.getDrawable() == null) { if (isVisible) { AnimUtils.fadeIn(mElapsedTime, AnimUtils.DEFAULT_DURATION); } } else { // Cross fading is buggy and not noticeable due to the multiple calls to this method // that switch drawables in the middle of the cross-fade animations. Just show the // photo directly instead. view.setVisibility(isVisible ? View.VISIBLE : View.GONE); } }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
private void setupButtonEvents(View header) { ImageView shareButton = (ImageView) header.findViewById(R.id.select_album_share); if (share != null || podcastId != null || !Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_SHARED, true) || Util.isOffline(context) || !UserUtil.canShare() || artistInfo != null) { shareButton.setVisibility(View.GONE); } else {/*from w ww.j a va 2s . c om*/ shareButton.setVisibility(View.GONE); shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createShare(SelectDirectoryFragment.this.entries); } }); } final ImageButton starButton = (ImageButton) header.findViewById(R.id.select_album_star); if (directory != null && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true) && artistInfo == null) { if (directory.isStarred()) { starButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { starButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.star_outline)); } starButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UpdateHelper.toggleStarred(context, directory, new UpdateHelper.OnStarChange() { @Override public void starChange(boolean starred) { if (directory.isStarred()) { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); starButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); } } @Override public void starCommited(boolean starred) { } }); } }); starButton.setVisibility(View.GONE); } else { starButton.setVisibility(View.GONE); } View ratingBarWrapper = header.findViewById(R.id.select_album_rate_wrapper); final RatingBar ratingBar = (RatingBar) header.findViewById(R.id.select_album_rate); if (directory != null && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true) && !Util.isOffline(context) && artistInfo == null) { ratingBar.setRating(directory.getRating()); ratingBarWrapper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UpdateHelper.setRating(context, directory, new UpdateHelper.OnRatingChange() { @Override public void ratingChange(int rating) { ratingBar.setRating(directory.getRating()); } }); } }); ratingBar.setVisibility(View.GONE); } else { ratingBar.setVisibility(View.GONE); } }
From source file:com.google.samples.apps.sergio.ui.BaseActivity.java
private View makeNavDrawerItem(final int itemId, ViewGroup container) { boolean selected = getSelfNavDrawerItem() == itemId; int layoutToInflate = 0; if (itemId == NAVDRAWER_ITEM_SEPARATOR) { layoutToInflate = R.layout.navdrawer_separator; } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) { layoutToInflate = R.layout.navdrawer_separator; } else {/*from w ww . ja v a 2 s.c om*/ layoutToInflate = R.layout.navdrawer_item; } View view = getLayoutInflater().inflate(layoutToInflate, container, false); if (isSeparator(itemId)) { // we are done UIUtils.setAccessibilityIgnore(view); return view; } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); int iconId = itemId >= 0 && itemId < NAVDRAWER_ICON_RES_ID.length ? NAVDRAWER_ICON_RES_ID[itemId] : 0; int titleId = itemId >= 0 && itemId < NAVDRAWER_TITLE_RES_ID.length ? NAVDRAWER_TITLE_RES_ID[itemId] : 0; // set icon and text iconView.setVisibility(iconId > 0 ? View.VISIBLE : View.GONE); if (iconId > 0) { iconView.setImageResource(iconId); } titleView.setText(getString(titleId)); formatNavDrawerItem(view, itemId, selected); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onNavDrawerItemClicked(itemId); } }); return view; }