Coder Social home page Coder Social logo

Comments (12)

noties avatar noties commented on September 28, 2024 1

Hey @Adonai !

Yeah, I think that the library should respect TextView canvas size to not exceed it (keeping original ratio of cause). Meanwhile, if it's an option, you could use HTML img tags. Markwon takes into account width and height attributes and allows then reference % and em (font size), so as pixels (actually everything else except % and em is considered to be in pixels). For example:

<!-- takes 33% of canvas width keeping the original ratio -->
<img src="my-super-image.png" width="33%">

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024 1

Ugh, compiling aar without uploading it is such a pain.
You should have told me about jitpack earlier, bro :)

https://jitpack.io/com/github/noties/Markwon/v1.0.5-SNAPSHOT/

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024

@noties, yep, thanks, I recognized the difference in htmlParser/native markdown.

The problem is that I can't control what users write in the app so for now will come up with small postprocessing hack.

Thanks for quick reply!

from markwon.

noties avatar noties commented on September 28, 2024

Hey @Adonai !

I have created a new branch for the next release and pushed there discussed changes, here. I have tested it and it works for me. How it's for you? πŸ˜‰

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024

@noties , I'll test it this week and report, thanks!

from markwon.

noties avatar noties commented on September 28, 2024

Dafuq is this? 😢 It's not created by me.

While we are on this I can recommend using local maven repo: https://noties.github.io/blog/2018/03/24/local-maven-repo no need to upload anything

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024

This thing is auto-generating build artifacts for any github repo you request it to do.
See this, very handy

from markwon.

noties avatar noties commented on September 28, 2024

Yeah, I don't like it. Maybe I should create a snapshot myself as development for the next release is mainly in one branch.

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024

Ok, tested this, works as expected. You may close this once it's released.
Thanks!

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024

The other problem, though, is that bounds in AsyncDrawable are resolved in setResult() but canvas width detection occurs in draw(). When TextView is just inflated its width and height are zero, thus AsyncDrawable may fail to properly resolve dimensions.

In particular, this happens when you have RecyclerView with TextView items and scroll too fast or reload adapter.

from markwon.

noties avatar noties commented on September 28, 2024

I think if you do something like this it should solve the RecyclerView issue:

public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyHolder> {

    @Override
    public void onBindViewHolder(@NonNull final MyHolder holder, final int position) {
        whenReady(holder.text, new Runnable() {
            @Override
            public void run() {
                Markwon.setMarkdown(holder.text, getMarkdown(position));
            }
        });
    }
    
    private static void whenReady(@NonNull final View view, @NonNull final Runnable action) {
        if (view.getWidth() == 0) {
            view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                    if (view.getWidth() > 0) {
                        view.getViewTreeObserver().removeOnPreDrawListener(this);
                        action.run();
                    }
                    return true;
                }
            });
        } else {
            action.run();
        }
    }
}

from markwon.

Kaned1as avatar Kaned1as commented on September 28, 2024

Thanks, I solved it the other but fairly similar way.
Anyway, this issue is resolved.

from markwon.

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.