小编24x*_*4x7的帖子

Picasso在listview中向上滚动时不断重新加载图像,加载缓慢

我一直在搜索SO线程的答案,但无法从之前的讨论中找出我的问题.我有一个listview加载大约50个图像(它曾经是大约100个图像,但根本没有加载任何图像).从api端点获取我的JSON内容(包括图像URL)后,通过适配器,我的代码将其放入listview中.

目前,有50张图片,当我向下滚动Feed时,毕加索将一次加载一张图片.我觉得好像保持滚动固定在列表视图中的一个项目将使该图像加载更快.然而,当我向上滚动时,它会将占位符放回并重新加载图像.有没有办法解决这个问题?

public class MainActivity extends Activity {
    private List<Post> myPosts = new ArrayList<Post>();
    protected String[] mBlogPostTitles;
    public static final String TAG = MainActivity.class.getSimpleName();//prints name of class without package name

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if(isNetworkAvailable()) {
            GetBlogPostsTask getBlogPostsTask = new GetBlogPostsTask(); // new thread
            getBlogPostsTask.execute();// don't call do in background directly
        }else{
            Toast.makeText(this, "Network is unavailable", Toast.LENGTH_LONG).show();
        }
    }
    public boolean isNetworkAvailable() {
        ConnectivityManager manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = manager.getActiveNetworkInfo();

        boolean isAvailable = false; …
Run Code Online (Sandbox Code Playgroud)

java android picasso

12
推荐指数
2
解决办法
9850
查看次数

Pyppeteer / Puppeteer NetworkError:执行上下文被破坏,很可能是因为导航

我正在使用 puppeteer 进行一些轻量的爬行 ~2K 页面。但我不断看到这个错误再次出现

  File "/env/local/lib/python3.7/site-packages/pyppeteer/execution_context.py", line 106, in evaluateHandle
    'userGesture': True,
pyppeteer.errors.NetworkError: Protocol error (Runtime.callFunctionOn): Cannot find context with specified id

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
...
  File "/user_code/main.py", line 434, in main_program
    crawl_data = asyncio.get_event_loop().run_until_complete(crawl(browser, url))
  File "/opt/python3.7/lib/python3.7/asyncio/base_events.py", line 573, in run_until_complete
    return future.result()
  File "/user_code/main.py", line 394, in crawl
    title = await page.title()
  File "/env/local/lib/python3.7/site-packages/pyppeteer/page.py", line 1437, in title
    return await frame.title()
  File "/env/local/lib/python3.7/site-packages/pyppeteer/frame_manager.py", line 752, in …
Run Code Online (Sandbox Code Playgroud)

python puppeteer pyppeteer

5
推荐指数
0
解决办法
1859
查看次数

配置模块的“运行时错误:在应用程序上下文之外工作”

我有一个从主文件调用的 config.py 模块,它有各种 app.configs 用于 jinja2filters 和我正在使用的其他一些插件:

config.py 的摘录:

from flask import current_app as app  
#imports go here

def function1:
    print("hello")

app.config['PROPERTY_1'] = 'configgoeshere'

#jinja2 functions and configs would go here like
app.jinja_env.filters['datetime'] = datetimeformat
Run Code Online (Sandbox Code Playgroud)

从 index.py 调用:

from flask import Flask, flash, render_template, jsonify, request, json, request, redirect, url_for, Response, send_from_directory

app = Flask(__name__)
app.config['DEBUG'] = False

app.config.from_object('config') #config file

############################################################################################################################
# MAIN ROUTES
############################################################################################################################
# The route for the homepage
@app.route('/')
def index():
Run Code Online (Sandbox Code Playgroud)

返回错误:

RuntimeError: working outside of …
Run Code Online (Sandbox Code Playgroud)

python jinja2 flask

4
推荐指数
1
解决办法
8033
查看次数

标签 统计

python ×2

android ×1

flask ×1

java ×1

jinja2 ×1

picasso ×1

puppeteer ×1

pyppeteer ×1