Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

synchronization issue

$
0
0

ParseQuery<ParseObject> query = ParseQuery.getQuery("Activity"); query.whereEqualTo("type", "follow"); query.whereEqualTo("fromUser", ParseUser.getCurrentUser()); query.include("toUser"); query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);

    //images of whom i am following
    ParseQuery&lt;ParseObject&gt; queryFollowed =ParseQuery.getQuery(&quot;Feed&quot;);
    queryFollowed.whereMatchesKeyInQuery(&quot;user&quot;, &quot;toUser&quot;, query);
    //query.whereEqualTo(&quot;mediaType&quot;, &quot;image&quot;);
    //query.include(&quot;user&quot;);
    // queryFollowed.whereExists(&quot;image&quot;);

    // my images 
    ParseQuery&lt;ParseObject&gt; userParseObjects = ParseQuery.getQuery(&quot;Feed&quot;);
    userParseObjects.whereEqualTo(&quot;user&quot;, ParseUser.getCurrentUser());
    //query.whereEqualTo(&quot;mediaType&quot;, &quot;image&quot;);
    //query.include(&quot;user&quot;);
    //userParseObjects.whereExists(&quot;image&quot;);

    // combine both queries
    List&lt;ParseQuery&lt;ParseObject&gt;&gt; queries = new ArrayList&lt;ParseQuery&lt;ParseObject&gt;&gt;();
    queries.add(userParseObjects);
    queries.add(queryFollowed);


    ParseQuery&lt;ParseObject&gt; mainQuery = ParseQuery.or(queries);
    mainQuery.include(&quot;user&quot;);
    mainQuery.setLimit(downloadCount);
    mainQuery.setSkip(skip);
    //mainQuery.whereEqualTo(&quot;mediaType&quot;, &quot;image&quot;);
    mainQuery.orderByDescending(&quot;updatedAt&quot;);

    Utilities.printLog(&quot;image above fing query&quot;);

    Utilities.printLog(&quot;current user&quot;+ParseUser.getCurrentUser());

    mainQuery.findInBackground(new FindCallback&lt;ParseObject&gt;(){
        @Override
        public void done(List&lt;ParseObject&gt; object, ParseException e) {
            // TODO Auto-generated method stub
            if (object == null) 
            {

                Utilities.printLog(&quot;error message&quot;+e.getMessage());
            }
            else 
            {
                if(object.size()==0)
                {
                    dataRemaing=false;
                    Utilities.printLog(&quot;object data remaining&quot;+dataRemaing);
                }

                Utilities.printLog(&quot;Size of Object&quot;+object.size());
                for(ParseObject aParseObject :object)
                {
                    final RowItem map = new RowItem();
                    //Utilities.printLog(&quot;object size&quot;+object.size());

                    /*final RowItem map = new RowItem();
                    ParseQuery&lt;ParseObject&gt; querylike = ParseQuery.getQuery(&quot;Activity&quot;);
                    querylike.whereEqualTo(&quot;type&quot;, &quot;like&quot;);
                    querylike.whereEqualTo(&quot;Photo&quot;, aParseObject);
                    querylike.whereEqualTo(&quot;fromUser&quot;, ParseUser.getCurrentUser());
                    querylike.findInBackground(new FindCallback&lt;ParseObject&gt;(){
                        @Override
                        public void done(List&lt;ParseObject&gt; objectlike, ParseException e) 
                        {
                            Utilities.printLog(&quot;objectlike&quot;+objectlike.size());
                            Utilities.printLog(&quot;object of like&quot;+objectlike);
                            if(objectlike.size()&gt;0)
                            {
                                map.setLikecheck(true);
                            }
                            else{
                                map.setLikecheck(false);
                            }
                        }
                    });*/

                    if(aParseObject.getString(&quot;mediaLink&quot;)!=null)
                    {
                        map.setUserPosetedPic(aParseObject.getString(&quot;mediaLink&quot;));
                        map.setImageId(aParseObject.getObjectId());
                        Utilities.printLog(&quot;objectid of selected pic in home&quot;+aParseObject.getObjectId());
                        Date updatedAt = aParseObject.getUpdatedAt();
                        String commentdate=Utilities.timeForPost(updatedAt);
                        map.setUserPosetedPicTime(commentdate);
                        int likecount=aParseObject.getInt(&quot;likesCount&quot;);
                        map.setLikecount(likecount);
                        int commentcount=aParseObject.getInt(&quot;commentsCount&quot;);
                        map.setCommentCount(commentcount);
                        map.setMediaType(aParseObject.getString(&quot;mediaType&quot;));
                        //Utilities.printLog(&quot;image link&quot;+aParseObject.getString(&quot;mediaLink&quot;));
                        if(aParseObject.get(&quot;user&quot;)!=null)
                        {

                            ParseUser user=(ParseUser)aParseObject.get(&quot;user&quot;);
                            map.setUserid(user.getObjectId());
                            Utilities.printLog(&quot;home user id&quot;+user.getObjectId());
                            Utilities.printLog(&quot;user object id&quot;+user.getObjectId());
                            Utilities.printLog(&quot;username&quot;+user.getString(&quot;displayName&quot;));
                            map.setUserName((String)user.getString(&quot;displayName&quot;));
                            //Uri myprofilePicUri=Uri.parse();
                            ParseFile myprofilepic=user.getParseFile(&quot;profilePictureMedium&quot;);
                            map.setUserProfilepic(myprofilepic.getUrl());


                        }

                    }

                    RowItemlist.add(map);
                //mAdapter.notifyDataSetChanged();
                }
            }

            updateData();
            if (progress!=null ) 
            {
                progress.cancel();
                progress.dismiss();
            }

        }

    });

i want to check in which post i have liked so that i can highlight the liked button . In for loop i am getting parseobject and the comment part is for checking whether the current post i have liked or not but getting some snchronization problem any help will appriciated

Thanks in Advance Roshani


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>