@Kroll.method
  public void setAchievementScore(
      final String achievement,
      final Float percentage,
      final Float value,
      final boolean showNotification) {
    final BAchievementListener listener =
        new BAchievementListener() {

          @Override
          public void onComplete(List<PlayerAchievement> a) {
            KrollDict data = new KrollDict();
            data.put("PlayerAchievement", a);
            fireEvent("onPlayerAchievement", data);
          }

          @Override
          public void onAchievementUnlocked(List<PlayerAchievement> a) {
            KrollDict data = new KrollDict();
            data.put("PlayerAchievement", a);
            fireEvent("onPlayerAchievementUnlocked", data);
          }

          @Override
          public void onBeintooError(Exception e) {
            fireEvent("onError", new KrollDict());
          }
        };

    Beintoo.currentContext = _tiContext.getAndroidContext();
    Beintoo.setAchievementScore(
        _tiContext.getAndroidContext(), achievement, percentage, value, listener);
  }
  public Leaderboard(Context context, String kind, String selectedContest) {
    super(context, R.style.ThemeBeintoo);
    setContentView(R.layout.leaderboardlist);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.current = this;
    this.currentContext = context;
    this.leader_kind = kind;
    this.codeID = selectedContest;

    // GETTING DENSITY PIXELS RATIO
    ratio = (context.getApplicationContext().getResources().getDisplayMetrics().densityDpi / 160d);
    // SET UP LAYOUTS
    double pixels = ratio * 40;
    RelativeLayout beintooBar = (RelativeLayout) findViewById(R.id.beintoobarsmall);
    beintooBar.setBackgroundDrawable(
        new BDrawableGradient(0, (int) pixels, BDrawableGradient.BAR_GRADIENT));

    listView = (ListView) findViewById(R.id.listView);
    listView.setVisibility(LinearLayout.GONE);
    listView.setCacheColorHint(0);

    LinearLayout content = (LinearLayout) findViewById(R.id.goodcontent);
    content.addView(progressLoading());

    LinearLayout tip = (LinearLayout) findViewById(R.id.tip);
    tip.setBackgroundDrawable(
        new BDrawableGradient(0, (int) (ratio * 27), BDrawableGradient.LIGHT_GRAY_GRADIENT));
    if (!Beintoo.isLogged(
        context)) { // IF THE USER IS NOT LOGGED HIDE TIPS FOR CHALLENGE AND SHOW SIGNUP BUTTON
      tip.setVisibility(LinearLayout.GONE);
      LinearLayout signup = (LinearLayout) findViewById(R.id.signupPlayer);
      signup.addView(SignupLayouts.signupRow(context, Beintoo.FEATURE_LEADERBOARD));
      signup.setVisibility(View.VISIBLE);
    }

    if (leader_kind != null && leader_kind.equals("ALLIANCES")) {
      findViewById(R.id.tip).setVisibility(View.GONE);
      findViewById(R.id.spacer).setVisibility(View.GONE);
    }

    imageManager = new ImageManager(currentContext);
    usersExts = new ArrayList<String>();
    usersNicks = new ArrayList<String>();

    listView.setOnItemClickListener(this);
    listView.setOnScrollListener(this);

    this.firstLoading();
  }
  @Kroll.method
  public void getPlayerScore(final String codeID) {
    BScoreListener listener =
        new BScoreListener() {

          @Override
          public void onComplete(PlayerScore p) {
            KrollDict data = new KrollDict();
            data.put("PlayerScore", p);
            fireEvent("onPlayerScore", data);
          }

          @Override
          public void onBeintooError(Exception e) {
            fireEvent("onError", new KrollDict());
          }
        };

    Beintoo.currentContext = _tiContext.getAndroidContext();
    Beintoo.getPlayerScoreAsync(_tiContext.getAndroidContext(), codeID, listener);
  }
  @Kroll.method
  public void GetVgood(final String codeID, final boolean isMultiple) {
    BGetVgoodListener listener =
        new BGetVgoodListener() {

          @Override
          public void onComplete(VgoodChooseOne v) {
            KrollDict data = new KrollDict();
            data.put("Vgood", v);
            fireEvent("onVgood", data);
          }

          @Override
          public void isOverQuota() {
            fireEvent("onVgoodOverquota", new KrollDict());
          }

          @Override
          public void nothingToDispatch() {
            fireEvent("onVgoodNothingToDispatch", new KrollDict());
          }

          @Override
          public void onError() {
            fireEvent("onError", new KrollDict());
          }
        };

    Beintoo.currentContext = _tiContext.getAndroidContext();
    Beintoo.GetVgood(
        _tiContext.getAndroidContext(),
        codeID,
        isMultiple,
        null,
        Beintoo.VGOOD_NOTIFICATION_ALERT,
        listener);
  }
 @Kroll.method
 public void setApiKey(String apikey) {
   Beintoo.setApiKey(apikey);
 }
 @Kroll.method
 public void beintooStart(boolean goToDashboard) {
   Beintoo.currentContext = _tiContext.getAndroidContext();
   Beintoo.BeintooStart(_tiContext.getAndroidContext(), goToDashboard);
 }
 @Kroll.method
 public void logout() {
   Beintoo.currentContext = _tiContext.getAndroidContext();
   Beintoo.logout(_tiContext.getAndroidContext());
 }
 @Kroll.method
 public boolean isLogged() {
   Beintoo.currentContext = _tiContext.getAndroidContext();
   return Beintoo.isLogged(_tiContext.getAndroidContext());
 }