use of android.view.animation.Animation.AnimationListener in project newsrob by marianokamp.
the class ShowArticleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if ("1".equals(NewsRob.getDebugProperties(this).getProperty("traceArticleDetailViewLaunch", "0")))
Debug.startMethodTracing("traceArticleDetialViewLaunch");
boolean isHwAccelerationEnabled = EntryManager.getInstance(this).isHardwareAccelerationAdvEnabled();
PL.log("User set hw accel to enabled=" + isHwAccelerationEnabled + " (activity: " + this + ").", this);
if (isHwAccelerationEnabled && !getEntryManager().isLightColorSchemeSelected()) {
PL.log("HW accel still disabled because of dark theme.", this);
isHwAccelerationEnabled = false;
}
if (isHwAccelerationEnabled)
SDK11Helper.enableHWAccelerationForActivity(this);
setTheme(getEntryManager().getCurrentThemeResourceId());
// setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
// gui
debug = "1".equals(NewsRob.getDebugProperties(this).getProperty("_articleDetailViewVerbose", "0"));
savedContentCursorPosition = -1;
requestWindowFeature(Window.FEATURE_NO_TITLE);
if (getIntent().getExtras() == null) {
finish();
return;
}
setContentView(com.newsrob.R.layout.show_article);
googleAdsUtil = new GoogleAdsUtil(getEntryManager());
uiHelper = new UIHelper(getEntryManager());
RelativeLayout container = getContainer();
registerForContextMenu(container);
container.setOnClickListener(this);
container.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
lastLongClickTarget = v;
return false;
}
});
embeddedWebClient = new EmbeddedWebViewClient();
createWebView(container);
createOnScreenControls(container);
// end-gui
// runnables
refreshUIRunnable = new Runnable() {
public void run() {
refreshUI();
}
};
hideTitlePreviewRunnable = new Runnable() {
public void run() {
hideTitlePreview();
}
};
titlePreviewContainer = findViewById(R.id.title_preview);
hideAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f);
hideAnimation.setDuration(300);
hideAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
titlePreviewContainer.setVisibility(View.INVISIBLE);
}
});
showAnimation = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f);
showAnimation.setDuration(300);
showAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
titlePreviewContainer.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
});
// end-runnables
initialize(getIntent());
}
use of android.view.animation.Animation.AnimationListener in project android_frameworks_base by AOSPA.
the class SlidingTab method startAnimating.
void startAnimating(final boolean holdAfter) {
mAnimating = true;
final Animation trans1;
final Animation trans2;
final Slider slider = mCurrentSlider;
final Slider other = mOtherSlider;
final int dx;
final int dy;
if (isHorizontal()) {
int right = slider.tab.getRight();
int width = slider.tab.getWidth();
int left = slider.tab.getLeft();
int viewWidth = getWidth();
// how much of tab to show at the end of anim
int holdOffset = holdAfter ? 0 : width;
dx = slider == mRightSlider ? -(right + viewWidth - holdOffset) : (viewWidth - left) + viewWidth - holdOffset;
dy = 0;
} else {
int top = slider.tab.getTop();
int bottom = slider.tab.getBottom();
int height = slider.tab.getHeight();
int viewHeight = getHeight();
// how much of tab to show at end of anim
int holdOffset = holdAfter ? 0 : height;
dx = 0;
dy = slider == mRightSlider ? (top + viewHeight - holdOffset) : -((viewHeight - bottom) + viewHeight - holdOffset);
}
trans1 = new TranslateAnimation(0, dx, 0, dy);
trans1.setDuration(ANIM_DURATION);
trans1.setInterpolator(new LinearInterpolator());
trans1.setFillAfter(true);
trans2 = new TranslateAnimation(0, dx, 0, dy);
trans2.setDuration(ANIM_DURATION);
trans2.setInterpolator(new LinearInterpolator());
trans2.setFillAfter(true);
trans1.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
Animation anim;
if (holdAfter) {
anim = new TranslateAnimation(dx, dx, dy, dy);
// plenty of time for transitions
anim.setDuration(1000);
mAnimating = false;
} else {
anim = new AlphaAnimation(0.5f, 1.0f);
anim.setDuration(ANIM_DURATION);
resetView();
}
anim.setAnimationListener(mAnimationDoneListener);
/* Animation can be the same for these since the animation just holds */
mLeftSlider.startAnimation(anim, anim);
mRightSlider.startAnimation(anim, anim);
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
slider.hideTarget();
slider.startAnimation(trans1, trans2);
}
use of android.view.animation.Animation.AnimationListener in project JamsMusicPlayer by psaravan.
the class QuickScrollGridView method init.
/**
* Initializing the QuickScroll, this function must be called.
* <p/>
*
* @param type the QuickScroll type. Available inputs: <b>QuickScroll.TYPE_POPUP</b> or <b>QuickScroll.TYPE_INDICATOR</b>
* @param list the GridView
* @param scrollable the adapter, must implement Scrollable interface
*/
public void init(final int type, final GridView grid, final Scrollable scrollable, final int style) {
if (isInitialized)
return;
this.type = type;
gridView = grid;
this.scrollable = scrollable;
groupPosition = -1;
fadeInAnimation = new AlphaAnimation(.0f, 1.0f);
fadeInAnimation.setFillAfter(true);
fadeOutAnimation = new AlphaAnimation(1.0f, .0f);
fadeOutAnimation.setFillAfter(true);
fadeOutAnimation.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
isScrolling = false;
}
});
isScrolling = false;
gridView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (isScrolling && (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN)) {
return true;
}
return false;
}
});
final RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
final RelativeLayout container = new RelativeLayout(getContext());
container.setBackgroundColor(Color.TRANSPARENT);
containerParams.addRule(RelativeLayout.ALIGN_TOP, getId());
containerParams.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
container.setLayoutParams(containerParams);
if (this.type == TYPE_POPUP || this.type == TYPE_POPUP_WITH_HANDLE) {
scrollIndicatorTextView = new TextView(getContext());
scrollIndicatorTextView.setTextColor(Color.WHITE);
scrollIndicatorTextView.setVisibility(View.INVISIBLE);
scrollIndicatorTextView.setGravity(Gravity.CENTER);
final RelativeLayout.LayoutParams popupParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
popupParams.addRule(RelativeLayout.CENTER_IN_PARENT);
scrollIndicatorTextView.setLayoutParams(popupParams);
setPopupColor(GREY_LIGHT, GREY_DARK, 1, Color.WHITE, 1);
setTextPadding(TEXT_PADDING, TEXT_PADDING, TEXT_PADDING, TEXT_PADDING);
container.addView(scrollIndicatorTextView);
} else {
scrollIndicator = createPin();
scrollIndicatorTextView = (TextView) scrollIndicator.findViewById(ID_PIN_TEXT);
(scrollIndicator.findViewById(ID_PIN)).getLayoutParams().width = 25;
container.addView(scrollIndicator);
}
// setting scrollbar width
final float density = getResources().getDisplayMetrics().density;
getLayoutParams().width = (int) (10 * density);
scrollIndicatorTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 32);
// scrollbar setup
if (style != STYLE_NONE) {
final RelativeLayout layout = new RelativeLayout(getContext());
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.ALIGN_LEFT, getId());
params.addRule(RelativeLayout.ALIGN_TOP, getId());
params.addRule(RelativeLayout.ALIGN_RIGHT, getId());
params.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
layout.setLayoutParams(params);
final View scrollbar = new View(getContext());
scrollbar.setBackgroundColor(GREY_SCROLLBAR);
final RelativeLayout.LayoutParams scrollBarParams = new RelativeLayout.LayoutParams(1, LayoutParams.MATCH_PARENT);
scrollBarParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
scrollBarParams.topMargin = SCROLLBAR_MARGIN;
scrollBarParams.bottomMargin = SCROLLBAR_MARGIN;
scrollbar.setLayoutParams(scrollBarParams);
layout.addView(scrollbar);
ViewGroup.class.cast(gridView.getParent()).addView(layout);
// creating the handlebar
if (this.type == TYPE_INDICATOR_WITH_HANDLE || this.type == TYPE_POPUP_WITH_HANDLE) {
handleBar = new View(getContext());
setHandlebarColor(BLUE_LIGHT, BLUE_LIGHT, BLUE_LIGHT_SEMITRANSPARENT);
final RelativeLayout.LayoutParams handleParams = new RelativeLayout.LayoutParams((int) (12 * density), (int) (36 * density));
handleBar.setLayoutParams(handleParams);
((RelativeLayout.LayoutParams) handleBar.getLayoutParams()).addRule(RelativeLayout.CENTER_HORIZONTAL);
layout.addView(handleBar);
gridView.setOnScrollListener(new OnScrollListener() {
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (onScrollListener != null)
onScrollListener.onScrollStateChanged(view, scrollState);
}
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (onScrollListener != null)
onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
if (!isScrolling && totalItemCount - visibleItemCount > 0) {
moveHandlebar(getHeight() * firstVisibleItem / (totalItemCount - visibleItemCount));
}
}
});
}
}
isInitialized = true;
ViewGroup.class.cast(gridView.getParent()).addView(container);
}
use of android.view.animation.Animation.AnimationListener in project mobile-android by photo.
the class IapDialog method handleHide.
private void handleHide() {
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.feather_iap_close_animation);
AnimationListener listener = new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
ViewGroup parent = (ViewGroup) getParent();
if (null != parent) {
parent.removeView(IapDialog.this);
}
}
};
animation.setAnimationListener(listener);
startAnimation(animation);
}
use of android.view.animation.Animation.AnimationListener in project mobile-android by photo.
the class IapNotificationLayout method show.
public void show(long delayMillis) {
AnimationListener listener = new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
hide();
}
};
Animation animation = new CustomAlphaAnimation(0.0f, 1.0f);
animation.setStartOffset(delayMillis);
animation.setInterpolator(new DecelerateInterpolator(1.0f));
animation.setDuration(mIapShowDuration);
animation.setAnimationListener(listener);
startAnimation(animation);
}
Aggregations