根据列中值的存在采取行动

时间:2016-01-23 18:21:42

标签: android parse-platform

我正在尝试检查parse.com columnKey某个特定行在列(名为File)内是否有值(数据),或者这不是我的意思曾经在swift for iOS上做到这一点

 guard let photo = object["File"] as? PFFile else { do soothing else }
    // here am firstly assigning a PFFile  name Photo  the value of an  parseObject's column ( if object haves file than assign else  ( do nothing) )

             photo.getDataInBackgroundWithBlock{
           (imageData:NSData?, error:NSError?)-> Void in
         // now am querying for data 

            if (error == nil){

                if object["File"] != nil {
                 cell.cellAttachment.alpha = 1
                 }}
            else if error != nil{
                print("error") //do nothing


            }
        }

    }
 //as you can see -  if parse object say (list) have value inside a key (File) than do something else do nothing

所以我的问题是我如何使用java创建一个android方法,比如这个用于检查一个键是否包含值而不是在我的数组中添加true,否则在我的数组中添加false 任何指导对我都有帮助

1 个答案:

答案 0 :(得分:1)

 //get all images
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Images");
    query.whereWithinKilometers("location", parseGeoPoint, 100);
    query.orderByDescending("createdAt");

    query.findInBackground(new FindCallback<ParseObject>() {

        @Override
        public void done(List<ParseObject> objects, ParseException e) {
            if (objects.size() > 0) {
                if (e == null) {
                    if (!objects.isEmpty()) {
                        setupAdapter((ArrayList) (objects));
                    }
                } else if (e.getCode() == ParseException.REQUEST_LIMIT_EXCEEDED) {
                    makeSnack("Error! Reloading images.");
                    displayImages(); // How many times you do this is your business...
                } else {
                    e.printStackTrace();
                    Log.v("error", e.getMessage());
                }
            } else {
                //TODO:// if not images, reregister loclistener
                makeSnack("No images located near you.");
            }
        }
    });