use of android.view.animation.AnimationSet in project actor-platform by actorapp.
the class ExplorerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d("Explorer Animation", "Created");
{
rootView = inflater.inflate(R.layout.picker_fragment_file_picker, container, false);
list = (ListView) rootView.findViewById(R.id.list);
Bundle bundle = getArguments();
statusView = (TextView) rootView.findViewById(R.id.status);
emptyView = rootView.findViewById(R.id.empty);
items = new ArrayList<ExplorerItem>();
if (bundle != null) {
path = bundle.getString("path");
Log.d(LOG_TAG, "Path: " + path);
File currentPathFile = new File(path);
File[] fileList = currentPathFile.listFiles();
title = currentPathFile.getPath();
if (title.contains(Environment.getExternalStorageDirectory().getPath())) {
title = title.replace(Environment.getExternalStorageDirectory().getPath(), "");
}
if (title.length() > 0 && title.toCharArray()[0] == '/') {
title = title.substring(1);
}
if (path.equals(Environment.getExternalStorageDirectory().getPath())) {
if (Environment.isExternalStorageEmulated()) {
title = getString(R.string.picker_file_memory_phone);
} else
title = getString((R.string.picker_file_memory_external));
} else if (path.equals("/"))
title = getString(R.string.picker_file_memory_phone);
if (fileList == null) {
statusView.setVisibility(View.VISIBLE);
File external = Environment.getExternalStorageDirectory();
if (path.equals(external.getPath()))
statusView.setText(R.string.picker_file_memory_external_error);
else
statusView.setText(R.string.picker_file_denied);
return rootView;
} else {
if (fileList.length == 0) {
emptyView.setVisibility(View.VISIBLE);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(280);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 150, 0);
slideInAnimation.addAnimation(translateAnimation);
emptyView.startAnimation(slideInAnimation);
statusView.setVisibility(View.VISIBLE);
AnimationSet slideInAnimation1 = new AnimationSet(true);
slideInAnimation1.setInterpolator(new MaterialInterpolator());
slideInAnimation1.setDuration(280);
//cause of offset
slideInAnimation1.setStartOffset(150);
AlphaAnimation alphaAnimation1 = new AlphaAnimation(0, 1);
slideInAnimation1.addAnimation(alphaAnimation1);
TranslateAnimation translateAnimation1 = new TranslateAnimation(0, 0, 150, 0);
slideInAnimation1.addAnimation(translateAnimation1);
statusView.startAnimation(slideInAnimation1);
statusView.setText(R.string.picker_file_directory_empty);
//return rootView;
}
}
Log.d(LOG_TAG, "Size: " + fileList.length);
for (File file : fileList) {
putItem(file);
}
Collections.sort(items, new FileNameOrderComparator());
insertBack();
adapter = new ExplorerAdapter(getActivity(), items);
} else {
welcome = true;
// items.add(new StorageItem(getActivity()));
adapter = new WelcomeExplorerAdapter(getActivity(), items);
items.add(new HeaderItem(getString(R.string.picker_file_header_main)));
String externalStorageState = Environment.getExternalStorageState();
Log.w(LOG_TAG, externalStorageState);
if (externalStorageState.equals(Environment.MEDIA_REMOVED) || externalStorageState.equals(Environment.MEDIA_BAD_REMOVAL) || externalStorageState.equals(Environment.MEDIA_UNKNOWN) || externalStorageState.equals(Environment.MEDIA_UNMOUNTED) || externalStorageState.equals(Environment.MEDIA_UNMOUNTABLE) || externalStorageState.equals(Environment.MEDIA_SHARED) || externalStorageState.equals(Environment.MEDIA_NOFS)) {
items.add(new StorageItem(getString(R.string.picker_file_memory_phone)));
} else {
/*
File cameraFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
if(cameraFile.exists()) {
items.add(new FolderItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),R.drawable.picker_folder_camera,getString(R.string.picker_files_camera)));
}*/
putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
putItem((Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)));
putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC));
putItem((Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)));
if (Environment.isExternalStorageEmulated()) {
items.add(new ExternalStorageItem(getString(R.string.picker_file_memory_phone), R.drawable.picker_memory));
} else
items.add(new ExternalStorageItem(getString(R.string.picker_file_memory_external), R.drawable.picker_sdcard));
if (Build.VERSION.SDK_INT >= 19) {
// putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS));
// even on sdk>19 documents folder does not work.
}
}
path = "";
title = getString(R.string.picker_file_activity_title);
ArrayList<ExplorerItem> historyItems = loadHistory();
if (!historyItems.isEmpty()) {
items.addAll(historyItems);
}
}
list.setAdapter(adapter);
list.setOnItemClickListener((BasePickerActivity) getActivity());
}
pickerActivity.updateCounter();
return rootView;
}
use of android.view.animation.AnimationSet in project actor-platform by actorapp.
the class ExplorerFragment method onCreateAnimator.
@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
Log.d("Explorer animation", "CreateAnimator: " + transit + " " + enter + " " + nextAnim);
int animationLength = 0;
if (nextAnim == R.animator.picker_fragment_explorer_welcome_enter) {
list.setAlpha(0);
list.post(new Runnable() {
@Override
public void run() {
list.setAlpha(1);
int offsetIncreaseOffset = 0;
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(180);
if (items.get(i) instanceof HeaderItem) {
offsetIncreaseOffset += 150;
slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
offsetIncreaseOffset += 200;
} else
slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 150, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
}
});
animationLength = list.getChildCount() * 100 + 50;
Log.d("Explorer animation", "CreateAnimator: enter");
} else if (nextAnim == R.animator.picker_fragment_explorer_enter) {
list.setAlpha(0);
list.post(new Runnable() {
@Override
public void run() {
list.setAlpha(1);
int offsetIncreaseOffset = 0;
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(100, 0, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
}
});
animationLength = list.getChildCount() * 100 + 50;
Log.d("Explorer animation", "CreateAnimator: enter");
} else if (nextAnim == R.animator.picker_fragment_explorer_welcome_exit || nextAnim == R.animator.picker_fragment_explorer_exit) {
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50);
slideInAnimation.setFillAfter(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setFillAfter(true);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, -100, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
// list.getChildCount() * 100 + 50;
animationLength = 0;
Log.d("Explorer animation", "CreateAnimator: exit");
} else if (nextAnim == R.animator.picker_fragment_explorer_return) {
list.setAlpha(0);
list.post(new Runnable() {
@Override
public void run() {
list.setAlpha(1);
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(-100, 0, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
}
});
animationLength = list.getChildCount() * 100 + 50;
Log.d("Explorer animation", "CreateAnimator: return");
} else if (nextAnim == R.animator.picker_fragment_explorer_out) {
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50);
slideInAnimation.setFillAfter(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setFillAfter(true);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 100, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
if (items.size() == 1) {
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setInterpolator(new MaterialInterpolator());
alphaAnimation.setDuration(100);
alphaAnimation.setFillAfter(true);
emptyView.startAnimation(alphaAnimation);
statusView.startAnimation(alphaAnimation);
animationLength = 250;
}
//else
// list.getChildCount() * 100 + 50;
animationLength = 0;
Log.d("Explorer animation", "CreateAnimator: out");
}
AnimatorSet animator = (AnimatorSet) AnimatorInflater.loadAnimator(pickerActivity, R.animator.picker_fragment_explorer_enter);
animator.setDuration(animationLength);
return animator;
}
use of android.view.animation.AnimationSet in project SmartAndroidSource by jaychou2012.
the class DragGridView method animateDragged.
// EVENT HELPERS
protected void animateDragged() {
View v = getChildAt(dragged);
int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
AnimationSet animSet = new AnimationSet(true);
ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * 3 / 4);
scale.setDuration(animT);
AlphaAnimation alpha = new AlphaAnimation(1, .5f);
alpha.setDuration(animT);
animSet.addAnimation(scale);
animSet.addAnimation(alpha);
animSet.setFillEnabled(true);
animSet.setFillAfter(true);
v.clearAnimation();
v.startAnimation(animSet);
}
use of android.view.animation.AnimationSet in project SmartAndroidSource by jaychou2012.
the class DragGridViewPager method animateDragged.
private void animateDragged() {
if (mLastDragged >= 0) {
final View v = getChildAt(mLastDragged);
final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
r.inset(-r.width() / 20, -r.height() / 20);
v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
v.layout(r.left, r.top, r.right, r.bottom);
AnimationSet animSet = new AnimationSet(true);
ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
scale.setDuration(ANIMATION_DURATION);
AlphaAnimation alpha = new AlphaAnimation(1, .5f);
alpha.setDuration(ANIMATION_DURATION);
animSet.addAnimation(scale);
animSet.addAnimation(alpha);
animSet.setFillEnabled(true);
animSet.setFillAfter(true);
v.clearAnimation();
v.startAnimation(animSet);
}
}
use of android.view.animation.AnimationSet in project KJFrameForAndroid by kymjs.
the class KJAnimations method openAnimation.
/**
* 打开的动画
*
* @param relativeLayout
* 子菜单容器
* @param background
* 子菜单背景
* @param menu
* 菜单按钮
* @param durationMillis
* 动画时间
*/
public static void openAnimation(RelativeLayout relativeLayout, ImageView menu, long durationMillis) {
relativeLayout.setVisibility(View.VISIBLE);
for (int i = 1; i < relativeLayout.getChildCount(); i++) {
ImageView imageView = null;
if (relativeLayout.getChildAt(i) instanceof ImageView) {
imageView = (ImageView) relativeLayout.getChildAt(i);
} else {
continue;
}
AnimationSet set = new AnimationSet(true);
set.addAnimation(getRotateAnimation(-360, 0, durationMillis));
set.addAnimation(getAlphaAnimation(0.5f, 1.0f, durationMillis));
set.addAnimation(getTranslateAnimation(menu.getLeft() - imageView.getLeft(), 0, menu.getTop() - imageView.getTop(), 0, durationMillis));
set.setFillAfter(true);
set.setDuration(durationMillis);
set.setStartOffset((i * 100) / (-1 + relativeLayout.getChildCount()));
set.setInterpolator(new OvershootInterpolator(1f));
imageView.startAnimation(set);
}
}
Aggregations