com.parse.ParseException Java Examples

The following examples show how to use com.parse.ParseException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From Oy with Apache License 2.0 6 votes vote down vote up
/**
 * Load the list of added friends into mFriends
 */
public void loadFriendsList() {
    mFriendsRelation = mCurrentUser.getRelation(ParseConstants.KEY_FRIENDS_RELATION);
    ParseQuery<ParseUser> query = mFriendsRelation.getQuery();
    query.addAscendingOrder(ParseConstants.KEY_USERNAME);
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> friends, ParseException e) {
            if (e == null) {
                mFriends = friends;
                mAdapter = new FriendsAdapter();
                getListView().setAdapter(mAdapter);
                OyUtils.setListViewHeightBasedOnChildren(getListView());
                Log.d("friends", mFriends.size() + "");
            } else {
                Toast.makeText(MainActivity.this, getString(R.string.error_friends), Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
Example #2
Source File: StarterApplication.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Parse.enableLocalDatastore(this);
    Parse.initialize(this, Constants.getConstant(this, R.string.PARSE_APP_ID),
            Constants.getConstant(this, R.string.PARSE_CLIENT_KEY));

    Fabric.with(this, new Crashlytics());
    Crashlytics.getInstance().setDebugMode(false);

    Crashlytics.log(Log.INFO, StarterApplication.class.getName(), "Starting Application - " + System.currentTimeMillis());
    NewsCatFileUtil.getInstance(this);
    UserPrefUtil.getInstance(this);
    ParseConfig.getInBackground(new ConfigCallback() {
        @Override
        public void done(ParseConfig config, ParseException e) {
            ConfigService.getInstance();
            ConfigService.getInstance().setInstance(StarterApplication.this);
        }
    });
}
 
Example #3
Source File: LikeUserCall.java    From protohipster with Apache License 2.0 6 votes vote down vote up
@Override
public void call() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseLikeTableDefinitions.PARSE_LIKE_TABLE);
    query.whereEqualTo(ParseLikeTableDefinitions.PARSE_LIKE_USER_ID, userId);

    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> parseLikes, ParseException e) {
            if (e == null) {
                if(parseLikes.size() > 0){
                    ParseObject likeObject = parseLikes.get(0);

                    likeObject.increment(ParseLikeTableDefinitions.PARSE_LIKE_NUM_LIKES);
                    likeObject.saveInBackground();
                }

                responseCallback.complete(userId);

            } else {
                LoggerProvider.getLogger().d(LOGTAG, "Error retrying info from parse");
            }
        }

    });
}
 
Example #4
Source File: OBAnalyticsManagerOnline.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
private void logEvent(final String eventName, Map<String, Object> properties)
{
    if (!OBConfigManager.sharedManager.isAnalyticsEnabled()) return;
    //
    MainActivity.log("OBAnalyticsManagerOnline.logEvent: " + eventName + " " + properties.toString());
    //
    ParseObject parseObject = new ParseObject(eventName);
    for (String key : properties.keySet())
    {
        parseObject.put(key, properties.get(key));
    }
    //
    parseObject.put(OBAnalytics.Params.DEVICE_UUID, OBSystemsManager.sharedManager.device_getUUID());
    parseObject.saveEventually(new SaveCallback()
    {
        @Override
        public void done (ParseException e)
        {
            if (e != null)
            {
                MainActivity.log("OBAnalyticsManagerOnline.logEvent.event save failed");
                e.printStackTrace();
            }
        }
    });
    //
    long currentTime = System.currentTimeMillis();
    // TODO: move the time frame for uploads to the config (1hour)
    if (currentTime - lastDataUploadTimestamp > 1000 * 60 * 60 * 1)
    {
        uploadData();
    }
}
 
Example #5
Source File: PerfTestParse.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
private void indexedStringEntityQueriesRun(int count) throws ParseException {
    // create entities
    List<IndexedStringEntity> entities = new ArrayList<>(count);
    String[] fixedRandomStrings = StringGenerator.createFixedRandomStrings(count);
    for (int i = 0; i < count; i++) {
        IndexedStringEntity entity = new IndexedStringEntity();
        entity.setIndexedString(fixedRandomStrings[i]);
        entities.add(entity);
    }
    log("Built entities.");

    // insert entities
    ParseObject.pinAll(entities);
    log("Inserted entities.");

    // query for entities by indexed string at random
    int[] randomIndices = StringGenerator.getFixedRandomIndices(QUERY_COUNT, count - 1);

    startClock();
    for (int i = 0; i < QUERY_COUNT; i++) {
        int nextIndex = randomIndices[i];

        ParseQuery<IndexedStringEntity> query = ParseQuery.getQuery(IndexedStringEntity.class);
        query.whereEqualTo(IndexedStringEntity.INDEXED_STRING, fixedRandomStrings[nextIndex]);
        //noinspection unused
        List<IndexedStringEntity> result = query.find();
    }
    stopClock(Benchmark.Type.QUERY_INDEXED);

    // delete all entities
    ParseObject.unpinAll();
    log("Deleted all entities.");
}
 
Example #6
Source File: ParseTools.java    From DataSync with Apache License 2.0 5 votes vote down vote up
public static <T extends ParseObject> List<T> findAllParseObjects(ParseQuery<T> query) throws ParseException {
    List <T> result = new ArrayList<T>();
    query.setLimit(DEFAULT_PARSE_QUERY_LIMIT);
    List<T> chunk = null;
    do {
        chunk = query.find();
        result.addAll(chunk);
        query.setSkip(query.getSkip() + query.getLimit());
    } while (chunk.size() == query.getLimit());
    return result;
}
 
Example #7
Source File: WebsiteListFragment.java    From Gazetti_Newspaper_Reader with MIT License 5 votes vote down vote up
private void getOldListItems(Date lastObjectCreatedAtDate) {

        ParseQuery<ParseObject> queryGetOldItems = ParseQuery.getQuery(dbToSearch);
        queryGetOldItems.whereEqualTo("newspaper_id", npIdString);
        queryGetOldItems.whereEqualTo("cat_id", catIdString);
        queryGetOldItems.whereLessThan("createdAt", lastObjectCreatedAtDate);
        queryGetOldItems.setLimit(20);
        queryGetOldItems.orderByDescending("createdAt");

        queryGetOldItems.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> articleObjectList, ParseException exception) {
                // Log.d(TAG, "Old Items articleObjectList " +
                // articleObjectList.size());
                if(exception == null){
                    retainedList.addAll(articleObjectList);
                    newsAdapter.notifyDataSetChanged();

                    // Log.d(TAG, "articleObjectList Retained " +
                    // retainedList.size());

                    mListView.removeFooterView(footerOnList);
                    mListViewContainer.setRefreshing(false);
                    flag_loading_old_data = false;
                } else {
                    Crashlytics.log("Wrong while fetching - " + exception.getMessage());
                    headerTextView.setText("Something went wrong!");
                }
            }

        });

    }
 
Example #8
Source File: GetLikesCall.java    From protohipster with Apache License 2.0 5 votes vote down vote up
@Override
public void call() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseLikeTableDefinitions.PARSE_LIKE_TABLE);
    query.whereContainedIn(ParseLikeTableDefinitions.PARSE_LIKE_USER_ID, userIds);

    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> parseLikes, ParseException e) {
            if (e == null) {
                GetLikesResponse response = new GetLikesResponse();

                for (ParseObject likeObject : parseLikes) {
                    String userId = likeObject.getString(ParseLikeTableDefinitions.PARSE_LIKE_USER_ID);
                    int numLikes = likeObject.getInt(ParseLikeTableDefinitions.PARSE_LIKE_NUM_LIKES);

                    response.add(userId, numLikes);
                }

                responseCallback.complete(response);

            } else {
                LoggerProvider.getLogger().d(LOGTAG, "Error retrying info from parse");
            }
        }

    });
}
 
Example #9
Source File: PerfTestParse.java    From android-database-performance with Apache License 2.0 4 votes vote down vote up
private void deleteAll() throws ParseException {
    ParseObject.unpinAll();
}
 
Example #10
Source File: ParseTools.java    From DataSync with Apache License 2.0 4 votes vote down vote up
public static <T extends ParseObject> List<T> findAllParseObjects(Class<T> clazz) throws ParseException {
    return findAllParseObjects(ParseQuery.getQuery(clazz));
}
 
Example #11
Source File: WebsiteListFragment.java    From Gazetti_Newspaper_Reader with MIT License 4 votes vote down vote up
private void getNewListItems() {

        mListViewContainer.setRefreshing(true);
        ParseQuery<ParseObject> queryGetNewItems = ParseQuery.getQuery(dbToSearch);
        queryGetNewItems.whereEqualTo("newspaper_id", npIdString);
        queryGetNewItems.whereEqualTo("cat_id", catIdString);
        queryGetNewItems.orderByDescending("createdAt");

        if (retainedList.size() > 0) {
            ParseObject topObject = retainedList.get(0);
            Date topObjectCreatedAt = topObject.getCreatedAt();
            queryGetNewItems.whereGreaterThan("createdAt", topObjectCreatedAt);
        }

        if (firstRun) {
            queryGetNewItems.setLimit(15);
        }
        //TODO: Try-catch with message
        queryGetNewItems.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> articleObjectList, ParseException exception) {

                if(exception == null){

                    retainedList.addAll(0, articleObjectList);

                    newsAdapter.notifyDataSetChanged();

                    dateLastUpdatedString = "Last Updated: "
                            + (DateUtils.formatDateTime(context, System.currentTimeMillis(), //
                            DateUtils.FORMAT_SHOW_TIME //
                                    | DateUtils.FORMAT_SHOW_WEEKDAY //
                                    | DateUtils.FORMAT_SHOW_DATE //
                                    | DateUtils.FORMAT_ABBREV_WEEKDAY //
                                    | DateUtils.FORMAT_NO_NOON //
                                    | DateUtils.FORMAT_NO_MIDNIGHT)); //
                    headerTextView.setText(dateLastUpdatedString);
                    mListViewContainer.setRefreshing(false);

                    if (mTwoPane) {
                        mListView.performItemClick(newsAdapter.getView(mActivatedPosition - 1, null, null),
                                mActivatedPosition, mActivatedPosition);

                    }
                    firstRun = false;
                } else {
                    Crashlytics.log("Wrong while fetching - " + exception.getMessage());
                    headerTextView.setText("Something went wrong!");
                }
            }

        });
    }