GridView的ParseQueryAdapter不从Parse加载对象

时间:2016-04-25 10:09:32

标签: android gridview parse-platform

我在片段中使用ParseQueryAdapter来显示Parse Cloud中的图像和文本。但它没有加载任何东西。

这是片段类

  //Set up a customized query
        ParseQueryAdapter.QueryFactory<ParseMap> factory =
                new ParseQueryAdapter.QueryFactory<ParseMap>() {
                    public ParseQuery<ParseMap> create() {
                        ParseQuery<ParseMap> query = ParseMap.getQuery();
                        query.orderByDescending("createdAt");
                        query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
                        query.setMaxCacheAge(43200000);
                        // query.whereWithinKilometers("GeoArea",mypoint,1);

                        return query;
                    }
                };

        // Set up the query adapter
        feedsQueryAdapter = new ParseQueryAdapter<ParseMap>(getActivity(), factory) {
            @Override
            public View getItemView(final ParseMap post, View view, ViewGroup parent) {
                if (view == null) {
                    view = View.inflate(getContext(), R.layout.feeds_image, null);
                }
                ImageView ThumbView = (ImageView) view.findViewById(R.id.videoThumb);
                TextView usernameView = (TextView) view.findViewById(R.id.grid_item_title);
                String VideoThumb = String.valueOf(post.getVideoThumb().getUrl());
                Picasso.with(FeedsFragment.this.getContext())
                        .load(VideoThumb)
                        .transform(new CircleTransform())
                        .resize(250,250)
                        .centerCrop()
                        .into(ThumbView);
                usernameView.setText(post.getUser());
                view.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        Intent intent = new Intent(FeedsFragment.this.getActivity(), SingleVideoView.class);
                        String VideoUri = String.valueOf(post.getVideo());
                        String intentViews = String.valueOf(post.getViews());
                        // Pass all data phone
                        intent.putExtra("video", VideoUri);
                        intent.putExtra("userId", post.getUserId());
                        intent.putExtra("objectId", post.getObjectId());
                        intent.putExtra("views", intentViews);

                        startActivity(intent);

                    }
                });
                return view;
            }
        };
        // Disable automatic loading when the adapter is attached to a view.
        feedsQueryAdapter.setAutoload(true);

        // Disable pagination, we'll manage the query limit ourselves
        feedsQueryAdapter.setPaginationEnabled(false);

        gridview = (GridView) rootView.findViewById(R.id.gridview);

        gridview.setAdapter(feedsQueryAdapter);

        return rootView;

我还在我的Application类中注册了Subclass。我尝试在网上浏览了很多教程,但它并没有帮我解决问题。

0 个答案:

没有答案