<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chao Shi on Medium]]></title>
        <description><![CDATA[Stories by Chao Shi on Medium]]></description>
        <link>https://medium.com/@cshi1017?source=rss-22141b2403b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W4w7RoGm0wZ1_FAy2RgNKg.jpeg</url>
            <title>Stories by Chao Shi on Medium</title>
            <link>https://medium.com/@cshi1017?source=rss-22141b2403b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:50:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cshi1017/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[.So Files in Android]]></title>
            <link>https://cshi1017.medium.com/so-files-in-android-b6d1a3e5f723?source=rss-22141b2403b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6d1a3e5f723</guid>
            <dc:creator><![CDATA[Chao Shi]]></dc:creator>
            <pubDate>Sun, 23 May 2021 20:14:54 GMT</pubDate>
            <atom:updated>2021-06-03T21:34:08.543Z</atom:updated>
            <content:encoded><![CDATA[<h3>.so Files in Android</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nfjLce7xV4pSxR7Ufbtv-A.png" /><figcaption>Design by <a href="https://medium.com/u/3b688d852bb9">Hannah Pratte</a></figcaption></figure><p>In this short article I would make a introduction about what are .SO File and why we need it in android codebase. Also I would indicates how we can fix the crash of <strong>“java.lang.UnsatisfiedLinkError: dlopen failed: library “XXX.so“ not found”</strong></p><h3><strong>What is .SO Files:</strong></h3><p><em>In a nutshell, .So Files is a shared objection library which can be loaded and excused during run time. We can leverage C++ native code in Android, and NDK compiles this code into .So Files.</em></p><h3><strong>Why we need to use .So File:</strong></h3><p><em>I think the the biggest and direct benefit is you can reduce the size of your app by using .So Files combining with your NDK. but, what else?</em></p><p><em>1.SO Files mechanism is to let developer maximize the leverage of C or C++ code in your current Android app.</em></p><p><em>2.So File is binary, using so file would be less costly than Java.</em></p><p><em>3.The Memory allocation of .So File would not be limited by Dalivik/ART which can avoid OOM in some ways.</em></p><p><em>4.Compared with Java, Decompilation of binary code is more difficult in .So Files.</em></p><h3><strong><em>What are the arm64、armeabi、armeabi-v7a、x86?</em></strong></h3><p><em>What are these files used for? Actually these files represent different architectures about CPU. They are here for making the compatibility for the cell phones with different CPU architectures. But in fact, the apicloud’s cloud compilation would only retain </em><strong><em>armeabi</em></strong><em>, which means </em><strong><em>you would need abiFilters to let NDK know what architectures the NDK should need for the compatibility.</em></strong></p><pre>ndk {<br>    abiFilters &quot;armeabi&quot;  <br>}</pre><h3><strong><em>How to fix the crash “java.lang.UnsatisfiedLinkError: dlopen failed: library “XXX.so“ not found”?</em></strong></h3><p><em>You probably met this crash before:</em></p><pre>java.lang.UnsatisfiedLinkError: dlopen failed: library &quot;xxx.so&quot; not found</pre><p><em>I think now you would definitely have some ideas for the fix after reading on the contents above. My recommendation here would be:</em></p><ol><li><em>Please check the NDK in your build gradle</em></li></ol><pre>ndk {<br>  abiFilters &#39;armeabi&quot;, &quot;armeabi-v7a&quot;, &quot;arm64-v8a&#39;<br>}</pre><p><em>2.Please check if there was any missing .SO Files under NDK lib, if you missed, copy and compile would work</em></p><p><em>Thats all I would like to share, hope you guys can enjoy!</em></p><p>Ref: <a href="https://blog.hike.in/reduce-the-size-of-your-app-by-moving-so-files-to-over-the-air-b51ca9dfdaf2">https://blog.hike.in/reduce-the-size-of-your-app-by-moving-so-files-to-over-the-air-b51ca9dfdaf2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6d1a3e5f723" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android AsyncListDiffer: RecyclerView’s Best Friend]]></title>
            <link>https://medium.com/quark-works/android-asynclistdiffer-recycleviews-best-friend-365f75d84f4?source=rss-22141b2403b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/365f75d84f4</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technews]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Chao Shi]]></dc:creator>
            <pubDate>Fri, 14 Feb 2020 16:36:53 GMT</pubDate>
            <atom:updated>2020-08-12T04:30:17.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWe0Dc7x5ygBiUtbDDYyyQ.png" /><figcaption>Design by <a href="https://medium.com/u/3b688d852bb9">Hannah Pratte</a></figcaption></figure><p>I think most Android developers are super familiar with RecyclerView, however you must also think of how to refresh the RecyclerView. In this tutorial, I will demonstrate an easy way on how to go about this process.</p><h3>&lt;Whole Refresh&gt;</h3><pre>Adapter.notifyDataSetChanged();</pre><p>This use to be the most common way to refresh the recyclerView, however its’ drawback are really obvious for two reasons:</p><ol><li>Refresh all the visible area on the recycleView, re-draw all the item. Not only this, if you have a bit more complex logic in your onBindViewHodler(), you will get stuck and lag.</li><li>Cannot fire off the RecyclerView animation, which has a bad user experience.</li></ol><h3>&lt;Partial Refresh&gt;</h3><p>To solve the problems mentioned above, RecyclerView has some partial refresh calls:</p><pre>Adapter.notifyItemChanged(int)<br>Adapter.notifyItemInserted(int)<br>Adapter.notifyItemRangeChanged(int, int)<br>Adapter.notifyItemRangeInserted(int, int)<br>Adapter.notifyItemRangeRemoved(int, int)</pre><p>This will give you a specific item/position to refresh. But, here comes the problem: What if you have a whole list? Do you have to calculate all the positions you need to refresh?</p><h3>DiffUtil:</h3><p>Google noticed this, and it published a Tool Class in support-recyclerview-v7:24 called DiffUtil.</p><p><strong>DiffUtil.callback:</strong></p><pre>private DiffUtil.Callback diffCallback = new DiffUtil.Callback() {<br>    @Override<br>    public int getOldListSize() {<br>        return oldList == null ? 0 : oldList.size();<br>    }</pre><pre>    @Override<br>    public int getNewListSize() {<br>        return newList == null ? 0 : newList.size();<br>    }</pre><pre>    @Override<br>    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {<br>        // return if the two items are the same <br>        // example: the item is the class of User, so the id of User         //would be used for check if these two user are the same<br>      <br>  return TextUtils.equals(oldList.get(oldItemPosition).getId(), newList.get(oldItemPosition).getId());<br>    }</pre><pre>    @Override<br>    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {<br>        //when areItemsTheSame return true, we need to check if<br>        //these two item have the same contents</pre><pre>        return oldList.get(oldItemPosition).getAge() == newList.get(newItemPosition).getAge();<br>    }<br>};</pre><p><strong>Get DiffResult:</strong></p><pre>DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(diffCallback);</pre><p><strong>Set DiffResult to Adapter:</strong></p><pre>mAdapter.setData(newList);<br> diffResult.dispatchUpdatesTo(mAdapter);</pre><p>Ok, since now we do not need notifyDataSetChanged() anymore, the performance of the refreshing can be improved. But, there are still some problems.</p><p><strong>DiffUtil.calculateDiff() is running on the main thread, if we get a big size for a new list or old list, we are going to block the thread!</strong></p><h3>Solution: AsyncListDiff</h3><p>Lets use some simple code to indicate how AsyncListDiff works:</p><pre>public class UserAdapter extends RecyclerView.Adapter&lt;UserAdapter.UserViewHolder&gt; {<br>    private AsyncListDiffer&lt;User&gt; mDiffer;//callBack<br>    private DiffUtil.ItemCallback&lt;User&gt; diffCallback = new DiffUtil.ItemCallback&lt;User&gt;() {<br>        @Override<br>        public boolean areItemsTheSame(User oldItem, User newItem) {<br>            return TextUtils.equals(oldItem.getId(), newItem.getId());<br>        }</pre><pre>        @Override<br>        public boolean areContentsTheSame(User oldItem, User newItem) {<br>            return oldItem.getAge() == newItem.getAge();<br>        }<br>    };//define AsyncListDiffer<br>    public UserAdapter() {<br>        mDiffer = new AsyncListDiffer&lt;&gt;(this, diffCallback);<br>    }</pre><pre>    @Override<br>    public int getItemCount() {<br>        return mDiffer.getCurrentList().size();<br>    }//method to submit list <br>    public void submitList(List&lt;User&gt; data) {<br>        mDiffer.submitList(data);<br>    }//method getItem by position<br>    public User getItem(int position) {<br>        return mDiffer.getCurrentList().get(position);<br>    }//override the method of Adapter<br>    @NonNull<br>    @Override<br>    public UserAdapter.UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {<br>        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_list, parent, false);<br>        return new UserViewHolder(itemView);<br>    }</pre><pre>    @Override<br>    public void onBindViewHolder(@NonNull UserAdapter.UserViewHolder holder, int position) {<br>        holder.setData(getItem(position));<br>    }</pre><p>Here are the steps for using AsyncListDiffer:</p><p><strong>Step 1: </strong>Create a DiffUtil.ItemCallback</p><p><strong>Step 2: </strong>Let AsyncListDiffer to handle all the data</p><p><strong>Step 3: </strong>Then what we are going to do is to use method submitList() to refresh the data/ui:</p><pre>mAdapter.submitList(users);</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fjtizku%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fjtizku&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a2fade0a3e76915294b246e05ecb6bb/href">https://medium.com/media/9a2fade0a3e76915294b246e05ecb6bb/href</a></iframe><p>As ever, QuarkWorks is available to help with any software application project — web, mobile, and more! If you are interested in our services you can check out our <a href="https://quarkworks.co/?source=post_page---------------------------">website</a>. We would love to answer any questions you have! Just reach out to us on our <a href="https://twitter.com/quarkworks_inc">Twitter</a>, <a href="https://www.facebook.com/Quarkworks/?source=post_page---------------------------">Facebook</a>, or <a href="https://www.linkedin.com/company/quarkworks/?source=post_page---------------------------">LinkedIn</a>.</p><p><a href="https://quarkworks.co/">QuarkWorks - Home</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=365f75d84f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quark-works/android-asynclistdiffer-recycleviews-best-friend-365f75d84f4">Android AsyncListDiffer: RecyclerView’s Best Friend</a> was originally published in <a href="https://medium.com/quark-works">QuarkWorks, Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>