use of android.graphics.drawable.AnimationDrawable in project remusic by aa112901.
the class AppCompatImageHelper method setImageDrawable.
/**
* Internal use
*/
private void setImageDrawable(Drawable drawable) {
if (skipNextApply())
return;
if (drawable instanceof AnimationDrawable) {
Log.e("drawable", "instanceof true");
AnimationDrawable drawable1 = ((AnimationDrawable) drawable);
((ImageView) mView).setImageDrawable(drawable1);
drawable1.start();
} else {
((ImageView) mView).setImageDrawable(drawable);
}
}
use of android.graphics.drawable.AnimationDrawable in project bunk by abhijitparida.
the class LoginActivity method setupLoginButton.
private void setupLoginButton() {
Button loginButton = findViewById(R.id.login);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = mUsernameInput.getText().toString();
String password = mPasswordInput.getText().toString();
mSharedPreferences.edit().putString("pref_student", username).apply();
mUsernameInput.setEnabled(false);
mPasswordInput.setEnabled(false);
mPasswordVisilibity.setEnabled(false);
mLoginButton.setEnabled(false);
mLoginButton.setText("LOADING...");
mLoginButton.setBackgroundResource(R.drawable.bg_login_button_loading);
((AnimationDrawable) mLoginButton.getBackground()).start();
mIterApi.getStudent(username, password, new IterApi.Callback() {
@Override
public void onData(@NonNull final Student student) {
if (mCache.getStudent(student.username) == null) {
Toast.makeText(mContext, "Credentials will be stored on your device until you Logout", Toast.LENGTH_SHORT).show();
}
mLoginButton.setText(emoji(0x1F60F) + emoji(0x1F60F) + emoji(0x1F60F));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(LoginActivity.this, AttendanceActivity.class);
intent.putExtra("student", new Gson().toJson(student));
startActivity(intent);
finish();
}
}, 750);
}
@Override
public void onError(@NonNull RuntimeException error) {
if (error instanceof ConnectionFailedException) {
Toast.makeText(mContext, "ITER servers are currently down", Toast.LENGTH_LONG).show();
} else if (error instanceof InvalidCredentialsException) {
Toast.makeText(mContext, "Invalid credentials", Toast.LENGTH_LONG).show();
} else if (error instanceof InvalidResponseException) {
Toast.makeText(mContext, "Invalid API response", Toast.LENGTH_LONG).show();
}
if ((error instanceof InvalidResponseException || error instanceof ConnectionFailedException) && mCache.getStudent(mSharedPreferences.getString("pref_student", null)) != null) {
mLoginButton.setText("¯\\_(ツ)_/¯");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(LoginActivity.this, AttendanceActivity.class);
startActivity(intent);
finish();
}
}, 750);
} else {
mSharedPreferences.edit().putString("pref_student", null).apply();
((AnimationDrawable) mLoginButton.getBackground()).stop();
mUsernameInput.setEnabled(true);
mPasswordInput.setEnabled(true);
mPasswordVisilibity.setEnabled(true);
mLoginButton.setBackgroundResource(R.drawable.bg_login_button_error);
mLoginButton.setText("ERROR");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mLoginButton.setEnabled(true);
mLoginButton.setText("BUNK!");
mLoginButton.setBackgroundResource(R.drawable.bg_login_button);
}
}, 2000);
}
}
});
}
});
}
use of android.graphics.drawable.AnimationDrawable in project android_packages_apps_Snap by LineageOS.
the class CameraControls method showUI.
public void showUI() {
if (!isAnimating)
enableTouch(false);
isAnimating = true;
int rotation = getUnifiedRotation();
mFrontBackSwitcher.animate().cancel();
if (TsMakeupManager.HAS_TS_MAKEUP) {
mTsMakeupSwitcher.animate().cancel();
} else {
mHdrSwitcher.animate().cancel();
}
if (mIsBokehMode) {
mBokehSwitcher.animate().cancel();
}
mSceneModeSwitcher.animate().cancel();
mFilterModeSwitcher.animate().cancel();
mSwitcher.animate().cancel();
mShutter.animate().cancel();
mVideoShutter.animate().cancel();
mMenu.animate().cancel();
mMute.animate().cancel();
mExitPanorama.animate().cancel();
mPreview.animate().cancel();
if (mViewList != null)
for (View v : mViewList) {
v.setVisibility(View.VISIBLE);
}
((ModuleSwitcher) mSwitcher).removePopup();
AnimationDrawable shutterAnim = (AnimationDrawable) mShutter.getBackground();
if (shutterAnim != null)
shutterAnim.stop();
mMenu.setVisibility(View.VISIBLE);
mPreview.setVisibility(View.VISIBLE);
mFrontBackSwitcher.animate().setListener(inlistener);
switch(rotation) {
case 0:
resetLocation(0, -mSize);
mFrontBackSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
if (TsMakeupManager.HAS_TS_MAKEUP) {
mTsMakeupSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
} else {
mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
}
if (mIsBokehMode) {
mBokehSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
}
mSceneModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mMute.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mExitPanorama.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mShutter.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mVideoShutter.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mPreview.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
break;
case 90:
resetLocation(-mSize, 0);
mFrontBackSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
if (TsMakeupManager.HAS_TS_MAKEUP) {
mTsMakeupSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
} else {
mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
}
if (mIsBokehMode) {
mBokehSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
}
mSceneModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mMute.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mExitPanorama.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mShutter.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mVideoShutter.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mPreview.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
break;
case 180:
resetLocation(0, mSize);
mFrontBackSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
if (TsMakeupManager.HAS_TS_MAKEUP) {
mTsMakeupSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
} else {
mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
}
if (mIsBokehMode) {
mBokehSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
}
mSceneModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mMute.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mExitPanorama.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mShutter.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mVideoShutter.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mPreview.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
break;
case 270:
resetLocation(mSize, 0);
mFrontBackSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
if (TsMakeupManager.HAS_TS_MAKEUP) {
mTsMakeupSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
} else {
mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
}
if (mIsBokehMode) {
mBokehSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
}
mSceneModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mMute.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mExitPanorama.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mShutter.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mVideoShutter.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mPreview.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
break;
}
if ((mRemainingPhotos.getVisibility() == View.INVISIBLE) && !mHideRemainingPhoto) {
mRemainingPhotos.setVisibility(View.VISIBLE);
}
mRefocusToast.setVisibility(View.GONE);
}
use of android.graphics.drawable.AnimationDrawable in project android_packages_apps_Dialer by MoKee.
the class CallCardFragment method setCallState.
@Override
public void setCallState(int state, int videoState, int sessionModificationState, DisconnectCause disconnectCause, String connectionLabel, Drawable callStateIcon, String gatewayNumber, boolean isWifi, boolean isConference, boolean isWaitingForRemoteSide, boolean isWorkCall) {
boolean isGatewayCall = !TextUtils.isEmpty(gatewayNumber);
CallStateLabel callStateLabel = getCallStateLabelFromState(state, videoState, sessionModificationState, disconnectCause, connectionLabel, isGatewayCall, isWifi, isConference, isWaitingForRemoteSide, isWorkCall);
Log.v(this, "setCallState " + callStateLabel.getCallStateLabel());
Log.v(this, "AutoDismiss " + callStateLabel.isAutoDismissing());
Log.v(this, "DisconnectCause " + disconnectCause.toString());
Log.v(this, "gateway " + connectionLabel + gatewayNumber);
// Check for video state change and update the visibility of the contact photo. The contact
// photo is hidden when the incoming video surface is shown.
// The contact photo visibility can also change in setPrimary().
boolean showContactPhoto = !VideoCallPresenter.showIncomingVideo(videoState, state);
mPhotoLarge.setVisibility(showContactPhoto ? View.VISIBLE : View.GONE);
// Check if the call subject is showing -- if it is, we want to bypass showing the call
// state.
boolean isSubjectShowing = mCallSubject.getVisibility() == View.VISIBLE;
boolean isSubChanged = (callStateIcon != mCallStateIcon.getDrawable());
if (TextUtils.equals(callStateLabel.getCallStateLabel(), mCallStateLabel.getText()) && !isSubjectShowing && !isSubChanged) {
// Nothing to do if the labels are the same
if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED) {
mCallStateLabel.clearAnimation();
mCallStateIcon.clearAnimation();
}
return;
}
if (isSubjectShowing) {
changeCallStateLabel(null);
callStateIcon = null;
} else {
// Update the call state label and icon.
setCallStateLabel(callStateLabel);
}
if (!TextUtils.isEmpty(callStateLabel.getCallStateLabel())) {
if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED) {
mCallStateLabel.clearAnimation();
} else {
mCallStateLabel.startAnimation(mPulseAnimation);
}
} else {
mCallStateLabel.clearAnimation();
}
if (callStateIcon != null) {
mCallStateIcon.setVisibility(View.VISIBLE);
// Invoke setAlpha(float) instead of setAlpha(int) to set the view's alpha. This is
// needed because the pulse animation operates on the view alpha.
mCallStateIcon.setAlpha(1.0f);
mCallStateIcon.setImageDrawable(callStateIcon);
MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors();
if (themeColors != null) {
// Change the alpha value in the 32 bit color of sim card, because the color of
// call background changed with the color of sim card.
// Set the tint mode to SCREEN to avoid the slot number in the sim icon to be
// covered.
int stateIconColor = (themeColors.mPrimaryColor & 0x00ffffff) | 0x7f000000;
mCallStateIcon.setImageTintMode(PorterDuff.Mode.SCREEN);
mCallStateIcon.setImageTintList(ColorStateList.valueOf(stateIconColor));
Log.d(this, "Set tint of call state icon to " + stateIconColor);
}
if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED || TextUtils.isEmpty(callStateLabel.getCallStateLabel())) {
mCallStateIcon.clearAnimation();
} else {
mCallStateIcon.startAnimation(mPulseAnimation);
}
if (callStateIcon instanceof AnimationDrawable) {
((AnimationDrawable) callStateIcon).start();
}
if (isSubChanged) {
updateColors();
}
} else {
mCallStateIcon.clearAnimation();
// Invoke setAlpha(float) instead of setAlpha(int) to set the view's alpha. This is
// needed because the pulse animation operates on the view alpha.
mCallStateIcon.setAlpha(0.0f);
mCallStateIcon.setVisibility(View.GONE);
}
mCallStateIcon.requestLayout();
if (VideoUtils.isVideoCall(videoState) || (state == Call.State.ACTIVE && sessionModificationState == Call.SessionModificationState.WAITING_FOR_RESPONSE)) {
mCallStateVideoCallIcon.setVisibility(View.VISIBLE);
} else {
mCallStateVideoCallIcon.setVisibility(View.GONE);
}
}
use of android.graphics.drawable.AnimationDrawable in project SmartAndroidSource by jaychou2012.
the class IcsProgressBar method tileifyIndeterminate.
/**
* Convert a AnimationDrawable for use as a barberpole animation. Each frame
* of the animation is wrapped in a ClipDrawable and given a tiling
* BitmapShader.
*/
private Drawable tileifyIndeterminate(Drawable drawable) {
if (drawable instanceof AnimationDrawable) {
AnimationDrawable background = (AnimationDrawable) drawable;
final int N = background.getNumberOfFrames();
AnimationDrawable newBg = new AnimationDrawable();
newBg.setOneShot(background.isOneShot());
for (int i = 0; i < N; i++) {
Drawable frame = tileify(background.getFrame(i), true);
frame.setLevel(10000);
newBg.addFrame(frame, background.getDuration(i));
}
newBg.setLevel(10000);
drawable = newBg;
}
return drawable;
}
Aggregations