Java 仅将新项从ParseQuery添加到ArrayList

Java 仅将新项从ParseQuery添加到ArrayList,java,android,parse-platform,arraylist,Java,Android,Parse Platform,Arraylist,我有一个ParseQuery,其中我从关系查询加载项。查询每次运行时都返回所有对象。我想将项目存储在我的mRipleListfromParse中,然后只提取新项目,将它们添加到我的ArrayList的开头(位置0),这样我就可以避免每次都提取所有数据 我尝试使用解析本地数据存储并缓存查询,但没有获得最佳结果。我还尝试保留对mRipleListFromParse的全局引用,但即使使用“mRipleListFromParse.clear()”,每次刷新数据时列表都会重复 有没有一个简单的方法来实现这

我有一个ParseQuery,其中我从关系查询加载项。查询每次运行时都返回所有对象。我想将项目存储在我的
mRipleListfromParse
中,然后只提取新项目,将它们添加到我的ArrayList的开头(位置0),这样我就可以避免每次都提取所有数据

我尝试使用解析本地数据存储并缓存查询,但没有获得最佳结果。我还尝试保留对mRipleListFromParse的全局引用,但即使使用“mRipleListFromParse.clear()”,每次刷新数据时列表都会重复

有没有一个简单的方法来实现这一点?这是问题所在。谢谢

 public void loadRipleItemsFromParse() {

    ParseUser currentUser = ParseUser.getCurrentUser();

    final ArrayList<DropItem> mRipleListFromParse = new ArrayList<>();

    ParseRelation createdRelation = currentUser.getRelation("createdDrops");
    ParseRelation completedRelation = currentUser.getRelation("completedDrops");

    ParseQuery createdQuery = createdRelation.getQuery();
    ParseQuery completedQuery = completedRelation.getQuery();

    List<ParseQuery<ParseObject>> queries = new ArrayList<>();
    queries.add(createdQuery);
    queries.add(completedQuery);

    ParseQuery<ParseObject> mainQuery = ParseQuery.or(queries);
    mainQuery.include("authorPointer");
    mainQuery.orderByDescending("createdAt");
    mainQuery.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> list, ParseException e) {

            if (e != null) {
                Log.i("KEVIN", "error error");

            } else {
                for (int i = 0; i < list.size(); i++) {

                    final DropItem dropItem = new DropItem();

                    //Drop Author Data//////////////////////////////////////////////////////////
                    ParseObject authorData = (ParseObject) list.get(i).get("authorPointer");

                    ParseFile parseProfilePicture = (ParseFile) authorData.get("parseProfilePicture");
                    if (parseProfilePicture != null) {
                        parseProfilePicture.getDataInBackground(new GetDataCallback() {
                            @Override
                            public void done(byte[] data, ParseException e) {
                                if (e == null) {
                                    Bitmap bmp =     BitmapFactory.decodeByteArray(data, 0, data.length);
//                                        Bitmap resized = Bitmap.createScaledBitmap(bmp, 100, 100, true);
                                    dropItem.setParseProfilePicture(bmp);
                                    updateRecyclerView(mRipleListFromParse);
                                }
                            }
                        });
                    }

                    //dropItemAll.setAuthorName(authorName);
                    dropItem.setAuthorName((String) authorData.get("displayName"));
                    //Author id
                    dropItem.setAuthorId(authorData.getObjectId());
                    //Author Rank
                    dropItem.setAuthorRank(authorData.getString("userRank"));

                    //Drop Data////////////////////////////////////////////////////////////////
                    //DropObjectId
                    dropItem.setObjectId(list.get(i).getObjectId());
                    //CreatedAt
                    dropItem.setCreatedAt(list.get(i).getCreatedAt());
                    //dropItem.createdAt = new SimpleDateFormat("EEE, MMM d yyyy @ hh 'o''clock' a").parse("date");
                    //Drop description
                    dropItem.setDescription(list.get(i).getString("description"));

                    //Riple Count
                    int ripleCount = (list.get(i).getInt("ripleCount"));
                    if (ripleCount == 1) {
                        dropItem.setRipleCount(String.valueOf(list.get(i).getInt("ripleCount") + " Riple"));
                    } else {
                        dropItem.setRipleCount(String.valueOf(list.get(i).getInt("ripleCount") + " Riples"));
                    }

                    //Comment Count
                    int commentCount = (list.get(i).getInt("commentCount"));
                    if (commentCount == 1) {
                        dropItem.setCommentCount(String.valueOf(list.get(i).getInt("commentCount") + " Comment"));
                    }else {
                        dropItem.setCommentCount(String.valueOf(list.get(i).getInt("commentCount") + " Comments"));
                    }

                    mRipleListFromParse.add(dropItem);

                }
            }
        }
    });
}
public void loadRipleItemsFromParse(){
ParseUser currentUser=ParseUser.getCurrentUser();
final ArrayList mRipleListFromParse=新ArrayList();
ParseRelation createdRelation=currentUser.getRelation(“createdDrops”);
ParseRelation completedRelation=currentUser.getRelation(“completedDrops”);
ParseQuery createdQuery=createdRelation.getQuery();
ParseQuery completedQuery=completedRelation.getQuery();
列表查询=新建ArrayList();
添加(createdQuery);
查询。添加(完成查询);
ParseQuery mainQuery=ParseQuery.or(查询);
mainQuery.include(“authorPointer”);
mainQuery.orderByDescending(“createdAt”);
findInBackground(新的FindCallback(){
@凌驾
公共作废完成(列表,异常解析){
如果(e!=null){
Log.i(“凯文”,“错误”);
}否则{
对于(int i=0;i