Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ImageDataSource.java #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

haibinpark
Copy link

fixbug: 选择图片,点击图片预览,返回后图片列表为空

fixbug: 选择图片,点击图片预览,返回后图片列表为空
@ForgottenR
Copy link

ForgottenR commented Jul 6, 2018

这个方法确实work,但是实际上movetofirst能解决的情况意味着data这个cursor实际上没有发生改变,否则data本身就是重新load出来的cursor了。在这种情况下如果重新用这个data来进行onLoadFinished回调实际上更新完的界面和之前没有变化。虽然一般情况下onLoadFinished耗时不长,但如果文件数量比较多,尤其是文件所属目录也很多的时候onLoadFinished回调耗时是很长的(因为特殊应用场合图片和目录都上千了,在设备上要有十几秒的等待时间)。每次ImageGridActivity的restart都需要重新执行onLoadFinished(比如切出去再切回来)感觉比较蠢,个人的解决方法如下:

public class ImageDataSource implements LoaderManager.LoaderCallbacks<Cursor> {    
...  
    private Cursor lastData=null;  
...  
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {  
        if (lastData==data) return;  
        lastData=data;  
...  
    }
...
}

@xie3120
Copy link

xie3120 commented Aug 3, 2018

File file = new File(imagePath); 可能会造成anr,你们觉得应该怎么解决呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants