使用JSoup动态加载内容

使用JSoup动态加载内容

本文介绍了使用JSoup动态加载内容-数据不会膨胀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个将HTML数据解析为RecyclerView的应用.我正在尝试使用JSoup:

  • 静态片段作为主页,
  • 一个动态片段,其内容在单击NavigationView时会发生更改.

  • 完整代码位于 GitHub 上,我已经打开了一个问题.问题是内容无法正确加载-夸大Fragment后没有显示任何数据,尽管我可以看到在日志中成功创建了ArrayList的数据.
    我认为问题出在ContentAdapter内部的ViewHolder.我已将Log.d放在onCreateViewHolderonBindViewHolder内-加载过程中未显示任何日志.

    I'm trying to create an app which is parsing HTML data into RecyclerView. Using JSoup, I'm trying to make:

  • A static fragment as a homepage,
  • A dynamic fragment with content being changed on click in NavigationView.

  • Full code is on GitHub, I've already opened an issue. The thing is content doesn't load properly - after inflating Fragment no data is being shown, although I can see a successful creation of ArrayList with my data in logs.
    I think the problem is with the ViewHolder inside ContentAdapter. I've put the Log.d inside both onCreateViewHolder and onBindViewHolder - no logs are shown during load process.

    每个数据都是公开的,因为该应用程序是为本地赠款项目创建的-完成后也将在Play商店中发布.

    Every single data there is public, as the app is being created for local grant project - it'll also be published in Play Store when finished.

    在此先感谢您提供的任何帮助!

    Thanks in advance for any help provided!

    推荐答案

    我已经找到答案了.我创建了Utils类,用于存储最重要的值并将其传递给活动或片段.我要做的就是重新格式化 Utils 为单例模式-之前调用Utils时,由于实例不同,没有显示任何数据.在使该类成为一个单独的类之后,就可以收集并正确显示数据.

    I've found the answer already.I've created Utils class for storing the most important values and passing them to activities or fragments. All I had to do was to reformat Utils to singleton pattern - when I was calling Utils previously, no data was shown because of different instances. After making this class a singleton, data was collected and displayed properly.

    这篇关于使用JSoup动态加载内容-数据不会膨胀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    08-22 15:56