// #sijapp cond.if modules_TOUCH is "true"#
 protected void stylusXMoved(TouchState state) {
   if (getWidth() / 2 < Math.abs(state.fromX - state.x)) {
     boolean isTrue = state.fromX < state.x;
     int currentModel = 0;
     if (Options.getBoolean(Options.OPTION_CL_HIDE_OFFLINE)) currentModel = 1;
     if (((RosterContent) content).getModel() == getUpdater().getChatModel()) currentModel = 2;
     currentModel = (currentModel + 3 + (isTrue ? -1 : +1)) % 3;
     switch (currentModel) {
       case 0:
         Options.setBoolean(Options.OPTION_CL_HIDE_OFFLINE, false);
         updateOfflineStatus();
         Options.safeSave();
         break;
       case 1:
         Options.setBoolean(Options.OPTION_CL_HIDE_OFFLINE, true);
         updateOfflineStatus();
         Options.safeSave();
         break;
       case 2:
         ((RosterContent) content).setModel(getUpdater().getChatModel());
         break;
     }
     updateTitle();
     Jimm.getJimm().getCL().activate();
   }
 }
Example #2
0
  public static long createGmtDate(String sdate) {
    Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    try {
      sdate = sdate.trim();
      int[] ofs = sdate.endsWith("Z") ? ofsFieldsB : ofsFieldsA;
      long result;
      if (Character.isDigit(sdate.charAt(0))) {
        int fieldLength = 4; // yearlen
        for (int i = 0; i < calFields.length; ++i) {
          int begIndex = ofs[i];
          int field = strToIntDef(sdate.substring(begIndex, begIndex + fieldLength), 0);
          if (1 == i) {
            field += Calendar.JANUARY - 1;
          }
          fieldLength = 2;
          c.set(calFields[i], field);
        }
        result = Math.max(0, c.getTime().getTime() / 1000);

      } else {
        String[] rfcDate = Util.explode(sdate, ' ');
        c.set(Calendar.YEAR, strToIntDef(rfcDate[3], 0));

        for (int i = 0; i < months.length; ++i) {
          if (months[i].equals(rfcDate[2])) {
            c.set(Calendar.MONTH, i);
            break;
          }
        }
        c.set(Calendar.DAY_OF_MONTH, strToIntDef(rfcDate[1], 0));
        c.set(Calendar.HOUR_OF_DAY, strToIntDef(rfcDate[4].substring(0, 2), 0));
        c.set(Calendar.MINUTE, strToIntDef(rfcDate[4].substring(3, 5), 0));
        c.set(Calendar.SECOND, strToIntDef(rfcDate[4].substring(6), 0));

        long delta =
            strToIntDef(rfcDate[5].substring(1, 3), 0) * 60 * 60
                + strToIntDef(rfcDate[5].substring(3, 5), 0) * 60;
        if ('+' == rfcDate[5].charAt(0)) {
          delta = -delta;
        }
        result = Math.max(0, c.getTime().getTime() / 1000 + delta);
      }
      return result;
    } catch (Exception ignored) {
    }
    return 0;
  }
Example #3
0
  public void __setStatus(String resource, int priority, byte index, String statusText) {
    if (StatusInfo.STATUS_OFFLINE == index) {
      resource = StringUtils.notNull(resource);
      if (resource.equals(currentResource)) {
        currentResource = null;
      }
      removeSubContact(resource);
      if (0 == subContacts.size()) {
        setOfflineStatus();
      }

    } else {
      SubContact c = getSubContact(resource);
      c.priority = (byte) Math.min(127, Math.max(priority, -127));
      c.status = index;
      c.statusText = statusText;
    }
  }
Example #4
0
  // Extracts the number value form String
  public static int decimalToInt(String string) {
    try {
      int i = string.indexOf('.');
      if (i < 0) {
        return Integer.parseInt(string) * 1000;

      } else {
        int value = Integer.parseInt(string.substring(0, i)) * 1000;
        string = string.substring(i + 1, Math.min(string.length(), i + 1 + 3));
        while (string.length() < 3) {
          string = string + "0";
        }
        return value + Integer.parseInt(string);
      }
    } catch (Exception ignored) {
      return 0;
    }
  }
Example #5
0
  // Generates int of money amount spent on connection
  protected int generateCostSum(int in, int out, boolean thisSession) {
    int cost = 0;
    int costOf1M = Options.getInt(Options.OPTION_COST_OF_1M) * 100;
    int costPacketLength = Math.max(Options.getInt(Options.OPTION_COST_PACKET_LENGTH), 1);

    long packets = 0;
    if (0 != in) {
      packets += (in + costPacketLength - 1) / costPacketLength;
    }
    if (0 != out) {
      packets += (out + costPacketLength - 1) / costPacketLength;
    }
    cost += (int) (packets * costPacketLength * costOf1M / (1024 * 1024));
    if (!usedToday() && (0 != sessionInTraffic) && (0 == costPerDaySum)) {
      costPerDaySum = costPerDaySum + Options.getInt(Options.OPTION_COST_PER_DAY);
      lastTimeUsed.setTime(new Date().getTime());
    }
    return cost + costPerDaySum;
  }
Example #6
0
 public static int nextRandInt() {
   return Math.abs(Math.max(Integer.MIN_VALUE + 1, rand.nextInt()));
 }