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(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addgroup); getContacts(); ParseUser pu = ParseUser.getCurrentUser(); ArrayList<String> names = (ArrayList<String>) pu.get("Names"); ArrayList<String> lastmessage = (ArrayList<String>) pu.get("Numbers"); List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>(); String[] from = new String[] {"rowid", "col_1"}; int[] to = new int[] {R.id.message_tv, R.id.time_tv}; for (int i = 0; i < names.size(); i++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("rowid", "" + names.get(i)); map.put("col_1", "" + lastmessage.get(i)); fillMaps.add(map); } lv = (ListView) findViewById(android.R.id.list); adapter = new SimpleAdapter(this, fillMaps, R.layout.list_item, from, to); lv.setAdapter(adapter); lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CheckBox cx = (CheckBox) view.findViewById(R.id.check); cx.toggle(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); user = ParseUser.getCurrentUser(); status = (String) user.get(getString(R.string.status)); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); viewPager = (ViewPager) findViewById(R.id.viewpager); setupViewPager(viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); mDrawerList = (ListView) findViewById(R.id.navList); mCardview = (CardView) findViewById(R.id.nav_card_view); addDrawerItems(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mActivityTitle = getTitle().toString(); mDrawerList.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 0 || position == 1) displyDialog(position); } }); setupDrawer(); mTextview = (TextView) findViewById(R.id.nav_text_view); mTextview.setText(user.get("fullName").toString() + "\n" + user.getUsername()); mImageView = (ImageView) findViewById(R.id.nav_pic); mImageView.setImageResource(R.drawable.person_default_image); mImageView.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent i = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, RESULT_LOAD_IMAGE); return false; } }); }
public static User getLoggedUser(Class<? extends SunshineUser> c) { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { if (user == null) user = new User(); if (currentUser.get("facebookData") == null) { user.setImg(currentUser.getParseFile("img").getUrl()); } else { try { JSONObject fb = new JSONObject(currentUser.getString("facebookData")); String id = fb.getString("id"); user.setImg("https://graph.facebook.com/" + id + "/picture?type=large"); } catch (JSONException e) { e.printStackTrace(); } } user.setEmail(currentUser.getEmail()); user.setName(currentUser.getString("name")); user.setUserName(currentUser.getUsername()); user.setObjectId(currentUser.getObjectId()); user.setCreatedAt(currentUser.getCreatedAt()); user.setUpdateAt(currentUser.getUpdatedAt()); return user; } else { return null; } }
private void createNewFriend(final ParseUser parseUser) { final ParseFile parseFile = (ParseFile) parseUser.get("avatar"); if (parseFile != null) { parseFile.getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { if (e != null) { e.printStackTrace(); return; } final Bitmap avatar = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); final String id = parseUser.getObjectId(); newFriend = new FriendItem( id, avatar, parseUser.getUsername(), parseUser.getString("fullName")); Intent intentAddFriend = new Intent(); intentAddFriend.setAction(CommonValue.ACTION_ADD_FRIEND); boolean isOnline = parseUser.getBoolean("isOnline"); intentAddFriend.putExtra("isOnline", isOnline); MainActivity.this.sendBroadcast(intentAddFriend); } }); } }
public PrivateProfile getPrivProfile() { privProfile = (PrivateProfile) u.get("privateProfile"); try { this.privProfile.fetchIfNeeded(); return privProfile; } catch (ParseException e) { return null; } }
public static void logout() { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { currentUser.logOut(); if (currentUser.get("facebookData") != null) { LoginManager.getInstance().logOut(); } } }
private void initializeProfileInformation() { imgAvatar = (CircleImageView) findViewById(R.id.imgAvatar); imgAvatar.setOnClickListener(this); final TextView txtName = (TextView) findViewById(R.id.txtName); final TextView txtEmail = (TextView) findViewById(R.id.txtEmail); if (((GlobalApplication) getApplication()).getAvatar() != null) { imgAvatar.setImageBitmap(((GlobalApplication) getApplication()).getAvatar()); txtName.setText(((GlobalApplication) getApplication()).getFullName()); txtEmail.setText(((GlobalApplication) getApplication()).getEmail()); Log.i(TAG, "Get Profile Information from GlobalApplication"); return; } Log.i(TAG, "Get Profile Information from Server"); ParseFile parseFile = (ParseFile) currentUser.get("avatar"); if (parseFile != null) { parseFile.getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { if (e == null) { String fullName = currentUser.getString("fullName"); String email = currentUser.getEmail(); userAvatar = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); imgAvatar.setImageBitmap(userAvatar); txtName.setText(fullName); txtEmail.setText(email); ((GlobalApplication) getApplication()).setAvatar(userAvatar); ((GlobalApplication) getApplication()).setFullName(fullName); ((GlobalApplication) getApplication()).setPhoneNumber(currentUser.getUsername()); ((GlobalApplication) getApplication()).setEmail(email); } } }); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_places); listView = (ListView) findViewById(R.id.listView); ParseUser currentUser = ParseUser.getCurrentUser(); String lastKnowLocation = (String) currentUser.get(Constants.LAST_KNOWN_LOCATION); if (lastKnowLocation != null) { String[] latLong = lastKnowLocation.split(","); locationLat = latLong[0]; locationLng = latLong[1]; } else { Toast.makeText(getBaseContext(), R.string.msg_no_current_location, Toast.LENGTH_LONG).show(); } placesListAdapter = new GenericListAdapter( this, R.layout.generic_list_item, Lists.transform(placesList, ListItemConverter.fromPlaceToListItem()), false); listView.setAdapter(placesListAdapter); listView.setOnItemClickListener(this); listPlaces(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile_edit); ParseUser currentUser = ParseUser.getCurrentUser(); // get UI components userPic = (ImageView) findViewById(R.id.view_curr_pic); nameEdit = (EditText) findViewById(R.id.profile_name_edit); addressEdit = (EditText) findViewById(R.id.profile_address_edit); phoneEdit = (EditText) findViewById(R.id.profile_user_phone_edit); phoneShareEdit = (Switch) findViewById(R.id.phone_switch_edit); resetPassword = (Button) findViewById(R.id.reset_password_button); saveChangesB = (Button) findViewById(R.id.save_changes_button); changePicB = (Button) findViewById(R.id.change_pic_button); // init ui components with user details ParseFile p = (ParseFile) currentUser.get("photo"); if (p != null) { try { Bitmap b = BitmapFactory.decodeByteArray(p.getData(), 0, p.getData().length); userPic.setImageBitmap(b); } catch (ParseException e) { Log.d("ProfileEdit", e.getMessage()); } } nameEdit.setHint(currentUser.get("name").toString()); addressEdit.setHint(Utils.addressToString(currentUser.getJSONArray("address"))); phoneEdit.setHint(currentUser.get("phone").toString()); phoneShareEdit.setChecked(currentUser.getBoolean("sharePhone")); resetPassword.setOnClickListener(this); saveChangesB.setOnClickListener(this); changePicB.setOnClickListener(this); // handle address selection ImageButton addressChangeButton = (ImageButton) findViewById(R.id.profile_address_change_edit); addressChangeButton.setOnClickListener(this); // handle user availability changes final LinearLayout availabilityItems = (LinearLayout) findViewById(R.id.edit_profile_availability_items); availabilityAdapter = new UserAvailabilityAdapter(this); availabilityAdapter.registerDataSetObserver( new DataSetObserver() { @Override public void onChanged() { availabilityItems.removeAllViews(); for (int i = 0; i < availabilityAdapter.getCount(); i++) { View row = availabilityAdapter.getView(i, null, availabilityItems); availabilityItems.addView(row); } } @Override public void onInvalidated() { availabilityItems.removeAllViews(); } }); // query all availability of current user and fill the adapter final ParseQuery<ParseObject> userAvailabilityQuery = new ParseQuery<>("UserAvailability"); userAvailabilityQuery.whereEqualTo("user", currentUser); userAvailabilityQuery.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> userAvailabilities, ParseException e) { if (e == null) { userAvailabilitiesList = userAvailabilities; int id = 0; for (ParseObject userAvailability : userAvailabilities) { AvailabilityRecord record = new AvailabilityRecord(); record.setTimeFrom(userAvailability.getInt("startTime")); record.setTimeUntil(userAvailability.getInt("endTime")); record.setTag(id++); JSONArray days = userAvailability.getJSONArray("days"); for (int i = 0; i < days.length(); i++) { try { record.setDay(days.getInt(i) - 1, true); } catch (JSONException e1) { } } availabilityAdapter.add(record); } availabilityAdapter.add(new AvailabilityRecord()); availabilityAdapter.notifyDataSetChanged(); } } }); }