Java 类com.parse.GetCallback 实例源码

项目:Clasick    文件:DisplayImage.java   
public static void retreiveprofile(String username , final Context context) {
    ParseQuery<ParseObject> query= ParseQuery.getQuery("Profile");
    query.whereEqualTo("user",username);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {

            if(parseObject!=null && e==null) {

                ParseFile file = (ParseFile) parseObject.get("image");
                String url = "http://wwww.webianks.com";

                if (file != null) {
                    url = file.getUrl().toString();
                }

                MainActivity.retriveProfileCallback(context, url);

            }else{
                //canntretrivee file
            }
        }
    });

}
项目:Clasick    文件:DisplayImage.java   
public static void retreivetimelineprofile(String username , final Context context) {
    ParseQuery<ParseObject> query= ParseQuery.getQuery("Profile");
    query.whereEqualTo("user",username);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {

            if(parseObject!=null && e==null) {

                ParseFile file = (ParseFile) parseObject.get("image");
                String url = "http://wwww.webianks.com";
                if (file != null) {

                    url = file.getUrl().toString();
                }

                Profile.retriveTimelineProfileCallback(context, url);

            }else{
                //canntretrivee file
            }
        }
    });

}
项目:BullshIT-DB_Android    文件:DetilActivity.java   
public void addCommentTask(){
    ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB");
    query.whereEqualTo("phone", Phone);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            Log.d("TAG","Done Loading Detail!");
            String NewComment = AddComment.getText().toString();
            List<String> CommentsList = parseObject.getList("comments");
            if(CommentsList==null){
                CommentsList = new ArrayList<String>();
            }
            CommentsList.add(NewComment+"["+GUID+"]");
            parseObject.put("comments",CommentsList);
            parseObject.saveInBackground();
            loadDetail();
        }
    });
}
项目:BullshIT-DB_Android    文件:AddNewConfirmDialog.java   
public void addCommentTask(String Number, final String Comment, final String GUID){
    ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB");
    query.whereEqualTo("phone", Number);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            Log.d("TAG", "Done Loading Detail!");
            List<String> CommentsList = parseObject.getList("comments");
            if(CommentsList==null){
                CommentsList = new ArrayList<String>();
            }
            CommentsList.add(Comment+"["+GUID+"]");
            parseObject.put("comments",CommentsList);
            parseObject.saveInBackground();
        }
    });
}
项目:RadarApp    文件:FollowFragment.java   
private void initData() {
    String id = getArguments().getString(USER_ID);
    mState = getArguments().getString(Constants.CATEGORY);

    if (id != null && mState != null) {
        QueryHelper.getUserById(id, new GetCallback<User>() {
            @Override
            public void done(User user, ParseException e) {
                if (e == null) {
                    mUser = user;

                    mUserQueryAdapter = new UserQueryAdapter(getActivity(), null, mState, mUser);
                    setListAdapter(mUserQueryAdapter);
                } else {
                    NotificationHelper.alert(getActivity(),
                            getString(R.string.dialog_error_title),
                            e.getMessage());
                }
            }
        });
    }
}
项目:RadarApp    文件:ProfileFragment.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onResume() {
    super.onResume();

    mPivBigAvatar.setParseFile(mUser.getAvatar());

    if (mUser.getAvatar() != null) {
        mPivBigAvatar.loadInBackground();
    } else {
        mPivBigAvatar.setBackground(getResources().getDrawable(R.drawable.ic_avatar));
    }

    if (mMyRoom != null) {
        mMyRoom.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
            @Override
            public void done(ParseObject room, ParseException e) {
                if (e == null) {
                    mRiMyRoom.setData(LocalDb.getInstance().getCurrentUser(), mMyRoom);
                }
            }
        });
    }

    setRoomUIElementsVisibility();
}
项目:RadarApp    文件:UserItem.java   
public void setData(User user) {
    mSelectedUser = user;

    mSelectedUser.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
        @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            mTvUsername.setText(mSelectedUser.getUsername());
            mPivAvatar.setParseFile(mSelectedUser.getAvatar());

            if (mSelectedUser.getAvatar() != null) {
                mPivAvatar.loadInBackground();
            } else {
                mPivAvatar.setBackground(getResources().getDrawable(R.drawable.ic_avatar));
            }

            if (!mCurrentUser.equals(mSelectedUser)) {
                mFbFollow.setData(mCurrentUser, mSelectedUser);
            }
        }
    });
}
项目:ClassDiscuss    文件:ParseDatabase.java   
public void setUsersImageToParse(String username, final File image){
    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.whereEqualTo("username", username);

    query.getFirstInBackground(new GetCallback<ParseUser>() {
        public void done(ParseUser UsersClass, ParseException e) {
            if (UsersClass == null) {
                Log.d("score", "no success setUsersImageToParse");
            } else {
                //success
                UsersClass.put("ProfilePic", image);
                UsersClass.saveInBackground();

                pullParseAndSetOtherUsersDatainBackground();

            }
        }
    });
}
项目:AutoTimeHelper    文件:SliceCRUD.java   
public void delete(final String id) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Slice");
    if (!NetworkStatus.isConnected)
        query.fromLocalDatastore();

    query.whereEqualTo("UUID", "" + id);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        public void done(ParseObject parseSlice, ParseException e) {
            if (parseSlice == null) {

                Log.i("Slice", "Deleted: The getFirst request failed.");
            } else {
                Log.i("Slice", "Slice " + id + " is deleted");
                parseSlice.put("deleted", true);
                parseSlice.pinInBackground();
                parseSlice.saveInBackground();
            }
        }
    });
}
项目:AutoTimeHelper    文件:PointCRUD.java   
public void read(String UUID, ParseObject parseLine, final List<Slice> sliceList) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Point");
    if (!NetworkStatus.isConnected)
        query.fromLocalDatastore();

    query.whereEqualTo("UUID", UUID);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        public void done(ParseObject parsePoint, ParseException e) {
            if (parsePoint == null) {
                Log.i("Point", "Read: The getFirst request failed.");
            } else {
                // try {
                Log.i("Point", "Starting read");
                // parsePoint.fetch();
                Point point = new Point(parsePoint.getDouble("x"), parsePoint.getDouble("y"));
                point.setObjectId(parsePoint.getString("UUID"));
                onresult.onResult(point, sliceList);
                // } catch (ParseException e1) {
                // Log.d("Point", "Read: object not nul, but" + e1);
                // e1.printStackTrace();
                // }

            }
        }
    });
}
项目:Fitness-Buddy-Group-Project    文件:PhoneNoVerificationActivity.java   
private void getCurrentUserId(String phoneNumber) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("SimpleUser");
    query.whereEqualTo("phone_number", phoneNumber);
    query.getFirstInBackground(new GetCallback<ParseObject>(){
        public void done(ParseObject object, ParseException e) {
        if (e == null) {
            String userId = object.getObjectId().toString();
            String currentUserObjId = userId;
            SimpleUser.currentUserObjectId = currentUserObjId;
            // Write the userId in shared pref if the user successfully signed up
            SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            SharedPreferences.Editor edit = pref.edit();
            edit.putString("userId", userId);
            edit.commit();

            Intent returnIntent = new Intent();
            setResult(RESULT_OK, returnIntent);
            finish();
            overridePendingTransition(R.anim.stay_in_place, R.anim.exit_to_bottom);
        } else {
            Log.d("DEBUG", "Error: " + e.getMessage());
        }
        }

    });
}
项目:Fitness-Buddy-Group-Project    文件:HomeActivity.java   
public void populateFavoriteTrainers() {
    showProgressWheel();
    final TrainersListFragment finalFragment = fragment;
    String currentUserId = getLoggedInUserId();

    // If userId is found; user has already signed up
    if (!currentUserId.equals("")) {

        ParseQuery<SimpleUser> query = ParseQuery.getQuery("SimpleUser");
        query.whereEqualTo("objectId", currentUserId);
        query.getFirstInBackground(new GetCallback<SimpleUser>() {
            @Override
            public void done(SimpleUser simpleUser, ParseException e) {
                SimpleUser.currentUserObject = simpleUser;
                showFavorites();
            }
        });
    } else {
        // Ask the user to sign up
        launchLoginActivity(LOGIN_FOR_FAVORITES);
    }
}
项目:AshaNetApp    文件:StreamAdapter.java   
void insertStockImage(String imageId, ImageView ivImage) {
    ivImage.setBackgroundColor(R.color.gray7);
    ParseQuery<StockImage> query = ParseQuery.getQuery(StockImage.class);
    final ImageView ivImageRef = ivImage;
    final String iid = imageId;
    Log.d("DEBUG", "Fetching StockImage " + imageId + " for ImageView " + ivImageRef);
    query.getInBackground
        (imageId,
         new GetCallback<StockImage>() {
            public void done(StockImage sImage, ParseException e) {
                if (e == null) {
                    Log.d("DEBUG", "Callback for StockImage " + sImage.getObjectId() +
                          " (expected " + iid + ") and ImageView " + ivImageRef);
                    if (ivImageRef.getTag().equals(sImage.getObjectId())) {
                        setImageFile(sImage, ivImageRef);
                    } else {
                        Log.d("DEBUG", "stale callback for " + sImage.getObjectId() + "; "
                              + "Image " +ivImageRef  + " is now "  + ivImageRef.getTag());
                    }
                } else {
                    Log.d("ERROR", "erp! " + e);
                }
            }
        });
}
项目:MentorMe    文件:DataService.java   
public static void getOrFetchUser(final long userId, final Async.Block<User> completion) {
    if (User.getUser(userId) != null) {
        if (completion != null) {
            completion.call(User.getUser(userId));
        }
    } else {
        getUser(userId, new GetCallback<User>() {
            @Override
            public void done(User user, ParseException e) {
                user.putInCache();
                if (completion != null) {
                    completion.call(e == null ? user : null);
                }
            }
        });
    }
}
项目:event-schedule-android    文件:Talk.java   
/**
 * Gets the data for a single talk. We use this instead of calling fetch on a ParseObject so that
 * we can use query cache if possible.
 */
public static void getInBackground(final String objectId, final GetCallback<Talk> callback) {
    ParseQuery<Talk> query = Talk.createQuery();
    query.whereEqualTo("objectId", objectId);
    query.findInBackground(new TalkFindCallback() {
        @Override
        protected void doneOnce(List<Talk> objects, ParseException e) {
            if (objects != null) {
                // Emulate the behavior of getFirstInBackground by using only the first result.
                if (objects.size() < 1) {
                    callback.done(null, new ParseException(ParseException.OBJECT_NOT_FOUND,
                        "No talk with id " + objectId + " was found."));
                } else {
                    callback.done(objects.get(0), e);
                }
            } else {
                callback.done(null, e);
            }
        }
    });
}
项目:event-schedule-android    文件:Event.java   
/**
 * Gets the data for a single event. We use this instead of calling fetch on a ParseObject so that
 * we can use query cache if possible.
 */
public static void getInBackground(final String objectId, final GetCallback<Event> callback) {
    ParseQuery<Event> query = Event.createQuery();
    query.whereEqualTo("objectId", objectId);
    query.findInBackground(new EventFindCallback() {
        @Override
        protected void doneOnce(List<Event> objects, ParseException e) {
            if (objects != null) {
                // Emulate the behavior of getFirstInBackground by using only the first result.
                if (objects.size() < 1) {
                    callback.done(null, new ParseException(ParseException.OBJECT_NOT_FOUND,
                        "No event with id " + objectId + " was found."));
                } else {
                    callback.done(objects.get(0), e);
                }
            } else {
                callback.done(null, e);
            }
        }
    });
}
项目:HereAStory-Android    文件:ParseDatabaseServiceImpl.java   
private void read(final String id, final boolean limited, final PointOfInterestReadHandler handler) {
    final LimitedPointOfInterest pointOfInterest = getPointOfInterestObject(limited);
    pointOfInterest.setId(id);

    ParseQuery<ParseObject> query = ParseQuery.getQuery(POI_TABLE);
    query.include(USER_TABLE);
    query.getInBackground(id, new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject object, ParseException e) {
            try {
                if (e == null) {
                    handleReadCompleted(limited, handler, pointOfInterest, object);
                } else {
                    handleReadFailed(id, limited, handler, e);
                }
            } catch (Exception ex) {
                handleReadFailed(id, limited, handler, ex);
            }
        }
    });
}
项目:HereAStory-Android    文件:ParseDatabaseServiceImpl.java   
@Override
public void incrementLikeCount(String storyId) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(POI_TABLE);
    query.getInBackground(storyId, new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject object, ParseException e) {
            try {
                if (e == null) {
                    Integer newValue = (Integer) object.getNumber(LIKE_COUNT) + 1;
                    object.put(LIKE_COUNT, newValue);
                    object.save();
                } else {
                    Log.e(LOG_TAG, "Failed adding like", e);
                }
            } catch (Exception ex) {
                Log.e(LOG_TAG, "Failed adding like", ex);
            }
        }
    });
}
项目:AndroidClient    文件:GoalDetailsActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == ADD_PAYMENT_REQUEST_CODE) {
        // Refresh Goal Detail view
        String objectId = data.getExtras().getString(Goal.GOAL_KEY);
        goal = ParseObject.createWithoutData(Goal.class, objectId);
        goal.fetchInBackground(new GetCallback<Goal>() {

            @Override
            public void done(Goal g, ParseException e) {
                if (e == null) {
                    populateViews();
                }
            }
        });
    }
}
项目:AndroidClient    文件:LCDetailsActivity.java   
private void getGoalData(String goalId) {
    ParseQuery<Goal> query = ParseQuery.getQuery(Goal.class);
    query.getInBackground(goalId, new GetCallback<Goal>() {

        @Override
        public void done(Goal g, ParseException e) {
            if (e == null) {
                goal = g;
                // Setup Activity title base on the goal name
                setTitle(g.getName());
                aposts = new GoalPostsAdapter(LCDetailsActivity.this, goal, posts);
                // llGoalPosts.setAdapter(aposts);

                getLCDetailsData();
            } else {
                Toast.makeText(LCDetailsActivity.this, R.string.parse_error_querying,
                        Toast.LENGTH_LONG).show();
            }
        }
    });

}
项目:BattlehackBarcelonaWedList    文件:LoginActivity.java   
private void setUpUser(Account acc) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Persons");
    query.whereEqualTo("email", acc.name);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            Person person = new Person();

            if (parseObject != null) {
                try {
                    person.setServerId(parseObject.getObjectId());
                    person.setName(parseObject.getString("name"));
                    person.setImage(parseObject.getString("image"));
                    person.setEmail(parseObject.getString("email"));
                    ContentValues values = new PersonCursor().setValues(person);

                    getContentResolver().insert(DataContract.PersonTable.CONTENT_URI, values);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
}
项目:BattlehackBarcelonaWedList    文件:SyncAdapter.java   
private void setUpUser(Account acc) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Persons");
    query.whereEqualTo("email", acc.name);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            Person person = new Person();

            if (parseObject != null) {
                try {
                    person.setServerId(parseObject.getObjectId());
                    person.setName(parseObject.getString("name"));
                    person.setImage(parseObject.getString("image"));
                    person.setEmail(parseObject.getString("email"));
                    ContentValues values = new PersonCursor().setValues(person);

                    getContext().getContentResolver().insert(DataContract.PersonTable.CONTENT_URI, values);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
}
项目:GCSApp    文件:ParseManager.java   
public void asyncGetUserInfo(final String username,final EMValueCallBack<EaseUser> callback){
    ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME);
    pQuery.whereEqualTo(CONFIG_USERNAME, username);
    pQuery.getFirstInBackground(new GetCallback<ParseObject>() {

        @Override
        public void done(ParseObject pUser, ParseException e) {
            if(pUser!=null){
                String nick = pUser.getString(CONFIG_NICK);
                ParseFile pFile = pUser.getParseFile(CONFIG_AVATAR);
                if(callback!=null){
                    EaseUser user = DemoHelper.getInstance().getContactList().get(username);
                    if(user!=null){
                        user.setNick(nick);
                        if (pFile != null && pFile.getUrl() != null) {
                            user.setAvatar(pFile.getUrl());
                        }
                    }else{
                        user = new EaseUser(username);
                        user.setNick(nick);
                        if (pFile != null && pFile.getUrl() != null) {
                               user.setAvatar(pFile.getUrl());
                           }
                    }
                    callback.onSuccess(user);
                }
            }else{
                if(callback!=null){
                    callback.onError(e.getCode(), e.getMessage());
                }
            }

        }
    });
}
项目:Mediator_Android    文件:NetWrapper.java   
public void getEventData(final ICardCallback<ILobbyEventCard> callback) {
    ParseQuery<LobbyEventCard> query = ParseQuery.getQuery(LobbyEventCard.class);
    query.getInBackground(Constans.PARSE_EVENT_OBJECT_ID, new GetCallback<LobbyEventCard>() {
        @Override
        public void done(LobbyEventCard object, ParseException e) {
            if (e == null) {
                callback.onSuccess(false, object);
            } else {
                callback.onError(e);
            }
        }
    });
}
项目:Clasick    文件:Timeline.java   
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        Profile activity = (Profile) getActivity();
        String selected_user = activity.sendmydata();

        View view = inflater.inflate(R.layout.activity_timeline, container, false);

        timeline_user_email = (TextView) view.findViewById(R.id.tv_usermail);
        timeline_question_count = (TextView) view.findViewById(R.id.question_count);
        timeline_designation = (TextView) view.findViewById(R.id.tv_timeline_desig);
        timeline_usernmae = (TextView) view.findViewById(R.id.set_user_orignalname);


        ParseQuery<ParseUser> query = ParseUser.getQuery();
        query.whereEqualTo("username", selected_user);
        query.getFirstInBackground(new GetCallback<ParseUser>() {
            @Override
            public void done(ParseUser parseUser, ParseException e) {
                if (e == null) {
                    user_name = parseUser.getString("Name");
                    user_desig = parseUser.getString("who");
                    user_email = parseUser.getEmail();
                    user_question_count = parseUser.get("query_count").toString();

                    timeline_usernmae.setText(user_name);
                    timeline_designation.setText(user_desig);
                    timeline_user_email.setText(user_email);
                    timeline_question_count.setText(user_question_count);

                } else {

                }

            }

        });

        return view;
    }
项目:Lab-Assistant    文件:IDNumberFragment.java   
private void checkID(final String idNumber)
{
    //lookup logic here
    ParseQuery<ParseObject> query = ParseQuery.getQuery(mGradeTableName);
    query.whereEqualTo("id_number",idNumber);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            if(e == null)
            {
                mListener.onStudentFound(mCourse,parseObject,mLabCount);
            }
            else
            {
                if(e.getCode() == ParseException.OBJECT_NOT_FOUND)
                {
                    Log.d("Student not found",idNumber+" not found in "+mGradeTableName+" table");
                    Toast.makeText(getActivity(),"Student "+idNumber+" Not found",Toast.LENGTH_LONG).show();

                }
                else
                {
                    //Some other error
                    Log.d("Parse error","Code:"+e.getCode());
                    Toast.makeText(getActivity(),"Internal error",Toast.LENGTH_LONG).show();
                }
            }
        }
    });
}
项目:Marketplace    文件:ActivityItemDetails.java   
private void showDialog(final String objectId){
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle("Confirm");
    alert.setMessage("Enter Password");

    final EditText input = new EditText(this);
    alert.setView(input);

    alert.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            final String value = input.getText().toString();

            ParseQuery<ParseObject> query = ParseQuery.getQuery("Product");
            query.whereEqualTo("objectId", objectId);
            query. getFirstInBackground(new GetCallback<ParseObject>() {
                @Override
                public void done(ParseObject parseObject, ParseException e) {
                    if(e==null){
                        if(parseObject.getString("password").equals(value)){
                            deleteItem(parseObject);
                        }else{
                            Toast.makeText(ActivityItemDetails.this, "Wrong Password!!", Toast.LENGTH_LONG).show();
                        }
                    }
                }
            });
        }
    });
    alert.show();
}
项目:BullshIT-DB_Android    文件:DetilActivity.java   
public void isBullshITBankBtnTask(){
    ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB");
    query.whereEqualTo("phone", Phone);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            Log.d("TAG","Done Loading Detail!");
            List<String> BullshITCountList = parseObject.getList("bullshitcount");
            if(BullshITCountList==null){
                BullshITCountList = new ArrayList<String>();
                Log.d("TAG","BullshITCountList is null");
            }
            if(BullshITCountList.contains(GUID)){
                BullshITBtnBg.setBackgroundColor(Color.parseColor("#ffffb600"));
                BullshITCountList.remove(GUID);
                Log.d("TAG","BullshITCount Minus");
            }else{
                BullshITBtnBg.setBackgroundColor(Color.RED);
                BullshITCountList.add(GUID);
                Log.d("TAG","BullshITCount Plus");
            }
            parseObject.put("bullshitcount",BullshITCountList);
            parseObject.saveInBackground();
            BullshITCount.setText(String.valueOf(BullshITCountList.size()));
        }
    });
}
项目:RadarApp    文件:HomeFragment.java   
private void fetchDataToViews() {
    if (mMyRoom != null) {
        roomOwnedVisibility();

        mMyRoom.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
            @Override
            public void done(ParseObject room, ParseException e) {
                mRiMyRoom.setData(mCurrentUser, mMyRoom);
            }
        });
    } else {
        roomNotOwnedVisibility();
    }
}
项目:RadarApp    文件:ProfileFragment.java   
private void initViews(View rootView) {
    mLlFollowing = (LinearLayout) rootView.findViewById(R.id.llFollowing);
    mLlFollower = (LinearLayout) rootView.findViewById(R.id.llFollower);
    mTvFollowingCount = (TextView) rootView.findViewById(R.id.tvFollowingCount);
    mTvFollowerCount = (TextView) rootView.findViewById(R.id.tvFollowerCount);
    mPivBigAvatar = (ParseImageView) rootView.findViewById(R.id.pivBigAvatar);
    mRiMyRoom = (RoomItem) rootView.findViewById(R.id.riMyRoom);
    mBtnCreate = (Button) rootView.findViewById(R.id.btnCreate);
    mBtnEditRoom = (Button) rootView.findViewById(R.id.btnEditRoom);
    mBtnDestroy = (Button) rootView.findViewById(R.id.btnDestroy);
    mBtnEditProfile = (Button) rootView.findViewById(R.id.btnEditProfile);
    mFbFollow = (FollowButton) rootView.findViewById(R.id.fbFollow);
    mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);

    mLlFollowing.setOnClickListener(this);
    mLlFollower.setOnClickListener(this);
    mBtnEditProfile.setOnClickListener(this);
    mBtnCreate.setOnClickListener(this);
    mBtnEditRoom.setOnClickListener(this);
    mBtnDestroy.setOnClickListener(this);

    mFollow.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            mTvFollowingCount.setText(mFollow.getFollowings().size() + "");
            mTvFollowerCount.setText(mFollow.getFollowers().size() + "");
        }
    });

    mFbFollow.setData(LocalDb.getInstance().getCurrentUser(), mUser);
}
项目:RadarApp    文件:FollowButton.java   
public void setData(final User currentUser, final User followUser) {
    final Follow follow = currentUser.getFollow();

    follow.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            final List<User> followingUsers = follow.getFollowings();

            // Don't show the Follow button, when it's you
            if (followUser.equals(currentUser)) {
                setVisibility(View.GONE);
                return;
            }

            if (followingUsers.contains(followUser)) {
                setColorToggleOn();
                setChecked(true);
            } else {
                setColorToggleOff();
                setChecked(false);
            }

            setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    onFollowClicked(followingUsers, followUser, currentUser);
                }
            });
        }
    });
}
项目:RadarApp    文件:EditRoomActivity.java   
private void init() {
    mLocalDb = LocalDb.getInstance();
    mCurrentUser = mLocalDb.getCurrentUser();
    mRoom = mCurrentUser.getRoom();
    mUsers = mRoom.getUsers();
    mSelectedUsers = new ArrayList<>();
    mUsersDeleted = false;

    mEtChangePassword = (EditText) findViewById(R.id.etChangePass);
    mEtChangeRoomName = (EditText) findViewById(R.id.etChangeRoomName);
    mBtnApplyChanges = (Button) findViewById(R.id.btnApplyChanges);
    mGvUsers = (GridView) findViewById(R.id.usersList);
    mSrlRefresh = (SwipeRefreshLayout) findViewById(R.id.srlRefresh);

    mRoom.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            mEtChangeRoomName.setHint(mRoom.getName());
        }
    });

    mEditRoomUserAdapter = new EditRoomUserAdapter(this, mUsers);
    mGvUsers.setAdapter(mEditRoomUserAdapter);

    mSrlRefresh.setColorSchemeColors(
            getResources().getColor(R.color.br_dark_background));

    mBtnApplyChanges.setOnClickListener(this);
    mGvUsers.setOnItemLongClickListener(this);
    mSrlRefresh.setOnRefreshListener(this);
}
项目:RadarApp    文件:EditRoomActivity.java   
@Override
public void onRefresh() {
    mRoom.fetchInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            mUsers.clear();
            mUsers.addAll(mRoom.getUsers());
            mEditRoomUserAdapter.notifyDataSetChanged();

            mSrlRefresh.setRefreshing(false);
        }
    });
}
项目:RadarApp    文件:RoomActivity.java   
private void setUpMap() {
    mMap.setMyLocationEnabled(true);

    navigateToCurrentLocationOnMap();

    String roomId = getIntent().getStringExtra(Constants.ROOM_ID);

    if (roomId != null) {
        QueryHelper.getRoomById(roomId, new GetCallback<Room>() {
            @Override
            public void done(Room room, ParseException e) {
                if (e == null) {
                    mRoom = room;
                    mLocalDb.setSelectedRoom(mRoom);

                    // Set activity title
                    getSupportActionBar().setTitle(mRoom.getName());

                    // Do an async update
                    updateMarkers();
                } else {
                    NotificationHelper.alert(RoomActivity.this,
                            getString(R.string.dialog_error_title),
                            e.getMessage());
                }
            }
        });
    }
}
项目:RadarApp    文件:EditRoomUserAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_user_cell, parent, false);
    }

    final ParseImageView ivIcon = (ParseImageView) convertView.findViewById(R.id.ivIcon);
    final TextView tvUsername = (TextView) convertView.findViewById(R.id.tvUsername);

    final User user = mUsers.get(position);
    user.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseObject, ParseException e) {
            ParseFile avatar = user.getAvatar();
            if (avatar != null)
                ivIcon.setParseFile(avatar);
            String username = user.getUsername();
            if (username != null)
                tvUsername.setText(username);

            ivIcon.loadInBackground();
        }
    });

    return convertView;
}
项目:androidClient    文件:RestaurantQuery.java   
public void fetch(Context context, final ModelUpdater<RestaurantModel> modelUpdater) {
    ParseQuery<RestaurantModel> restaurantQuery = ParseQuery.getQuery(RestaurantModel.class);
    restaurantQuery.fromLocalDatastore();
    Log.v("Parse info:", "Started restaurant query");
    restaurantQuery.getInBackground(restaurantId, new GetCallback<RestaurantModel>() {
        public void done(RestaurantModel res, ParseException e) {
            Log.v("Parse info:", "Restaurant query returned");
            List<RestaurantModel> result = new ArrayList<RestaurantModel>();
            result.add(res);
            modelUpdater.onDataModelUpdate(result, e);
        }
    });
}
项目:androidClient    文件:DealQuery.java   
public void fetch(Context context, final ModelUpdater<DealModel> modelUpdater) {
    ParseQuery<DealModel> restaurantQuery = ParseQuery.getQuery(DealModel.class);
    restaurantQuery.fromLocalDatastore();
    Log.v("Parse info:", "Started deal query");
    restaurantQuery.getInBackground(dealId, new GetCallback<DealModel>() {
        public void done(DealModel res, ParseException e) {
            Log.v("Parse info:", "Dealquery returned");
            List<DealModel> result = new ArrayList<DealModel>();
            result.add(res);
            modelUpdater.onDataModelUpdate(result, e);
        }
    });
}
项目:ClassDiscuss    文件:ParseDatabase.java   
private void initiateChannels() {
    //create new channels to parse only if the user is new
    //get the object id now and save it for future use
    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.whereEqualTo("email", Profiles.getInstance().loginEmail);

    //check if email already existed in database
    query.getFirstInBackground(new GetCallback<ParseUser>() {
        public void done(ParseUser object, ParseException e) {
            if (object == null) {
                //get the object id now and save it for future uses
                setMyChannelObjectId(object.getObjectId());
                object.put("channels", "");

                object.saveInBackground();
            } else {
                //already exists
                //get the object id now and save it for future uses
                setMyChannelObjectId(object.getObjectId());

                //set the subscribed channels list locally
                String channelList = object.getString("channels");
                MyChannels subscriptionList = MyChannels.getInstance();
                subscriptionList.initiateLocalChannelsList(channelList);

                Log.d("score", "subscription list updated");
            }
        }
    });
}
项目:ClassDiscuss    文件:ParseDatabase.java   
public void UpdateChannelsToParse(final String HashMapStrings) {
    ParseQuery<ParseUser> query = ParseUser.getQuery();
    // Retrieve the object by id
    query.getInBackground(getMyChannelObjectId(), new GetCallback<ParseUser>() {
        public void done(ParseUser ParseChannels, ParseException e) {
            if (e == null) {
                MyChannels list = MyChannels.getInstance();
                //we are just gonna update the string
                ParseChannels.put("channels", HashMapStrings);
                ParseChannels.saveInBackground();
            }
        }
    });
}
项目:AutoTimeHelper    文件:SliceCRUD.java   
public void sync(Table table) {
    Log.i("Slice", "" + NetworkStatus.isConnected);

    Log.i("Slice", "Slice synchronized start");
    for (final Slice slice : table.getList()) {
        if (slice.getId() == null) {
            create(slice);
        } else {
            ParseQuery<ParseObject> query = ParseQuery.getQuery("Slice");
            if (!NetworkStatus.isConnected)
                query.fromLocalDatastore();

            query.whereEqualTo("UUID", slice.getId());
            query.getFirstInBackground(new GetCallback<ParseObject>() {
                public void done(ParseObject parseSlice, ParseException e) {
                    if (parseSlice == null) {
                        Log.i("Slice", "Sync: The getFirst request failed.");
                    } else {
                        if (!slice.getUpdatedat().equals(parseSlice.getUpdatedAt()))// ----------
                            try {
                                update(slice);
                            } catch (InterruptedException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }
                        Log.i("Slice", "Sync: update dont need");
                    }
                }
            });
        }
    }

}