List of usage examples for android.transition TransitionManager beginDelayedTransition
public static void beginDelayedTransition(final ViewGroup sceneRoot)
From source file:io.plaidapp.ui.DesignerNewsLogin.java
private void showLoading() { TransitionManager.beginDelayedTransition(container); title.setVisibility(View.GONE); usernameLabel.setVisibility(View.GONE); passwordLabel.setVisibility(View.GONE); actionsContainer.setVisibility(View.GONE); loading.setVisibility(View.VISIBLE); }
From source file:nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapterv2.java
@Override public void onBindViewHolder(ViewHolder holder, final int position) { final GBDevice device = deviceList.get(position); final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device); holder.container.setOnClickListener(new View.OnClickListener() { @Override//from ww w . j a v a 2 s . c om public void onClick(View v) { if (device.isInitialized() || device.isConnected()) { showTransientSnackbar(R.string.controlcenter_snackbar_need_longpress); } else { showTransientSnackbar(R.string.controlcenter_snackbar_connecting); GBApplication.deviceService().connect(device); } } }); holder.container.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (device.getState() != GBDevice.State.NOT_CONNECTED) { showTransientSnackbar(R.string.controlcenter_snackbar_disconnecting); GBApplication.deviceService().disconnect(); } return true; } }); holder.deviceImageView.setImageResource(R.drawable.level_list_device); //level-list does not allow negative values, hence we always add 100 to the key. holder.deviceImageView.setImageLevel(device.getType().getKey() + 100 + (device.isInitialized() ? 100 : 0)); holder.deviceNameLabel.setText(getUniqueDeviceName(device)); if (device.isBusy()) { holder.deviceStatusLabel.setText(device.getBusyTask()); holder.busyIndicator.setVisibility(View.VISIBLE); } else { holder.deviceStatusLabel.setText(device.getStateString()); holder.busyIndicator.setVisibility(View.INVISIBLE); } //begin of action row //battery holder.batteryStatusBox.setVisibility(View.GONE); short batteryLevel = device.getBatteryLevel(); if (batteryLevel != GBDevice.BATTERY_UNKNOWN) { holder.batteryStatusBox.setVisibility(View.VISIBLE); holder.batteryStatusLabel.setText(device.getBatteryLevel() + "%"); BatteryState batteryState = device.getBatteryState(); if (BatteryState.BATTERY_CHARGING.equals(batteryState) || BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) { holder.batteryIcon.setImageLevel(device.getBatteryLevel() + 100); } else { holder.batteryIcon.setImageLevel(device.getBatteryLevel()); } } //fetch activity data holder.fetchActivityDataBox.setVisibility( (device.isInitialized() && coordinator.supportsActivityDataFetching()) ? View.VISIBLE : View.GONE); holder.fetchActivityData.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTransientSnackbar(R.string.busy_task_fetch_activity_data); GBApplication.deviceService().onFetchActivityData(); } }); //take screenshot holder.takeScreenshotView.setVisibility( (device.isInitialized() && coordinator.supportsScreenshots()) ? View.VISIBLE : View.GONE); holder.takeScreenshotView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTransientSnackbar(R.string.controlcenter_snackbar_requested_screenshot); GBApplication.deviceService().onScreenshotReq(); } }); //manage apps holder.manageAppsView.setVisibility( (device.isInitialized() && coordinator.supportsAppsManagement()) ? View.VISIBLE : View.GONE); holder.manageAppsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device); Class<? extends Activity> appsManagementActivity = coordinator.getAppsManagementActivity(); if (appsManagementActivity != null) { Intent startIntent = new Intent(context, appsManagementActivity); startIntent.putExtra(GBDevice.EXTRA_DEVICE, device); context.startActivity(startIntent); } } }); //set alarms holder.setAlarmsView.setVisibility(coordinator.supportsAlarmConfiguration() ? View.VISIBLE : View.GONE); holder.setAlarmsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent startIntent; startIntent = new Intent(context, ConfigureAlarms.class); context.startActivity(startIntent); } }); //show graphs holder.showActivityGraphs.setVisibility(coordinator.supportsActivityTracking() ? View.VISIBLE : View.GONE); holder.showActivityGraphs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent startIntent; startIntent = new Intent(context, ChartsActivity.class); startIntent.putExtra(GBDevice.EXTRA_DEVICE, device); context.startActivity(startIntent); } }); ItemWithDetailsAdapter infoAdapter = new ItemWithDetailsAdapter(context, device.getDeviceInfos()); infoAdapter.setHorizontalAlignment(true); holder.deviceInfoList.setAdapter(infoAdapter); justifyListViewHeightBasedOnChildren(holder.deviceInfoList); holder.deviceInfoList.setFocusable(false); final boolean detailsShown = position == expandedDevicePosition; boolean showInfoIcon = device.hasDeviceInfos() && !device.isBusy(); holder.deviceInfoView.setVisibility(showInfoIcon ? View.VISIBLE : View.GONE); holder.deviceInfoBox.setActivated(detailsShown); holder.deviceInfoBox.setVisibility(detailsShown ? View.VISIBLE : View.GONE); holder.deviceInfoView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { expandedDevicePosition = detailsShown ? -1 : position; TransitionManager.beginDelayedTransition(parent); notifyDataSetChanged(); } } ); holder.findDevice.setVisibility(device.isInitialized() ? View.VISIBLE : View.GONE); holder.findDevice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (device.getType() == DeviceType.VIBRATISSIMO) { Intent startIntent; startIntent = new Intent(context, VibrationActivity.class); startIntent.putExtra(GBDevice.EXTRA_DEVICE, device); context.startActivity(startIntent); return; } GBApplication.deviceService().onFindDevice(true); //TODO: extract string resource if we like this solution. Snackbar.make(parent, R.string.control_center_find_lost_device, Snackbar.LENGTH_INDEFINITE) .setAction("Found it!", new View.OnClickListener() { @Override public void onClick(View v) { GBApplication.deviceService().onFindDevice(false); } }).setCallback(new Snackbar.Callback() { @Override public void onDismissed(Snackbar snackbar, int event) { GBApplication.deviceService().onFindDevice(false); super.onDismissed(snackbar, event); } }).show(); // ProgressDialog.show( // context, // context.getString(R.string.control_center_find_lost_device), // context.getString(R.string.control_center_cancel_to_stop_vibration), // true, true, // new DialogInterface.OnCancelListener() { // @Override // public void onCancel(DialogInterface dialog) { // GBApplication.deviceService().onFindDevice(false); // } // }); } } ); //remove device, hidden under details holder.removeDevice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(context).setCancelable(true) .setTitle(context.getString(R.string.controlcenter_delete_device_name, device.getName())) .setMessage(R.string.controlcenter_delete_device_dialogmessage) .setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { DeviceCoordinator coordinator = DeviceHelper.getInstance() .getCoordinator(device); if (coordinator != null) { coordinator.deleteDevice(device); } DeviceHelper.getInstance().removeBond(device); } catch (Exception ex) { GB.toast(context, "Error deleting device: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex); } finally { Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST); LocalBroadcastManager.getInstance(context).sendBroadcast(refreshIntent); } } }).setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // do nothing } }).show(); } }); }
From source file:io.plaidapp.ui.DesignerNewsLogin.java
private void showLoading() { TransitionManager.beginDelayedTransition(container); title.setVisibility(View.GONE); usernameLabel.setVisibility(View.GONE); permissionPrimer.setVisibility(View.GONE); passwordLabel.setVisibility(View.GONE); actionsContainer.setVisibility(View.GONE); loading.setVisibility(View.VISIBLE); }
From source file:io.plaidapp.ui.DesignerNewsLogin.java
private void showLogin() { TransitionManager.beginDelayedTransition(container); title.setVisibility(View.VISIBLE); usernameLabel.setVisibility(View.VISIBLE); passwordLabel.setVisibility(View.VISIBLE); actionsContainer.setVisibility(View.VISIBLE); loading.setVisibility(View.GONE); }
From source file:com.achep.acdisplay.ui.components.MediaWidget.java
/** * Updates the content of the view to latest metadata * provided by {@link com.achep.acdisplay.services.media.MediaController2#getMetadata()}. *///from w w w. ja v a 2 s . c o m private void populateMetadata() { if (mIdle) { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } } Metadata metadata = mMediaController.getMetadata(); ViewUtils.safelySetText(mTitleView, metadata.title); ViewUtils.safelySetText(mSubtitleView, metadata.subtitle); mDurationText.setText(formatTime(metadata.duration)); mSeekUiAtomic.stop(); mSeekBar.setMax(Math.min(100, (int) (metadata.duration / 1000L))); if (mArtworkView != null) { mArtworkView.setImageBitmap(metadata.bitmap); } }
From source file:io.plaidapp.ui.PlayerActivity.java
void bindPlayer() { if (player == null) return;//from ww w . j av a 2 s . com final Resources res = getResources(); final NumberFormat nf = NumberFormat.getInstance(); Glide.with(this).load(player.getHighQualityAvatarUrl()).placeholder(R.drawable.avatar_placeholder) .transform(circleTransform).into(avatar); playerName.setText(player.name.toLowerCase()); if (!TextUtils.isEmpty(player.bio)) { DribbbleUtils.parseAndSetText(bio, player.bio); } else { bio.setVisibility(View.GONE); } shotCount .setText(res.getQuantityString(R.plurals.shots, player.shots_count, nf.format(player.shots_count))); if (player.shots_count == 0) { shotCount.setCompoundDrawablesRelativeWithIntrinsicBounds(null, getDrawable(R.drawable.avd_no_shots), null, null); } setFollowerCount(player.followers_count); likesCount .setText(res.getQuantityString(R.plurals.likes, player.likes_count, nf.format(player.likes_count))); // load the users shots dataManager = new PlayerShotsDataManager(this, player) { @Override public void onDataLoaded(List<Shot> data) { if (data != null && data.size() > 0) { if (adapter.getDataItemCount() == 0) { loading.setVisibility(View.GONE); ViewUtils.setPaddingTop(shots, likesCount.getBottom()); } adapter.addAndResort(data); } } }; adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this)); shots.setAdapter(adapter); shots.setItemAnimator(new SlideInItemAnimator()); shots.setVisibility(View.VISIBLE); layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); shots.setLayoutManager(layoutManager); shots.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadData(); } }); shots.setHasFixedSize(true); // forward on any clicks above the first item in the grid (i.e. in the paddingTop) // to 'pass through' to the view behind shots.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final int firstVisible = layoutManager.findFirstVisibleItemPosition(); if (firstVisible > 0) return false; // if no data loaded then pass through if (adapter.getDataItemCount() == 0) { return container.dispatchTouchEvent(event); } final RecyclerView.ViewHolder vh = shots.findViewHolderForAdapterPosition(0); if (vh == null) return false; final int firstTop = vh.itemView.getTop(); if (event.getY() < firstTop) { return container.dispatchTouchEvent(event); } return false; } }); // check if following if (dataManager.getDribbblePrefs().isLoggedIn()) { if (player.id == dataManager.getDribbblePrefs().getUserId()) { TransitionManager.beginDelayedTransition(container); follow.setVisibility(View.GONE); ViewUtils.setPaddingTop(shots, container.getHeight() - follow.getHeight() - ((ViewGroup.MarginLayoutParams) follow.getLayoutParams()).bottomMargin); } else { final Call<Void> followingCall = dataManager.getDribbbleApi().following(player.id); followingCall.enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { following = response.isSuccessful(); if (!following) return; TransitionManager.beginDelayedTransition(container); follow.setText(R.string.following); follow.setActivated(true); } @Override public void onFailure(Call<Void> call, Throwable t) { } }); } } if (player.shots_count > 0) { dataManager.loadData(); // kick off initial load } else { loading.setVisibility(View.GONE); } }
From source file:io.plaidapp.ui.PlayerActivity.java
@OnClick(R.id.follow) void follow() {/*from www .ja va2 s.co m*/ if (DribbblePrefs.get(this).isLoggedIn()) { if (following != null && following) { final Call<Void> unfollowCall = dataManager.getDribbbleApi().unfollow(player.id); unfollowCall.enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { } @Override public void onFailure(Call<Void> call, Throwable t) { } }); following = false; TransitionManager.beginDelayedTransition(container); follow.setText(R.string.follow); follow.setActivated(false); setFollowerCount(followerCount - 1); } else { final Call<Void> followCall = dataManager.getDribbbleApi().follow(player.id); followCall.enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { } @Override public void onFailure(Call<Void> call, Throwable t) { } }); following = true; TransitionManager.beginDelayedTransition(container); follow.setText(R.string.following); follow.setActivated(true); setFollowerCount(followerCount + 1); } } else { Intent login = new Intent(this, DribbbleLogin.class); MorphTransform.addExtras(login, ContextCompat.getColor(this, R.color.dribbble), getResources().getDimensionPixelSize(R.dimen.dialog_corners)); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, follow, getString(R.string.transition_dribbble_login)); startActivity(login, options.toBundle()); } }
From source file:com.android.deskclock.stopwatch.StopwatchFragment.java
/** * Show or hide the list of laps.// w ww.jav a2 s . c om */ private void showOrHideLaps(boolean clearLaps) { final ViewGroup sceneRoot = (ViewGroup) getView(); if (sceneRoot == null) { return; } TransitionManager.beginDelayedTransition(sceneRoot); if (clearLaps) { mLapsAdapter.clearLaps(); } final boolean lapsVisible = mLapsAdapter.getItemCount() > 0; mLapsList.setVisibility(lapsVisible ? VISIBLE : GONE); if (Utils.isPortrait(getActivity())) { // When the lap list is visible, it includes the bottom padding. When it is absent the // appropriate bottom padding must be applied to the container. final Resources res = getResources(); final int bottom = lapsVisible ? 0 : res.getDimensionPixelSize(R.dimen.fab_height); final int top = sceneRoot.getPaddingTop(); final int left = sceneRoot.getPaddingLeft(); final int right = sceneRoot.getPaddingRight(); sceneRoot.setPadding(left, top, right, bottom); } }
From source file:com.bullmobi.message.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.easynotification_scene_music, container, false); assert sceneView != null; }/* ww w .ja v a 2s . co m*/ mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:com.achep.acdisplay.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.acdisplay_scene_music, container, false); assert sceneView != null; }//from www .ja v a 2 s .c o m mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }