Skip to content

Instantly share code, notes, and snippets.

Edward Chiang edwardinubuntu

Block or report user

Report or block edwardinubuntu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@edwardinubuntu
edwardinubuntu / HomeFragment.java
Created Mar 10, 2014
Create organizer relation
View HomeFragment.java
final ParseRelation parseRelation = eachParseObject.getRelation("orgRelation");
ParseQuery<ParseObject> relationQuery = parseRelation.getQuery();
relationQuery.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if (parseObjects.size() == 0) {
ParseQuery orgQuery = new ParseQuery("Organizer");
try {
ParseObject orgObject = orgQuery.getFirst();
Log.d(DailyKind.TAG, "orgObject: " + orgObject.getObjectId());
@edwardinubuntu
edwardinubuntu / boundingRectWithSize
Created Jun 25, 2014
How to calculate cell height.
View boundingRectWithSize
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
LHIdeaGroupCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IdeaGroupCell"];
CGFloat labelWidth = cell.descriptionLabel.width;
LHIdeaGroup *currentGroup = [self.objects objectAtIndex:indexPath.row];
CGRect r = [currentGroup.Description boundingRectWithSize:CGSizeMake(labelWidth, 0)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName: cell.descriptionLabel.font}
context:nil];
@edwardinubuntu
edwardinubuntu / gist:5778172308a0126b589a
Created Nov 5, 2014
Parsing open gov data from array
View gist:5778172308a0126b589a
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (!connectionError) {
NSError *error = nil;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
if (!error) {
for (NSDictionary *eachPark in jsonArray) {
NSString *title = [eachPark objectForKey:@"stitle"];
NSString *body = [eachPark objectForKey:@"xbody"];
NSLog(@"Park info: %@, %@", title, body);
@edwardinubuntu
edwardinubuntu / DreamAdapter.java
Last active Aug 29, 2015
Set image view height equals to width.
View DreamAdapter.java
final ImageView dreamImageView = (ImageView)rootView.findViewById(R.id.dream_image_view);
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)dreamImageView.getLayoutParams();
params.height = displayMetrics.widthPixels;
dreamImageView.setLayoutParams(params);
@edwardinubuntu
edwardinubuntu / Photo.java
Created Mar 28, 2015
Parse Object Subclassing
View Photo.java
package tw.alphacamp.tripphotoapp.object;
import com.parse.ParseClassName;
import com.parse.ParseFile;
import com.parse.ParseGeoPoint;
import com.parse.ParseObject;
/**
* Created by edward_chiang on 15/1/24.
*/
View MapFragment.java
@Override
public void onMapReady(final GoogleMap googleMap) {
ParseQuery<Photo> photoParseQuery = ParseQuery.getQuery(Photo.class);
photoParseQuery.setCachePolicy(ParseQuery.CachePolicy.CACHE_ELSE_NETWORK);
photoParseQuery.findInBackground(new FindCallback<Photo>() {
@Override
public void done(List<Photo> photos, ParseException e) {
if (e == null) {
photoList.clear();
View PostStoryActivity.java
// Create ParseFile
final ParseFile file = new ParseFile(ParseUser.getCurrentUser().getUsername() + "_"+ Calendar.getInstance().getTimeInMillis() + ".jpg", image);
if (progressDialog!=null && !progressDialog.isShowing()) {
progressDialog.show();
}
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
final ParseObject imageObject = new ParseObject("GraphicImage");
imageObject.put("imageType", "file");
View UserLoginFragment.java
final TextView userErrorTextView = (TextView)rootView.findViewById(R.id.user_login_exception_text_view);
rootView.findViewById(R.id.user_login_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (userIdLoginEditText.getText() != null
&& userIdLoginEditText.getText().length() > 0
&& userPasswordLoginEditText.getText() != null
&& userPasswordLoginEditText.getText().length() > 0) {
View StoriesLatestFragment.java
@Override
protected void loadStories(final boolean more) {
final ParseQuery<ParseObject> parseQuery = ParseQuery.getQuery("Story");
parseQuery.include("StoryTeller");
parseQuery.orderByDescending("createdAt");
parseQuery.include("ideaPointer");
parseQuery.include("graphicPointer");
ParseQuery<Flag> flagQuery = ParseQuery.getQuery(Flag.class);
flagQuery.whereEqualTo("Object", "Story");
View UserSignUpFragment.java
ParseUser user = new ParseUser();
user.setUsername(emailEditText.getText().toString());
user.put("name", userNameEditText.getText().toString());
user.setEmail(emailEditText.getText().toString());
user.setPassword(userPasswordSignUpConfirmEditText.getText().toString());
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
rootView.findViewById(R.id.user_signup_progressBar).setVisibility(View.GONE);
if (e == null) {
You can’t perform that action at this time.