Search in sources :

Example 56 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project SnackBar by MrEngineer13.

the class SnackContainer method init.

private void init() {
    mInAnimationSet = new AnimationSet(false);
    TranslateAnimation mSlideInAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);
    mOutAnimationSet = new AnimationSet(false);
    TranslateAnimation mSlideOutAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f);
    AlphaAnimation mFadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
    mOutAnimationSet.addAnimation(mSlideOutAnimation);
    mOutAnimationSet.addAnimation(mFadeOutAnimation);
    mOutAnimationSet.setDuration(ANIMATION_DURATION);
    mOutAnimationSet.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            removeAllViews();
            if (!mSnacks.isEmpty()) {
                sendOnHide(mSnacks.poll());
            }
            if (!isEmpty()) {
                showSnack(mSnacks.peek());
            } else {
                setVisibility(View.GONE);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 57 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project ExpandableTextView by Manabu-GT.

the class ExpandableTextView method applyAlphaAnimation.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void applyAlphaAnimation(View view, float alpha) {
    if (isPostHoneycomb()) {
        view.setAlpha(alpha);
    } else {
        AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha);
        // make it instant
        alphaAnimation.setDuration(0);
        alphaAnimation.setFillAfter(true);
        view.startAnimation(alphaAnimation);
    }
}
Also used : AlphaAnimation(android.view.animation.AlphaAnimation) TargetApi(android.annotation.TargetApi)

Example 58 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project actor-platform by actorapp.

the class InputBarFragment method showAudio.

protected void showAudio() {
    if (Build.VERSION.SDK_INT >= 23) {
        if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[] { Manifest.permission.RECORD_AUDIO, Manifest.permission.VIBRATE }, PERMISSION_REQUEST_RECORD_AUDIO);
            return;
        }
    }
    if (isAudioVisible) {
        return;
    }
    isAudioVisible = true;
    hideView(attachButton);
    hideView(messageEditText);
    hideView(emojiButton);
    audioFile = ActorSDK.sharedActor().getMessenger().getInternalTempFile("voice_msg", "opus");
    getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    voiceRecordActor.send(new VoiceCaptureActor.Start(audioFile));
    slideAudio(0);
    audioTimer.setText("00:00");
    TranslateAnimation animation = new TranslateAnimation(Screen.getWidth(), 0, 0, 0);
    animation.setDuration(160);
    audioContainer.clearAnimation();
    audioContainer.setAnimation(animation);
    audioContainer.animate();
    audioContainer.setVisibility(View.VISIBLE);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0.2f);
    alphaAnimation.setDuration(800);
    alphaAnimation.setRepeatMode(AlphaAnimation.REVERSE);
    alphaAnimation.setRepeatCount(AlphaAnimation.INFINITE);
    recordPoint.clearAnimation();
    recordPoint.setAnimation(alphaAnimation);
    recordPoint.animate();
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) VoiceCaptureActor(im.actor.sdk.core.audio.VoiceCaptureActor) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 59 with AlphaAnimation

use of android.view.animation.AlphaAnimation 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;
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) TranslateAnimation(android.view.animation.TranslateAnimation) HeaderItem(im.actor.sdk.controllers.pickers.file.items.HeaderItem) AlphaAnimation(android.view.animation.AlphaAnimation) MaterialInterpolator(im.actor.sdk.controllers.pickers.file.view.MaterialInterpolator) ListView(android.widget.ListView) FileNameOrderComparator(im.actor.sdk.controllers.pickers.file.util.FileNameOrderComparator) TextView(android.widget.TextView) File(java.io.File) AnimationSet(android.view.animation.AnimationSet) ExternalStorageItem(im.actor.sdk.controllers.pickers.file.items.ExternalStorageItem) StorageItem(im.actor.sdk.controllers.pickers.file.items.StorageItem) ExternalStorageItem(im.actor.sdk.controllers.pickers.file.items.ExternalStorageItem)

Example 60 with AlphaAnimation

use of android.view.animation.AlphaAnimation 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;
}
Also used : MaterialInterpolator(im.actor.sdk.controllers.pickers.file.view.MaterialInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AnimatorSet(android.animation.AnimatorSet) HeaderItem(im.actor.sdk.controllers.pickers.file.items.HeaderItem) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation)

Aggregations

AlphaAnimation (android.view.animation.AlphaAnimation)261 Animation (android.view.animation.Animation)111 TranslateAnimation (android.view.animation.TranslateAnimation)89 AnimationSet (android.view.animation.AnimationSet)78 ScaleAnimation (android.view.animation.ScaleAnimation)56 View (android.view.View)29 LinearInterpolator (android.view.animation.LinearInterpolator)26 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)26 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)26 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)26 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)26 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)26 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)26 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)26 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)26 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)26 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)26 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)26 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)26 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)26