خرید بک لینک

Vote count: 0

I have this remote Html that I am successfully parsing with Jsoup. The particular element I am parsing has <img> tags in it and I would want to display the images in the positions where the tags appear.

I have already written a Volley class that I am using to fetch Images in another activity and it's working in that activity. However, I am finding it difficult to implement it for this activity.

Sample remote Html

<body class="sin">
    <div class="ks">
        <div class="wrap">

            <div class="content-right-sidebar-wrap">
                <main class="content">

                    //A lot of ueeded tags

                    <article class="post-1989009 post type-post post" itemscope="" itemtype="http://schema.org/CreativeWork">
                        <header class="post-header"> 
                            <h1 class="post-title" itemprop="headline">Yet Another 6GB RAM Phone: LeEco Le Max 2 Unveiled</h1>
                        </header>

                        //A lot of ueeded tags

                        <div class="post-content" itemprop="text">
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec nisi lectus. In consectetur nunc accumsan dui molestie, ut ultricies elit lobortis.
                                <a href="https://website.com/2002/03/odales-cursus-sed-eget-dolor.html">odales cursus sed eget dolor</a> Etiam arcu risus, aliquet porta pharetra non, pharetra in dui..
                            </p>

                            <p>
                                <img class="aligncenter size-full wp-image-19289" src="https://website.com/wp-content/uploads/2002/04/image-39.jpeg" alt="LeEco Le Max 2" width="800" height="450" srcset="https://website.com/wp-content/uploads/2002/09/gutter-bkan.jpeg 800w, https://website.com/wp-content/uploads/2002/09/gutter-bkan-300x169.jpeg 300w, https://website.com/wp-content/uploads/2002/09/gutter-bkan-768x432.jpeg 768w, https://website.com/wp-content/uploads/2002/09/gutter-bkan-265x150.jpeg 265w, https://website.com/wp-content/uploads/2002/09/gutter-bkan-320x180.jpeg 320w" sizes="(max-width: 800px) 100vw, 800px">
                            </p>
                            <p>Sed porta aliquet sollicitudin. Vivamus commodo placerat sapien vitae interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus</p>

                            <p> eu massa volutpat, volutpat ipsum id, maximus risus. Etiam maximus lobortis enim sed eleifend. Integer imperdiet, augue accumsan ultricies faucibus, orci orci porttitor velit, semper fringilla</p>

                                <img class="aligncenter size-full wp-image-19290" src="https://website.com/wp-content/uploads/2002/07/guter-lop.jpeg" alt="LeEco Le Max 2" width="728" height="324" srcset="https://website.com/wp-content/uploads/2002/07/guter-lop.jpeg 728w, https://website.com/wp-content/uploads/2002/07/guter-lop-300x134.jpeg 300w" sizes="(max-width: 728px) 100vw, 728px">
                            </p>
                            <p>Sed nec nunc nec eros vulputate vehicula. Duis laoreet ex vel auctor finibus. Sed semper blandit massa, at molestie ligula vestibulum in. Nulla vestibulum viverra risus vitae fringilla</p>

                            <h2>Luccuii</h2>
                            <p>Leuismod ultrices libero at consequat. Quisque vestibulum vulputate vehicula. Vivamus posuere nibh tincidunt tristique faucibus. Integer sed vulputate dui, a luctus sem. Suspendisse potenti.</p>

                        </div>
                     //Skipped the closing tags
                       ...

I'm fetching the value in <div class="post-content" itemprop="text"> with

String postContent = doc.select("div.post-content").first().html();
postContent.setText(Html.fromHtml(post_content));

This is my Volley class I use to fetch images in another activity.

public class VolleyRequest {
    private static VolleyRequest sVolleyRequest;
    private static Context sContext;
    private RequestQueue mRequestQueue;
    private ImageLoader mImageLoader;

    public VolleyRequest(Context context) {
        this.sContext = context;
        this.mRequestQueue = getRequestQueue();

        mImageLoader = new ImageLoader(mRequestQueue,
                new  ImageLoader.ImageCache() {
                    private final LruCache<String, Bitmap>
                    mCache = new LruCache<>(20);

                    @Override
                    public Bitmap getBitmap(String url) {
                        retu mCache.get(url);
                    }

                    @Override
                    public void putBitmap(String url, Bitmap bitmap) {
                        mCache.put(url, bitmap);
                    }

                });
    }

    public static synchronized VolleyRequest getInstance(Context context) {
        if (sVolleyRequest == null) {
            sVolleyRequest = new VolleyRequest(context);
        }
        retu sVolleyRequest;
    }

    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            Cache cache = new DiskBasedCache(sContext.getCacheDir(), 10 * 1024 * 1024);
            Network network = new BasicNetwork(new HurlStack());
            mRequestQueue = new RequestQueue(cache, network);
            // Don't forget to start the volley request queue
            mRequestQueue.start();
        }
        retu mRequestQueue;
    }

    public ImageLoader getImageLoader() {
        retu mImageLoader;
    }
}

The different between that activity (where VolleyRequest works) and this activity is that in that activity, I am able to supply an image url and an ImageView. But in this case I couldn't because of the dynamic positions of the images.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 5 ارديبهشت 1395 ساعت: 19:48

صفحه بندی