Android 固定活动项(ParseObject子类)并通过fromPin(pinName)立即检索-列表为空

Android 固定活动项(ParseObject子类)并通过fromPin(pinName)立即检索-列表为空,android,parse-platform,Android,Parse Platform,我有一个非常简单的片段,它基本上调用了一个方法,该方法尝试从internet检索自定义解析对象,固定它们,然后重新加载带有固定项的UI ListView,无论internet调用是否成功(因此,在没有internet连接的情况下,有一个回退缓存机制) 以下是两个关键方法: // This is called in onViewCreated() and onResume() of the fragment private void reloadWalletsFromInternet() {

我有一个非常简单的片段,它基本上调用了一个方法,该方法尝试从internet检索自定义解析对象,固定它们,然后重新加载带有固定项的UI ListView,无论internet调用是否成功(因此,在没有internet连接的情况下,有一个回退缓存机制)

以下是两个关键方法:

// This is called in onViewCreated() and onResume() of the fragment
private void reloadWalletsFromInternet() {
    ParseQuery<Wallet> queryLiveData = ParseQuery.getQuery(Wallet.class);
    queryLiveData.findInBackground(new FindCallback<Wallet>() {
        @Override
        public void done(final List<com.hasmobi.money.models.Wallet> list, ParseException e) {
            if (list != null && list.size() > 0) {
                for (final Wallet w : list) {
                    w.pinInBackground("wallets", new SaveCallback() {
                        @Override
                        public void done(ParseException e) {
                            reloadWalletsFromLocalstore();
                        }
                    });
                }

            } else {
                Log.d(getClass().getSimpleName(), "no wallets retrieved from internet");
                reloadWalletsFromLocalstore();
            }
        }
    });
}

private void reloadWalletsFromLocalstore() {
    final ParseQuery<Wallet> queryLocalData = ParseQuery.getQuery(Wallet.class);

    queryLocalData.fromLocalDatastore();
    queryLocalData.fromPin("wallets");

    queryLocalData.findInBackground(new FindCallback<Wallet>() {
        @Override
        public void done(List<Wallet> list, ParseException e) {

            // Here I am receiving 0 items in "list" which is wrong
            // (e is "null")
        }
    });
}

我在几个地方放了两行战略性的
Log.d()
行,代码成功地通过这两种方法运行,并且
reloadWalletsFromInternet()
中的for()循环成功运行,似乎将收到的每个钱包对象锁定在pin组“Wallet”中。但是,
reloadWalletsFromLocalstore()
对该组中的PIN进行的后续查询似乎无法检索这些钱包对象。

下面的代码将完成此工作。 摆脱
querycaldata.fromPin(“钱包”)

private void重载walletsfromlocalstore(){
final ParseQuery queryLocalData=ParseQuery.getQuery(Wallet.class);
queryLocalData.fromLocalDatastore();
findInBackground(新的FindCallback(){
@凌驾
公共作废完成(列表,异常解析){
//在这里,我收到“列表”中的0项,这是错误的
//(e为“空”)
}
});
}

我认为您不需要这一行queryLocalData.fromLocalDatastore();仅使用此选项对我有效queryLocalData.fromPin(“钱包”);作为调试步骤,请尝试使用queryLocalData.fromPin();不指定pin名称。
    ParseObject.registerSubclass(Wallet.class);
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, "my keys", "my keys");
private void reloadWalletsFromLocalstore() {
    final ParseQuery<Wallet> queryLocalData = ParseQuery.getQuery(Wallet.class);

    queryLocalData.fromLocalDatastore();


    queryLocalData.findInBackground(new FindCallback<Wallet>() {
        @Override
        public void done(List<Wallet> list, ParseException e) {

            // Here I am receiving 0 items in "list" which is wrong
            // (e is "null")
        }
    });
}