Java Code Examples for android.widget.ImageView#getVisibility()

The following examples show how to use android.widget.ImageView#getVisibility() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
	ImageView imageView = (ImageView) ((RelativeLayout)view).getChildAt(1);
	if (imageView.getVisibility() == View.INVISIBLE) {
		if (selectImages.size() >= COUNT_MAX) {
			UIToast.show(context, "只能选择" + COUNT_MAX + "照片");
			return;
		}
		imageView.setVisibility(View.VISIBLE);
		selectImages.add(images.get(position));
	}else {
		imageView.setVisibility(View.INVISIBLE);
		selectImages.remove(images.get(position));
	}
	topRightButton.setText("预览(" + selectImages.size() + ")");
	if (selectImages.size() > 0) {
		topRightButton.setTextColor(Color.parseColor("#EFEFEF"));
		bottomRightButton.setVisibility(View.VISIBLE);
	}else {
		topRightButton.setTextColor(Color.parseColor("#5F5F5F"));
		bottomRightButton.setVisibility(View.GONE);
	}
}
 
Example 2
@Override
public void onParentCollapsed(RecyclerView rv, ParentViewHolder pvh, int position,
        boolean pendingCause, boolean byUser)
{
    Logger.e(TAG,
             "onParentCollapsed=" + position + ",tag=" + rv.getTag() + ",byUser=" + byUser);

    if (pvh == null) return;
    ImageView arrow = pvh.getView(R.id.arrow);
    if (arrow.getVisibility() != View.VISIBLE) return;
    float currRotate = arrow.getRotation();
    float rotate = 360;
    //未展开完全并且当前旋转角度小于180,逆转回去
    if (currRotate < 180) {
        rotate = 0;
    }
    if (pendingCause) {
        arrow.setRotation(rotate);
    } else {
        arrow.animate()
             .rotation(rotate)
             .setDuration(mItemAnimator.getRemoveDuration() + 180)
             .start();
    }
}
 
Example 3
@Override
public void onParentExpanded(RecyclerView rv, ParentViewHolder pvh, int position,
        boolean pendingCause, boolean byUser)
{
    Logger.e(TAG, "onParentExpanded=" + position + "," + rv.getTag() + ",byUser=" + byUser);
    if (pvh == null) return;
    ImageView arrow = pvh.getView(R.id.arrow);
    if (arrow.getVisibility() != View.VISIBLE) return;
    float currRotate = arrow.getRotation();
    //重置为从0开始旋转
    if (currRotate == 360) {
        arrow.setRotation(0);
    }
    if (pendingCause) {
        arrow.setRotation(180);
    } else {
        arrow.animate()
             .rotation(180)
             .setDuration(mItemAnimator.getAddDuration() + 180)
             .start();
    }
}
 
Example 4
@Override
public void onParentCollapsed(RecyclerView rv, ParentViewHolder pvh, int position,
        boolean pendingCause, boolean byUser)
{
    Logger.e(TAG,
            "onParentCollapsed=" + position + ",tag=" + rv.getTag() + ",byUser=" + byUser);

    if (pvh == null) return;
    final ImageView arrow = pvh.getView(R.id.arrow);
    if (arrow.getVisibility() != View.VISIBLE) return;
    final float currRotate = arrow.getRotation();
    float rotate = 360;
    //未展开完全并且当前旋转角度小于180,逆转回去
    if (currRotate < 180) {
        rotate = 0;
    }
    if (pendingCause) {
        arrow.setRotation(rotate);
    } else {
        arrow.animate().rotation(rotate)
                .setDuration(mItemAnimator.getRemoveDuration() + 180).start();
    }
}
 
Example 5
private void updateProgress(StepProgress progress, View progressStepContainer) {
    ProgressBar progBar = Ui.findView(progressStepContainer, R.id.spinner);
    ImageView checkmark = Ui.findView(progressStepContainer, R.id.checkbox);

    // don't show the spinner again if we've already shown the checkmark,
    // regardless of the underlying state that might hide
    if (checkmark.getVisibility() == View.VISIBLE) {
        return;
    }

    progressStepContainer.setVisibility(View.VISIBLE);

    if (progress.status == StepProgress.STARTING) {
        checkmark.setVisibility(View.GONE);

        progBar.setProgressDrawable(tintedSpinner);
        progBar.setVisibility(View.VISIBLE);

    } else {
        progBar.setVisibility(View.GONE);

        checkmark.setImageDrawable(tintedCheckmark);
        checkmark.setVisibility(View.VISIBLE);
    }
}
 
Example 6
Source Project: Dashchan   File: ViewUnit.java    License: Apache License 2.0 6 votes vote down vote up
public void displayLoadedThumbnailsForPosts(ListView listView, String key, Bitmap bitmap, boolean error) {
	for (int i = 0; i < listView.getChildCount(); i++) {
		View view = listView.getChildAt(i);
		Object tag = view.getTag();
		if (tag instanceof PostViewHolder) {
			PostViewHolder holder = (PostViewHolder) tag;
			for (int j = 0; j < holder.getAttachmentViewCount(); j++) {
				holder.getAttachmentView(j).handleLoadedImage(key, bitmap, error, false);
			}
			ArrayList<ImageView> badgeImages = holder.badgeImages;
			if (badgeImages != null) {
				for (ImageView imageView : badgeImages) {
					if (imageView.getVisibility() == View.VISIBLE && key.equals(imageView.getTag())) {
						imageView.setImageBitmap(bitmap);
					}
				}
			}
		}
	}
}
 
Example 7
private void updateProgress(StepProgress progress, View progressStepContainer) {
    ProgressBar progBar = Ui.findView(progressStepContainer, R.id.spinner);
    ImageView checkmark = Ui.findView(progressStepContainer, R.id.checkbox);

    // don't show the spinner again if we've already shown the checkmark,
    // regardless of the underlying state that might hide
    if (checkmark.getVisibility() == View.VISIBLE) {
        return;
    }

    progressStepContainer.setVisibility(View.VISIBLE);

    if (progress.status == StepProgress.STARTING) {
        checkmark.setVisibility(View.GONE);

        progBar.setProgressDrawable(tintedSpinner);
        progBar.setVisibility(View.VISIBLE);

    } else {
        progBar.setVisibility(View.GONE);

        checkmark.setImageDrawable(tintedCheckmark);
        checkmark.setVisibility(View.VISIBLE);
    }
}
 
Example 8
public void clearSelectedDay() {
    if (lastSelectedDayCalendar != null) {
        ViewGroup dayOfTheMonthBackground = getDayOfMonthBackground(lastSelectedDayCalendar);

        // If it's today, keep the current day style
        Calendar nowCalendar = Calendar.getInstance();
        if (nowCalendar.get(Calendar.YEAR) == lastSelectedDayCalendar.get(Calendar.YEAR) && nowCalendar.get(Calendar.DAY_OF_YEAR) == lastSelectedDayCalendar.get(Calendar.DAY_OF_YEAR)) {
            dayOfTheMonthBackground.setBackgroundResource(R.drawable.ring);
        } else {
            dayOfTheMonthBackground.setBackgroundResource(android.R.color.transparent);
        }

        TextView dayOfTheMonth = getDayOfMonthText(lastSelectedDayCalendar);
        dayOfTheMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_day_of_the_month_font));

        ImageView circleImage1 = getCircleImage1(lastSelectedDayCalendar);
        ImageView circleImage2 = getCircleImage2(lastSelectedDayCalendar);
        if (circleImage1.getVisibility() == VISIBLE) {
            DrawableCompat.setTint(circleImage1.getDrawable(), ContextCompat.getColor(getContext(), R.color.roboto_calendar_circle_1));
        }

        if (circleImage2.getVisibility() == VISIBLE) {
            DrawableCompat.setTint(circleImage2.getDrawable(), ContextCompat.getColor(getContext(), R.color.roboto_calendar_circle_2));
        }
    }
}
 
Example 9
Source Project: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 6 votes vote down vote up
public void removeAllData() {
    int size = data.size();
    data.clear();
    for (int i = 0;
         i < size;
         i++) {
        final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0);
        if (iv.getVisibility() == View.VISIBLE) {
            ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setDuration(300);
            anim.setFillAfter(true);
            iv.startAnimation(anim);
            if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
                iv.removeCallbacks((Runnable) iv.getTag());
            }
            HideIvRunnable r = new HideIvRunnable(iv);
            iv.setTag(r);
            iv.postDelayed(r, 300);
        }
    }
}
 
Example 10
public void deleteLast(){
    int size = data.size();
    if(size <= 0){
        return;
    }
    data.remove(size - 1);
    final ImageView iv = (ImageView) ((FrameLayout) getChildAt(size - 1)).getChildAt(0);
    if(iv.getVisibility() == View.VISIBLE){
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(300);
        anim.setFillAfter(true);
        iv.startAnimation(anim);
        iv.postDelayed(new Runnable() {
            @Override
            public void run() {
                iv.setVisibility(View.INVISIBLE);
            }
        }, 300);
    }
}
 
Example 11
public void removeAllData(){
    int size = data.size();
    data.clear();
    for(int i = 0; i < size; i++){
        final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0);
        if(iv.getVisibility() == View.VISIBLE){
            ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setDuration(300);
            anim.setFillAfter(true);
            iv.startAnimation(anim);
            iv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    iv.setVisibility(View.INVISIBLE);
                }
            }, 300);
        }
    }
}
 
Example 12
Source Project: hash-checker   File: HashesListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void callItemClick() {
    ImageView ivAdditionalIcon = getIvItemAdditionalIcon();
    boolean visible = ivAdditionalIcon.getVisibility() == View.VISIBLE;
    ivAdditionalIcon.setVisibility(visible ? View.INVISIBLE : View.VISIBLE);

    hashTypeSelectListener.hashTypeSelect(hashTypeAtPosition);
    dismissBottomSheet();
}
 
Example 13
@Override
public void onParentExpanded(RecyclerView rv, ParentViewHolder pvh, int position,
        boolean pendingCause, boolean byUser)
{
    Logger.e(TAG, "onParentExpanded=" + position + "," + rv.getTag() + ",byUser=" + byUser);
    if (pvh == null) return;
    ImageView arrow = pvh.getView(R.id.arrow);
    if (arrow.getVisibility() != View.VISIBLE) return;
    float currRotate = arrow.getRotation();
    //重置为从0开始旋转
    if (currRotate == 360) {
        arrow.setRotation(0);
    }
    if (pendingCause) {
        arrow.setRotation(180);
    } else {
        arrow.animate()
             .rotation(180)
             .setDuration(mItemAnimator.getAddDuration() + 180)
             .start();
    }

    //            if (byUser) {
    //                int scrollToPos =
    //                        pvh.getAdapterPosition() + ((MyParent) pvh.getParent()).getChildCount();
    //                rv.scrollToPosition(scrollToPos);
    //            }
}
 
Example 14
@Override
public void onParentExpandableStateChanged(RecyclerView rv, ParentViewHolder pvh,
        int position, boolean expandable)
{
    Logger.e(TAG, "onParentExpandableStateChanged=" + position + "," + rv.getTag());
    if (pvh == null) return;
    ImageView arrow = pvh.getView(R.id.arrow);
    if (expandable && arrow.getVisibility() != View.VISIBLE) {
        arrow.setVisibility(View.VISIBLE);
        arrow.setRotation(pvh.isExpanded() ? 180 : 0);
    } else if (!expandable && arrow.getVisibility() == View.VISIBLE) {
        arrow.setVisibility(View.GONE);
    }
}
 
Example 15
Source Project: Ruisi   File: PostsActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void setSubForums() {
    View toolbar = findViewById(R.id.myToolBar);
    if (toolbar != null) {
        ImageView arrow = toolbar.findViewById(R.id.arrow);
        if (arrow.getVisibility() == View.VISIBLE) {
            return;
        }
        TextView title = toolbar.findViewById(R.id.title);
        title.setOnClickListener(changeSubForumClickListener);
        arrow.setVisibility(View.VISIBLE);
        arrow.setOnClickListener(changeSubForumClickListener);
    }
}
 
Example 16
private void setupItem(LinearLayout ll, TextView textView,ImageView imgView, TabItemSpec tabItem){
    float density = getResources().getDisplayMetrics().density;
    
    if (tabItem.iconId != 0) {
        imgView.setImageResource(tabItem.iconId);
        imgView.setVisibility(VISIBLE);
    } else if (tabItem.iconDrawable != null) {
        imgView.setImageDrawable(tabItem.iconDrawable);
        imgView.setVisibility(VISIBLE);
    } else {
        imgView.setVisibility(GONE);
    }

    if (tabItem.title != null && !tabItem.title.isEmpty()) {
        textView.setText(tabItem.title);
        textView.setVisibility(VISIBLE);
    } else {
        textView.setVisibility(GONE);
    }

    if (imgView.getVisibility() == VISIBLE && textView.getVisibility() == VISIBLE) {
        ll.setMinimumHeight((int) (LARGE_MIN_HEIGHT * density));
    } else {
        ll.setMinimumHeight((int) (SMALL_MIN_HEIGHT * density));
    }
    
    if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
    }
}
 
Example 17
public void markDayAsSelectedDay(@NonNull Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    // Clear previous current day mark
    clearSelectedDay();

    // Store current values as last values
    lastSelectedDayCalendar = calendar;

    // Mark current day as selected
    ViewGroup dayOfTheMonthBackground = getDayOfMonthBackground(calendar);
    dayOfTheMonthBackground.setBackgroundResource(R.drawable.circle);

    TextView dayOfTheMonth = getDayOfMonthText(calendar);
    dayOfTheMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_selected_day_font));

    ImageView circleImage1 = getCircleImage1(calendar);
    ImageView circleImage2 = getCircleImage2(calendar);
    if (circleImage1.getVisibility() == VISIBLE) {
        DrawableCompat.setTint(circleImage1.getDrawable(), ContextCompat.getColor(getContext(), R.color.roboto_calendar_selected_day_font));
    }

    if (circleImage2.getVisibility() == VISIBLE) {
        DrawableCompat.setTint(circleImage2.getDrawable(), ContextCompat.getColor(getContext(), R.color.roboto_calendar_selected_day_font));
    }
}
 
Example 18
Source Project: a   File: TabLayout.java    License: GNU General Public License v3.0 4 votes vote down vote up
private void updateTextAndIcon(@Nullable final TextView textView,
                               @Nullable final ImageView iconView) {
    final Drawable icon = mTab != null ? mTab.getIcon() : null;
    final CharSequence text = mTab != null ? mTab.getText() : null;
    final CharSequence contentDesc = mTab != null ? mTab.getContentDescription() : null;

    if (iconView != null) {
        if (icon != null) {
            iconView.setImageDrawable(icon);
            iconView.setVisibility(VISIBLE);
            setVisibility(VISIBLE);
        } else {
            iconView.setVisibility(GONE);
            iconView.setImageDrawable(null);
        }
        iconView.setContentDescription(contentDesc);
    }

    final boolean hasText = !TextUtils.isEmpty(text);
    if (textView != null) {
        if (hasText) {
            textView.setText(text);
            textView.setVisibility(VISIBLE);
            setVisibility(VISIBLE);
        } else {
            textView.setVisibility(GONE);
            textView.setText(null);
        }
        textView.setContentDescription(contentDesc);
    }

    if (iconView != null) {
        MarginLayoutParams lp = ((MarginLayoutParams) iconView.getLayoutParams());
        int bottomMargin = 0;
        if (hasText && iconView.getVisibility() == VISIBLE) {
            // If we're showing both text and icon, add some margin bottom to the icon
            bottomMargin = dpToPx(DEFAULT_GAP_TEXT_ICON);
        }
        if (bottomMargin != lp.bottomMargin) {
            lp.bottomMargin = bottomMargin;
            iconView.requestLayout();
        }
    }
    TooltipCompat.setTooltipText(this, hasText ? null : contentDesc);
}
 
Example 19
private void updateTextAndIcon(
    @Nullable final TextView textView, @Nullable final ImageView iconView) {
  final Drawable icon =
      (tab != null && tab.getIcon() != null)
          ? DrawableCompat.wrap(tab.getIcon()).mutate()
          : null;
  final CharSequence text = tab != null ? tab.getText() : null;

  if (iconView != null) {
    if (icon != null) {
      iconView.setImageDrawable(icon);
      iconView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      iconView.setVisibility(GONE);
      iconView.setImageDrawable(null);
    }
  }

  final boolean hasText = !TextUtils.isEmpty(text);
  if (textView != null) {
    if (hasText) {
      textView.setText(text);
      if (tab.labelVisibilityMode == TAB_LABEL_VISIBILITY_LABELED) {
        textView.setVisibility(VISIBLE);
      } else {
        textView.setVisibility(GONE);
      }
      setVisibility(VISIBLE);
    } else {
      textView.setVisibility(GONE);
      textView.setText(null);
    }
  }

  if (iconView != null) {
    MarginLayoutParams lp = ((MarginLayoutParams) iconView.getLayoutParams());
    int iconMargin = 0;
    if (hasText && iconView.getVisibility() == VISIBLE) {
      // If we're showing both text and icon, add some margin bottom to the icon
      iconMargin = (int) ViewUtils.dpToPx(getContext(), DEFAULT_GAP_TEXT_ICON);
    }
    if (inlineLabel) {
      if (iconMargin != MarginLayoutParamsCompat.getMarginEnd(lp)) {
        MarginLayoutParamsCompat.setMarginEnd(lp, iconMargin);
        lp.bottomMargin = 0;
        // Calls resolveLayoutParams(), necessary for layout direction
        iconView.setLayoutParams(lp);
        iconView.requestLayout();
      }
    } else {
      if (iconMargin != lp.bottomMargin) {
        lp.bottomMargin = iconMargin;
        MarginLayoutParamsCompat.setMarginEnd(lp, 0);
        // Calls resolveLayoutParams(), necessary for layout direction
        iconView.setLayoutParams(lp);
        iconView.requestLayout();
      }
    }
  }

  final CharSequence contentDesc = tab != null ? tab.contentDesc : null;
  TooltipCompat.setTooltipText(this, hasText ? null : contentDesc);
}
 
Example 20
@Override
public void run() {
    try {
        if(activity.measurementService.isRecording()) {
            int seconds = activity.measurementService.getLeqAdded();
            if(seconds >= MeasurementActivity.DEFAULT_MINIMAL_LEQ && !activity.buttonrecord.isEnabled()) {
                activity.buttonrecord.setEnabled(true);
            }
            Chronometer chronometer = (Chronometer) activity
                    .findViewById(R.id.chronometer_recording_time);
            if (activity.chronometerWaitingToStart.getAndSet(false)) {
                chronometer.setBase(SystemClock.elapsedRealtime() - seconds * 1000);
                TextView overlayMessage = (TextView) activity.findViewById(R.id.textView_message_overlay);
                if(activity.measurementService.isPaused()) {
                    chronometer.stop();
                    chronometer.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.pause_anim));
                    overlayMessage.setText(R.string.measurement_pause);
                } else {
                    chronometer.clearAnimation();
                    chronometer.start();
                    overlayMessage.setText("");
                }
            }

            //Update accuracy hint
            final TextView accuracyText = (TextView) activity.findViewById(R.id.textView_value_gps_precision);
            final ImageView accuracyImageHint = (ImageView) activity.findViewById(R.id.imageView_value_gps_precision);
            Location location = activity.measurementService.getLastLocation();
            if(location != null) {
                float lastPrecision = location.getAccuracy();
                if (lastPrecision < APROXIMATE_LOCATION_ACCURACY) {
                    accuracyImageHint.setImageResource(R.drawable.gps_fixed);
                    accuracyText.setText(activity.getString(R.string.gps_hint_precision,
                            (int)lastPrecision));
                } else {
                    accuracyImageHint.setImageResource(R.drawable.gps_not_fixed);
                    accuracyText.setText(activity.getString(R.string.gps_hint_precision,
                            (int)lastPrecision));
                }
                if (accuracyImageHint.getVisibility() == View.INVISIBLE) {
                    accuracyImageHint.setVisibility(View.VISIBLE);
                }
                long now = System.currentTimeMillis();
                if(now - activity.lastMapLocationRefresh >= REFRESH_MAP_LOCATION_RATE) {
                    activity.getMapControler().updateLocationMarker(new MapFragment.LatLng(location.getLatitude(), location.getLongitude()), location.getAccuracy());
                    activity.lastMapLocationRefresh = now;
                }
            } else {
                accuracyImageHint.setImageResource(R.drawable.gps_off);
                accuracyText.setText(R.string.no_gps_hint);
            }
            // Update current location of user
            final double leq = activity.measurementService.getAudioProcess().getLeq(false);
            activity.setData(activity.measurementService.getAudioProcess().getLeq(false));
            // Change the text and the textcolor in the corresponding textview
            // for the Leqi value
            LeqStats leqStats =
                    activity.measurementService.getFastLeqStats();
            final TextView mTextView = (TextView) activity.findViewById(R.id.textView_value_SL_i);
            formatdBA(leq, mTextView);
            if(activity.measurementService.getLeqAdded() != 0) {
                // Stats are only available if the recording of previous leq are activated
                final TextView valueMin = (TextView) activity.findViewById(R.id
                        .textView_value_Min_i);
                formatdBA(leqStats.getLeqMin(), valueMin);
                final TextView valueMax = (TextView) activity.findViewById(R.id
                        .textView_value_Max_i);
                formatdBA(leqStats.getLeqMax(), valueMax);
                final TextView valueMean = (TextView) activity.findViewById(R.id
                        .textView_value_Mean_i);
                formatdBA(leqStats.getLeqMean(), valueMean);
            }


            int nc = MeasurementActivity.getNEcatColors(leq);    // Choose the color category in
            // function of the sound level
            mTextView.setTextColor(activity.NE_COLORS[nc]);

            // Spectrum data
            activity.updateSpectrumGUI();
        } else {
            activity.initGuiState();
        }

        // Debug processing time
    } finally {
        activity.isComputingMovingLeq.set(false);
    }
}