List of usage examples for android.view View setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java
private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { //- ------------------------------------------------------- // String text = rawResult.getText(); if (text != null && StringUtils.isUrl(text)) { if (text.contains("scan_login")) { statusView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); showConfirmLogin(text);//w ww. jav a 2 s .com return; } if (text.contains("oschina.net")) { UIHelper.showUrlRedirect(CaptureActivity.this, text); finish(); return; } } try { BarCode2 bc = BarCode2.parse(text); int type = bc.getType(); switch (type) { case BarCode2.SIGN_IN:// handleSignIn(bc); return; default: break; } } catch (JSONException e) { e.printStackTrace(); } //- ------------------------------------------------------- // CharSequence displayContents = resultHandler.getDisplayContents(); if (copyToClipboard && !resultHandler.areContentsSecure()) { ClipboardInterface.setText(displayContents, this); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (resultHandler.getDefaultButtonID() != null && prefs.getBoolean(PreferencesActivity.KEY_AUTO_OPEN_WEB, false)) { resultHandler.handleButtonPress(resultHandler.getDefaultButtonID()); return; } statusView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); resultView.setVisibility(View.VISIBLE); ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view); if (barcode == null) { barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.app_icon)); } else { barcodeImageView.setImageBitmap(barcode); } TextView formatTextView = (TextView) findViewById(R.id.format_text_view); formatTextView.setText(rawResult.getBarcodeFormat().toString()); TextView typeTextView = (TextView) findViewById(R.id.type_text_view); typeTextView.setText(resultHandler.getType().toString()); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); TextView timeTextView = (TextView) findViewById(R.id.time_text_view); timeTextView.setText(formatter.format(new Date(rawResult.getTimestamp()))); TextView metaTextView = (TextView) findViewById(R.id.meta_text_view); View metaTextViewLabel = findViewById(R.id.meta_text_view_label); metaTextView.setVisibility(View.GONE); metaTextViewLabel.setVisibility(View.GONE); Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata(); if (metadata != null) { StringBuilder metadataText = new StringBuilder(20); for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) { if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) { metadataText.append(entry.getValue()).append('\n'); } } if (metadataText.length() > 0) { metadataText.setLength(metadataText.length() - 1); metaTextView.setText(metadataText); metaTextView.setVisibility(View.VISIBLE); metaTextViewLabel.setVisibility(View.VISIBLE); } } TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view); contentsTextView.setText(displayContents); int scaledSize = Math.max(22, 32 - displayContents.length() / 4); contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view); supplementTextView.setText(""); supplementTextView.setOnClickListener(null); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL, true)) { //SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, // resultHandler.getResult(), // historyManager, // this); } int buttonCount = resultHandler.getButtonCount(); ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view); buttonView.requestFocus(); for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) { TextView button = (TextView) buttonView.getChildAt(x); if (x < buttonCount) { button.setVisibility(View.VISIBLE); button.setText(resultHandler.getButtonText(x)); button.setOnClickListener(new ResultButtonListener(resultHandler, x)); } else { button.setVisibility(View.GONE); } } }
From source file:io.intue.kamu.BestNearbyFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {/*w w w . j av a2s .c o m*/ // if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { // LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + // (mCursor == null ? ": cursor is null" : ": bad data index.")); // return; // } if (mresult == null) { return; } Venue result = mresult.get(dataIndex); final String sessionId = result.getId(); if (sessionId == null) { return; } // first, read session info from cursor and put it in convenience variables final String sessionTitle = result.getName(); //final String speakerNames = "SessionsQuery.SPEAKER_NAMES"; //final String sessionAbstract = "SessionsQuery.ABSTRACT"; //final long sessionStart = 44454544; //final long sessionEnd = 334343433; //final String roomName = "SessionsQuery.ROOM_NAME"; int sessionColor = 0; sessionColor = sessionColor == 0 ? getResources().getColor(R.color.transparent) : sessionColor; //final String snippet = "SessionsQuery.SNIPPET"; final Spannable styledSnippet = null; final boolean starred = false; //final String[] tags = "A,B,C".split(","); // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where final boolean hasLivestream = false; final long now = UIUtils.getCurrentTime(context); final boolean happeningNow = false; // text that says "LIVE" if session is live, or empty if session is not live //final String liveNowText = ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet); //final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); //final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View boxView = view.findViewById(R.id.info_box); final View sessionTargetView = view.findViewById(R.id.session_target); if (sessionColor == 0) { // use default sessionColor = getResources().getColor(R.color.transparent); } sessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView.setColorFilter(UIUtils.setColorAlpha(sessionColor, UIUtils.SESSION_PHOTO_SCRIM_ALPHA)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ((BaseActivity) getActivity()).getLPreviewUtils().setViewName(photoView, "photo_" + sessionId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(sessionColor); } else { photoView.setBackgroundColor(sessionColor); } String photo = result.getPhotoUrl(); if (!TextUtils.isEmpty(photo)) { mImageLoader.loadImage(photo, photoView, true /*crop*/); } else { // cleaning the (potentially) recycled photoView, in case this session has no photo: photoView.setImageDrawable(null); } // render title titleView.setText(sessionTitle == null ? "?" : sessionTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { subtitleView.setText(result.getAddress()); } else if (shortSubtitleView != null) { shortSubtitleView.setText(result.getAddress()); } // render category // if (categoryView != null) { // TagMetadata.Tag groupTag = mTagMetadata.getSessionGroupTag(tags); // if (groupTag != null && !Config.Tags.SESSIONS.equals(groupTag.getId())) { // categoryView.setText(groupTag.getName()); // categoryView.setVisibility(View.VISIBLE); // } else { // categoryView.setVisibility(View.GONE); // } // } // if a snippet view is available, render the session snippet there. if (snippetView != null) { //if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); // } else { // // render speaker names and abstracts into the snippet view // mBuffer.setLength(0); // if (!TextUtils.isEmpty(speakerNames)) { // mBuffer.append(speakerNames).append(". "); // } // if (!TextUtils.isEmpty(sessionAbstract)) { // mBuffer.append(sessionAbstract); // } // snippetView.setText(mBuffer.toString()); // } } // if (abstractView != null && !mIsSearchCursor) { // // render speaker names and abstracts into the abstract view // mBuffer.setLength(0); // if (!TextUtils.isEmpty(speakerNames)) { // mBuffer.append(speakerNames).append("\n\n"); // } // if (!TextUtils.isEmpty(sessionAbstract)) { // mBuffer.append(sessionAbstract); // } // abstractView.setText(mBuffer.toString()); // } // in expanded mode, the box background color follows the session color //if (useExpandedMode()) { boxView.setBackgroundColor(sessionColor); //} // show or hide the "in my schedule" indicator view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE); // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the session abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(sessionColor); } } // if this session is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the session details view final View finalPhotoView = photoView; sessionTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onSessionSelected(sessionId, finalPhotoView); } }); // animate this card // if (dataIndex > mMaxDataIndexAnimated) { // mMaxDataIndexAnimated = dataIndex; // } }
From source file:de.madvertise.android.sdk.MadvertiseView.java
/** * Set the visibility state of this view. * * @param visibility - set the visibility with <code>VISIBLE</code>, * <code>INVISIBLE</code> or <code>GONE</code>. *///from w w w . ja va 2s.c o m @Override public void setVisibility(int visibility) { int originVisibility = super.getVisibility(); if (originVisibility != visibility) { synchronized (this) { int childViewCounter = getChildCount(); for (int i = 0; i < childViewCounter; i++) { View child = getChildAt(i); child.setVisibility(visibility); } super.setVisibility(visibility); } } }
From source file:android.support.v7.app.AlertController.java
private void setupView() { final View parentPanel = mWindow.findViewById(R.id.parentPanel); final View defaultTopPanel = parentPanel.findViewById(R.id.topPanel); final View defaultContentPanel = parentPanel.findViewById(R.id.contentPanel); final View defaultButtonPanel = parentPanel.findViewById(R.id.buttonPanel); // Install custom content before setting up the title or buttons so // that we can handle panel overrides. final ViewGroup customPanel = (ViewGroup) parentPanel.findViewById(R.id.customPanel); setupCustomContent(customPanel);//from w w w .j ava 2 s. c om final View customTopPanel = customPanel.findViewById(R.id.topPanel); final View customContentPanel = customPanel.findViewById(R.id.contentPanel); final View customButtonPanel = customPanel.findViewById(R.id.buttonPanel); // Resolve the correct panels and remove the defaults, if needed. final ViewGroup topPanel = resolvePanel(customTopPanel, defaultTopPanel); final ViewGroup contentPanel = resolvePanel(customContentPanel, defaultContentPanel); final ViewGroup buttonPanel = resolvePanel(customButtonPanel, defaultButtonPanel); setupContent(contentPanel); setupButtons(buttonPanel); setupTitle(topPanel); final boolean hasCustomPanel = customPanel != null && customPanel.getVisibility() != View.GONE; final boolean hasTopPanel = topPanel != null && topPanel.getVisibility() != View.GONE; final boolean hasButtonPanel = buttonPanel != null && buttonPanel.getVisibility() != View.GONE; // Only display the text spacer if we don't have buttons. if (!hasButtonPanel) { if (contentPanel != null) { final View spacer = contentPanel.findViewById(R.id.textSpacerNoButtons); if (spacer != null) { spacer.setVisibility(View.VISIBLE); } } } if (hasTopPanel) { // Only clip scrolling content to padding if we have a title. if (mScrollView != null) { mScrollView.setClipToPadding(true); } } // Update scroll indicators as needed. if (!hasCustomPanel) { final View content = mListView != null ? mListView : mScrollView; if (content != null) { final int indicators = (hasTopPanel ? ViewCompat.SCROLL_INDICATOR_TOP : 0) | (hasButtonPanel ? ViewCompat.SCROLL_INDICATOR_BOTTOM : 0); setScrollIndicators(contentPanel, content, indicators, ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_BOTTOM); } } final ListView listView = mListView; if (listView != null && mAdapter != null) { listView.setAdapter(mAdapter); final int checkedItem = mCheckedItem; if (checkedItem > -1) { listView.setItemChecked(checkedItem, true); listView.setSelection(checkedItem); } } }
From source file:com.onebus.view.MainActivity.java
/** * init mapview//from w w w. ja v a 2s .c o m */ public void initMap() { mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); // remove map logo mMapView.removeViewAt(1); int childCount = mMapView.getChildCount(); View zoom = null; for (int i = 0; i < childCount; i++) { View child = mMapView.getChildAt(i); if (child instanceof ZoomControls) { zoom = child; break; } } zoom.setVisibility(View.GONE); mBaiduMap = mMapView.getMap(); UiSettings mUiSettings = mBaiduMap.getUiSettings(); mUiSettings.setCompassEnabled(false); mBaiduMap.setMyLocationEnabled(true); mLocClient = new LocationClient(this); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setOpenGps(true); option.setCoorType("bd09ll"); option.setScanSpan(1000); option.setIsNeedAddress(true); mLocClient.setLocOption(option); mLocClient.start(); }
From source file:com.facebook.android.friendsmash.GameFragment.java
@SuppressWarnings("unused") private void spawnImage(final boolean extraImage) { // Instantiate Random Generator Random randomGenerator = new Random(System.currentTimeMillis()); // 1 in every 5 images should be a celebrity the user should not smash - calculate that here // Unless it is the first image fired, in which case it should always be the smashable image boolean shouldSmash = true; if (firstImageFired) { if (randomGenerator.nextInt(5) == 4 && firstImageFired) { shouldSmash = false;/*from www . j a v a 2 s. co m*/ } } else if (!firstImageFired) { shouldSmash = true; firstImageFired = true; } // Create a new ImageView with a user to smash final UserImageView userImageView = (new UserImageView(getActivity(), shouldSmash)); userImageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (userImageView.shouldSmash()) { // Smashed the right image ... // Increment the score setScore(getScore() + 1 + userImageView.getExtraPoints()); // Hide the userImageView v.setVisibility(View.GONE); // Remove it from the userImageViews List in this GameFragment getUserImageViews().remove(v); } else { // Smashed the wrong image ... wrongImageSmashed(userImageView); } return false; } }); userImageView.setLayoutParams(new LinearLayout.LayoutParams(iconWidth, iconWidth)); gameFrame.addView(userImageView); userImageViews.add(userImageView); // Set the bitmap of the userImageView ... if (userImageView.shouldSmash()) { // The user should smash this image, so set the correct image if (FriendSmashApplication.IS_SOCIAL) { // User is logged into FB ... if (friendToSmashBitmap != null) { // Bitmap for the friend to smash has already been retrieved, so use this setFriendImageAndFire(userImageView, friendToSmashBitmap, extraImage); } else { // Otherwise, the Bitmap for the friend to smash hasn't been retrieved, so retrieve it and set it // Show the spinner while retrieving progressContainer.setVisibility(View.VISIBLE); // If a friend has been passed in, use that attribute, otherwise use the random friend that has been selected final String friendToSmashID = friendToSmashIDProvided != null ? friendToSmashIDProvided : ((FriendSmashApplication) getActivity().getApplication()) .getFriend(friendToSmashIndex).getId(); // Fetch the bitmap and fire the image fetchFriendBitmapAndFireImages(userImageView, friendToSmashID, extraImage); } } else { // User is not logged into FB ... setCelebImageAndFire(userImageView, celebToSmashIndex, extraImage); } } else { // The user should not smash this image, so set it to a random celebrity (but not the one being shown if it's the non-social game) int randomCelebToSmashIndex; do { randomCelebToSmashIndex = randomGenerator.nextInt(CELEBS.length); } while (randomCelebToSmashIndex == celebToSmashIndex); setCelebImageAndFire(userImageView, randomCelebToSmashIndex, extraImage); } }
From source file:com.amaze.carbonfilemanager.utils.files.Futils.java
public void crossfade(View buttons, final View pathbar) { // Set the content view to 0% opacity but visible, so that it is visible // (but fully transparent) during the animation. buttons.setAlpha(0f);/*from ww w.j ava 2s. c o m*/ buttons.setVisibility(View.VISIBLE); // Animate the content view to 100% opacity, and clear any animation // listener set on the view. buttons.animate().alpha(1f).setDuration(100).setListener(null); pathbar.animate().alpha(0f).setDuration(100).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { pathbar.setVisibility(View.GONE); } }); // Animate the loading view to 0% opacity. After the animation ends, // set its visibility to GONE as an optimization step (it won't // participate in layout passes, etc.) }
From source file:cl.ipp.katbag.fragment.Player.java
public void editMode() { View line_vertical = (View) v.findViewById(R.id.player_line_vertical_editmode); View line_horizontal = (View) v.findViewById(R.id.player_line_horizontal_editmode); if (editMode) { line_vertical.setVisibility(View.VISIBLE); line_horizontal.setVisibility(View.VISIBLE); } else {//www . j a v a 2 s . c o m line_vertical.setVisibility(View.GONE); line_horizontal.setVisibility(View.GONE); } }