use of android.view.animation.Animation.AnimationListener in project StandOut by pingpongboss.
the class FloatingFolder method onTouchBody.
@Override
public boolean onTouchBody(final int id, final Window window, final View view, MotionEvent event) {
if (id != APP_SELECTOR_ID && event.getAction() == MotionEvent.ACTION_MOVE) {
final StandOutLayoutParams params = (StandOutLayoutParams) window.getLayoutParams();
final View folderView = window.findViewById(R.id.folder);
final ImageView screenshot = (ImageView) window.findViewById(R.id.preview);
FolderModel folder = mFolders.get(id);
// if touch edge
if (params.x <= 0) {
// first time touch edge
if (folder.fullSize) {
folder.fullSize = false;
final Drawable drawable = getResources().getDrawable(R.drawable.ic_menu_archive);
screenshot.setImageDrawable(drawable);
mFadeOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
folderView.setVisibility(View.GONE);
// post so that the folder is invisible
// before
// anything else happens
screenshot.post(new Runnable() {
@Override
public void run() {
// preview should be centered
// vertically
params.y = params.y + params.height / 2 - drawable.getIntrinsicHeight() / 2;
params.width = drawable.getIntrinsicWidth();
params.height = drawable.getIntrinsicHeight();
updateViewLayout(id, params);
screenshot.setVisibility(View.VISIBLE);
screenshot.startAnimation(mFadeIn);
}
});
}
});
folderView.startAnimation(mFadeOut);
}
} else {
// first time not touch edge
if (!folder.fullSize) {
folder.fullSize = true;
mFadeOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Log.d("FloatingFolder", "Animation started");
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Log.d("FloatingFolder", "Animation ended");
screenshot.setVisibility(View.GONE);
// post so that screenshot is invisible
// before anything else happens
screenshot.post(new Runnable() {
@Override
public void run() {
StandOutLayoutParams originalParams = getParams(id, window);
Drawable drawable = screenshot.getDrawable();
screenshot.setImageDrawable(null);
params.y = params.y - originalParams.height / 2 + drawable.getIntrinsicHeight() / 2;
params.width = originalParams.width;
params.height = originalParams.height;
updateViewLayout(id, params);
folderView.setVisibility(View.VISIBLE);
folderView.startAnimation(mFadeIn);
}
});
}
});
screenshot.startAnimation(mFadeOut);
}
}
}
return false;
}
use of android.view.animation.Animation.AnimationListener in project StandOut by pingpongboss.
the class StandOutWindow method hide.
/**
* Hide a window corresponding to the id. Show a notification for the hidden
* window.
*
* @param id
* The id of the window.
*/
public final synchronized void hide(int id) {
// get the view corresponding to the id
final Window window = getWindow(id);
if (window == null) {
throw new IllegalArgumentException("Tried to hide(" + id + ") a null window.");
}
// alert callbacks and cancel if instructed
if (onHide(id, window)) {
Log.d(TAG, "Window " + id + " hide cancelled by implementation.");
return;
}
// ignore if window is already hidden
if (window.visibility == Window.VISIBILITY_GONE) {
Log.d(TAG, "Window " + id + " is already hidden.");
}
// check if hide enabled
if (Utils.isSet(window.flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
window.visibility = Window.VISIBILITY_TRANSITION;
// get the hidden notification for this view
Notification notification = getHiddenNotification(id);
// get animation
Animation animation = getHideAnimation(id);
try {
// animate
if (animation != null) {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// remove the window from the window manager
mWindowManager.removeView(window);
window.visibility = Window.VISIBILITY_GONE;
}
});
window.getChildAt(0).startAnimation(animation);
} else {
// remove the window from the window manager
mWindowManager.removeView(window);
}
} catch (Exception ex) {
ex.printStackTrace();
}
// display the notification
notification.flags = notification.flags | Notification.FLAG_NO_CLEAR | Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(getClass().hashCode() + id, notification);
} else {
// if hide not enabled, close window
close(id);
}
}
use of android.view.animation.Animation.AnimationListener in project JamsMusicPlayer by psaravan.
the class FilesFoldersFragment method slideUpListView.
/**
* Slides in the ListView.
*/
private void slideUpListView() {
getDir(rootDir, null);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(600);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
listView.setVisibility(View.VISIBLE);
}
});
listView.startAnimation(animation);
}
use of android.view.animation.Animation.AnimationListener in project JamsMusicPlayer by psaravan.
the class QuickScroll 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 ListView
* @param scrollable the adapter, must implement Scrollable interface
*/
public void init(final int type, final ListView list, final Scrollable scrollable, final int style) {
if (isInitialized)
return;
this.type = type;
listView = list;
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;
listView.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(listView.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);
listView.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(listView.getParent()).addView(container);
}
use of android.view.animation.Animation.AnimationListener in project glitch-hq-android by tinyspeck.
the class HomeScreen method dismissSidebar.
public void dismissSidebar() {
// Get display width
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
// Create the dismiss animation
Animation animation = new TranslateAnimation(width, 0, 0, 0);
animation.setDuration(m_sidebarAnimationDuration);
animation.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
// Get display width
Display display = getWindowManager().getDefaultDisplay();
// Move back to normal position and fill the whole display
// width-wise
// m_stack.layout(-27, 0, display.getWidth(),
// m_stack.getHeight());
HomeScreen.this.m_showingSidebar = false;
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
animation.setFillAfter(true);
// Run the dismiss animation
m_stack.startAnimation(animation);
m_stack.getParent().bringChildToFront(m_stack);
}
Aggregations