下面列出了android.view.View#VISIBLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void run() {
while (mIsForeground) {
//音量
if (mVolumeSeekbar.getVisibility() == View.VISIBLE) {
final int max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
final int current = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
runOnUiThread(() -> mVolumeSeekbar.setProgress((int) (current * 1.0 / max * 100)));
}
if (!MusicServiceRemote.isPlaying()) {
continue;
}
int progress = MusicServiceRemote.getProgress();
if (progress > 0 && progress < mDuration) {
mCurrentTime = progress;
mHandler.sendEmptyMessage(UPDATE_TIME_ALL);
try {
//1000ms时间有点长
sleep(500);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
public static boolean onScreenArea(View view) {
if (view == null || view.getVisibility() != View.VISIBLE) {
return false;
}
int[] p = new int[2];
view.getLocationOnScreen(p);
LayoutParams lp = view.getLayoutParams();
int viewH = 0;
if (lp != null) {
viewH = lp.height;
} else {
viewH = view.getHeight();
}
return (p[1] > 0 && (p[1] - WXViewUtils.getScreenHeight(WXEnvironment.sApplication) < 0))
|| (viewH + p[1] > 0 && p[1] <= 0);
}
@Override
public void onBackPressed() {
//原生控件点击后退关闭
if (mNativeAdLayout != null && mNativeAdLayout.getVisibility() == View.VISIBLE) {
mNativeAdLayout.removeAllViews();
mNativeAdLayout.setVisibility(View.GONE);
return;
}
// 如果有需要,可以点击后退关闭插播广告。
if (!SpotManager.getInstance(mContext).disMiss()) {
super.onBackPressed();
}
}
@Override
public void onPageFinishedLoading(String url) {
LOG.d(TAG, "onPageFinished(" + url + ")");
clearLoadTimeoutTimer();
// Broadcast message that page has loaded
pluginManager.postMessage("onPageFinished", url);
// Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
if (engine.getView().getVisibility() != View.VISIBLE) {
Thread t = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(2000);
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
pluginManager.postMessage("spinner", "stop");
}
});
} catch (InterruptedException e) {
}
}
});
t.start();
}
// Shutdown if blank loaded
if (url.equals("about:blank")) {
pluginManager.postMessage("exit", null);
}
}
private static boolean isHittable(View view) {
if (view.getVisibility() != View.VISIBLE) {
return false;
}
if (ViewCompat.getInstance().getAlpha(view) < 0.001f) {
return false;
}
return true;
}
private void updateVisibility() {
if (this.topFoldFactor == DEFAULT_BACKOFF_MULT && this.bottomFoldFactor == DEFAULT_BACKOFF_MULT) {
if (getVisibility() != View.GONE) {
setVisibility(View.GONE);
}
} else if (getVisibility() != View.VISIBLE) {
setVisibility(View.VISIBLE);
}
}
public final boolean isVisible() {
Animation currentAnim = getAnimation();
if (null != currentAnim) {
return mInAnim == currentAnim;
}
return getVisibility() == View.VISIBLE;
}
/**
* Set up the UI depending to the total number of channel the user is subscribed to.
*
* @param totalSubbedChannels Total number of channel the user is subscribed to.
*/
private void setupUiAccordingToNumOfSubbedChannels(int totalSubbedChannels) {
if (totalSubbedChannels <= 0) {
swipeRefreshLayout.setVisibility(View.GONE);
noSubscriptionsText.setVisibility(View.VISIBLE);
} else {
if (swipeRefreshLayout.getVisibility() != View.VISIBLE) {
swipeRefreshLayout.setVisibility(View.VISIBLE);
noSubscriptionsText.setVisibility(View.GONE);
}
}
}
private void setupValueAdapter() {
if (mValueSubscription != null) {
mValueSubscription.unsubscribe();
}
if (getValueSpinnerVisibility() != View.VISIBLE) {
return;
}
mValueAdapter = null;
switch (mFactory.getType()) {
case AutoPlaylistRule.SONG:
setupSongAdapter();
break;
case AutoPlaylistRule.ARTIST:
setupArtistAdapter();
break;
case AutoPlaylistRule.ALBUM:
setupAlbumAdapter();
break;
case AutoPlaylistRule.GENRE:
setupGenreAdapter();
break;
case AutoPlaylistRule.PLAYLIST:
setupPlaylistAdapter();
break;
}
notifyPropertyChanged(BR.valueAdapter);
}
@Override
public String getSelectedWalletName() {
if ( mWalletSpinner.getVisibility() != View.VISIBLE ) {
return null;
}
if ( mWalletSpinner.getSelectedItemPosition() == WALLET_SPINNER_SELECT_NOTICE_INDEX) { // select wallet notice
return null;
}
return mWalletSpinner.getSelectedItem().toString();
}
public WaitVisibilityChange(long duration, int visibility) {
super(duration);
if (visibility != View.GONE && visibility != View.INVISIBLE &&
visibility != View.VISIBLE) {
throw new IllegalArgumentException("wrong visibility: " + visibility);
}
this.visibility = visibility;
}
@Override
protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
if (visibility == View.VISIBLE) {
registerSensorManager();
} else {
unregisterSensorManager();
}
}
@Override
void updateCheckboxState(CheckBox checkBox, boolean graphObjectSelected) {
checkBox.setChecked(graphObjectSelected);
int visible = (graphObjectSelected || selectionStrategy
.shouldShowCheckBoxIfUnselected()) ? View.VISIBLE : View.GONE;
checkBox.setVisibility(visible);
}
protected boolean isContentViewVisible() {
return mLayoutContainer.getVisibility() == View.VISIBLE;
}
private void updateClipView(int firstVisibleItem) {
if (firstVisibleItem == RecyclerView.NO_POSITION) {
return;
}
int height = 0;
int top = 0;
View child = listView.getChildAt(0);
if (child != null) {
if (firstVisibleItem == 0) {
top = child.getTop();
height = overScrollHeight + (top < 0 ? top : 0);
}
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mapViewClip.getLayoutParams();
if (layoutParams != null) {
if (height <= 0) {
if (mapView.getVisibility() == View.VISIBLE) {
mapView.setVisibility(View.INVISIBLE);
mapViewClip.setVisibility(View.INVISIBLE);
}
} else {
if (mapView.getVisibility() == View.INVISIBLE) {
mapView.setVisibility(View.VISIBLE);
mapViewClip.setVisibility(View.VISIBLE);
}
}
mapViewClip.setTranslationY(Math.min(0, top));
mapView.setTranslationY(Math.max(0, -top / 2));
if (markerImageView != null) {
markerImageView.setTranslationY(markerTop = -top - AndroidUtilities.dp(42) + height / 2);
markerXImageView.setTranslationY(-top - AndroidUtilities.dp(7) + height / 2);
}
if (routeButton != null) {
routeButton.setTranslationY(top);
}
layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams();
if (layoutParams != null && layoutParams.height != overScrollHeight + AndroidUtilities.dp(10)) {
layoutParams.height = overScrollHeight + AndroidUtilities.dp(10);
if (googleMap != null) {
googleMap.setPadding(AndroidUtilities.dp(70), 0, AndroidUtilities.dp(70), AndroidUtilities.dp(10));
}
mapView.setLayoutParams(layoutParams);
}
}
}
}
private void setItemViewVisibilityById(int id, boolean visible) {
int visible_value = visible ? View.VISIBLE : View.GONE;
itemView.findViewById(id).setVisibility(visible_value);
}
/**
* 点击触摸显示和隐藏逻辑
*/
@Override
protected void onClickUiToggle() {
if (mIfCurrentIsFullscreen && mLockCurScreen && mNeedLockFull) {
setViewShowState(mLockScreen, VISIBLE);
return;
}
if (mCurrentState == CURRENT_STATE_PREPAREING) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPrepareingClear();
} else {
changeUiToPreparingShow();
}
}
} else if (mCurrentState == CURRENT_STATE_PLAYING) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPlayingClear();
} else {
changeUiToPlayingShow();
}
}
} else if (mCurrentState == CURRENT_STATE_PAUSE) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPauseClear();
} else {
changeUiToPauseShow();
}
}
} else if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToCompleteClear();
} else {
changeUiToCompleteShow();
}
}
} else if (mCurrentState == CURRENT_STATE_PLAYING_BUFFERING_START) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPlayingBufferingClear();
} else {
changeUiToPlayingBufferingShow();
}
}
}
}
public boolean willDrawIcon() {
return mIconView.getVisibility() == View.VISIBLE;
}
public boolean isShowing() {
return mContainerView.getVisibility() == View.VISIBLE;
}
private void showToolTipPerSettings(FetchedAppSettings settings) {
if (settings != null && settings.getNuxEnabled() && getVisibility() == View.VISIBLE) {
String toolTipString = settings.getNuxContent();
displayToolTip(toolTipString);
}
}