高仿新版58 加载动画

Overview

#效果图先行#

58同城效果

实现的效果

#地址:# github 直达

Android Arsenal ###gradle
/build.gradle

repositories {
    maven {
        url "https://jitpack.io"
    }
}

/app/build.gradle

dependencies {
	        compile 'com.github.zzz40500:android-shapeLoadingView:1.0.3.2'
	}

#usage#

布局上


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"         android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
   android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <com.mingle.widget.LoadingView
        android:id="@+id/loadView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</RelativeLayout>

动画自动加载

Comments
  • Build error

    Build error

    Hi, There seems to be a build error related to resources: https://jitpack.io/com/github/zzz40500/android-shapeLoadingView/1.0.3/build.log

    :shapeloading:processReleaseResources 
    Position 4:25-47 : No resource found that matches the given name (at 'background' with value '@drawable/aa_dialog_bg').
    
    opened by jitpack-io 4
  • not available........pls update

    not available........pls update

    i cant sync this using compile 'com.github.zzz40500:android-shapeLoadingView:64e0c03321'

    in build.gradle........pls tell me if this is available..............

    pls reply ...........

    opened by hkk007 3
  • 在view#onDetachedFromWindow cancel 动画,但由于循环嵌套,动画会再后台一直跑

    在view#onDetachedFromWindow cancel 动画,但由于循环嵌套,动画会再后台一直跑

     public void upThrow() {
            ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this.mShapeLoadingView, "translationY", new float[]{mDistance, 0.0F});
            ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(this.mIndicationIm, "scaleX", new float[]{0.2F, 1.0F});
            ObjectAnimator objectAnimator1 = null;
            switch (mShapeLoadingView.getShape()) {
                case SHAPE_RECT:
                    objectAnimator1 = ObjectAnimator.ofFloat(this.mShapeLoadingView, "rotation", new float[]{0.0F, -120.0F});
                    break;
                case SHAPE_CIRCLE:
                    objectAnimator1 = ObjectAnimator.ofFloat(this.mShapeLoadingView, "rotation", new float[]{0.0F, 180.0F});
                    break;
                case SHAPE_TRIANGLE:
                    objectAnimator1 = ObjectAnimator.ofFloat(this.mShapeLoadingView, "rotation", new float[]{0.0F, 180.0F});
            }
    
            objectAnimator.setDuration(500L);
            objectAnimator1.setDuration(500L);
            objectAnimator.setInterpolator(new DecelerateInterpolator(this.factor));
            objectAnimator1.setInterpolator(new DecelerateInterpolator(this.factor));
            mAnimatorSetupThrow = new AnimatorSet();
            mAnimatorSetupThrow.setDuration(500L);
            mAnimatorSetupThrow.playTogether(new Animator[]{objectAnimator, objectAnimator1, scaleIndication});
            mAnimatorSetupThrow.addListener(new Animator.AnimatorListener() {
                public void onAnimationStart(Animator animation) {
                }
    
                public void onAnimationEnd(Animator animation) {
                    freeFall();
                    AppLogger.i("TAG", "freeFall end");
    
                }
    
                public void onAnimationCancel(Animator animation) {
                    AppLogger.i("TAG", "freeFall cancel");
                }
    
                public void onAnimationRepeat(Animator animation) {
                }
            });
    //        mAnimatorSetupThrow.start();
        }
    
        public void freeFall() {
            ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this.mShapeLoadingView, "translationY", new float[]{0.0F, mDistance});
            ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(this.mIndicationIm, "scaleX", new float[]{1.0F, 0.2F});
            objectAnimator.setDuration(500L);
            objectAnimator.setInterpolator(new AccelerateInterpolator(this.factor));
            mAnimatorSetfreeFall = new AnimatorSet();
            mAnimatorSetfreeFall.setDuration(500L);
            mAnimatorSetfreeFall.playTogether(new Animator[]{objectAnimator, scaleIndication});
            mAnimatorSetfreeFall.addListener(new Animator.AnimatorListener() {
                public void onAnimationStart(Animator animation) {
                }
    
                public void onAnimationEnd(Animator animation) {
                    mShapeLoadingView.changeShape();
    //                upThrow();
                    AppLogger.i("TAG", "upThrow end");
                }
    
                public void onAnimationCancel(Animator animation) {
                    AppLogger.i("TAG", "upThrow cancel");
                }
    
                public void onAnimationRepeat(Animator animation) {
                }
            });
            mAnimatorSetfreeFall.start();
        }
    
    
    
        @Override
        protected void onDetachedFromWindow() {
            super.onDetachedFromWindow();
    
             mAnimatorSetfreeFall.cance()
        }
    

    无效

    opened by xwdz 2
  • build fail

    build fail

    2015-07-31T09:20:38+00:00: ./gradlew assembleDebug
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :shapeloading:compileLint
    :shapeloading:copyReleaseLint UP-TO-DATE
    :shapeloading:mergeReleaseProguardFiles
    :shapeloading:preBuild UP-TO-DATE
    :shapeloading:preReleaseBuild UP-TO-DATE
    :shapeloading:checkReleaseManifest
    :shapeloading:prepareReleaseDependencies
    :shapeloading:compileReleaseAidl
    :shapeloading:compileReleaseRenderscript
    :shapeloading:generateReleaseBuildConfig
    :shapeloading:generateReleaseAssets UP-TO-DATE
    :shapeloading:mergeReleaseAssets
    :shapeloading:generateReleaseResValues
    :shapeloading:generateReleaseResources
    :shapeloading:packageReleaseResources
    :shapeloading:processReleaseManifest
    :shapeloading:processReleaseResources Position 4:25-47 : No resource found that matches the given name (at 'background' with value '@drawable/aa_dialog_bg').
    
     FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':shapeloading:processReleaseResources'.
    > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/data1/android-sdk-linux/build-tools/21.1.2/aapt'' finished with non-zero exit value 1
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    BUILD FAILED
    
    opened by liaohuqiu 2
  • fix memory leak

    fix memory leak

    Can't stop shapeLoadingView, there are some memory leak in widget. This is a patch to fix this bug.

    Subject: [PATCH] fix memory leak
    
    Change-Id: I704c3f34bebc586fb4ceeee758115625a7a5776f
    
    ---
    
    diff 
    
             addView(view, layoutParams);
    
    +        startLoading(900);
         }
    
         public void setLoadingText(CharSequence loadingText) {
             loadTextView.setText(loadingText);
    +    }
    +
    +    private AnimatorSet mAnimatorSet = null;
    +
    +    private Runnable mFreeFallRunnable = new Runnable() {
    +        @Override
    +        public void run() {
    +            freeFall();
    +        }
    +    };
    +
    +    private void startLoading(long delay) {
    +        if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
    +            return;
    +        }
    +        this.removeCallbacks(mFreeFallRunnable);
    +        if (delay > 0) {
    +        this.postDelayed(mFreeFallRunnable, delay);
    +    } else {
    +        this.post(mFreeFallRunnable);
    +        }
    +    }
    +
    +    private void stopLoading() {
    +        if (mAnimatorSet != null) {
    +            if (mAnimatorSet.isRunning()) {
    +                mAnimatorSet.cancel();
    +            }
    +            mAnimatorSet = null;
    +        }
    +        this.removeCallbacks(mFreeFallRunnable);
    +    }
    +
    +    @Override
    +    public void setVisibility(int visibility) {
    +        super.setVisibility(visibility);
    +        if (visibility == View.VISIBLE) {
    +            startLoading();
    +        } else {
    +            stopLoading();
    +        }
         }
    
         /**
    @@ -113,18 +143,13 @@
             ObjectAnimator objectAnimator1 = null;
             switch (shapeLoadingView.getShape()) {
                 case SHAPE_RECT:
    -
                     objectAnimator1 = ObjectAnimator.ofFloat(shapeLoadingView, "rotation", 0, -120);
    -
                     break;
                 case SHAPE_CIRCLE:
                     objectAnimator1 = ObjectAnimator.ofFloat(shapeLoadingView, "rotation", 0, 180);
    -
                     break;
                 case SHAPE_TRIANGLE:
    -
                     objectAnimator1 = ObjectAnimator.ofFloat(shapeLoadingView, "rotation", 0, 180);
    -
                     break;
             }
    
    @@ -139,25 +164,24 @@
             animatorSet.addListener(new Animator.AnimatorListener() {
                 @Override
                 public void onAnimationStart(Animator animation) {
    -
                 }
    
                 @Override
                 public void onAnimationEnd(Animator animation) {
    -                freeFall();
    -
    +                if (LoadingView.this.getVisibility() == View.VISIBLE) {
    +                    freeFall();
    +                }
                 }
    
                 @Override
                 public void onAnimationCancel(Animator animation) {
    -
                 }
    
                 @Override
                 public void onAnimationRepeat(Animator animation) {
    -
                 }
             });
    +        mAnimatorSet = animatorSet;
             animatorSet.start();
    
         }
    @@ -180,27 +204,25 @@
             animatorSet.addListener(new Animator.AnimatorListener() {
                 @Override
                 public void onAnimationStart(Animator animation) {
    -
                 }
    
                 @Override
                 public void onAnimationEnd(Animator animation) {
    -
    -                shapeLoadingView.changeShape();
    -                upThrow();
    +                if (LoadingView.this.getVisibility() == View.VISIBLE) {
    +                    shapeLoadingView.changeShape();
    +                    upThrow();
    +                }
                 }
    
                 @Override
                 public void onAnimationCancel(Animator animation) {
    -
                 }
    
                 @Override
                 public void onAnimationRepeat(Animator animation) {
    -
                 }
             });
    +        mAnimatorSet = animatorSet;
             animatorSet.start();
    -
         }
     }
    
    
    opened by moubenmao 2
  • Rendering Problems

    Rendering Problems

    I trying to use the lib in my app but it shows me Rendering Problems at android studio designer and that is the problem stack

    android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F060034. at android.content.res.BridgeResources.throwException(BridgeResources.java:699) at android.content.res.BridgeResources.getColor(BridgeResources.java:191) at com.mingle.widget.ShapeLoadingView.init(ShapeLoadingView.java:52) at com.mingle.widget.ShapeLoadingView.(ShapeLoadingView.java:37) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:408) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105) at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:385) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350) at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:708) at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932) at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697) at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589) at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178) at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212) at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:327) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

    opened by humazed 2
  • 引用LayoutView的类无法释放

    引用LayoutView的类无法释放

    即便LayoutView不可见,仍然会无限次数的做"上抛下落"动画

    startLoading和stopLoading方法中的mAnimatorSet并没有在后续赋值.而且在stopLoading方法中做anim.cancel前应该移除动画监听.即mAnimatorSet.removeAllListeners()

    opened by huazhenzhu 1
  • custom color by typedArray

    custom color by typedArray

    <color name="circle">#aa738ffe</color>
    <color name="dialog_bg">#f5f5f5</color>
    <color name="rect">#aae84e40</color>
    <color name="shadow">#25808080</color>
    <color name="triangle">#aa72d572</color>
    <color name="view_bg">#00000000</color>
    

    and custom size plz...it's too small now...

    opened by onewilk 0
Releases(1.0.3.2)
Owner
轻微
轻微