Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);
    backView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            currentActivity.finish();
          }
        });

    ActionBar.LayoutParams params =
        new ActionBar.LayoutParams(
            ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid =
        LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
      String url =
          Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
      APIHelper.getInstance(currentActivity)
          .getRequest(
              currentActivity,
              url,
              new ApiListener() {
                @Override
                public void onApiSuccess(ApiResponse apiResponse) {
                  try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName =
                        location != null && location.has("name") ? location.getString("name") : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                      new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                      attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                  } catch (JSONException e) {

                  }
                }

                @Override
                public void onApiError(LIApiError apiError) {}
              });

      ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
      View viewOnLI = viewOnLIStub.inflate();
      Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
      viewOnLIButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              DeepLinkHelper.getInstance()
                  .openOtherProfile(
                      currentActivity,
                      person.getLinkedinId(),
                      new DeepLinkListener() {
                        @Override
                        public void onDeepLinkSuccess() {}

                        @Override
                        public void onDeepLinkError(LIDeepLinkError error) {}
                      });
            }
          });
    } else {
      attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
  }
Exemplo n.º 2
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   LISessionManager.getInstance(getApplicationContext())
       .onActivityResult(this, requestCode, resultCode, data);
 }