public UsersAdapter(List<QBUser> dataSource, Context ctx) { this.dataSource = dataSource; this.inflater = LayoutInflater.from(ctx); filtered = new ArrayList<>(); final QBUser self = ChatService.getInstance().getCurrentUser(); String location = self.getCustomData().toString(); String[] latLong = location.split(";"); double myLat = Double.parseDouble(latLong[0]); double myLon = Double.parseDouble(latLong[1]); for (QBUser u : dataSource) { try { location = u.getCustomData().toString(); latLong = location.split(";"); if (directDistance( myLat, myLon, Double.parseDouble(latLong[0]), Double.parseDouble(latLong[1])) > 100) { continue; } } catch (Exception e) { continue; } filtered.add(u); } }
public static ArrayList<Integer> getFriendIdsList(List<QBUser> friendList) { ArrayList<Integer> friendIdsList = new ArrayList<Integer>(); for (QBUser friend : friendList) { friendIdsList.add(friend.getId()); } return friendIdsList; }
public static ArrayList<Integer> getOpponentsIds(List<QBUser> opponents) { ArrayList<Integer> ids = new ArrayList<Integer>(); for (QBUser user : opponents) { ids.add(user.getId()); } return ids; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.list_item_user, null); holder = new ViewHolder(); holder.login = (TextView) convertView.findViewById(R.id.userLogin); holder.add = (CheckBox) convertView.findViewById(R.id.addCheckBox); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // final QBUser user = dataSource.get(position); final QBUser user = filtered.get(position); if (user != null) { holder.login.setText(user.getLogin()); holder.add.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if ((((CheckBox) v).isChecked())) { selected.add(user); } else { selected.remove(user); } } }); holder.add.setChecked(selected.contains(user)); } return convertView; }
@Override public void onResume() { super.onResume(); QBUser user = AppSession.getSession().getUser(); if (user != null) { fullNameTextView.setText(user.getFullName()); } addActions(); }
@Override public void onBindViewHolder(ViewHolder holder, int position) { final QBUser user = opponents.get(position); // holder.opponentsName.setText(user.getFullName()); holder.setUserId(user.getId()); if (position == (opponents.size() - 1)) { adapterListener.OnBindLastViewHolder(holder, position); } }
private void storeRegistration(Context context, Bundle registration) { PrefsHelper prefsHelper = PrefsHelper.getPrefsHelper(); int appVersion = Utils.getAppVersionCode(context); prefsHelper.savePref(PrefsHelper.PREF_REG_ID, registration.getString(PrefsHelper.PREF_REG_ID)); QBUser user = AppSession.getSession().getUser(); if (user != null) { prefsHelper.savePref(PrefsHelper.PREF_REG_USER_ID, user.getId()); } prefsHelper.savePref( PrefsHelper.PREF_IS_SUBSCRIBED_ON_SERVER, registration.getBoolean(PrefsHelper.PREF_IS_SUBSCRIBED_ON_SERVER, false)); prefsHelper.savePref(PrefsHelper.PREF_APP_VERSION, appVersion); }
protected int getItemViewType(CombinationMessage combinationMessage) { boolean ownMessage = !combinationMessage.isIncoming(currentUser.getId()); if (combinationMessage.getNotificationType() == null) { if (ownMessage) { return TYPE_OWN_MESSAGE; } else { return TYPE_OPPONENT_MESSAGE; } } else { return TYPE_REQUEST_MESSAGE; } }
private void updatePasswords(String oldPasswordText, String newPasswordText) { qbUser.setOldPassword(oldPasswordText); qbUser.setPassword(newPasswordText); }
private void saveUserCredentials(QBUser user) { user.setPassword(newPasswordEditText.getText().toString()); AppSession.getSession().updateUser(user); }