Exemplo n.º 1
0
  private void getTarifas() {
    ParseQuery<Tarifa> query = Tarifa.getQuery();
    query.findInBackground(
        new FindCallback<Tarifa>() {
          @Override
          public void done(List<Tarifa> list, com.parse.ParseException e) {
            mTarifas = list;

            List<String> tarifasList = new ArrayList<>();
            for (Tarifa tarifa : list) tarifasList.add(tarifa.getName());

            ArrayAdapter<String> adapter =
                new ArrayAdapter<>(
                    EditRecibo.this, android.R.layout.simple_spinner_item, tarifasList);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            mSpinner.setAdapter(adapter);

            Tarifa tarifa = null;
            try {
              tarifa = mUser.getParseObject(ParseConstants.KEY_TARIFA).fetchIfNeeded();
            } catch (com.parse.ParseException e1) {
              e1.printStackTrace();
            }

            if (tarifa != null) mSpinner.setSelection(adapter.getPosition(tarifa.getName()));
          }
        });
  }
Exemplo n.º 2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /** Called when the activity is first created. */
    setContentView(R.layout.stream);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser == null) {
      startActivity(new Intent(this, StartActivity.class));
    }

    ParseQuery query = new ParseQuery("Vow");
    query.whereEqualTo("user", ParseUser.getCurrentUser());
    query.findInBackground(
        new FindCallback() {
          public void done(List<ParseObject> evidence, com.parse.ParseException e) {
            if (e == null) {
              setListAdapter(new EvidenceAdapter(StreamActivity.this, evidence));
            } else {
              Log.d("Dmitrij", "Error: " + e.getMessage());
            }
          }
        });

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }
  }
Exemplo n.º 3
0
  /** This function downloads the Splash Image from the Parse Table 'Splash' */
  public void downloadSplashImage() {
    Log.e("downloadSplashImage", "downloadSplashImage");

    dialog1.setMessage("Downloading Splash Image...");
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Splash");
    query.whereEqualTo("username", Login.USERNAME);
    query.findInBackground(
        new FindCallback<ParseObject>() {
          public void done(List<ParseObject> objects, ParseException e) {
            if (e == null) {
              ParseFile myFile = objects.get(0).getParseFile("image");
              myFile.getDataInBackground(
                  new GetDataCallback() {
                    public void done(byte[] data, ParseException e) {
                      if (e == null) {
                        // user the function writeFile() to create the file in the Internal Memory
                        // the file name will be like someusername_splash.jpg
                        writeFile(data, Login.USERNAME + "_splash.jpg");
                        // once the splash image is downloaded, we need to download the images for
                        // the listview.
                        downloadImages();
                      } else {
                        Log.e("Something went wrong", "Something went wrong");
                      }
                    }
                  });
            } else {
              Log.e("PARSE", "Error: " + e.getMessage());
            }
          }
        });
  }
Exemplo n.º 4
0
  private void retrieveMessages() {
    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstants.CLASS_MESSAGES);
    query.whereEqualTo(ParseConstants.KEY_RECIPIENT_IDS, ParseUser.getCurrentUser().getObjectId());
    query.addDescendingOrder(ParseConstants.KEY_CREATED_AT);
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> messages, ParseException e) {

            if (mSwipe.isRefreshing()) {
              mSwipe.setRefreshing(false);
            }

            if (e == null) {
              // We found the message
              mMessages = messages;
              String[] usernames = new String[mMessages.size()];
              int i = 0;
              for (ParseObject message : mMessages) {
                usernames[i] = message.getString(ParseConstants.KEY_SENDER_NAME);
                i++;
              }
              if (getListView().getAdapter() == null) {
                MessageAdapter adapter = new MessageAdapter(getListView().getContext(), mMessages);
                setListAdapter(adapter);
              } else {
                // Refill listview
                ((MessageAdapter) getListView().getAdapter()).refill(mMessages);
              }
            }
          }
        });
  }
  public static Task<ArrayList<ParseObject>> fetchFirstDataFromParse(
      ArrayList<ParseQuery<ParseObject>> arrayList) {

    final TaskCompletionSource<ArrayList<ParseObject>> successful = new TaskCompletionSource<>();

    ArrayList<Task<List<ParseObject>>> mutu = new ArrayList<>();

    for (ParseQuery<ParseObject> query : arrayList) {

      mutu.add(query.findInBackground());
    }

    Task.whenAllResult(mutu)
        .continueWith(
            new Continuation<List<List<ParseObject>>, Object>() {
              @Override
              public Object then(Task<List<List<ParseObject>>> task) throws Exception {
                return null;
              }
            });
    /*

            Task.whenAllResult(mutu).continueWith(new Continuation<List<List<ParseObject>>, Object>() {
                @Override
                public Object then(Task<List<List<ParseObject>>> task) throws Exception {
                    //successful.setResult(task.getResult());
                    successful.setResult();

                    return task;
                }
            });

    */
    return successful.getTask();
  }
Exemplo n.º 6
0
  public void show1(View v) {
    String code = tv.getText().toString();
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Image");
    query.whereEqualTo("Image", code);
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> parseObjects, ParseException e) {
            ParseFile file = (ParseFile) parseObjects.get(0).get("ImageFile");
            file.getDataInBackground(
                new GetDataCallback() {
                  @Override
                  public void done(byte[] bytes, ParseException e) {
                    Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
                    img1.setImageBitmap(bmp);
                  }
                });
          }
        });

    /*DBAdapter1 db = new DBAdapter1(this);
    String name = db.getbook(code);

    Uri muri = Uri.parse(name);
     s = getPath(muri);
        System.out.println("Image Path : " + s);
        img1.setImageURI(muri);*/
  }
  @Override
  protected void onResume() {
    super.onResume();
    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Status");
    query.orderByAscending("createdAt");

    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> status, ParseException e) {
            if (e == null) {
              // Success
              /*mStatus = status;
              StatusAdapter adapter = new StatusAdapter(getListView().getContext(), mStatus);
              setListAdapter(adapter);*/

              LoadStatus(status);

            } else {
              // there was a problem. Alert user

            }
          }
        });
  }
Exemplo n.º 8
0
  private void getUserDetailsFromTwitter() {
    final String name = ParseTwitterUtils.getTwitter().getScreenName().toString();

    ParseQuery<ParseUser> query = ParseQuery.getQuery("_User");
    query.findInBackground(
        new FindCallback<ParseUser>() {
          public void done(List<ParseUser> objects, com.parse.ParseException e) {
            // userlist.addAll(objects);
            // ParseUser currentUser = ParseUser.getCurrentUser();

            for (int i = 0; i < objects.size() - 1; i++) {
              // Log.d("demo", "user obj id" + userlist.get(i).getObjectId());
              if (objects.get(i).get("name").toString().equals(name)) {
                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                // intent.putExtra(NAME, name);
                startActivity(intent);
                flag = 0;
              } else {
                flag = 1;
              }
            }
            if (flag == 1) {
              Intent intent = new Intent(LoginActivity.this, Twitterlogin.class);
              intent.putExtra(NAME, name);
              startActivity(intent);
            }
          }
        });
  }
Exemplo n.º 9
0
  private void retrieveMessages() {
    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstant.CLASS_MESSAGE);
    query.whereEqualTo(ParseConstant.KEY_RECIPIENT_IDS, ParseUser.getCurrentUser().getObjectId());
    query.addDescendingOrder(ParseConstant.KEY_CREATED_AT);
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> list, ParseException e) {
            getActivity().setProgressBarIndeterminateVisibility(false);
            if (mSwipeRefreshLayout.isRefreshing()) {
              mSwipeRefreshLayout.setRefreshing(false);
            }

            if (e == null) {
              // No found message
              mMessages = list;
              String[] usernames = new String[mMessages.size()];
              int i = 0;
              for (ParseObject message : mMessages) {
                usernames[i] = message.getString(ParseConstant.KEY_SENDER_NAME);
                i++;
              }
              if (getListView().getAdapter() == null) {
                MessageAdapter adapter = new MessageAdapter(getListView().getContext(), mMessages);
                setListAdapter(adapter);
              } else {
                // refill the adapter
                ((MessageAdapter) getListView().getAdapter()).refill(mMessages);
              }
            }
          }
        });
  }
Exemplo n.º 10
0
  @Override
  protected void onResume() {
    super.onResume();
    if (!onResumeHasRun) {
      onResumeHasRun = true;
      return;
    }

    movieList = new ArrayList<String>();
    noItemsTV.setVisibility(View.GONE);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser != null) {
      ParseQuery<ParseObject> query = ParseQuery.getQuery("itemInfo");
      query.whereEqualTo("user", currentUser);
      query.findInBackground(
          new FindCallback<ParseObject>() {

            @Override
            public void done(List<ParseObject> movObjs, ParseException arg1) {
              // TODO Auto-generated method stub
              if (arg1 == null) {
                for (ParseObject object : movObjs) {
                  movieList.add(object.get("title").toString());
                }
                setAdapter();
              } else {
                Log.d("Error", "Error: " + arg1.getMessage());
              }
            }
          });
    }
  }
Exemplo n.º 11
0
 private void receiveMessage() {
   // Construct query to execute
   ParseQuery<Message> query = ParseQuery.getQuery(Message.class);
   // Configure limit and sort order
   query.setLimit(MAX_CHAT_MESSAGES_TO_SHOW);
   query.orderByAscending("createdAt");
   // Execute query to fetch all messages from Parse asynchronously
   // This is equivalent to a SELECT query with SQL
   query.findInBackground(
       new FindCallback<Message>() {
         public void done(List<Message> messages, ParseException e) {
           if (e == null) {
             mMessages.clear();
             // Parses through all messages in Parse, if message goes with convo then add to
             // listview
             for (int i = 0; i < messages.size(); i++) {
               if (messages.get(i).getString("ID") == null) {
                 continue;
               }
               if (messages.get(i).getID().equals(convo.getObjectId())) {
                 mMessages.add(messages.get(i));
               }
             }
             mAdapter.notifyDataSetChanged(); // update adapter
             lvChat.invalidate(); // redraw listview
           } else {
             Log.d("message", "Error: " + e.getMessage());
           }
         }
       });
 }
Exemplo n.º 12
0
 private void loadSaturdayFromParse() {
   ParseQuery<Saturday> query = Saturday.getQuery();
   query.findInBackground(
       new FindCallback<Saturday>() {
         public void done(List<Saturday> saturdayList, ParseException e) {
           if (e == null) {
             ParseObject.pinAllInBackground(
                 (List<Saturday>) saturdayList,
                 new SaveCallback() {
                   public void done(ParseException e) {
                     if (e == null) {
                       if (!getActivity().isFinishing()) {
                         saturdaySGWListAdapter.loadObjects();
                         saturdayLoyolaListAdapter.loadObjects();
                       }
                     } else {
                       Log.i("MainActivity", "Error pinning saturday: " + e.getMessage());
                     }
                   }
                 });
           } else {
             Log.i(
                 "MainActivity",
                 "loadSaturdayFromParse: Error finding pinned saturday: " + e.getMessage());
           }
         }
       });
 }
  private void updatePostList() {
    // Create query for objects of type "Post"
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

    // Restrict to cases where the author is the current user.
    // Note that you should pass in a ParseUser and not the
    // String representation of that user
    query.whereEqualTo("author", ParseUser.getCurrentUser());
    // Run the query
    query.findInBackground(
        new FindCallback<ParseObject>() {

          @Override
          public void done(List<ParseObject> postList, ParseException e) {
            if (e == null) {
              // If there are results, update the list of posts
              // and notify the adapter
              posts.clear();
              for (ParseObject post : postList) {
                posts.add(post.getString("textContent"));
              }
              ((ArrayAdapter<String>) getListAdapter()).notifyDataSetChanged();
            } else {
              Log.d("Post retrieval", "Error: " + e.getMessage());
            }
          }
        });
  }
  public void getQuotes(final Context context) {
    row_quotes = new ArrayList<RowQuote>();

    query.whereExists("createdAt");
    query.orderByDescending("createdAt");
    query.setLimit(1000);

    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> quoteList, ParseException e) {
            if (e == null) {
              for (int i = 0; i < quoteList.size(); i++) {
                String quote = quoteList.get(i).getString("Quote");
                String name = quoteList.get(i).getString("Name");
                row_quotes.add(new RowQuote(name, quote));

                //						if (i == quoteList.size()-1) {
                //							last_item_date = quoteList.get(i).getCreatedAt();
                //						}
              }
            } else {
              row_quotes.add(
                  new RowQuote(
                      "Justin",
                      "hm, either you don't have internet connection or my database is down"));
            }

            row_adapter = new RowQuoteAdapter(context, row_quotes);
            list = (ListView) getActivity().findViewById(R.id.list);
            list.setAdapter(row_adapter);
          }
        });
  }
Exemplo n.º 15
0
 // load user's profile image from parse - added by alex, edited by Jamie
 public void retrieveImage(String struser) {
   ParseQuery query = ParseUser.getQuery();
   query.whereContains("username", struser);
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> objects, ParseException e) {
           if (e == null) {
             // The query was successful.
             // Locate the column named "ImageName" and set
             // the string
             for (ParseObject ob : objects) {
               ParseFile fileObject = (ParseFile) ob.getParseFile("profileImg");
               if (fileObject != null) {
                 profileImg.setParseFile(fileObject);
                 profileImg.loadInBackground(
                     new GetDataCallback() {
                       @Override
                       public void done(byte[] bytes, ParseException e) {
                         // nothing to be done
                       }
                     });
               } else profileImg.setImageResource(R.drawable.no_image);
             }
           } else {
             // Something went wrong. Look at the ParseException to see what's up.
           }
         }
       });
 }
Exemplo n.º 16
0
  // TODO: What to do with strings? leave it of clean it
  public void getNewPosts(final NewsFeedAdapter adapter) {

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");
    query.setLimit(2);
    query.orderByDescending("createdAt");
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> list, ParseException e) {
            if (e == null) {
              ArrayList<News> news = new ArrayList<News>();
              for (ParseObject item : list) {
                News n = new News();

                n.setTitle(item.getString("title"));
                n.setLocation(item.getString("location"));
                n.setTime(item.getString("time"));
                n.setText(item.getString("text"));
                n.setIndicator((ArrayList<String>) item.get("icons"));
                n.setType(item.getString("type"));
                n.setDate(item.getDate("date"));
                n.setAuthor(item.getString("Author"));
                n.setCreatedAt(item.getCreatedAt());
                Log.d("CREATEDAT", item.getCreatedAt().toString());
                news.add(n);
              }
              mLast = list.get(list.size() - 1).getInt("number");
              adapter.addItems(news);
            } else {
              e.printStackTrace();
            }
          }
        });
  }
Exemplo n.º 17
0
 private void startManageContent() {
   // if you're logged
   if (app.logged()) {
     findViewById(R.id.progress).setVisibility(View.VISIBLE);
     manageNotLoggedText.setVisibility(View.GONE);
     ParseQuery<ParseObject> query = ParseQuery.getQuery(Consts.PROTEST);
     query.whereEqualTo(Consts.P_ADMIN, app.getUsername());
     query.orderByDescending("createdAt");
     query.findInBackground(
         new FindCallback<ParseObject>() {
           public void done(List<ParseObject> retrievedProtestList, ParseException e) {
             if (e == null) {
               manageProtestArrList = Protest.convertList(retrievedProtestList);
               manageProtestAdapter =
                   new ProtestsAdapter(con, R.layout.row_protest, manageProtestArrList);
               manageProtestList.setAdapter(manageProtestAdapter);
               showHideNoProtestsMsg(retrievedProtestList);
             } else {
               Log.v(TAG, "Error: " + e.getMessage());
             }
             findViewById(R.id.progress).setVisibility(View.GONE);
           }
         });
   } else {
     notLogged("view protests you manage ", getString(R.string.unregistered_manage));
   }
 }
Exemplo n.º 18
0
 public void theyRequested(final ParseUser user) {
   ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
   query.whereEqualTo("areFriends", false);
   query.whereEqualTo("fromUser", user.getObjectId() + "");
   query.whereEqualTo("toUser", currentUser.getObjectId() + "");
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> list, ParseException e) {
           if (e == null && list.size() > 0) {
             ParseObject relation = list.get(0);
             relation.put("areFriends", true);
             relation.saveInBackground();
             new AlertDialog.Builder(Friends.this)
                 .setTitle("This User Already Sent You a Request!")
                 .setMessage("You Two Are Now Friends!")
                 .setPositiveButton(
                     "OK",
                     new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                         add.setEnabled(true);
                         getRelations();
                         setNotifications();
                       }
                     })
                 .show();
           } else {
             createRelation(user);
           }
         }
       });
 }
Exemplo n.º 19
0
  // open history chat from parse
  private void GetingHistoryChat(final String friend, final String me) {

    ParseQuery<ParseObject> GetMessageTable = ParseQuery.getQuery("Message");
    GetMessageTable.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> object, ParseException e) {
            if (e == null) {
              for (int indx = 0; indx < object.size(); indx++) {
                // if its my message
                if (object.get(indx).getString("Receiver").matches(friend)
                    && object.get(indx).getString("Sender").matches(me)) {
                  abp.add(
                      new ChatMessage(
                          side,
                          object.get(indx).getString("txt")
                              + "\n"
                              + object.get(indx).getString("Time")));
                } else if (object.get(indx).getString("Receiver").matches(me)
                    && object.get(indx).getString("Sender").matches(friend)) {
                  abp.add(
                      new ChatMessage(
                          !side,
                          object.get(indx).getString("txt")
                              + "\n"
                              + object.get(indx).getString("Time")));
                }
              }
            }
          }
        });
  }
Exemplo n.º 20
0
 public void areFriends1(final ParseUser user) {
   ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
   query.whereEqualTo("areFriends", true);
   query.whereEqualTo("toUser", currentUser.getObjectId() + "");
   query.whereEqualTo("fromUser", user.getObjectId() + "");
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> list, ParseException e) {
           findViewById(R.id.LoadingIcon).setVisibility(View.INVISIBLE);
           if (e == null && list.size() > 0) {
             new AlertDialog.Builder(Friends.this)
                 .setTitle("You Are Already Friends!")
                 .setPositiveButton(
                     "OK",
                     new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                         add.setEnabled(true);
                       }
                     })
                 .show();
           } else {
             alreadyRequested(user);
           }
         }
       });
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_trainer_details);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      getWindow().setNavigationBarColor(getResources().getColor(R.color.navigationBarColor));
    }

    setupToolbar();

    // Get the trainer object from parse and setup the view
    trainerId = getIntent().getStringExtra("trainerId");
    ParseQuery<Trainer> query = ParseQuery.getQuery("Trainer");
    query.whereEqualTo("objectId", trainerId);
    query.include("favorited_by");
    query.findInBackground(
        new FindCallback<Trainer>() {
          @Override
          public void done(List<Trainer> list, com.parse.ParseException e) {
            Log.d("DEBUG", ((Trainer) list.get(0)).getName());
            m_trainer = list.get(0);

            // Get the gym where the trainer goes to workout
            getTrainerGym();
          }
        });
  }
Exemplo n.º 22
0
  public void syncWithParse() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_SAVED_WORD);
    query.whereEqualTo(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser());
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> words, ParseException e) {
            if (e == null) {
              // delete current data in Parse
              for (ParseObject word : words) {
                word.deleteInBackground();
              }

              // save data in local database to Parse
              ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_SAVED_WORD);
              query.whereEqualTo(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser());
              query.fromLocalDatastore();
              query.findInBackground(
                  new FindCallback<ParseObject>() {
                    @Override
                    public void done(List<ParseObject> words, ParseException e) {
                      if (e == null) {
                        // save each word to Parse
                        for (ParseObject word : words) {
                          word.saveInBackground();
                        }
                      }
                    }
                  });
            }
          }
        });
  }
Exemplo n.º 23
0
  public void getContactInfos(List<String> usernames, final EMValueCallBack<List<User>> callback) {
    ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME);
    pQuery.whereContainedIn(CONFIG_USERNAME, usernames);
    pQuery.findInBackground(
        new FindCallback<ParseObject>() {

          @Override
          public void done(List<ParseObject> arg0, ParseException arg1) {
            if (arg0 != null) {
              List<User> mList = new ArrayList<User>();
              for (ParseObject pObject : arg0) {
                User user = new User();
                ParseFile parseFile = pObject.getParseFile(CONFIG_AVATAR);
                if (parseFile != null) {
                  user.setAvatar(parseFile.getUrl());
                }
                user.setNick(pObject.getString(CONFIG_NICK));
                user.setUsername(pObject.getString(CONFIG_USERNAME));
                setUserHearder(user);
                mList.add(user);
              }
              callback.onSuccess(mList);
            } else {
              callback.onError(arg1.getCode(), arg1.getMessage());
            }
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_choosehackathon);

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Hackathon");
    query.findInBackground(
        new FindCallback<ParseObject>() {
          public void done(final List<ParseObject> hackathonList, ParseException e) {
            if (e == null) {
              final ArrayList<String> hackathonNames = new ArrayList<String>();
              final ListView listChooseHackathon =
                  (ListView) findViewById(R.id.listChooseHackathon);
              for (ParseObject o : hackathonList) hackathonNames.add(o.getString("name"));
              ArrayAdapter<String> aa =
                  new ArrayAdapter<String>(
                      context, android.R.layout.simple_list_item_1, hackathonNames);
              listChooseHackathon.setAdapter(aa);
              listChooseHackathon.setOnItemClickListener(
                  new AdapterView.OnItemClickListener() {
                    public void onItemClick(
                        AdapterView<?> parentView, View childView, int position, long id) {
                      Intent i = new Intent(context, HackathonInfoActivity.class);
                      Bundle b = new Bundle();
                      b.putString("hackathon_id", hackathonList.get(position).getObjectId());
                      b.putString("user_id", getIntent().getExtras().getString("user_id"));
                      i.putExtras(b);
                      startActivity(i);
                    }
                  });
            } else alertMessage("Error", "Error retrieving hackathons", true);
          }
        });
  }
  protected void getMarkersFromParse() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Route");
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> routeObjects, com.parse.ParseException e) {
            if (e == null) {

              for (ParseObject object : routeObjects) {
                String id = object.getObjectId().toString();
                double longitude = object.getParseGeoPoint("startingPointGeo").getLongitude();
                double latitude = object.getParseGeoPoint("startingPointGeo").getLatitude();
                String title = object.getString("startingPoint");
                String destination = object.getString("destination");

                Marker marker =
                    mGoogleMap.addMarker(
                        new MarkerOptions()
                            .position(new LatLng(latitude, longitude))
                            .title("#id: " + id)
                            .snippet(
                                title
                                    + " - "
                                    + destination
                                    + "\nStart date: "
                                    + object.getString("date")
                                    + "\nStart time: "
                                    + object.getString("time")));

                mMarkers.add(marker);
              }
            }
          }
        });
  }
  private void displayInfo() {
    // get the info that was passed in from EventVoteActivity
    String eventId = getIntent().getExtras().getString("eventId");
    position = getIntent().getExtras().getInt("position");

    // find the Event in Parse to grab info from
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Event");
    query.whereEqualTo("objectId", eventId);
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> list, ParseException e) {
            if (e == null) {
              // set the text on the page to the information for that restaurant
              // that is stored in Parse
              ParseObject obj = list.get(0);
              restaurantName.setText((String) obj.getList("restaurants").get(position));
              rating.setText((String) obj.getList("ratings").get(position));
              type.setText((String) obj.getList("typeOfFood").get(position));
              address.setText((String) obj.getList("addresses").get(position));
              phone.setText((String) obj.getList("phoneNumbers").get(position));
            }
          }
        });
  }
Exemplo n.º 27
0
 public void alreadyRequested(final ParseUser user) {
   ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
   query.whereEqualTo("areFriends", false);
   query.whereEqualTo("toUser", user.getObjectId() + "");
   query.whereEqualTo("fromUser", currentUser.getObjectId() + "");
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> list, ParseException e) {
           if (e == null && list.size() > 0) {
             new AlertDialog.Builder(Friends.this)
                 .setTitle("You Already Sent a Request to This User!")
                 .setPositiveButton(
                     "OK",
                     new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                         add.setEnabled(true);
                       }
                     })
                 .show();
           } else {
             theyRequested(user);
           }
         }
       });
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_company_post, container, false);
    postList = (GridView) root.findViewById(R.id.company_list);
    postRole = new ArrayList<String>();
    postCompany = new ArrayList<String>();
    jobData = new ArrayList<ParseObject>();

    // Query from jobPost class
    ParseQuery<ParseObject> postQuery = ParseQuery.getQuery("JobPost");
    postQuery.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> parseObjects, ParseException e) {
            if (e == null) {
              jobData = parseObjects;
              int i = 0;
              for (ParseObject pData : jobData) {

                // add Company Name and Role in List View
                postRole.add(pData.getString(Constant.KEY_ROLE));
                postCompany.add(pData.getString(Constant.KEY_USER_NAME));
                System.out.print(postRole);
                Log.d("Parse data fetch", postRole.toString());
                i++;
              }

              // Call Custom Adapter
              JobListAdapter adapter = new JobListAdapter(getActivity(), postRole, postCompany);
              postList.setAdapter(adapter);
            }
          }
        });

    // post list item click listener
    postList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Bundle bundle = new Bundle();
            bundle.putString("User_Name", jobData.get(position).getString(Constant.KEY_USER_NAME));
            bundle.putString("Role", jobData.get(position).getString(Constant.KEY_ROLE));
            bundle.putString("Skill", jobData.get(position).getString(Constant.KEY_SKILL));
            bundle.putString("Location", jobData.get(position).getString(Constant.KEY_LOCATION));
            bundle.putString("Mission", jobData.get(position).getString(Constant.KEY_MISSION));

            // replace with another fragment
            AboutCompanyFragment frag = new AboutCompanyFragment();
            frag.setArguments(bundle);
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.company_post, frag, "MY_FRAG");
            fragmentTransaction.commit();
          }
        });
    return root;
  }
Exemplo n.º 29
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);

    listView = (ListView) getActivity().findViewById(R.id.listView1);
    dates = new ArrayList<String>();
    steps = new ArrayList<Integer>();

    statsList1 = new ArrayList<Stats>();
    statsList2 = new ArrayList<Stats>();
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Walking");
    query.whereEqualTo("user", ParseUser.getCurrentUser());
    query.addDescendingOrder("date");
    query.findInBackground(
        new FindCallback<ParseObject>() {

          @Override
          public void done(List<ParseObject> arg0, ParseException arg1) {
            // TODO Auto-generated method stub
            Log.d("demo", "Parse Objects size " + arg0.size());
            if (arg1 == null) {
              Log.d("score", "Retrieved " + arg0.size() + " scores");
              for (ParseObject p : arg0) {
                Log.d("demonew", p.getString("date") + " " + p.get("steps"));
                stats = new Stats();
                dates.add(p.getString("date"));
                steps.add(p.getInt("steps"));
                stats.setDate(p.getString("date"));
                stats.setStep(p.getInt("steps"));
                Log.d("demo", stats.toString());
                if (!statsList1.contains(stats)) {
                  statsList1.add(stats);
                }
                Log.d("demo", statsList1.toString());
              }

            } else {
              Log.d("score", "Error: " + arg1.getMessage());
            }

            for (int i = 0, j = (statsList1.size() - 1);
                i < statsList1.size() && j >= 0;
                i++, j--) {
              statsList2.add(statsList1.get(j));
            }

            Log.d("demo", "dates " + dates + "");
            Log.d("demo", "steps " + steps + "");
            Log.d("demo", "StatsList1 " + statsList1 + "");
            Log.d("demo", "StatsList2 " + statsList1 + "");

            adapter = new ListAdapater(getActivity(), R.layout.list_view_row, statsList2);
            listView.setAdapter(adapter);
            adapter.setNotifyOnChange(true);
          }
        });
  }
  /** Khoi tao cac thanh phan trong giao dien */
  private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    statuses = getResources().getStringArray(R.array.project_status);
    projectNameInput = (EditText) findViewById(R.id.projectnameInput);
    descriptionInput = (EditText) findViewById(R.id.descriptionInput);
    categoryInput = (EditText) findViewById(R.id.categoryInput);
    listAccessAccount = (ListView) findViewById(R.id.listAccessAccount);
    listCategory = (ListView) findViewById(R.id.listCategories);
    statusInput = (Spinner) findViewById(R.id.statusInput);
    accessAccountInput = (Spinner) findViewById(R.id.accessAccountInput);
    addCategoryBtn = (Button) findViewById(R.id.addCategory);
    addUserBtn = (Button) findViewById(R.id.addAccount);
    delCategoryBtn = (Button) findViewById(R.id.delCategory);
    delUserBtn = (Button) findViewById(R.id.delAccount);
    submitBtn = (Button) findViewById(R.id.submitBtn);

    project = new Project();

    // Lenh truy van cac user trong bang user
    ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_TABLE);

    // Chi lay ra cot username
    query.selectKeys(Collections.singletonList(USER_NAME));

    query.whereGreaterThan(USER_ACCESS_LEVEL, 0);
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(final List<ParseObject> objects, ParseException e) {
            // neu khong co loi tra ve
            if (e == null) {
              users = objects;
              for (ParseObject user : users) {
                accessAccounts.add(user.getString(USER_NAME));
              }
              statusInput.setAdapter(
                  new ArrayAdapter<>(
                      getBaseContext(), android.R.layout.simple_dropdown_item_1line, statuses));
              accessAccountInput.setAdapter(
                  new ArrayAdapter<>(
                      getBaseContext(), android.R.layout.simple_list_item_1, accessAccounts));

              addedAccountsAdapter =
                  new ListViewAdapter(getBaseContext(), R.layout.item_lv_layout, addedAccounts);
              listAccessAccount.setAdapter(addedAccountsAdapter);
              SetHeightListView.setListViewHeightBasedOnChildren(listAccessAccount);

              addedCategoriesAdapter =
                  new ListViewAdapter(getBaseContext(), R.layout.item_lv_layout, addedCategories);
              listCategory.setAdapter(addedCategoriesAdapter);
              SetHeightListView.setListViewHeightBasedOnChildren(listCategory);
            }
          }
        });
  }