/**
  * Check whether a user-defined profile in this profile manager already has this name.
  *
  * @param name The name to test for
  * @return Returns <code>true</code> if a profile with the given name exists
  */
 public boolean containsName(String name) {
   for (final Iterator<Profile> iter = fProfilesByName.iterator(); iter.hasNext(); ) {
     Profile curr = iter.next();
     if (name.equals(curr.getName())) {
       return true;
     }
   }
   return false;
 }
 public int compareTo(Profile o) {
   if (o instanceof SharedProfile) {
     return -1;
   }
   if (o instanceof CustomProfile) {
     return getName().compareToIgnoreCase(o.getName());
   }
   return 1;
 }
 /**
  * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the
  * set of profiles has been modified between the two calls, the sequence is guaranteed to
  * correspond to the one returned by <code>getSortedProfiles</code>.
  *
  * @return All names, sorted alphabetically
  * @see #getSortedProfiles()
  */
 public String[] getSortedDisplayNames() {
   final String[] sortedNames = new String[fProfilesByName.size()];
   int i = 0;
   for (final Iterator<Profile> iter = fProfilesByName.iterator(); iter.hasNext(); ) {
     Profile curr = iter.next();
     sortedNames[i++] = curr.getName();
   }
   return sortedNames;
 }
Пример #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    // implementation !! Check how current user is being shown for visibility of edit button !!
    ParseUser currentUser = ParseUser.getCurrentUser();
    Log.d("demo", "Current user is: " + currentUser);

    // receive list
    if (getIntent().getExtras() != null) {
      profile = (Profile) getIntent().getExtras().getSerializable("PROFILE");
      profiles = (ArrayList<Profile>) getIntent().getExtras().getSerializable("PROFILES");
    }

    TextView tvName = (TextView) findViewById(R.id.textViewProfileName);
    tvName.setText(profile.getName());

    TextView tvGender = (TextView) findViewById(R.id.textViewProfileGender);
    tvGender.setText(profile.getGender());

    ImageView iv = (ImageView) findViewById(R.id.imageViewProfilePic);
    Picasso.with(ProfileDetail.this).load(profile.getImageUrl()).into(iv);

    Button butEdit = (Button) findViewById(R.id.buttonEdit);
    if (currentUser.getUsername().equals(profile.getUserName())) {
      butEdit.setEnabled(true);
      butEdit.setVisibility(View.INVISIBLE);

    } else {
      butEdit.setText("Send Message");
      butEdit.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent i = new Intent(getBaseContext(), ComposeMessage.class);
              i.putExtra("PROFILE", profile);
              i.putExtra("PROFILES", profiles);
              i.putExtra(
                  "TOUSER",
                  profile.getUserName()); // !! Needs to be changed to userId in implementation !!
              startActivity(i);
            }
          });
    }
  }
  // define how to get a view for a ListView
  // based on code by hmkcode found on http://hmkcode.com/android-custom-listview-items-row/
  @Override
  public View getView(int index, View convert, ViewGroup parent) {

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View currentBidView = inflater.inflate(R.layout.current_bids_list_item, parent, false);

    TextView sessionView = (TextView) currentBidView.findViewById(R.id.sessionTitle);
    TextView amountView = (TextView) currentBidView.findViewById(R.id.amount);
    TextView statusView = (TextView) currentBidView.findViewById(R.id.status);

    Session bidSession = arrayList.get(index).getBidSession();
    Profile tempProfile = MethodsController.getProfile(bidSession.getTutorID());
    String sessionString = bidSession.getTitle() + " <i>by " + tempProfile.getName() + "</i>";
    String amountString = "Bid: <b>$" + arrayList.get(index).getAmount() + "</b> per hour.";
    String statusString = "Bid Status: <b>" + arrayList.get(index).getStatus() + "</b>.";

    sessionView.setText(Html.fromHtml(sessionString));
    amountView.setText(Html.fromHtml(amountString));
    statusView.setText(Html.fromHtml(statusString));

    return currentBidView;
  }
Пример #6
0
    @Override
    public void onClick(View v) {
      callExternalOnClickListener(v);

      Context context = getContext();

      AccessToken accessToken = AccessToken.getCurrentAccessToken();

      if (accessToken != null) {
        // Log out
        if (confirmLogout) {
          // Create a confirmation dialog
          String logout = getResources().getString(R.string.com_facebook_loginview_log_out_action);
          String cancel = getResources().getString(R.string.com_facebook_loginview_cancel_action);
          String message;
          Profile profile = Profile.getCurrentProfile();
          if (profile != null && profile.getName() != null) {
            message =
                String.format(
                    getResources().getString(R.string.com_facebook_loginview_logged_in_as),
                    profile.getName());
          } else {
            message =
                getResources().getString(R.string.com_facebook_loginview_logged_in_using_facebook);
          }
          AlertDialog.Builder builder = new AlertDialog.Builder(context);
          builder
              .setMessage(message)
              .setCancelable(true)
              .setPositiveButton(
                  logout,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                      getLoginManager().logOut();
                    }
                  })
              .setNegativeButton(cancel, null);
          builder.create().show();
        } else {
          getLoginManager().logOut();
        }
      } else {
        LoginManager loginManager = getLoginManager();
        loginManager.setDefaultAudience(getDefaultAudience());
        loginManager.setLoginBehavior(getLoginBehavior());

        if (LoginAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
          if (LoginButton.this.getFragment() != null) {
            loginManager.logInWithPublishPermissions(
                LoginButton.this.getFragment(), properties.permissions);
          } else {
            loginManager.logInWithPublishPermissions(
                LoginButton.this.getActivity(), properties.permissions);
          }
        } else {
          if (LoginButton.this.getFragment() != null) {
            loginManager.logInWithReadPermissions(
                LoginButton.this.getFragment(), properties.permissions);
          } else {
            loginManager.logInWithReadPermissions(
                LoginButton.this.getActivity(), properties.permissions);
          }
        }
      }

      AppEventsLogger logger = AppEventsLogger.newLogger(getContext());

      Bundle parameters = new Bundle();
      parameters.putInt("logging_in", (accessToken != null) ? 0 : 1);

      logger.logSdkEvent(loginLogoutEventName, null, parameters);
    }
Пример #7
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // 特定の行(position)のデータを得る
    Profile item = (Profile) getItem(position);

    // convertViewは使い回しされている可能性があるのでnullの時だけ新しく作る
    if (null == convertView) {
      convertView = layoutInflater_.inflate(R.layout.profilerow, null);
    }

    // 奇数行
    if (position % 2 == 0) {
      convertView.setBackgroundColor(Color.parseColor("#FFE0C0"));
    }
    // 偶数行
    else {
      convertView.setBackgroundColor(Color.parseColor("#FFEABF"));
    }

    // CustomDataのデータをViewの各Widgetにセットする
    // ID
    TextView textView_id;
    textView_id = (TextView) convertView.findViewById(R.id.id);
    textView_id.setText(item.getId());

    // 会社名
    TextView textView_company;
    textView_company = (TextView) convertView.findViewById(R.id.company);
    textView_company.setText(item.getCompany());

    // 役職
    TextView textView_yakushoku;
    textView_yakushoku = (TextView) convertView.findViewById(R.id.yakushoku);
    textView_yakushoku.setText(item.getYakushoku());

    // 名前
    TextView textView_name;
    textView_name = (TextView) convertView.findViewById(R.id.name);
    textView_name.setText(item.getName());

    // メールアドレス
    TextView textView_mail;
    textView_mail = (TextView) convertView.findViewById(R.id.mail);
    textView_mail.setText(item.getMail());

    // 電話番号
    TextView textView_phone;
    textView_phone = (TextView) convertView.findViewById(R.id.phone);
    textView_phone.setText(item.getPhone());

    // 20161008 yasui add start
    // よみがな
    TextView textView_nameKana;
    textView_nameKana = (TextView) convertView.findViewById(R.id.nameKana);
    textView_nameKana.setText(item.getNameKana());

    // 性別
    TextView textView_sex;
    textView_sex = (TextView) convertView.findViewById(R.id.sex);
    textView_sex.setText(Integer.toString(item.getSex()));

    // メモ
    TextView textView_memo;
    textView_memo = (TextView) convertView.findViewById(R.id.memo);
    textView_memo.setText(item.getMemo());
    // 20161008 yasui add end

    return convertView;
  }
Пример #8
0
  /**
   * Initializes all auxiliary data structures. First the {@link de.xirp.profile.Profile profile}
   * beans are parsed. After that, all same named {@link de.xirp.profile.Profile profiles} obtain a
   * unique name. The incomplete {@link de.xirp.profile.Profile profiles} are added to the
   * corresponding map and the complete {@link de.xirp.profile.Profile profiles} are also added to
   * their corresponding map. <br>
   * <br>
   * After that step, the {@link de.xirp.profile.Robot robot} beans are created by the parser for
   * each {@link de.xirp.profile.Profile profile}. The {@link de.xirp.profile.Robot robots} are
   * created and added to the corresponding {@link java.util.Vector vector} in the {@link
   * de.xirp.profile.Profile profiles}. While parsing the {@link de.xirp.profile.Robot robots} the
   * contained {@link de.xirp.profile.CommunicationSpecification comm-spec} beans are parsed and
   * added to the corresponding {@link java.util.Vector vector} in the {@link de.xirp.profile.Robot
   * robot}. After all {@link de.xirp.profile.Robot robots} have been created, all same named {@link
   * de.xirp.profile.Robot robots} obtain a unique name. <br>
   * <br>
   * All {@link de.xirp.profile.Profile profiles} and {@link de.xirp.profile.Robot robots} obtain
   * unique names to guarantee that {@link de.xirp.profile.Profile profiles} and {@link
   * de.xirp.profile.Robot robots} can be clearly identified. The unique names are achieved by
   * enumerating the same named objects.
   *
   * @throws JAXBException if something went wrong while parsing.
   * @see de.xirp.profile.Robot
   * @see de.xirp.profile.Profile
   * @see de.xirp.profile.CommunicationSpecification
   */
  private void init() throws JAXBException {
    logClass.info(I18n.getString("ProfileParser.log.parsing")); // $NON-NLS-1$
    File profDir = new File(Constants.CONF_PROFILES_DIR);
    File dtdP =
        new File(Constants.CONF_PROFILES_DIR + File.separator + "profile.dtd"); // $NON-NLS-1$

    File dtdC =
        new File(
            Constants.CONF_COMMSPECS_DIR + File.separator + "communication.dtd"); // $NON-NLS-1$

    File dtdR = new File(Constants.CONF_ROBOTS_DIR + File.separator + "robot.dtd"); // $NON-NLS-1$

    if (!dtdP.exists()) {
      try {
        throw new FileNotFoundException(
            I18n.getString("ProfileParser.log.noProfilesDTD", dtdP.getName())); // $NON-NLS-1$
      } catch (FileNotFoundException e) {
        logClass.info(
            I18n.getString("ProfileParser.log.failed") + Constants.LINE_SEPARATOR); // $NON-NLS-1$
        logClass.error(
            "Error: "
                + e.getMessage() // $NON-NLS-1$
                + Constants.LINE_SEPARATOR,
            e);
      }
    } else if (!dtdC.exists()) {
      try {
        throw new FileNotFoundException(
            I18n.getString("ProfileParser.log.noProfilesDTD", dtdC.getName())); // $NON-NLS-1$
      } catch (FileNotFoundException e) {
        logClass.info(
            I18n.getString("ProfileParser.log.failed") + Constants.LINE_SEPARATOR); // $NON-NLS-1$
        logClass.error(
            "Error: "
                + e.getMessage() // $NON-NLS-1$
                + Constants.LINE_SEPARATOR,
            e);
      }
    } else if (!dtdR.exists()) {
      try {
        throw new FileNotFoundException(
            I18n.getString("ProfileParser.log.noProfilesDTD", dtdR.getName())); // $NON-NLS-1$
      } catch (FileNotFoundException e) {
        logClass.info(
            I18n.getString("ProfileParser.log.failed") + Constants.LINE_SEPARATOR); // $NON-NLS-1$
        logClass.error(
            "Error: "
                + e.getMessage() // $NON-NLS-1$
                + Constants.LINE_SEPARATOR,
            e);
      }
    }

    File[] files =
        profDir.listFiles(
            new FilenameFilter() {

              public boolean accept(File dir, String name) {
                return name.endsWith(Constants.PROFILE_POSTFIX);
              }
            });

    if (files.length <= 0) {
      try {
        throw new FileNotFoundException(
            I18n.getString("ProfileParser.exception.noProfilesFound")); // $NON-NLS-1$
      } catch (FileNotFoundException e) {
        logClass.info(
            I18n.getString("ProfileParser.log.failed") // $NON-NLS-1$
                + Constants.LINE_SEPARATOR
                + e.getMessage()
                + Constants.LINE_SEPARATOR);
        logClass.info(
            I18n.getString("ProfileParser.log.noProfilesLoaded") // $NON-NLS-1$
                + Constants.LINE_SEPARATOR);
      }
    }

    MultiValueHashMap<String, Profile> profileNames = new MultiValueHashMap<String, Profile>();

    Profile profile;
    for (File xmlFile : files) {
      profile = parseProfile(xmlFile);
      profile.setProFile(xmlFile);
      profileNames.put(profile.getName(), profile);
    }

    List<Profile> prfls = new ArrayList<Profile>();
    for (Entry<String, List<Profile>> e : profileNames.entrySet()) {
      List<Profile> list = e.getValue();
      if (list.size() > 1) {
        for (int i = 0; i < list.size(); i++) {
          Profile aux = list.get(i);
          aux.setName(aux.getName() + " #" + (i + 1)); // $NON-NLS-1$
          prfls.add(aux);
        }
      } else {
        prfls.add(list.get(0));
      }
    }

    MultiValueHashMap<String, Robot> robotNames = new MultiValueHashMap<String, Robot>();

    for (Profile p : prfls) {
      for (Robot r : p.getRobots()) {
        robotNames.put(r.getName(), r);
      }
    }

    for (Entry<String, List<Robot>> e : robotNames.entrySet()) {
      List<Robot> list = e.getValue();
      if (list.size() > 1) {
        for (int i = 0; i < list.size(); i++) {
          Robot aux = list.get(i);
          aux.setName(aux.getName() + " #" + (i + 1)); // $NON-NLS-1$
        }
      }
    }

    for (Profile p : prfls) {
      if (p.isComplete()) {
        profiles.put(p.getName(), p);
      } else {
        incompleteProfiles.put(p.getName(), p);
      }
    }
  }