protected ParseObject createMessage() {

    // Create a new ParseObject
    ParseObject message = new ParseObject(ParseConstants.CLASS_MESSAGES);

    // Send the message to a sender
    message.put(ParseConstants.KEY_SENDER_ID, ParseUser.getCurrentUser().getObjectId());
    message.put(ParseConstants.KEY_SENDER_NAME, ParseUser.getCurrentUser().getUsername());
    message.put(ParseConstants.KEY_RECIPIENT_IDS, getRecipientIds());
    message.put(ParseConstants.KEY_FILE_TYPE, mFileType);

    byte[] fileBytes = FileHelper.getByteArrayFromFile(this, mMediaUri);

    if (fileBytes == null) {
      return null;
    } else {

      if (mFileType.equals(ParseConstants.TYPE_IMAGE)) {
        // Reduce the size of the file to upload it on the backend
        fileBytes = FileHelper.reduceImageForUpload(fileBytes);
      }
      String fileName = FileHelper.getFileName(this, mMediaUri, mFileType);

      ParseFile file = new ParseFile(fileName, fileBytes);

      // Attach it to the message method
      message.put(ParseConstants.KEY_FILE, file);

      return message;
    }
  }
 private void createItsBetaRelationForCurrentUser() {
   final ParseObject itsbeta = new ParseObject("ItsBeta");
   itsbeta.put("facebookAccessToken", auth.getAccessToken());
   itsbeta.put("facebookUserId", auth.getFacebookId());
   itsbeta.put("type", "fb_user_id");
   itsbeta.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(ParseException e) {
           if (e != null) {
             finishBackgroundProcess();
           }
           ParseUser user = ParseUser.getCurrentUser();
           ParseRelation relation = user.getRelation("ItsBeta");
           relation.add(itsbeta);
           user.saveEventually(
               new SaveCallback() {
                 @Override
                 public void done(ParseException e) {
                   if (e != null) {
                     finishBackgroundProcess();
                   }
                 }
               });
         }
       });
 }
 private void createAlbum() {
   if (albumName.getText() != null) {
     ParseObject album = new ParseObject("albums");
     album.put("userId", mUser.getUserId());
     album.put("nameAlbum", albumName.getText().toString());
     album.saveInBackground(
         new SaveCallback() {
           @Override
           public void done(ParseException e) {
             if (e == null) {
               ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("albums");
               query.whereEqualTo("userId", mUser.getUserId());
               query.whereEqualTo("nameAlbum", albumName.getText().toString());
               query.getFirstInBackground(
                   new GetCallback<ParseObject>() {
                     @Override
                     public void done(ParseObject parseObject, ParseException e) {
                       savePhoto(parseObject.getObjectId());
                     }
                   });
             }
           }
         });
   }
 }
 public void parseOutbreak(String sickness, double latitude, double longitude) {
   ParseObject outbreak = new ParseObject("Outbreak");
   ParseGeoPoint point = new ParseGeoPoint(latitude, longitude);
   outbreak.put("sickness", sickness);
   outbreak.put("location", point);
   outbreak.saveInBackground();
 }
  public void saveNote() {
    String titleToSave = titleEditText.getText().toString().trim();
    String contentToSave = contentEditText.getText().toString().trim();

    if (!contentToSave.isEmpty() || !titleToSave.isEmpty()) {
      if (note == null) {
        ParseObject post = new ParseObject("Post");
        post.put("title", titleToSave);
        post.put("content", contentToSave);
        post.put("author", ParseUser.getCurrentUser());
        post.saveInBackground();
        callback.onNoteAdded(titleToSave, contentToSave);
      } else {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");
        final String newTitleToSave = titleToSave;
        final String newContentToSave = contentToSave;
        query.getInBackground(
            note.getId(),
            new GetCallback<ParseObject>() {
              @Override
              public void done(ParseObject parseObject, ParseException e) {
                if (e == null) {
                  parseObject.put("title", newTitleToSave);
                  parseObject.put("content", newContentToSave);
                  callback.onNoteChanged(new Note(newTitleToSave, newContentToSave), note);
                  parseObject.saveInBackground();
                }
              }
            });
      }
    }
  }
Beispiel #6
0
    // @JavascriptInterface
    public void showData(String[] data) {
      String firstName = data[0];
      String lastName = data[1];
      String phoneNumber = data[2];
      String emailAddress = data[3];

      // A LITTLE VAILDATION
      if (firstName.equals("") || firstName.length() == 0) {
        Toast toast =
            Toast.makeText(getApplicationContext(), "CHECK FIRST NAME", Toast.LENGTH_LONG);
        toast.show();
      } else if (lastName.equals("") || lastName.length() == 0) {
        Toast toast = Toast.makeText(getApplicationContext(), "CHECK LAST NAME", Toast.LENGTH_LONG);
        toast.show();
      } else if (phoneNumber.equals("") || phoneNumber.length() == 0 || phoneNumber.length() < 12) {
        Toast toast =
            Toast.makeText(getApplicationContext(), "CHECK YOUR PHONE NUMBER", Toast.LENGTH_LONG);
        toast.show();
      } else if (emailAddress.equals("")
          || emailAddress.length() == 0
          || !(emailAddress.contains("@"))) {
        Toast toast = Toast.makeText(getApplicationContext(), "CHECK EMAIL", Toast.LENGTH_LONG);
        toast.show();
      } else {
        ParseObject contactObject = new ParseObject("ContactObject");
        contactObject.put("fname", firstName);
        contactObject.put("lname", lastName);
        contactObject.put("phone", phoneNumber);
        contactObject.put("email", emailAddress);
        contactObject.saveInBackground();

        Intent i = new Intent(mContext, AddFriend.class);
        startActivity(i);
      }
    }
  public UpdateImage(Activity activity) {

    Bitmap bitmap =
        BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_action_name);
    // Convert it to byte
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    // Compress image to lower quality scale 1 - 100
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
    byte[] image = stream.toByteArray();

    // Create the ParseFile
    ParseFile file = new ParseFile("androidbegin.png", image);
    // Upload the image into Parse Cloud
    file.saveInBackground();

    // Create a New Class called "ImageUpload" in Parse
    ParseObject imgupload = new ParseObject("ImageUpload");

    // Create a column named "ImageName" and set the string
    imgupload.put("ImageName", "AndroidBegin Logo");

    // Create a column named "ImageFile" and insert the image
    imgupload.put("ImageFile", file);

    // Create the class and the columns
    imgupload.saveInBackground();
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
      Bundle extras = data.getExtras();
      Bitmap imageBitmap = (Bitmap) extras.get("data");
      mImageView = (ImageView) findViewById(R.id.imgView);

      // Saving in Parse server
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
      byte[] dataTostore = stream.toByteArray();

      final ParseFile imgFile = new ParseFile("img.png", dataTostore);
      imgFile.saveInBackground();

      GalleryObj tempPicObj = new GalleryObj();
      ParseObject obj = new ParseObject("Gallery");

      obj.put("pic", imgFile);
      obj.put("Apartment", ParseUser.getCurrentUser().getString("Apartment"));
      try {
        obj.save();
        tempPicObj.id = obj.getObjectId();
        tempPicObj.pic = imageBitmap;
        STgallery.getInstance().add(tempPicObj);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      adapter.notifyDataSetChanged();
    }
  }
Beispiel #9
0
  private void sendMessage() {
    EditText messageTxt = (EditText) findViewById(R.id.txt);
    if (messageTxt.length() == 0) {
      return;
    }

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(messageTxt.getWindowToken(), 0);

    ReliUser user = MainActivity.user;

    String s = messageTxt.getText().toString();
    final Message message = new Message(s, new Date(), user.getParseID(), user.getFullName());
    messagesList.add(message);
    chatAdapter.notifyDataSetChanged();
    messageTxt.setText(null);

    ParseObject po = new ParseObject(discussionTableName);
    po.put(Const.COL_MESSAGE_SENDER_ID, user.getParseID());
    po.put(Const.COL_MESSAGE_SENDER_NAME, user.getFullName());
    po.put(Const.COL_MESSAGE_CONTENT, s);
    po.saveEventually(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            message.setStatus(
                (e == null) ? MessageStatus.STATUS_SENT : MessageStatus.STATUS_FAILED);

            chatAdapter.notifyDataSetChanged();
          }
        });
  }
 public boolean updateParseNickName(final String nickname) {
   String username = EMChatManager.getInstance().getCurrentUser();
   ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME);
   pQuery.whereEqualTo(CONFIG_USERNAME, username);
   ParseObject pUser = null;
   try {
     pUser = pQuery.getFirst();
     if (pUser == null) {
       return false;
     }
     pUser.put(CONFIG_NICK, nickname);
     pUser.save();
     return true;
   } catch (ParseException e) {
     if (e.getCode() == ParseException.OBJECT_NOT_FOUND) {
       pUser = new ParseObject(CONFIG_TABLE_NAME);
       pUser.put(CONFIG_USERNAME, username);
       pUser.put(CONFIG_NICK, nickname);
       try {
         pUser.save();
         return true;
       } catch (ParseException e1) {
         e1.printStackTrace();
         EMLog.e(TAG, "parse error " + e1.getMessage());
       }
     }
     e.printStackTrace();
     EMLog.e(TAG, "parse error " + e.getMessage());
   }
   return false;
 }
 public String uploadParseAvatar(byte[] data) {
   String username = EMChatManager.getInstance().getCurrentUser();
   ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME);
   pQuery.whereEqualTo(CONFIG_USERNAME, username);
   ParseObject pUser = null;
   try {
     pUser = pQuery.getFirst();
     if (pUser == null) {
       pUser = new ParseObject(CONFIG_TABLE_NAME);
       pUser.put(CONFIG_USERNAME, username);
     }
     ParseFile pFile = new ParseFile(data);
     pUser.put(CONFIG_AVATAR, pFile);
     pUser.save();
     return pFile.getUrl();
   } catch (ParseException e) {
     if (e.getCode() == ParseException.OBJECT_NOT_FOUND) {
       try {
         pUser = new ParseObject(CONFIG_TABLE_NAME);
         pUser.put(CONFIG_USERNAME, username);
         ParseFile pFile = new ParseFile(data);
         pUser.put(CONFIG_AVATAR, pFile);
         pUser.save();
         return pFile.getUrl();
       } catch (ParseException e1) {
         e1.printStackTrace();
         EMLog.e(TAG, "parse error " + e1.getMessage());
       }
     } else {
       e.printStackTrace();
       EMLog.e(TAG, "parse error " + e.getMessage());
     }
   }
   return null;
 }
Beispiel #12
0
 private void submitEssay() {
   final ProgressDialog progress = new ProgressDialog(CopyEssay.this);
   progress.setMessage(getString(R.string.please_wait_message));
   progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   progress.setCancelable(false);
   progress.show();
   String t = title.getText().toString();
   String s = subject.getText().toString();
   ParseObject essay = new ParseObject("essays");
   essay.put("title", t);
   essay.put("subject", s);
   essay.put("content", essay_txt.getText().toString());
   essay.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(com.parse.ParseException e) {
           if (e != null) {
             e.printStackTrace();
           } else {
             progress.dismiss();
             displaySnackbar();
             Intent intent = new Intent(CopyEssay.this, HomeScreen.class);
             startActivity(intent);
           }
         }
       });
 }
 private void addSongToParse(String id, String url, String title, String artist) {
   ParseObject song = new ParseObject("Song");
   song.put("songId", id);
   song.put("url", url);
   song.put("title", title);
   song.put("artist", artist);
   song.saveInBackground();
 }
Beispiel #14
0
    public ParseObject createParseObject() {
      ParseObject parseObject = new ParseObject("Images");
      parseObject.put("downsized", mDownSized.createParseObject());
      parseObject.put("downsizedStill", mDownSizedStill.createParseObject());
      parseObject.put("original", mOriginal.createParseObject());
      parseObject.put("small", mSmall.createParseObject());

      return parseObject;
    }
Beispiel #15
0
  public static ParseObject createCommunity(String title, Location location) {
    ParseObject newCommunity = new ParseObject(Common.OBJECT_COMMUNITY);
    newCommunity.put(Common.OBJECT_COMMUNITY_TITLE, title);
    newCommunity.put(Common.OBJECT_COMMUNITY_LAT, String.valueOf(location.getLatitude()));
    newCommunity.put(Common.OBJECT_COMMUNITY_LONG, String.valueOf(location.getLongitude()));
    newCommunity.saveInBackground();

    return newCommunity;
  }
Beispiel #16
0
  static float[] updateGraph() {
    long timeStep = 1445214540000L;
    float[] results = new float[numData];

    ParseQuery<ParseObject> query = ParseQuery.getQuery("data");
    query.whereEqualTo("flag", 1);
    try {
      ParseObject flagged = query.getFirst();
      timeStep = flagged.getLong("unixTimeStamp");
      flagged.put("flag", 0);
      flagged.saveInBackground();
      Log.d("Find Flag", flagged.getObjectId());
    } catch (ParseException e) {
      Log.d("Find Flag", "Error: " + e.getMessage());
    }
    query = ParseQuery.getQuery("data");
    query.orderByAscending("unixTimeStamp");
    query.whereGreaterThan("unixTimeStamp", timeStep);
    try {
      ParseObject nextFlag = query.getFirst();
      nextFlag.put("flag", 1);
      nextFlag.saveInBackground();
      Log.d("Set Next Flag", nextFlag.getObjectId() + " is " + nextFlag.getInt("flag"));
    } catch (ParseException e) {
      Log.d("Set Next Flag", "Error: " + e.getMessage());
    }
    query = ParseQuery.getQuery("data");
    query.orderByDescending("unixTimeStamp");
    query.whereLessThan("unixTimeStamp", timeStep);
    for (int i = 0; i < numData; i++) {
      try {
        ParseObject data = query.getFirst();
        results[numData - i - 1] = (float) data.getInt("Bg");
        query.whereLessThan("unixTimeStamp", data.getLong("unixTimeStamp"));
      } catch (ParseException e) {
        Log.d("Fill Results Array", "Failed");
      }
    }
    /*query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> data, ParseException e) {
            int i = 0;

            if (e == null) {
                Log.d("Blood Glucose", "Retrieved " + data.size() + " Blood Glucose Data Points");
                for(ParseObject person : data) {
                    results[i] = person.getInt("Bg");
                    i++;
                }
            }
            else {
                Log.d("Blood Glucose", "Error: " + e.getMessage());
            }
        }
    });*/
    return results;
  }
 private void savePic() {
   String fileName = Long.toString(System.currentTimeMillis()) + ".png";
   ParseFile file = new ParseFile(fileName, photoBytes);
   file.saveInBackground();
   ParseObject pictureSave = new ParseObject("Album");
   pictureSave.put("userName", UserInfo.username);
   pictureSave.put("picture", file);
   pictureSave.put("fileName", fileName);
   pictureSave.saveInBackground();
   Toast.makeText(getApplicationContext(), "Picture has been saved", Toast.LENGTH_SHORT).show();
 }
  public static void sendAttachmentMessage(
      ParseObject customerRequest, String attachmentType, byte[] attachmentData) {
    ParseObject message = new ParseObject("Message");
    message.put("customerRequest", customerRequest);
    message.put("sender", ParseUser.getCurrentUser());
    message.put("receiver", customerRequest.getParseUser("bidder"));
    message.put("messageType", "attachment:" + attachmentType);
    allMessages.add(message);
    message.saveInBackground();

    sendNotification();
  }
  public static void sendTextMessage(ParseObject customerRequest, String text) {
    ParseObject message = new ParseObject("Message");
    message.put("customerRequest", customerRequest);
    message.put("sender", ParseUser.getCurrentUser());
    message.put("receiver", customerRequest.getParseUser("bidder"));
    message.put("messageType", "text");
    message.put("text", text);
    allMessages.add(message);
    message.saveInBackground();

    sendNotification();
  }
 // Uploads data to parse server as student object
 private void addToParse() {
   ParseObject studentObj = new ParseObject("Student");
   studentObj.put("name", name);
   studentObj.put("facebookID", facebookID);
   studentObj.addAll("courses", classes);
   studentObj.addAll("friendsList", friendsList);
   try {
     studentObj.save();
   } catch (ParseException a) {
     a.printStackTrace();
   }
 }
Beispiel #21
0
  public void addWord(String word, String meaning) {
    // convert to ParseObject
    ParseObject object = new ParseObject(ParseConstants.CLASS_SAVED_WORD);
    object.put(ParseConstants.SAVED_WORD, word);
    object.put(ParseConstants.SAVED_WORD_MEANING, meaning);
    object.put(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser());

    // save to local database
    object.pinInBackground();
    // save to Parse
    object.saveInBackground();
  }
Beispiel #22
0
  private void dumpDataSet(DataSet dataSet) {
    DateFormat dateFormat = getTimeInstance();

    // Cambiar el formato de fecha? fecha con dias
    for (DataPoint dp : dataSet.getDataPoints()) {
      ParseObject testObject = new ParseObject("PasosDia");
      testObject.put("Steps", dp.getValue(Field.FIELD_STEPS).toString());
      testObject.put("StartDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
      testObject.put("EndDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
      testObject.put("Usuario", ParseUser.getCurrentUser());
      testObject.saveInBackground();
    }
  }
 private void send() {
   Time now = new Time();
   now.setToNow();
   String apptime = Integer.toString(now.hour) + ":" + Integer.toString(now.second);
   sendChatMessage();
   ParseObject newmessage = new ParseObject("Message");
   newmessage.put("Sender", MY_ID);
   newmessage.put("Receiver", FriendParseObjectID);
   newmessage.put("txt", userMessage);
   newmessage.put("Read", false);
   newmessage.put("Time", apptime);
   newmessage.saveInBackground();
 }
Beispiel #24
0
    @Override
    public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
      // try {
      String key = m.getName();

      if (args.length == 0) {
        // built-in
        if ("objectData".equals(key)) return new ParseObjectData(obj);
        if (ParseBase.PARSE_OBJECT.equals(key)) return obj;

        // user define
        final Class<?> returnType = m.getReturnType();
        String typeName = returnType.getName();
        if (typeName.equalsIgnoreCase("float")) {
          return (float) obj.getDouble(key);
        } else {
          Object object = obj.get(key);
          if (returnType.isPrimitive() && object == null) {
            return 0;
          } else if (object != null
              && ParseObject.class.isInstance(object)
              && ParseBase.class.isAssignableFrom(returnType)) {
            return ((ParseFacade<?>) ParseFacade.get(returnType)).wrap((ParseObject) object);
          } else if (object != null
              && !returnType.isInstance(object)
              && !returnType.isPrimitive()) {
            return null;
          } else {
            return object;
          }
        }
      } else { // arg.length == 1
        // set value
        Object object = args[0];
        if (key.equals("objectId")) System.out.println("value " + object);

        if (object instanceof ParseBase) {
          obj.put(key, ((ParseBase) object).parseObject());
        } else {
          obj.put(key, object);
        }

        return null;
      }
      // } catch (InvocationTargetException e) {
      // throw e.getTargetException();
      // } catch (Exception e) {
      // throw e;
      // }
      // return something
    }
Beispiel #25
0
  public void post() {
    buffer = new ByteArrayOutputStream();
    scaledTakenImage.compress(Bitmap.CompressFormat.JPEG, 100, buffer);
    photoFile = new ParseFile(buffer.toByteArray());
    photoFile.saveInBackground();

    if (etFoodDesc.getText() == null
        || etFeedCap.getText() == null
        || etExp.getText() == null
        || location == null
        || photoFile == null) {
      Toast.makeText(this, "Please provide all the information", Toast.LENGTH_SHORT).show();
      return;
    }

    ParseObject parseObject = new ParseObject("FoodData");
    parseObject.put("fooddesc", etFoodDesc.getText().toString());
    parseObject.put("feedcap", etFeedCap.getText().toString());
    parseObject.put("timeexp", etExp.getText().toString());
    parseObject.put("lat", location.getLatitude());
    parseObject.put("lon", location.getLongitude());
    parseObject.put("photo", photoFile);
    parseObject.put("ownerid", ParseUser.getCurrentUser().getObjectId());
    parseObject.put("ownername", ParseUser.getCurrentUser().getUsername());
    parseObject.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            if (e == null)
              Toast.makeText(PostActivity.this, "Posted Sucessfully", Toast.LENGTH_SHORT).show();
          }
        });
  }
Beispiel #26
0
  public void CreateClick(View view) throws ParseException {
    String name;
    String description;
    String date;

    EditText viewText = (EditText) findViewById(R.id.editText);
    name = viewText.getText().toString();

    viewText = (EditText) findViewById(R.id.editText2);
    description = viewText.getText().toString();

    // viewText = (EditText) findViewById(R.id.calendarView);
    // date = viewText.getText().toString();

    ParseUser user = ParseUser.getCurrentUser();
    ParseObject bulletin = new ParseObject("BulletinBoard");
    bulletin.put("DeleteDate", "Oct 31, 2015");
    bulletin.put("Notification", description);
    bulletin.put("Name", name);
    bulletin.put("Apartment", user.get("Apartment"));

    bulletin.saveInBackground();
    finish();
    viewText = (EditText) findViewById(R.id.calendarView);
    date = viewText.getText().toString();

    bulletin.put("DeleteDate", date);
    bulletin.put("Notification", description);
    bulletin.put("Name", name);
    bulletin.put("Apartment", user.get("Apartment"));
    bulletin.saveInBackground();
  }
  private void activePatientData() {

    ParseQuery<ParseObject> query = ParseQuery.getQuery("PatientDetails");
    query.whereEqualTo("patientId", patientIdRemove);
    try {
      ParseObject object = query.getFirst();
      object.put("status", "Active");
      object.save();
    } catch (ParseException e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }

    /*	ParseQuery<ParseObject> query3 = ParseQuery.getQuery("_User");
    query3.whereEqualTo("userId", patientIdRemove);
    try {
    	ParseObject object = query3.getFirst();
    	object.put("status", "Active");
    	object.save();

    	}catch (ParseException e2) {
    	// TODO Auto-generated catch block
    	e2.printStackTrace();
    }*/

    Toast.makeText(SearchPatientByAdmin.this, "Patient Active", Toast.LENGTH_SHORT).show();
  }
Beispiel #28
0
 public void createRelation(final ParseUser user) {
   ParseObject relation = new ParseObject("Friends");
   relation.put("fromUser", currentUser.getObjectId() + "");
   relation.put("toUser", user.getObjectId() + "");
   relation.put("areFriends", false);
   relation.saveInBackground();
   new AlertDialog.Builder(Friends.this)
       .setTitle("Request Sent to " + user.getUsername() + "!")
       .setPositiveButton(
           "OK",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               add.setEnabled(true);
             }
           })
       .show();
 }
  protected ParseObject CreateMessage(String message) {
    ParseUser currentuser = ParseUser.getCurrentUser();
    String currbranch, curryear;

    currbranch = currentuser.getString(ParseConstants.KEY_BRANCH);
    curryear = postyear;

    String channel = currbranch + curryear;
    Log.v("yearrr yahaa kya bakar hhhh!!!", channel + " " + postyear);
    ParseObject temp = new ParseObject(channel);
    temp.put(ParseConstants.KEY_SENDER_NAME, ParseUser.getCurrentUser().getUsername());
    temp.put(ParseConstants.KEY_POST, message);
    Calendar c = Calendar.getInstance();
    Date d = c.getTime();
    temp.put("sent_date", d);

    return temp;
  }
  public void addCityName(int position) {

    final City city = alSeachCities.get(position);

    ParseObject userCities = new ParseObject("userCities");

    userCities.put("CityName", city.getCityName());
    userCities.put("CityCode", city.getCityCode());
    userCities.put("UserEmail", ParseUser.getCurrentUser().getString("email"));
    userCities.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(com.parse.ParseException arg0) {
            Toast.makeText(
                    AddLocationActivity.this, "Added " + city.getCityName(), Toast.LENGTH_SHORT)
                .show();
          }
        });
  }