<commit_before>package com.kickstarter.ui.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.kickstarter.KSApplication;
import com.kickstarter.R;
import com.kickstarter.libs.ActivityRequestCodes;
import com.kickstarter.libs.BaseActivity;
import com.kickstarter.libs.Money;
import com.kickstarter.libs.qualifiers.RequiresPresenter;
import com.kickstarter.models.Project;
import com.kickstarter.models.Reward;
import com.kickstarter.presenters.ProjectPresenter;
import com.kickstarter.ui.adapters.ProjectAdapter;
import com.kickstarter.ui.views.IconTextView;

import javax.inject.Inject;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

@RequiresPresenter(ProjectPresenter.class)
public class ProjectActivity extends BaseActivity<ProjectPresenter> {
  private ProjectAdapter adapter;

  @Bind(R.id.rewards_recycler_view) RecyclerView rewardsRecyclerView;
  @Bind(R.id.star_icon) IconTextView starIconTextView;
  @Bind(R.id.back_project_button) Button backProjectButton;
  @Bind(R.id.manage_pledge_button) Button managePledgeButton;
  @Bind(R.id.view_pledge_button) Button viewPledgeButton;

  @Inject Money money;

  @Override
  protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.project_layout);
    ButterKnife.bind(this);
    ((KSApplication) getApplication()).component().inject(this);

    final Intent intent = getIntent();
    final Project project = intent.getParcelableExtra(getString(R.string.intent_project)); // Project can be null!
    final String param = intent.getStringExtra(getString(R.string.intent_project_param));
    presenter.initialize(project, param);

    adapter = new ProjectAdapter(presenter);
    rewardsRecyclerView.setAdapter(adapter);
    rewardsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  }

  public void setProjectActionButton(@NonNull final Project project) {
    if (!project.isBacking() && project.isLive()) {
      backProjectButton.setVisibility(View.VISIBLE);
    } else {
      backProjectButton.setVisibility(View.GONE);
    }

    if (project.isBacking() && project.isLive()) {
      managePledgeButton.setVisibility(View.VISIBLE);
    } else {
      managePledgeButton.setVisibility(View.GONE);
    }

    if (project.isBacking() && !project.isLive()) {
      viewPledgeButton.setVisibility(View.VISIBLE);
    } else {
      viewPledgeButton.setVisibility(View.GONE);
    }
  }

  public void show(@NonNull final Project project) {
    final int starColor = (project.isStarred()) ? R.color.green : R.color.dark_gray;
    starIconTextView.setTextColor(ContextCompat.getColor(this, starColor));
    adapter.takeProject(project);
    setProjectActionButton(project);
  }

  @OnClick(R.id.back_project_button)
  public void backProjectButtonOnClick() {
    presenter.takeBackProjectClick();
  }

  @OnClick(R.id.manage_pledge_button)
  public void managePledgeOnClick() {
    presenter.takeManagePledgeClick();
  }

  @OnClick(R.id.view_pledge_button)
  public void viewPledgeOnClick() {
    presenter.takeViewPledgeClick();
  }

  public void managePledge(@NonNull final Project project) {
    final Intent intent = new Intent(this, CheckoutActivity.class)
      .putExtra(getString(R.string.intent_project), project)
      .putExtra(getString(R.string.intent_url), project.editPledgeUrl())
      .putExtra(getString(R.string.intent_toolbar_title), getString(R.string.Manage_pledge));
    startActivityWithTransition(intent, R.anim.slide_in_right, R.anim.fade_out_slide_out_left);
  }

  @Override
  public void onBackPressed() {
    super.onBackPressed();
    overrideExitTransition();
  }

  public void overrideExitTransition() {
    overridePendingTransition(R.anim.fade_in_slide_in_left, R.anim.slide_out_right);
  }

  @OnClick(R.id.star_icon)
  public void starProjectClick() {
    presenter.takeStarClick();
  }

  @OnClick(R.id.share_icon)
  public void shareProject() {
    presenter.takeShareClick();
  }

  public void showProjectDescription(@NonNull final Project project) {
    startWebViewActivity(project.descriptionUrl());
  }

  public void showCreatorBio(@NonNull final Project project) {
    startWebViewActivity(project.creatorBioUrl());<commit_msg>update star toggle logic in project activity<commit_after>package com.kickstarter.ui.activities;

import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.kickstarter.KSApplication;
import com.kickstarter.R;
import com.kickstarter.libs.ActivityRequestCodes;
import com.kickstarter.libs.BaseActivity;
import com.kickstarter.libs.Money;
import com.kickstarter.libs.qualifiers.RequiresPresenter;
import com.kickstarter.models.Project;
import com.kickstarter.models.Reward;
import com.kickstarter.presenters.ProjectPresenter;
import com.kickstarter.ui.adapters.ProjectAdapter;

import javax.inject.Inject;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

@RequiresPresenter(ProjectPresenter.class)
public class ProjectActivity extends BaseActivity<ProjectPresenter> {
  private ProjectAdapter adapter;

  @Bind(R.id.rewards_recycler_view) RecyclerView rewardsRecyclerView;
  @Bind(R.id.star_fab) FloatingActionButton starFab;
  @Bind(R.id.back_project_button) Button backProjectButton;
  @Bind(R.id.manage_pledge_button) Button managePledgeButton;
  @Bind(R.id.view_pledge_button) Button viewPledgeButton;

  @Inject Money money;

  @Override
  protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.project_layout);
    ButterKnife.bind(this);
    ((KSApplication) getApplication()).component().inject(this);

    final Intent intent = getIntent();
    final Project project = intent.getParcelableExtra(getString(R.string.intent_project)); // Project can be null!
    final String param = intent.getStringExtra(getString(R.string.intent_project_param));
    presenter.initialize(project, param);

    adapter = new ProjectAdapter(presenter);
    rewardsRecyclerView.setAdapter(adapter);
    rewardsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  }

  public void show(@NonNull final Project project) {
    adapter.takeProject(project);

    final Drawable starDrawable = ContextCompat.getDrawable(this, R.drawable.ic_star_black_24dp);
    setProjectActionButton(project, starDrawable);
    toggleStarColor(project, starDrawable);
  }

  public void setProjectActionButton(@NonNull final Project project, @NonNull final Drawable starDrawable) {
    if (project.isLive()) {
      starFab.setImageDrawable(starDrawable);
      starFab.setVisibility(View.VISIBLE);
    } else {
      starFab.setVisibility(View.GONE);
    }

    if (!project.isBacking() && project.isLive()) {
      backProjectButton.setVisibility(View.VISIBLE);
    } else {
      backProjectButton.setVisibility(View.GONE);
    }

    if (project.isBacking() && project.isLive()) {
      managePledgeButton.setVisibility(View.VISIBLE);
    } else {
      managePledgeButton.setVisibility(View.GONE);
    }

    if (project.isBacking() && !project.isLive()) {
      viewPledgeButton.setVisibility(View.VISIBLE);
    } else {
      viewPledgeButton.setVisibility(View.GONE);
    }
  }

  public void toggleStarColor(@NonNull final Project project, @NonNull final Drawable starDrawable) {
    final int starColor = (project.isStarred()) ? R.color.green : R.color.text_primary;
    starDrawable.setColorFilter(ContextCompat.getColor(this, starColor), PorterDuff.Mode.SRC_ATOP);
  }

  @OnClick(R.id.back_project_button)
  public void backProjectButtonOnClick() {
    presenter.takeBackProjectClick();
  }

  @OnClick(R.id.manage_pledge_button)
  public void managePledgeOnClick() {
    presenter.takeManagePledgeClick();
  }

  @OnClick(R.id.view_pledge_button)
  public void viewPledgeOnClick() {
    presenter.takeViewPledgeClick();
  }

  public void managePledge(@NonNull final Project project) {
    final Intent intent = new Intent(this, CheckoutActivity.class)
      .putExtra(getString(R.string.intent_project), project)
      .putExtra(getString(R.string.intent_url), project.editPledgeUrl())
      .putExtra(getString(R.string.intent_toolbar_title), getString(R.string.Manage_pledge));
    startActivityWithTransition(intent, R.anim.slide_in_right, R.anim.fade_out_slide_out_left);
  }

  @Override
  public void onBackPressed() {
    super.onBackPressed();
    overrideExitTransition();
  }

  public void overrideExitTransition() {
    overridePendingTransition(R.anim.fade_in_slide_in_left, R.anim.slide_out_right);
  }

  @OnClick(R.id.star_fab)
  public void starProjectClick() {
    presenter.takeStarClick();
  }

//  @OnClick(R.id.share_icon)
//  public void shareProject() {
//    presenter.takeShareClick();
//  }

  public void showProjectDescription(@NonNull final Project project) {
    startWebViewActivity(project.descriptionUrl());
  }

  public void showCreatorBio(@NonNull final Project project) {
    startWebViewActivity(project.creatorBioUrl());
{'fraction_non_alphanumeric': 0.10548223350253808, 'fraction_numerical': 0.0008121827411167512, 'mean_word_length': 5.187814070351759, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '139315', 'n_tokens_mistral': 3058, 'n_tokens_neox': 2945, 'n_words': 490}