List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:com.example.zf_android.activity.MerchantEdit.java
@Override protected void onActivityResult(final int requestCode, int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) { return;/*from w w w .ja v a2 s. com*/ } String value = ""; if (data != null) { value = data.getStringExtra("value"); } switch (requestCode) { case TYPE_1: merchantEntity.setTitle(value); tv1.setText(value); break; case TYPE_2: merchantEntity.setLegalPersonName(value); tv2.setText(value); break; case TYPE_3: merchantEntity.setLegalPersonCardId(value); tv3.setText(value); break; case TYPE_4: merchantEntity.setBusinessLicenseNo(value); tv4.setText(value); break; case TYPE_5: merchantEntity.setTaxRegisteredNo(value); tv5.setText(value); break; case TYPE_6: merchantEntity.setOrganizationCodeNo(value); tv6.setText(value); break; case TYPE_7: Province province = (Province) data.getSerializableExtra(Constants.CityIntent.SELECTED_PROVINCE); City city = (City) data.getSerializableExtra(Constants.CityIntent.SELECTED_CITY); if (province == null || city == null) { merchantEntity.setCityId(0); tv7.setText(""); } else { merchantEntity.setCityId(city.getId()); tv7.setText(province.getName() + city.getName()); } break; case TYPE_KHYH: merchantEntity.setAccountBankName(value); tvkhyh.setText(value); break; case TYPE_8: merchantEntity.setBankOpenAccount(value); tv8.setText(value); break; case REQUEST_UPLOAD_IMAGE: case REQUEST_TAKE_PHOTO: { final LinearLayout layout = linearLayout.get(MerchantEdit.this.type); final Handler handler = new Handler() { private int type; @Override public void handleMessage(Message msg) { this.type = MerchantEdit.this.type; if (msg.what == 1) { // CommonUtil.toastShort(MerchantEdit.this, // (String) msg.obj); layout.setClickable(false); layout.findViewById(R.id.imgView).setVisibility(View.VISIBLE); layout.findViewById(R.id.textView).setVisibility(View.GONE); String url = (String) msg.obj; layout.setClickable(true); switch (type) { case TYPE_10: merchantEntity.setCardIdFrontPhotoPath(url); break; case TYPE_11: merchantEntity.setCardIdBackPhotoPath(url); break; case TYPE_12: merchantEntity.setBodyPhotoPath(url); break; case TYPE_13: merchantEntity.setLicenseNoPicPath(url); break; case TYPE_14: merchantEntity.setTaxNoPicPath(url); break; case TYPE_15: merchantEntity.setOrgCodeNoPicPath(url); break; case TYPE_16: merchantEntity.setAccountPicPath(url); break; default: break; } } else { CommonUtil.toastShort(MerchantEdit.this, getString(R.string.toast_upload_failed)); layout.setClickable(true); } } }; if (null != layout) { ImageView imgView = (ImageView) layout.findViewById(R.id.imgView); TextView textView = (TextView) layout.findViewById(R.id.textView); imgView.setVisibility(View.GONE); textView.setVisibility(View.VISIBLE); textView.setText(getString(R.string.apply_uploading)); layout.setClickable(false); } new Thread() { @Override public void run() { String realPath = ""; if (requestCode == REQUEST_TAKE_PHOTO) { realPath = photoPath; } else { Uri uri = data.getData(); if (uri != null) { realPath = Tools.getRealPathFromURI(MerchantEdit.this, uri); } } if (TextUtils.isEmpty(realPath)) { handler.sendEmptyMessage(0); return; } CommonUtil.uploadFile(realPath, "img", new CommonUtil.OnUploadListener() { @Override public void onSuccess(String result) { try { JSONObject jo = new JSONObject(result); String url = jo.getString("result"); Message msg = new Message(); msg.what = 1; msg.obj = url; handler.sendMessage(msg); } catch (JSONException e) { handler.sendEmptyMessage(0); } } @Override public void onFailed(String message) { handler.sendEmptyMessage(0); } }); } }.start(); break; } default: break; } }
From source file:com.amazon.android.contentbrowser.helper.AuthHelper.java
/** * Load powered by logo from preferences with Glide. * * @param context The context to use. * @param poweredByLogoImageView The image view to use. *///from w w w .ja va 2 s .com public void loadPoweredByLogo(Context context, ImageView poweredByLogoImageView) { try { String mvpdUrl = Preferences.getString(PreferencesConstants.MVPD_LOGO_URL); if (poweredByLogoImageView == null || mvpdUrl.isEmpty()) { Log.d(TAG, "No MVPD image view or URL found."); return; } poweredByLogoImageView.setVisibility(View.INVISIBLE); RequestListener listener = new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { poweredByLogoImageView.setVisibility(View.INVISIBLE); Log.e(TAG, "Get image with glide failed for powered by logo!!!", e); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { poweredByLogoImageView.setVisibility(View.VISIBLE); return false; } }; GlideHelper.loadImageIntoView(poweredByLogoImageView, context, mvpdUrl, listener, android.R.color.transparent, new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent))); } catch (Exception e) { Log.e(TAG, "loadPoweredByLogo failed, activity may not include it.", e); } }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Drop money from the top of the layout to the bottom simulating that a * coin or bill is inserted in the moneybox. * /*from www.j ava 2s .c o m*/ * @param leftMargin * Left side of the coin/bill * @param width * Width of the image to slide down * @param m * Movement with the value of the money to drop */ protected void dropMoney(int leftMargin, int width, Movement m) { ImageView money; AnimationSet moneyDrop; RelativeLayout layout; RelativeLayout.LayoutParams lpParams; Rect r; Activity parent; CurrencyValueDef curr; parent = getActivity(); curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount())); r = curr.getDrawable().getBounds(); money = new ImageView(parent); money.setVisibility(View.INVISIBLE); money.setImageDrawable(curr.getDrawable().getConstantState().newDrawable()); money.setTag(curr); money.setId((int) m.getIdMovement()); layout = findLayout(); lpParams = new RelativeLayout.LayoutParams(r.width(), r.height()); lpParams.leftMargin = leftMargin; lpParams.rightMargin = layout.getWidth() - (leftMargin + width); lpParams.topMargin = 0; lpParams.bottomMargin = r.height(); layout.addView(money, lpParams); moneyDrop = createDropAnimation(money, layout, curr); money.setVisibility(View.VISIBLE); SoundsManager.playMoneySound(curr.getType()); VibratorManager.vibrateMoneyDrop(curr.getType()); money.startAnimation(moneyDrop); }
From source file:android.support.v7.widget.SuggestionsAdapter.java
/** * Sets the drawable in an image view, makes sure the view is only visible if there * is a drawable./* w w w. j a v a2s .co m*/ */ private void setViewDrawable(ImageView v, Drawable drawable, int nullVisibility) { // Set the icon even if the drawable is null, since we need to clear any // previous icon. v.setImageDrawable(drawable); if (drawable == null) { v.setVisibility(nullVisibility); } else { v.setVisibility(View.VISIBLE); // This is a hack to get any animated drawables (like a 'working' spinner) // to animate. You have to setVisible true on an AnimationDrawable to get // it to start animating, but it must first have been false or else the // call to setVisible will be ineffective. We need to clear up the story // about animated drawables in the future, see http://b/1878430. drawable.setVisible(false, false); drawable.setVisible(true, false); } }
From source file:net.reichholf.dreamdroid.fragment.MediaPlayerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dual_list_media_view, null, false); setAdapter(v);//from w w w . ja v a 2s . c o m // only if detail view is available the application should have // listeners for the buttons if (isDetailViewAvailable(v)) { ImageButton togglePlaylistButton = (ImageButton) v.findViewById(R.id.toggle_playlist); ListView playList = (ListView) v.findViewById(R.id.playlist); playList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) { ExtendedHashMap item = mPlaylist.get(position); playFile(item.getString(Mediaplayer.KEY_SERVICE_REFERENCE), PLAYLIST_AS_ROOT); } }); playList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ExtendedHashMap item = mPlaylist.get(position); deleteFromPlaylist(item.getString(Mediaplayer.KEY_SERVICE_REFERENCE)); return true; } }); togglePlaylistButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ListView playList = (ListView) getView().findViewById(R.id.playlist); ImageView cover = (ImageView) getView().findViewById(R.id.cover); int vis = playList.getVisibility(); playList.setVisibility(cover.getVisibility()); cover.setVisibility(vis); } }); ImageButton playButton = (ImageButton) v.findViewById(R.id.imageButtonPlay); playButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { play(); } }); ImageButton stopButton = (ImageButton) v.findViewById(R.id.imageButtonStop); stopButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { stop(); } }); ImageButton previousButton = (ImageButton) v.findViewById(R.id.imageButtonPrevious); previousButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { previous(); } }); ImageButton nextbutton = (ImageButton) v.findViewById(R.id.imageButtonNext); nextbutton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { next(); } }); } SlidingPaneLayout spl = (SlidingPaneLayout) v.findViewById(R.id.sliding_pane); if (spl != null) { spl.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { @Override public void onPanelSlide(View view, float v) { return; } @Override public void onPanelOpened(View view) { getListView().setEnabled(true); getActionBarActivity().supportInvalidateOptionsMenu(); } @Override public void onPanelClosed(View view) { getListView().setEnabled(false); getActionBarActivity().supportInvalidateOptionsMenu(); } }); spl.openPane(); } reloadPlaylist(); reload(); return v; }
From source file:com.koushikdutta.superuser.FragmentIntro.java
@Nullable @Override// ww w . j a v a 2 s. co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View parent = inflater.inflate(layoutResId, container, false); if (layoutResId != R.layout.fragment_intro_0) return parent; final ImageView superuser = (ImageView) parent.findViewById(R.id.superuser); final ImageView background = (ImageView) parent.findViewById(R.id.superuser_back); final TextView title = (TextView) parent.findViewById(R.id.title); final TextView desc = (TextView) parent.findViewById(R.id.tour); final Animation fadeIn, zoomIn; fadeIn = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in); zoomIn = AnimationUtils.loadAnimation(getContext(), R.anim.zoom_in); fadeIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { background.startAnimation(zoomIn); background.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); zoomIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { Animation fadeIn2 = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in); fadeIn2.setDuration(1000); fadeIn2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { Animation fadeIn3 = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in); fadeIn3.setDuration(400); fadeIn3.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { ((ActivityIntro) getActivity()).setProgressButtonEnabled(true); } @Override public void onAnimationRepeat(Animation animation) { } }); desc.startAnimation(fadeIn3); desc.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); title.startAnimation(fadeIn2); title.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); new Handler().postDelayed(new Runnable() { @Override public void run() { superuser.startAnimation(fadeIn); superuser.setVisibility(View.VISIBLE); } }, 600); return parent; }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
/** * Determines visibility of a social icon, sets up a click listener to allow the user to * navigate to the social network associated with the icon, and sets up a content description * for the icon.//from w w w . j a va2 s . co m */ private void setUpSpeakerSocialIcon(final SessionDetailModel.Speaker speaker, ImageView socialIcon, final String socialUrl, String socialNetworkName, final String packageName) { if (socialUrl == null || socialUrl.isEmpty()) { socialIcon.setVisibility(View.GONE); } else { socialIcon.setContentDescription( getString(R.string.speaker_social_page, socialNetworkName, speaker.getName())); socialIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UIUtils.fireSocialIntent(getActivity(), Uri.parse(socialUrl), packageName); } }); } }
From source file:fm.krui.kruifm.StreamFragment.java
/** * Enables and disables the loading indicator for UI views. * @param showLoadingIndicator True to enable, false to disable. *//*from w w w.j a v a 2s . c o m*/ private void setLoadingIndicator(final boolean showLoadingIndicator) { Log.v(TAG, "setLoadingIndicator called!"); Log.v(TAG, "Called with " + showLoadingIndicator + " parameter."); // Instantiate views ProgressBar progressBar = (ProgressBar) getActivity().findViewById(R.id.album_art_progressbar); ImageView albumArtPaneImageView = (ImageView) getActivity().findViewById(R.id.album_art_pane); ImageView albumArtLoadingPaneImageView = (ImageView) getActivity() .findViewById(R.id.album_art_loading_pane); if (showLoadingIndicator) { // Show loading indicators progressBar.setVisibility(View.VISIBLE); albumArtLoadingPaneImageView.setVisibility(View.VISIBLE); albumArtPaneImageView.setVisibility(View.INVISIBLE); } else { // Hide progressBar and placeholder image and re-show album art pane. progressBar.setVisibility(View.INVISIBLE); albumArtLoadingPaneImageView.setVisibility(View.INVISIBLE); albumArtPaneImageView.setVisibility(View.VISIBLE); } }
From source file:org.mariotaku.twidere.activity.support.CustomTabEditorActivity.java
public void setExtraFieldView(final View view, final Object value) { final TextView text1 = (TextView) view.findViewById(android.R.id.text1); final TextView text2 = (TextView) view.findViewById(android.R.id.text2); final ImageView icon = (ImageView) view.findViewById(android.R.id.icon); final boolean displayProfileImage = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true); final boolean displayName = mPreferences.getBoolean(KEY_NAME_FIRST, true); final UserColorNameManager manager = UserColorNameManager.getInstance(this); text1.setVisibility(View.VISIBLE); text2.setVisibility(View.VISIBLE); icon.setVisibility(displayProfileImage ? View.VISIBLE : View.GONE); if (value instanceof ParcelableUser) { final ParcelableUser user = (ParcelableUser) value; text1.setText(manager.getUserNickname(user.id, user.name, false)); text2.setText("@" + user.screen_name); if (displayProfileImage) { mImageLoader.displayProfileImage(icon, user.profile_image_url); }//from w w w . j a v a2 s . co m } else if (value instanceof ParcelableUserList) { final ParcelableUserList userList = (ParcelableUserList) value; final String createdBy = manager.getDisplayName(userList, displayName, false); text1.setText(userList.name); text2.setText(getString(R.string.created_by, createdBy)); if (displayProfileImage) { mImageLoader.displayProfileImage(icon, userList.user_profile_image_url); } } else if (value instanceof CharSequence) { text2.setVisibility(View.GONE); icon.setVisibility(View.GONE); text1.setText((CharSequence) value); } }
From source file:org.schabi.newpipe.detail.VideoItemDetailFragment.java
private void updateInfo(final StreamInfo info) { Activity a = getActivity();// w ww .ja v a 2 s . co m RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detail_text_content_layout); final TextView videoTitleView = (TextView) activity.findViewById(R.id.detail_video_title_view); TextView uploaderView = (TextView) activity.findViewById(R.id.detail_uploader_view); TextView viewCountView = (TextView) activity.findViewById(R.id.detail_view_count_view); TextView thumbsUpView = (TextView) activity.findViewById(R.id.detail_thumbs_up_count_view); TextView thumbsDownView = (TextView) activity.findViewById(R.id.detail_thumbs_down_count_view); TextView uploadDateView = (TextView) activity.findViewById(R.id.detail_upload_date_view); TextView descriptionView = (TextView) activity.findViewById(R.id.detail_description_view); RecyclerView nextStreamView = (RecyclerView) activity.findViewById(R.id.detail_next_stream_content); RelativeLayout nextVideoRootFrame = (RelativeLayout) activity .findViewById(R.id.detail_next_stream_root_layout); TextView similarTitle = (TextView) activity.findViewById(R.id.detail_similar_title); Button backgroundButton = (Button) activity .findViewById(R.id.detail_stream_thumbnail_window_background_button); View topView = activity.findViewById(R.id.detailTopView); Button channelButton = (Button) activity.findViewById(R.id.channel_button); // prevents a crash if the activity/fragment was already left when the response came if (channelButton != null) { progressBar.setVisibility(View.GONE); if (info.next_video != null) { // todo: activate this function or remove it nextStreamView.setVisibility(View.GONE); } else { nextStreamView.setVisibility(View.GONE); activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE); } textContentLayout.setVisibility(View.VISIBLE); if (android.os.Build.VERSION.SDK_INT < 18) { playVideoButton.setVisibility(View.VISIBLE); } else { ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view); playArrowView.setVisibility(View.VISIBLE); } if (!showNextStreamItem) { nextVideoRootFrame.setVisibility(View.GONE); similarTitle.setVisibility(View.GONE); } videoTitleView.setText(info.title); topView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == android.view.MotionEvent.ACTION_UP) { ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view); View extra = activity.findViewById(R.id.detailExtraView); if (extra.getVisibility() == View.VISIBLE) { extra.setVisibility(View.GONE); arrow.setImageResource(R.drawable.arrow_down); } else { extra.setVisibility(View.VISIBLE); arrow.setImageResource(R.drawable.arrow_up); } } return true; } }); // Since newpipe is designed to work even if certain information is not available, // the UI has to react on missing information. videoTitleView.setText(info.title); if (!info.uploader.isEmpty()) { uploaderView.setText(info.uploader); } else { activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE); } if (info.view_count >= 0) { viewCountView.setText(Localization.localizeViewCount(info.view_count, a)); } else { viewCountView.setVisibility(View.GONE); } if (info.dislike_count >= 0) { thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a)); } else { thumbsDownView.setVisibility(View.INVISIBLE); activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE); } if (info.like_count >= 0) { thumbsUpView.setText(Localization.localizeNumber(info.like_count, a)); } else { thumbsUpView.setVisibility(View.GONE); activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE); thumbsDownView.setVisibility(View.GONE); activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE); } if (!info.upload_date.isEmpty()) { uploadDateView.setText(Localization.localizeDate(info.upload_date, a)); } else { uploadDateView.setVisibility(View.GONE); } if (!info.description.isEmpty()) { descriptionView.setText(Html.fromHtml(info.description)); } else { descriptionView.setVisibility(View.GONE); } descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); // parse streams Vector<VideoStream> streamsToUse = new Vector<>(); for (VideoStream i : info.video_streams) { if (useStream(i, streamsToUse)) { streamsToUse.add(i); } } textContentLayout.setVisibility(View.VISIBLE); if (info.next_video == null) { activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE); } if (info.related_streams != null && !info.related_streams.isEmpty()) { initSimilarVideos(info); } else { activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE); activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE); } setupActionBarHandler(info); if (autoPlayEnabled) { playVideo(info); } if (android.os.Build.VERSION.SDK_INT < 18) { playVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playVideo(info); } }); } backgroundButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playVideo(info); } }); if (info.channel_url != null && info.channel_url != "") { channelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(activity, ChannelActivity.class); i.putExtra(ChannelActivity.CHANNEL_URL, info.channel_url); i.putExtra(ChannelActivity.SERVICE_ID, info.service_id); startActivity(i); } }); } else { channelButton.setVisibility(Button.GONE); } initThumbnailViews(info); } }