private void updateAnchors(int newScore) { boolean selectAnchorNotLikely = (newScore == 0); mAnchorNotLikely.setTextColor(selectAnchorNotLikely ? mColorSelected : mColorBlack); mAnchorNotLikely.setAlpha(selectAnchorNotLikely ? 1f : 0.38f); boolean selectAnchorLikely = (newScore == 10); mAnchorLikely.setTextColor(selectAnchorLikely ? mColorSelected : mColorBlack); mAnchorLikely.setAlpha(selectAnchorLikely ? 1f : 0.38f); }
private void setTitleAlpha(float alpha) { mAlphaForegroundColorSpan.setAlpha(alpha); mSpannableString.setSpan( mAlphaForegroundColorSpan, 0, mSpannableString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getActivity().getActionBar().setTitle(mSpannableString); mName.setAlpha(1.0f - alpha); mDescription.setAlpha(1.0f - alpha); }
private void showPostVoteAnimation(Vote vote) { if (vote == null || vote == Vote.NEUTRAL) return; // quickly center the vote button simulateScroll(); String text = vote == Vote.UP ? "+" : (vote == Vote.DOWN ? "-" : "*"); voteAnimationIndicator.setText(text); voteAnimationIndicator.setVisibility(View.VISIBLE); voteAnimationIndicator.setAlpha(0); voteAnimationIndicator.setScaleX(0.7f); voteAnimationIndicator.setScaleY(0.7f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( voteAnimationIndicator, ofFloat(View.ALPHA, 0, 0.6f, 0.7f, 0.6f, 0), ofFloat(View.SCALE_X, 0.7f, 1.3f), ofFloat(View.SCALE_Y, 0.7f, 1.3f)); animator.start(); animator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { View view = PostFragment.this.voteAnimationIndicator; if (view != null) { view.setVisibility(View.GONE); } } }); }
@Override public void onPaused(Uri rideUri) { if (!rideUri.equals(mRideUri)) return; mChkRecord.setChecked(false, false); mChkRecordText.setText(R.string.display_chkRecord_paused); if (mChkRecordTextAnimator.isStarted()) mChkRecordTextAnimator.cancel(); mChkRecordText.setAlpha(1f); }
@Override public void bindView(View view, Context context, Cursor cursor) { RideCursor c = (RideCursor) cursor; // Title (name / date) TextView txtTitle = ViewHolder.get(view, R.id.txtTitle); String name = c.getName(); long createdDateLong = c.getCreatedDate().getTime(); String createdDateTimeStr = DateUtils.formatDateTime( context, createdDateLong, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); if (name == null) { txtTitle.setText(createdDateTimeStr); } else { txtTitle.setText(name + "\n" + createdDateTimeStr); } // Summary TextView txtSummary = ViewHolder.get(view, R.id.txtSummary); CharSequence details = null; Animator animator = (Animator) view.getTag(R.id.animator); // Cancel the animation / reset the alpha in any case if (animator != null) animator.cancel(); txtSummary.setAlpha(1); RideState rideState = c.getState(); switch (rideState) { case CREATED: details = context.getString(R.string.ride_list_notStarted); txtSummary.setTextColor(mColorDefault); txtSummary.setEnabled(false); break; case ACTIVE: details = context.getString(R.string.ride_list_active); if (animator == null) { animator = AnimatorInflater.loadAnimator(context, R.animator.blink); animator.setTarget(txtSummary); view.setTag(R.id.animator, animator); } animator.start(); txtSummary.setTextColor(mColorActive); txtSummary.setEnabled(true); break; case PAUSED: // Distance float distance = c.getDistance(); details = TextUtils.concat(UnitUtil.formatDistance(distance, true, .85f, false), " - "); // Duration long duration = c.getDuration(); details = TextUtils.concat(details, DateTimeUtil.formatDuration(context, duration)); txtSummary.setTextColor(mColorDefault); txtSummary.setEnabled(true); break; } txtSummary.setText(details); }
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { float alpha = 1 - (float) Math.max(0, mParallaxImageHeight - scrollY) / mParallaxImageHeight; setToolBarBackgroundAlpha(mToolbar, alpha, primaryColor); setStatusBarBackgroundAlpha(statusBar, alpha + 0.2f, ActionBarView.darkenColor(primaryColor)); note.setAlpha(1 - alpha); date.setAlpha(1 - alpha); ViewHelper.setTranslationY(mImageView, scrollY / 2); }
/** Show the label using an animation */ private void showLabel() { mLabel.setVisibility(View.VISIBLE); mLabel.setAlpha(0f); mLabel.setTranslationY(mLabel.getHeight()); mLabel .animate() .alpha(1f) .translationY(0f) .setDuration(ANIMATION_DURATION) .setListener(null) .start(); }
public void updatePlaceAddingTipVisibility() { boolean placeIsBeingAdded = getView() != null && getView().findViewById(R.id.addPlaceCircle) != null && ((ImageView) getView().findViewById(R.id.addPlaceCircle)).getDrawable() != null; boolean noPlacesAdded = MainApplication.places != null && (MainApplication.places.names() == null || MainApplication.places.names().length() == 0); placeAddingTip.setAlpha(noPlacesAdded && !placeIsBeingAdded ? 1 : 0); }
/** Show pre-send animation */ public void showPreSend() { // Update display metrics mDisplay.getRealMetrics(mDisplayMetrics); final int statusBarHeight = mContext .getResources() .getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); if (mScreenshotBitmap == null || mAttached) { return; } mScreenshotView.setOnTouchListener(this); mScreenshotView.setImageBitmap(mScreenshotBitmap); mScreenshotView.setTranslationX(0f); mScreenshotView.setAlpha(1.0f); mScreenshotView.setPadding(0, statusBarHeight, 0, 0); mScreenshotLayout.requestFocus(); mTextHint.setAlpha(0.0f); mTextHint.setVisibility(View.VISIBLE); mHintAnimator.start(); // Lock the orientation. // The orientation from the configuration does not specify whether // the orientation is reverse or not (ie landscape or reverse landscape). // So we have to use SENSOR_LANDSCAPE or SENSOR_PORTRAIT to make sure // we lock in portrait / landscape and have the sensor determine // which way is up. int orientation = mContext.getResources().getConfiguration().orientation; switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; break; case Configuration.ORIENTATION_PORTRAIT: mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; break; default: mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; break; } mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams); // Disable statusbar pull-down mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND); mAttached = true; mPreAnimator.start(); }
/** Creates a view into which preview text can be placed. */ private TextView createPreviewTextView() { final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // final Resources res = getContext().getResources(); // final float textSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_text_size); final TextView textView = new TextView(getContext()); textView.setLayoutParams(params); textView.setTextColor(Color.WHITE); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mToastTextSize); textView.setSingleLine(true); textView.setEllipsize(TruncateAt.MIDDLE); textView.setGravity(Gravity.CENTER); textView.setAlpha(0f); return textView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // If we weren't given a view, inflate one if (convertView == null) { convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_divesite, null); } // Configure the view for this DiveSite Resources resources = mContext.getResources(); Divesite c = getItem(position); TextView titleTextView = (TextView) convertView.findViewById(R.id.divesite_titleTextView); titleTextView.setText(c.getName()); titleTextView.setAlpha(87); TextView depthTextView = (TextView) convertView.findViewById(R.id.divesite_depthTextView); depthTextView.setText(c.getMaxDepth()); depthTextView.setAlpha(54); ProportionalImageView imageView = (ProportionalImageView) convertView.findViewById(R.id.list_imageView); String smallImageName = "s" + c.getPhoto(); final int resourceID = resources.getIdentifier(smallImageName, "drawable", mContext.getPackageName()); imageView.setImageResource(resourceID); setHasOptionsMenu(true); return convertView; }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.slamon_main); // Get views by id and relevant variables for further use backgroundView = (RelativeLayout) findViewById(R.id.background_layout); textView = (TextView) findViewById(R.id.debug_text_window); textView.setAlpha(0f); textView.setMovementMethod(new ScrollingMovementMethod()); animationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); // Create filter for receiving broadcasted Intents and instantiate broadcaster broadcastManager = LocalBroadcastManager.getInstance(this); broadcastManager.registerReceiver(receiver, filter); }
/** Hide the label using an animation */ private void hideLabel() { mLabel.setAlpha(1f); mLabel.setTranslationY(0f); mLabel .animate() .alpha(0f) .translationY(mLabel.getHeight()) .setDuration(ANIMATION_DURATION) .setListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLabel.setVisibility(View.GONE); } }) .start(); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void animate(View view) { if (!expanded) { iv.setImageDrawable(searchToBar); searchToBar.start(); iv.animate().translationX(0f).setDuration(duration).setInterpolator(interp); text.animate() .alpha(1f) .setStartDelay(duration - 100) .setDuration(100) .setInterpolator(interp); } else { iv.setImageDrawable(barToSearch); barToSearch.start(); iv.animate().translationX(offset).setDuration(duration).setInterpolator(interp); text.setAlpha(0f); } expanded = !expanded; }
@Override public View getView(int i, View view, ViewGroup viewGroup) { int type = getItemViewType(i); if (type == 0) { if (view == null) { LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = li.inflate(R.layout.settings_section_layout, viewGroup, false); } TextView textView = (TextView)view.findViewById(R.id.settings_section_text); if (i == 0) { textView.setText(getStringEntry(R.string.MessageNotifications)); } else if (i == 5) { textView.setText(getStringEntry(R.string.GroupNotifications)); } else if (i == 10) { textView.setText(getStringEntry(R.string.InAppNotifications)); } else if (i == 14) { textView.setText(getStringEntry(R.string.Events)); } else if (i == 16) { textView.setText(getStringEntry(R.string.Reset)); } } if (type == 1) { if (view == null) { LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = li.inflate(R.layout.settings_row_check_notify_layout, viewGroup, false); } TextView textView = (TextView)view.findViewById(R.id.settings_row_text); View divider = view.findViewById(R.id.settings_row_divider); ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); boolean enabled = false; boolean enabledAll = preferences.getBoolean("EnableAll", true); if (i == 1 || i == 6) { if (i == 1) { enabled = enabledAll; } else if (i == 6) { enabled = preferences.getBoolean("EnableGroup", true); } textView.setText(getStringEntry(R.string.Alert)); divider.setVisibility(View.VISIBLE); } else if (i == 2 || i == 7) { if (i == 2) { enabled = preferences.getBoolean("EnablePreviewAll", true); } else if (i == 7) { enabled = preferences.getBoolean("EnablePreviewGroup", true); } textView.setText(getStringEntry(R.string.MessagePreview)); divider.setVisibility(View.VISIBLE); } else if (i == 3 || i == 8) { if (i == 3) { enabled = preferences.getBoolean("EnableVibrateAll", true); } else if (i == 8) { enabled = preferences.getBoolean("EnableVibrateGroup", true); } textView.setText(getStringEntry(R.string.Vibrate)); divider.setVisibility(View.VISIBLE); } else if (i == 11) { enabled = preferences.getBoolean("EnableInAppSounds", true); textView.setText(getStringEntry(R.string.InAppSounds)); divider.setVisibility(View.VISIBLE); } else if (i == 12) { enabled = preferences.getBoolean("EnableInAppVibrate", true); textView.setText(getStringEntry(R.string.InAppVibrate)); divider.setVisibility(View.VISIBLE); } else if (i == 13) { enabled = preferences.getBoolean("EnableInAppPreview", true); textView.setText(getStringEntry(R.string.InAppPreview)); divider.setVisibility(View.INVISIBLE); } else if (i == 15) { enabled = preferences.getBoolean("EnableContactJoined", true); textView.setText(getStringEntry(R.string.ContactJoined)); divider.setVisibility(View.INVISIBLE); } if (enabled) { checkButton.setImageResource(R.drawable.btn_check_on); } else { checkButton.setImageResource(R.drawable.btn_check_off); } if (i != 1 && !enabledAll && i != 15) { view.setEnabled(false); if(android.os.Build.VERSION.SDK_INT >= 11) { checkButton.setAlpha(0.3f); textView.setAlpha(0.3f); } } else { if(android.os.Build.VERSION.SDK_INT >= 11) { checkButton.setAlpha(1.0f); textView.setAlpha(1.0f); } view.setEnabled(true); } } else if (type == 2) { if (view == null) { LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = li.inflate(R.layout.settings_row_detail_layout, viewGroup, false); } TextView textView = (TextView)view.findViewById(R.id.settings_row_text); TextView textViewDetail = (TextView)view.findViewById(R.id.settings_row_text_detail); View divider = view.findViewById(R.id.settings_row_divider); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); boolean enabledAll = preferences.getBoolean("EnableAll", true); if (i == 4 || i == 9) { if (i == 4) { String name = preferences.getString("GlobalSound", getStringEntry(R.string.Default)); if (name.equals("NoSound")) { textViewDetail.setText(getStringEntry(R.string.NoSound)); } else { textViewDetail.setText(name); } } else if (i == 9) { String name = preferences.getString("GroupSound", getStringEntry(R.string.Default)); if (name.equals("NoSound")) { textViewDetail.setText(getStringEntry(R.string.NoSound)); } else { textViewDetail.setText(name); } } textView.setText(getStringEntry(R.string.Sound)); divider.setVisibility(View.INVISIBLE); } else if (i == 17) { textView.setText(getStringEntry(R.string.ResetAllNotifications)); textViewDetail.setText(getStringEntry(R.string.UndoAllCustom)); divider.setVisibility(View.INVISIBLE); } if (i != 17 && !enabledAll) { view.setEnabled(false); if(android.os.Build.VERSION.SDK_INT >= 11) { textView.setAlpha(0.3f); textViewDetail.setAlpha(0.3f); divider.setAlpha(0.3f); } } else { if(android.os.Build.VERSION.SDK_INT >= 11) { textView.setAlpha(1.0f); textViewDetail.setAlpha(1.0f); divider.setAlpha(1.0f); } view.setEnabled(true); } } return view; }
private void setCurrentTitle_City(String city_name, float alpha) { TextView city_name_textview = (TextView) findViewById(R.id.city_name); city_name_textview.setText(city_name); city_name_textview.setAlpha(alpha); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); title.setAlpha(0); accountUtils = new CacheUtils(this, CacheUtils.CacheType.FOR_ACCOUNT); mNvMenu.getmMenuLv().setOnItemClickListener(this); mDrawerLayout.setDrawerListener( new DrawerLayout.SimpleDrawerListener() { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); // mLogo.setImageResource(R.mipmap.back); mLogo.setState(MaterialMenuDrawable.IconState.ARROW); list_clickable = false; } @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); title.setAlpha(slideOffset); title2.setAlpha(1 - slideOffset); mLogo.setTransformationOffset( MaterialMenuDrawable.AnimationState.BURGER_ARROW, slideOffset); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); // mLogo.setImageResource(R.mipmap.open_left_menu); mLogo.setState(MaterialMenuDrawable.IconState.BURGER); list_clickable = true; } }); adapter = new BookListAdapter(); listView.setAdapter(adapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (list_clickable) { buy(App.courseList.get(position), position); } } }); mPtrv.setOnRefreshListener( new PullToRefreshView.OnRefreshListener() { @Override public void onRefresh() { if (NetworkChecker.IsNetworkAvailable(MainActivity.this)) { refrushBookList(); } else showToast("网络错误"); } }); if (App.courseList.size() == 0) { if (NetworkChecker.IsNetworkAvailable(MainActivity.this)) { refrushBookList(); } else showToast("网络错误"); } }
private void fadeInStartButton() { mButtonStartApp.setVisibility(View.VISIBLE); mButtonStartApp.setAlpha(0); mButtonStartApp.animate().alpha(1); }
private void updateSubmitBtn(boolean enable) { mBtnSubmit.setTextColor(enable ? mColorEnabled : mColorBlack); mBtnSubmit.setAlpha(enable ? 1f : 0.26f); mBtnSubmit.setEnabled(enable); }
public void setTextViewAlpha(float alpha) { textView.setAlpha(alpha); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this)); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Point displaySize = new Point(); getWindowManager().getDefaultDisplay().getRealSize(displaySize); vsv = new AppRTCGLView(this, displaySize); VideoRendererGui.setView(vsv); remoteRender = VideoRendererGui.create(0, 0, 100, 100); localRender = VideoRendererGui.create(70, 5, 25, 25); vsv.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { toggleHUD(); } }); setContentView(vsv); logAndToast("Tap the screen to toggle stats visibility"); hudView = new TextView(this); hudView.setTextColor(Color.BLACK); hudView.setBackgroundColor(Color.WHITE); hudView.setAlpha(0.4f); hudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); hudView.setVisibility(View.INVISIBLE); addContentView(hudView, hudLayout); if (!factoryStaticInitialized) { abortUnless( PeerConnectionFactory.initializeAndroidGlobals(this, true, true), "Failed to initializeAndroidGlobals"); factoryStaticInitialized = true; } AudioManager audioManager = ((AudioManager) getSystemService(AUDIO_SERVICE)); // TODO(fischman): figure out how to do this Right(tm) and remove the // suppression. @SuppressWarnings("deprecation") boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn(); audioManager.setMode( isWiredHeadsetOn ? AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION); audioManager.setSpeakerphoneOn(!isWiredHeadsetOn); sdpMediaConstraints = new MediaConstraints(); sdpMediaConstraints.mandatory.add( new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true")); sdpMediaConstraints.mandatory.add( new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true")); final Intent intent = getIntent(); if ("android.intent.action.VIEW".equals(intent.getAction())) { connectToRoom(intent.getData().toString()); return; } showGetRoomUI(); }
private void _showTapText() { _tapEventTxtShow.setVisibility(View.VISIBLE); _tapEventTxtShow.setAlpha(1f); ViewCompat.animate(_tapEventTxtShow).alphaBy(-1f).setDuration(400); }
private void init(Context context, AttributeSet attrs, int defStyle) { // Load custom attributes final int layout; final CharSequence text; final CharSequence hint; final ColorStateList hintColor; final int inputType; final int imeOptions; if (attrs == null) { layout = R.layout.float_label; text = null; hint = null; hintColor = null; inputType = EditorInfo.TYPE_CLASS_TEXT; imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; } else { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabel, defStyle, 0); layout = a.getResourceId(R.styleable.FloatLabel_android_layout, R.layout.float_label); text = a.getText(R.styleable.FloatLabel_android_text); hint = a.getText(R.styleable.FloatLabel_android_hint); hintColor = a.getColorStateList(R.styleable.FloatLabel_android_textColorHint); inputType = a.getInt(R.styleable.FloatLabel_android_inputType, EditorInfo.TYPE_CLASS_TEXT); imeOptions = a.getInt(R.styleable.FloatLabel_android_imeOptions, EditorInfo.IME_ACTION_UNSPECIFIED); a.recycle(); } inflate(context, layout, this); mEditText = (TextView) findViewById(R.id.edit_text); if (mEditText == null) { throw new RuntimeException("Your layout must have an EditText whose ID is @id/edit_text"); } mEditText.setHint(hint); mEditText.setText(text); if (hintColor != null) { mEditText.setHintTextColor(hintColor); } mEditText.setInputType(inputType); mEditText.setImeOptions(imeOptions); mLabel = (TextView) findViewById(R.id.float_label); if (mLabel == null) { throw new RuntimeException("Your layout must have a TextView whose ID is @id/float_label"); } mLabel.setText(mEditText.getHint()); // Listen to EditText to know when it is empty or nonempty mEditText.addTextChangedListener(new EditTextWatcher()); // Check current state of EditText if (mEditText.getText().length() == 0) { mLabel.setAlpha(0); mLabelShowing = false; } else { mLabel.setVisibility(View.VISIBLE); mLabelShowing = true; } // Mark init as complete to prevent accidentally breaking the view by // adding children mInitComplete = true; }