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; }
@Override protected Void doInBackground(Void... params) { // Create the array soaplist = new ArrayList<WorldPopulation>(); try { ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Product"); // query.orderByAscending("Product"); ob = query.find(); for (ParseObject Product : ob) { // Locate images in Picture column ParseFile image = (ParseFile) Product.get("Picture"); WorldPopulation map = new WorldPopulation(); if (Product.get("Category").equals("soaps and shampoos")) { map.setPrice((String) Product.get("Price")); map.setProduct((String) Product.get("Product")); map.setCategory((String) Product.get("Category")); map.setQuantity(Integer.parseInt(Product.get("qty").toString())); map.setPicture(image.getUrl()); soaplist.add(map); } } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override protected Void doInBackground(Void... params) { // Create the array photoarraylist = new ArrayList<PhotoList>(); try { // Locate the class table named "ImageUpload" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("ImageUpload"); // Locate the column named "position" in Parse.com and order list // by descending order of created. query.orderByDescending("createdAt"); query.setLimit(15); ob = query.find(); for (ParseObject po : ob) { // retrieve objectID and Title String stringTitle = (String) po.get("Title"); String stringObjectID = po.getObjectId(); // retrieve the image file ParseFile image = (ParseFile) po.get("Photo"); PhotoList map = new PhotoList(); map.setPhoto(image.getUrl()); map.setObjectID(stringObjectID); map.setTitle(stringTitle); photoarraylist.add(map); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override protected Void doInBackground(Void... params) { // Create the array menulista = new ArrayList<MenuSetGet>(); try { // Locate the class table named "Country" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("computadoras"); // Locate the column named "ranknum" in Parse.com and order list // by ascending query.orderByAscending("orden"); ob = query.find(); for (ParseObject country : ob) { // Locate images in flag column ParseFile image = (ParseFile) country.get("imagen"); MenuSetGet map = new MenuSetGet(); map.setNombre((String) country.get("nombre")); map.setDetalle((String) country.get("Detalle")); map.setPrecio((String) country.get("precio")); map.setImagen(image.getUrl()); menulista.add(map); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); ParseObject message = mMessages.get(position); String messageType = message.getString(ParseConstant.KEY_FILE_TYPE); ParseFile file = message.getParseFile(ParseConstant.KEY_FILE); Uri fileUri = Uri.parse(file.getUrl()); if (messageType.equals(ParseConstant.TYPE_IMAGE)) { Intent intent = new Intent(getActivity(), ViewimageActivity.class); intent.setData(fileUri); startActivity(intent); } else { Intent intent = new Intent(Intent.ACTION_VIEW, fileUri); intent.setDataAndType(fileUri, "video/*"); startActivity(intent); } // Delete it List<String> ids = message.getList(ParseConstant.KEY_RECIPIENT_IDS); if (ids.size() == 1) { // last recipients message.deleteInBackground(); } else { ids.remove(ParseUser.getCurrentUser().getObjectId()); ArrayList<String> idsToRemove = new ArrayList<String>(); idsToRemove.add(ParseUser.getCurrentUser().getObjectId()); message.removeAll(ParseConstant.KEY_RECIPIENT_IDS, idsToRemove); message.saveInBackground(); } }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ((TextView) view.findViewById(R.id.property_title)).setText(mProperty.getString("title")); ((TextView) view.findViewById(R.id.property_category)) .setText("Type: " + mProperty.getString("category")); ((TextView) view.findViewById(R.id.property_facing)) .setText("Facing: " + mProperty.getString("facing_side")); ((TextView) view.findViewById(R.id.property_floors)) .setText("Floors: " + mProperty.getInt("no_of_floors")); ((TextView) view.findViewById(R.id.property_description)) .setText("Description: " + mProperty.getString("major_things_available")); ((TextView) view.findViewById(R.id.property_parking)) .setText("Parking: " + (mProperty.getBoolean("parking") ? " Available" : "Not Available")); ((TextView) view.findViewById(R.id.property_price)) .setText("Price: Rs." + mProperty.getInt("price") + "/-"); ((TextView) view.findViewById(R.id.property_price_negotiable)) .setText("Price Negotiable: " + (mProperty.getBoolean("price_negotiable") ? "Yes" : "No")); ((TextView) view.findViewById(R.id.property_location)) .setText("Location: " + mProperty.getString("location")); ((TextView) view.findViewById(R.id.property_landmark)) .setText("Landmark: " + mProperty.getString("landmark")); ParseFile image = mProperty.getParseFile("property_image"); final ImageView imageView = (ImageView) view.findViewById(R.id.property_full_image); Glide.with(getActivity()).load(image.getUrl()).centerCrop().into(imageView); }
public String getThumbnailUrl() throws UnavailableThumbnailException { ParseFile thumbnail = getParseFile(KEY_THUMBNAIL); if (thumbnail == null) { throw new UnavailableThumbnailException(); } return thumbnail.getUrl(); }
public String getVideoUrl() throws UnavailableVideoException { ParseFile video = getParseFile(KEY_VIDEO); if (video == null) { throw new UnavailableVideoException(); } return video.getUrl(); }
public String getPictureUrl() throws UnavailablePictureException { ParseFile picture = getParseFile(KEY_PICTURE); if (picture == null) { throw new UnavailablePictureException(); } return picture.getUrl(); }
@Override public void onBindViewHolder(ViewHolder holder, int position) { holder.mUser = mUsers.get(position); holder.mUserNameView.setText(mUsers.get(position).getString("name")); Balance userBalance = null; try { userBalance = holder.mUser.getParseObject("balances").fetchIfNeeded(); } catch (ParseException e) { e.printStackTrace(); } holder.mUserBalance.setText(String.valueOf(userBalance.getBalance())); ParseFile file = mUsers.get(position).getParseFile("photo"); if (file != null) { Glide.with(mContext) .load(file.getUrl()) .centerCrop() .transform(new CircleTransform(mContext)) .into(holder.mUserPhoto); } }
public static User createUser(ParseObject parseObject) { cache().put(parseObject); String profilePictureUrl = null; Object object; if (parseObject.has("profile_picture")) { profilePictureUrl = parseObject.getString("profile_picture"); object = parseObject.get("profile_picture"); ParseFile file = (ParseFile) object; String url = file.getUrl(); profilePictureUrl = url; } User user = new User(parseObject.getObjectId()); user.setProfilePictureUrl(profilePictureUrl); if (parseObject.has("username")) { user.setName(parseObject.getString("username")); } if (parseObject.has("info")) { user.setInfo(parseObject.getString("info")); } return user; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.single_post_view); try { ParseFile imageFile = (ParseFile) ParseUser.getCurrentUser().get("imageFile"); imageUrl = imageFile.getUrl(); } catch (Exception e) { imageUrl = "Anonymous"; e.printStackTrace(); } Intent bundle = getIntent(); postId = bundle.getStringExtra("postObjectId"); postText = bundle.getStringExtra("postText"); postAuthor = bundle.getStringExtra("postAuthor"); postDisplayName = bundle.getStringExtra("postDisplayName"); postImageUrl = bundle.getStringExtra("postImage"); postLat = bundle.getDoubleExtra("postLat", 0); postLon = bundle.getDoubleExtra("postLon", 0); Log.d(TAG, "postLon:" + postLon); Log.d(TAG, "postLat: " + postLat); commentEditText = (EditText) findViewById(R.id.singlePostEditText); sendButton = (ImageButton) findViewById(R.id.singlePostSendButton); sendButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { newComment(); } }); imageLoader = ImageLoader.getInstance(); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_launcher) .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) .cacheInMemory(true) .build(); commentsListView = (ListView) findViewById(R.id.singlePostListView); adapter = new CommentsAdapter(this, postId); commentsListView.setAdapter(adapter); map = (MapFragment) getFragmentManager().findFragmentById(R.id.singlePostMap); view = this.getLayoutInflater().inflate(R.layout.marker, null); Log.d(TAG, "Context: " + this); iconGenerator = new IconGenerator(this); Log.d(TAG, "view: " + view); iconGenerator.setContentView(view); TextView displayName = (TextView) view.findViewById(R.id.markerDisplayName); displayName.setText(postDisplayName); TextView text = (TextView) view.findViewById(R.id.markerText); if (postText.length() > 40) { text.setText(postText.substring(0, 37) + "..."); } else { text.setText(postText.toString()); } ImageView postImage = (ImageView) view.findViewById(R.id.markerImage); if (postImageUrl.equals("Anonymous")) { postImage.setImageResource(R.drawable.ic_launcher); MarkerOptions markerOpts1 = new MarkerOptions().position(new LatLng(postLat, postLon)); // Display a green marker with the post information Bitmap iconBitmap = iconGenerator.makeIcon(); markerOpts1 = markerOpts1.icon(BitmapDescriptorFactory.fromBitmap(iconBitmap)); map.getMap().clear(); // Add a new marker Marker marker = map.getMap().addMarker(markerOpts1); // mapMarkers.put(post.getObjectId(), marker); } else { // imageLoader.displayImage(post.getImageURL(), // postImage, options); imageLoader.displayImage( postImageUrl, postImage, options, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { // TODO Auto-generated method stub } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { // TODO Auto-generated method stub } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { Log.d(TAG, "loading complete image"); MarkerOptions markerOpts = new MarkerOptions().position(new LatLng(postLat, postLon)); // Display a green marker with the post // information Bitmap iconBitmap = iconGenerator.makeIcon(); markerOpts = markerOpts.icon(BitmapDescriptorFactory.fromBitmap(iconBitmap)); map.getMap().clear(); // Add a new marker Marker marker = map.getMap().addMarker(markerOpts); } @Override public void onLoadingCancelled(String imageUri, View view) { // TODO Auto-generated method stub } }); } }
/** @return string url of user's photo */ public String getUserPhotoUrl() { if (mUserPhotoFile == null) { return null; } return mUserPhotoFile.getUrl(); }