All Projects → NoEndToLF → View Load Retry

NoEndToLF / View Load Retry

Licence: mit
这个加载框架有点不一样,针对View进行加载,加载页面还保持了原View的属性,侧重点在灵活,哪里需要加载哪里,加载状态页面完全自定义,无任何限制,针对加载结果可以按需配置对应页面,LeakCanary检测无内存泄漏

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to View Load Retry

View-Load-ReTry
这个加载框架有点不一样,针对View进行加载,加载页面还保持了原View的属性,侧重点在灵活,哪里需要加载哪里,加载状态页面完全自定义,无任何限制,针对加载结果可以按需配置对应页面,LeakCanary检测无内存泄漏
Stars: ✭ 116 (-2.52%)
Mutual labels:  gif, retry, refresh
Burstlinker
🚀 A simple GIF encoder for Android.
Stars: ✭ 111 (-6.72%)
Mutual labels:  gif
Livelygifs
An app show your Live Photo and export as GIF.
Stars: ✭ 92 (-22.69%)
Mutual labels:  gif
Gifdec
small C GIF decoder
Stars: ✭ 100 (-15.97%)
Mutual labels:  gif
Shellpic
ASCII-art is so 2013
Stars: ✭ 94 (-21.01%)
Mutual labels:  gif
Fancy Flutter Alert Dialog
flutter package to show well designed alert dialog
Stars: ✭ 103 (-13.45%)
Mutual labels:  gif
Node Sorry
生成表情gif
Stars: ✭ 90 (-24.37%)
Mutual labels:  gif
Sketch
Sketch 是 Android 上一个强大且全面的图片加载器,支持 GIF,手势缩放以及分块显示超大图片。Sketch is a powerful and comprehensive image loader on Android, with support for GIF, gesture zooming, block display super large image
Stars: ✭ 1,557 (+1208.4%)
Mutual labels:  gif
Backoff
Python library providing function decorators for configurable backoff and retry
Stars: ✭ 1,670 (+1303.36%)
Mutual labels:  retry
Ffmpeg Gif Script For Bash
Turn your videos into palette-mapped gifs with this easy script
Stars: ✭ 100 (-15.97%)
Mutual labels:  gif
React Native Rk Pull To Refresh
a pull to refresh component for react-native, same api on both android and ios
Stars: ✭ 100 (-15.97%)
Mutual labels:  refresh
Job
JOB, make your short-term command as a long-term job. 将命令行规划成任务的工具
Stars: ✭ 98 (-17.65%)
Mutual labels:  retry
Arrowdrawable
纯Paint实现的一个射箭效果,可用作Loading动画。
Stars: ✭ 103 (-13.45%)
Mutual labels:  refresh
Kgif
Tool for creating gif file from capturing active window.
Stars: ✭ 94 (-21.01%)
Mutual labels:  gif
Zoompreviewpicture
拓展性极高类似微信图片和视频浏览,常见应用场景如微信朋友圈照片九宫格和微信聊天图片图片,视频,gif预览
Stars: ✭ 1,576 (+1224.37%)
Mutual labels:  gif
Guzzle retry middleware
Middleware for Guzzle v6+ that automatically retries HTTP requests on 429, 503 responses.
Stars: ✭ 90 (-24.37%)
Mutual labels:  retry
Gifserver
A server for transcoding gif to video on the fly
Stars: ✭ 100 (-15.97%)
Mutual labels:  gif
Gif Frames
🖼 Extract frames from an animated GIF with pure JS
Stars: ✭ 100 (-15.97%)
Mutual labels:  gif
Twittnuker
Android 4.0+ Twitter Client
Stars: ✭ 117 (-1.68%)
Mutual labels:  gif
Pull To Refresh
ESPullToRefresh is developed and maintained by Vincent Li. If you have any questions or issues in using ESPullToRefresh, welcome to issue. If you want to contribute to ESPullToRefresh, Please submit Pull Request, I will deal with it as soon as possible.
Stars: ✭ 1,591 (+1236.97%)
Mutual labels:  refresh

View-Load-ReTry

View-Load-ReTry:这个加载框架有点不一样,针对View进行加载,加载页面还保持了原View的属性,侧重点在灵活,哪里需要加载哪里

  • 原理 :找到需要加载的View,放入FrameLayout(包含自定义的各种情况的加载反馈View),再把FrameLayout放回需要加载View的Parent中 ,然后根据需求调用显示加载或者异常View。
  • 功能 :只要当前需要加载View有Parent就可以实现加载反馈(仅不支持复用型的View场景),同一页面支持N个View的加载,彼此互不影响。
  • 封装 :全局配置封装,与业务解耦,一个入口控制全部的加载反馈页面。

示例,Demo只添加了一种Error反馈页面做演示,使用时可按需自定义多种Error反馈页面(Gif中的View残留现象是录制时丢帧问题,嘿嘿)

常规使用 Activity+Fragment多View加载
normal fix

使用   

初步配置

引入

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.NoEndToLF:View-Load-ReTry:2.0.2'
}

自定义加载状态页面 Adapter,继承 BaseLoadRetryAdapter,下面各方法都是按需被调用,取决于你主动设置的显示哪个Adapter。

方法 参数 作用
onLoadStart View 显示这个加载状态页面前开始前调用,用于你自定义页面中控件的初始化,此View为当前显示的加载页面View,以下方法中的View都是。
getCoverViewLayoutId return R.layout 加载页面的布局Layout
onFalied View,Ogject 加载失败的回调(会在你主动调用错误页面对应的那个Adapter里调用),Object可以是任意的对象,方便你显示加载错误的原因
onSuccess View 加载成功的回调(会在你设置的Load状态那个Adapter里调用),这里可以做一些加载动画的停止操作,另需要手动让View.Gone,暴露在这里是方便各位添加加载页面消失的动画

自定义Adapter示例(Demo中normal用法)

public class LoadAdapterForActivity extends BaseLoadRetryAdapter{
    @Override
    public void onLoadStart(View view) {
        ((TextView)view.findViewById(R.id.tv_text)).setText("加载中 ...");
    }
    @Override
    public void onFalied(View view, Object object) {
    }
/**这里在加载完成的时候做了一个淡出动画*/
    @Override
    public void onSuccess(View view) {
        AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
        alphaAnimation.setDuration(500);
        view.startAnimation(alphaAnimation);
        view.setVisibility(View.GONE);
    }

    @Override
    public int getCoverViewLayoutId() {
        return R.layout.load_activity;
    }
}
/**默认给加载失败页面添加了点击事件,回调到retry方法,开始重试,重试时显示加载中Adapter对应的页面*/
public class NetErrorAdapterForActivity extends BaseLoadRetryAdapter{
    @Override
    public void onLoadStart(View view) {
        ((TextView)view.findViewById(R.id.tv_retry)).setText("点击重新加载");
    }

    @Override
    public void onFalied(View view, Object object) {
        ((ImageView) view.findViewById(R.id.iv_head)).setImageResource(R.mipmap.timeout);
        ((TextView)view.findViewById(R.id.tv_text)).setText((String)object);
        ((TextView)view.findViewById(R.id.tv_retry)).setVisibility(View.VISIBLE);
    }

    @Override
    public void onSuccess(View view) {
      
    }

    @Override
    public int getCoverViewLayoutId() {
        return R.layout.retry_activity;
    }
}

示例代码(Demo中normal用法):建议在 Application的 onCreate中进行初始化,有多少个Adapter就添加多少个,这里统一了入口是方便管理。

LoadRetryManager.getInstance().addAdapter(new LoadAdapterForActivity());
LoadRetryManager.getInstance().addAdapter(new NetErrorAdapterForActivity());.......

最常规用法,针对一个View(针对多个View和针对一个View用法一致,流程都是针对某个View的)

方法 参数 作用
register View,LoadRetryRefreshListener 注册
startLoad View,Class<? extends BaseLoadRetryAdapter> 开始加载,加载中类Adapter.Calss
unRegister View 解除绑定
unRegister List 解除多个View的绑定
onSuccess View 加载成功,会调用View对应加载中Adapter的onSuccess方法
onFailed   View,Class<? extends BaseLoadRetryAdapter>,Object 加载失败时显示加载失败类Adapter.Class对应的页面,并调用该Adapter的onFalied()方法,Object为加载失败原因

1、注册,一般在 onCreate中调用

LoadRetryManager.getInstance().register(view, new LoadRetryListener() {
            @Override
            public void load() {
                //执行你的网络请求
               //dosomething();
            }

            @Override
            public void reTry() {
                //执行你的重试请求
                //dosomethingRetry();
            }
        });       

2、开始加载

LoadRetryManager.getInstance().load(view, LoadAdapterForActivity.class);     

3、加载结果回调,在你的请求成功和失败的回调中加入加载结果回调

            @Override
            public void onSuccess(Integer value) {
            //加载成功你要做的事.....
            
                //加载结果回调
                LoadRetryManager.getInstance().onSuccess(view);
            }

            @Override
            public void onFailed(Throwable e) {
            //加载失败你要做的事.....
            
                //加载结果回调
             LoadRetryManager.getInstance().onFailed(view, NetErrorAdapterForActivity.class, "请检查网络连接");

            }        

4、解除绑定

//在Activity中
Override
    protected void onDestroy() {
        super.onDestroy();
        LoadRetryManager.getInstance().unRegister(view);

	//加载多个View时建议在BaseActivity中封装方法,维护一个List<View>,每注册一个加载View就Add一次,解绑时方便操作
        LoadRetryManager.getInstance().unRegister(list); 
    }
//在Fragment中
@Override
    public void onDestroyView() {
        super.onDestroyView();
        LoadRetryManager.getInstance().unRegister(view);

	//加载多个View时建议在BaseFragment中封装方法,维护一个List<View>,每注册一个加载View就Add一次,解绑时方便操作
        LoadRetryManager.getInstance().unRegister(list); 
    }

为何要造这个看起来重复的轮子

目前好多开源的加载反馈框架大多是针对Activity和Fragment的,原理都是从根上替换加载布局,但是有个缺点,反馈布局的作用域太大了,不够灵活,现在闲的蛋疼造这个轮子也是为了灵活性,比如说Sample中的同一个页面要加载3块内容的时候,这个轮子的优势就显示出来了,而且原View具有的基本特性加载反馈页面依然包含。

反馈与建议

License

Copyright (c) [2018] [static]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].