Coder Social home page Coder Social logo

Comments (8)

xuexiangjys avatar xuexiangjys commented on May 28, 2024 1

我大概猜到是为什么了,可能是屏幕横竖屏切换的时候,资源被回收了

from xupdate.

xuexiangjys avatar xuexiangjys commented on May 28, 2024 1

已修复:
49b9261

from xupdate.

xuexiangjys avatar xuexiangjys commented on May 28, 2024

理论上IUpdateProxy是不可能为null的,你得把错误发生的详情仔细描述清楚

from xupdate.

tanglufeng avatar tanglufeng commented on May 28, 2024

你好,感谢您的回复。这是友盟统计的数据,我没有复现,但是这个崩溃数量是最高的。截图已发送到您的邮箱,请查收

from xupdate.

xuexiangjys avatar xuexiangjys commented on May 28, 2024

@tanglufeng 貌似并没有收到你的邮件

from xupdate.

tanglufeng avatar tanglufeng commented on May 28, 2024

估计是到垃圾箱了,麻烦您再找找。github怎么不能传图啊

from xupdate.

tanglufeng avatar tanglufeng commented on May 28, 2024

app

             XUpdate.get()
            .debug(false)
            .isWifiOnly(false)     //默认设置只在wifi下检查版本更新
            .isGet(true)          //默认设置使用get请求检查版本
            .param("VersionCode", UpdateUtils.getVersionCode(this)) //设置默认公共请求参数
            .param("AppKey", getPackageName())
            .setOnUpdateFailureListener(new OnUpdateFailureListener() { //设置版本更新出错的监听
                @Override
                public void onFailure(UpdateError error) {
                    if (!MyApplication.isHome) {
                        ToastUtil.showShortToast(mContext, error.toString());
                    }

                }
            })
            .setIUpdateHttpService(new OKHttpUpdateHttpService()) //这个必须设置!实现网络请求功能。
            .init(this);   //这个必须初始化

首页

     String mUpdateUrl = Constant.WEBROOT + "api/version";
    XUpdate.newBuild(MainActivity.this)
            .updateUrl(mUpdateUrl)
            .update();

接口实现

public class OKHttpUpdateHttpService implements IUpdateHttpService {
@OverRide
public void asyncGet(@nonnull String url, @nonnull Map<String, Object> params, @nonnull final Callback callBack) {
OkGo.get(url).params(transform(params)).execute(new StringCallback() {
@OverRide
public void onSuccess(Response response) {
callBack.onSuccess(response.body());
}

        @Override
        public void onError(Response<String> response) {
            callBack.onError(response.getException());
        }
    });
}

@Override
public void asyncPost(@NonNull String url, @NonNull Map<String, Object> params, @NonNull final Callback callBack) {
    OkGo.<String>post(url)
            .params(transform(params))
            .execute(new StringCallback() {
                @Override
                public void onSuccess(Response<String> response) {
                    callBack.onSuccess(response.body());
                }

                @Override
                public void onError(Response<String> response) {
                    callBack.onError(response.getException());
                }
            });
}

/**
 * 下载
 *
 * @param url      下载地址
 * @param path     文件保存路径
 * @param fileName 文件名称
 * @param callback 回调
 */
@Override
public void download(@NonNull String url, @NonNull String path, @NonNull String fileName, @NonNull final DownloadCallback callback) {
    OkGo.<File>get(url).execute(new FileCallback(path, fileName) {
        @Override
        public void onSuccess(Response<File> response) {
            callback.onSuccess(response.body());
        }

        @Override
        public void onError(Response<File> response) {
            callback.onError(response.getException());
        }

        @Override
        public void onStart(Request<File, ? extends Request> request) {
            callback.onStart();
        }

        @Override
        public void downloadProgress(Progress progress) {
            callback.onProgress(progress.fraction, progress.totalSize);
        }
    });

}

@Override
public void cancelDownload(@NonNull String url) {

}

private Map<String, String> transform(Map<String, Object> params) {
    Map<String, String> map = new TreeMap<>();
    for (Map.Entry<String, Object> entry : params.entrySet()) {
        map.put(entry.getKey(), entry.getValue().toString());
    }
    return map;
}

}

from xupdate.

tanglufeng avatar tanglufeng commented on May 28, 2024

对,刚刚已经复现了。谢谢修复。

from xupdate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.