@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 TiUITableView getTableView() {
   TiContext ctx = getTiContext();
   if (ctx != null) {
     return (TiUITableView) getView(ctx.getActivity());
   }
   return null;
 }
Esempio n. 3
0
 private void initApplication(KrollContext kroll) {
   if (kroll != null) {
     TiContext tiContext = kroll.getTiContext();
     if (tiContext != null) {
       weakApplication =
           new WeakReference<TiApplication>(
               (TiApplication) tiContext.getActivity().getApplication());
     }
   }
 }
  @Kroll.method
  public void submitScoreWithVgoodCheck(
      final int lastScore, final int threshold, final String codeID) {
    final BSubmitScoreListener slistener =
        new BSubmitScoreListener() {
          @Override
          public void onComplete() {
            fireEvent("onSubmitComplete", new KrollDict());
          }

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

    final BGetVgoodListener glistener =
        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();
    SubmitScoreManager ssm = new SubmitScoreManager();
    ssm.submitScoreWithVgoodCheck(
        _tiContext.getAndroidContext(),
        lastScore,
        threshold,
        codeID,
        false,
        null,
        Beintoo.VGOOD_NOTIFICATION_ALERT,
        slistener,
        glistener);
  }
Esempio n. 5
0
  private void handleBackgroundImage(KrollDict d) {
    String bg = d.getString(TiC.PROPERTY_BACKGROUND_IMAGE);
    String bgSelected = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE);
    String bgFocused = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_IMAGE);
    String bgDisabled = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_IMAGE);

    String bgColor = d.getString(TiC.PROPERTY_BACKGROUND_COLOR);
    String bgSelectedColor = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR);
    String bgFocusedColor = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_COLOR);
    String bgDisabledColor = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_COLOR);

    TiContext tiContext = getProxy().getTiContext();
    if (bg != null) {
      bg = tiContext.resolveUrl(null, bg);
    }
    if (bgSelected != null) {
      bgSelected = tiContext.resolveUrl(null, bgSelected);
    }
    if (bgFocused != null) {
      bgFocused = tiContext.resolveUrl(null, bgFocused);
    }
    if (bgDisabled != null) {
      bgDisabled = tiContext.resolveUrl(null, bgDisabled);
    }

    if (bg != null
        || bgSelected != null
        || bgFocused != null
        || bgDisabled != null
        || bgColor != null
        || bgSelectedColor != null
        || bgFocusedColor != null
        || bgDisabledColor != null) {
      if (background == null) {
        applyCustomBackground(false);
      }

      Drawable bgDrawable =
          TiUIHelper.buildBackgroundDrawable(
              tiContext,
              bg,
              bgColor,
              bgSelected,
              bgSelectedColor,
              bgDisabled,
              bgDisabledColor,
              bgFocused,
              bgFocusedColor);
      background.setBackgroundDrawable(bgDrawable);
    }
  }
  @Kroll.method
  public void appendRow(Object row, @Kroll.argument(optional = true) KrollDict options) {
    TiContext ctx = getTiContext();
    if (ctx == null) {
      Log.w(LCAT, "Context has been GC'd, not appending row");
      return;
    }
    if (ctx.isUIThread()) {
      handleAppendRow(row);
      return;
    }

    sendBlockingUiMessage(MSG_APPEND_ROW, row);
  }
 @Kroll.method
 public void insertRowAfter(
     int index, Object data, @Kroll.argument(optional = true) KrollDict options) {
   TiContext ctx = getTiContext();
   if (ctx == null) {
     Log.w(LCAT, "Context has been GC'd, not inserting row.");
     return;
   }
   if (ctx.isUIThread()) {
     handleInsertRowAfter(index, data);
     return;
   }
   sendBlockingUiMessage(MSG_INSERT_ROW, data, INSERT_ROW_AFTER, index);
 }
 @Kroll.method
 public void deleteRow(int index, @Kroll.argument(optional = true) KrollDict options) {
   TiContext ctx = getTiContext();
   if (ctx == null) {
     Log.w(LCAT, "Context has been GC'd, not deleting row.");
     return;
   }
   if (ctx.isUIThread()) {
     handleDeleteRow(index);
     return;
   }
   Message msg = getUIHandler().obtainMessage(MSG_DELETE_ROW);
   msg.arg1 = index;
   msg.sendToTarget();
 }
  public TiTableViewRowProxyItem(TiContext tiContext) {
    super(tiContext);

    this.handler = new Handler(this);
    this.leftImage = new ImageView(tiContext.getActivity());
    leftImage.setVisibility(GONE);
    addView(leftImage, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    this.content = new TiCompositeLayout(tiContext.getActivity());
    content.setMinimumHeight(48);
    addView(content, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    this.rightImage = new ImageView(tiContext.getActivity());
    rightImage.setVisibility(GONE);
    addView(rightImage, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  }
Esempio n. 10
0
 @Kroll.setProperty
 @Kroll.method
 public void setData(Object[] data, @Kroll.argument(optional = true) KrollDict options) {
   TiContext ctx = getTiContext();
   Object[] actualData = data;
   if (data != null && data.length > 0 && data[0] instanceof Object[]) {
     actualData = (Object[]) data[0];
   }
   if (ctx == null) {
     Log.w(LCAT, "Context has been GC'd, not setting table data.");
     return;
   }
   if (ctx.isUIThread()) {
     handleSetData(actualData);
   } else {
     sendBlockingUiMessage(MSG_SET_DATA, actualData);
   }
 }
 public void setBackgroundImageProperty(TiDict d, String property) {
   String path = TiConvert.toString(d, property);
   String url = tiContext.resolveUrl(null, path);
   TiBaseFile file = TiFileFactory.createTitaniumFile(tiContext, new String[] {url}, false);
   try {
     setBackgroundDrawable(new BitmapDrawable(TiUIHelper.createBitmap(file.getInputStream())));
   } catch (IOException e) {
     Log.e(LCAT, "Error creating background image from path: " + path.toString(), e);
   }
 }
Esempio n. 12
0
  public TiResourceFile(TiContext tiContext, String path) {
    super(tiContext, TYPE_RESOURCE);
    this.path = path;
    this.loadFromSDCard =
        tiContext.getTiApp().getSystemProperties().getBool(LOAD_FROM_SD_CARD, false);

    if (loadFromSDCard) {
      Log.d(LCAT, "Loading data from sdcard");
    }
  }
  @Kroll.method
  public void submitScore(
      final int lastScore, final String codeID, final boolean showNotification) {
    final BSubmitScoreListener listener =
        new BSubmitScoreListener() {
          @Override
          public void onComplete() {
            fireEvent("onSubmitComplete", new KrollDict());
          }

          @Override
          public void onBeintooError(Exception e) {
            fireEvent("onError", new KrollDict());
          }
        };
    Beintoo.currentContext = _tiContext.getAndroidContext();
    SubmitScoreManager ssm = new SubmitScoreManager();
    ssm.submitScore(
        _tiContext.getAndroidContext(), lastScore, null, true, Gravity.BOTTOM, listener);
  }
  /** CORE METHODS */
  @Kroll.method
  public void playerLogin() {
    final BPlayerLoginListener listener =
        new BPlayerLoginListener() {
          @Override
          public void onComplete(Player p) {
            KrollDict data = new KrollDict();
            data.put("player", p);
            fireEvent("onLogin", data);
          }

          @Override
          public void onError() {
            fireEvent("onError", new KrollDict());
          }
        };
    Beintoo.currentContext = _tiContext.getAndroidContext();
    PlayerManager pm =
        new PlayerManager(TiContext.getCurrentTiContext().getActivity().getApplicationContext());
    pm.playerLogin(_tiContext.getAndroidContext(), listener);
  }
  @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);
  }
 public TiBaseTableViewItem(TiContext tiContext) {
   super(tiContext.getActivity());
   this.tiContext = tiContext;
   this.handler = new Handler(this);
 }
 @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());
 }
 @Kroll.method
 public void beintooStart(boolean goToDashboard) {
   Beintoo.currentContext = _tiContext.getAndroidContext();
   Beintoo.BeintooStart(_tiContext.getAndroidContext(), goToDashboard);
 }
 public Drawable loadDrawable(String url) {
   if (tfh == null) {
     tfh = new TiFileHelper(tiContext.getActivity());
   }
   return tfh.loadDrawable(url, false);
 }