Exemple #1
0
 public void moveItemTemp(int paramInt1, int paramInt2)
 {
   if (paramInt1 != paramInt2)
     return;
   int i = this.mTempRowMapping.get(paramInt1, paramInt1);
   if (paramInt1 > paramInt2)
   {
     j = paramInt1;
     while (j > paramInt2)
     {
       SparseIntArray localSparseIntArray1 = this.mTempRowMapping;
       SparseIntArray localSparseIntArray2 = this.mTempRowMapping;
       int k = j + -1;
       int m = j + -1;
       int n = localSparseIntArray2.get(k, m);
       localSparseIntArray1.put(j, n);
       j += -1;
     }
   }
   int j = paramInt1;
   while (j < paramInt2)
   {
     SparseIntArray localSparseIntArray3 = this.mTempRowMapping;
     SparseIntArray localSparseIntArray4 = this.mTempRowMapping;
     int i1 = j + 1;
     int i2 = j + 1;
     int i3 = localSparseIntArray4.get(i1, i2);
     localSparseIntArray3.put(j, i3);
     j += 1;
   }
   this.mTempRowMapping.put(paramInt2, i);
 }
  @Override
  public Object[] getSections() {
    positionOfSection = new SparseIntArray();
    sectionOfPosition = new SparseIntArray();
    int count = getCount();
    list = new ArrayList<String>();
    list.add(getContext().getString(R.string.search_header));
    positionOfSection.put(0, 0);
    sectionOfPosition.put(0, 0);
    for (int i = 1; i < count; i++) {

      String letter = getItem(i).getHeader();
      EMLog.d(
          TAG,
          "contactadapter getsection getHeader:" + letter + " name:" + getItem(i).getUsername());
      int section = list.size() - 1;
      if (list.get(section) != null && !list.get(section).equals(letter)) {
        list.add(letter);
        section++;
        positionOfSection.put(section, i);
      }
      sectionOfPosition.put(i, section);
    }
    return list.toArray(new String[list.size()]);
  }
 @Before
 public void setup() {
   final SparseIntArray bucketSizes = new SparseIntArray();
   bucketSizes.put(32, 2);
   bucketSizes.put(64, 1);
   bucketSizes.put(128, 1);
   mPool = new FakeNativeMemoryChunkPool(new PoolParams(128, bucketSizes));
 }
Exemple #4
0
 static {
   SparseIntArray localSparseIntArray = new SparseIntArray();
   ab = localSparseIntArray;
   localSparseIntArray.put(0, efj.YL);
   ab.put(1, efj.YJ);
   ab.put(2, efj.YM);
   ab.put(3, efj.YK);
 }
Exemple #5
0
  public static boolean isPortAvailable(int port) {
    boolean available = true;

    int available_code = mOpenPorts.get(port);

    if (available_code != 0) return available_code != 1;

    try {
      // attempt 3 times since proxy and server could be still releasing
      // their ports
      for (int i = 0; i < 3; i++) {
        Socket channel = new Socket();
        InetSocketAddress address =
            new InetSocketAddress(InetAddress.getByName(mNetwork.getLocalAddressAsString()), port);

        channel.connect(address, 200);

        available = !channel.isConnected();

        channel.close();

        if (available) break;

        Thread.sleep(200);
      }
    } catch (Exception e) {
      available = true;
    }

    mOpenPorts.put(port, available ? 2 : 1);

    return available;
  }
  @Test
  public void testAssertSparseIntArrayEquals() {
    final SparseIntArray sparseIntArray = new SparseIntArray();
    sparseIntArray.put(3, 15);
    sparseIntArray.put(1, 15);

    SparseAsserts.assertSparseIntArrayEquals(sparseIntArray, sparseIntArray);
  }
 public int getPictureId(int position) {
   int id = mSparseIntArray.get(position);
   if (id == 0) {
     id = mIdsList.get(mRandom.nextInt(mSize));
     mSparseIntArray.put(position, id);
   }
   return id;
 }
 public SparseIntArray buildFilterIndex(ArrayList<Filter> myFilterList) {
   SparseIntArray myPositionMap = new SparseIntArray();
   Integer position = 0;
   for (Filter myCat : myFilterList) {
     myPositionMap.put(myCat.getID(), position);
     position++;
   }
   return myPositionMap;
 }
 public SparseIntArray buildCategoryIndex(ArrayList<Category> myCategoryList) {
   SparseIntArray myPositionMap = new SparseIntArray();
   Integer position = 0;
   for (Category myCat : myCategoryList) {
     myPositionMap.put(myCat.getID(), position);
     position++;
   }
   return myPositionMap;
 }
 private int efficientTextSizeSearch(
     final int start, final int end, final SizeTester sizeTester, final RectF availableSpace) {
   if (!_enableSizeCache) return binarySearch(start, end, sizeTester, availableSpace);
   final String text = getText().toString();
   final int key = text == null ? 0 : text.length();
   int size = _textCachedSizes.get(key);
   if (size != 0) return size;
   size = binarySearch(start, end, sizeTester, availableSpace);
   _textCachedSizes.put(key, size);
   return size;
 }
 private int efficientTextSizeSearch(
     int start, int end, SizeTester sizeTester, RectF availableSpace) {
   if (!mEnableSizeCache) {
     return binarySearch(start, end, sizeTester, availableSpace);
   }
   String text = getText().toString();
   int key = text == null ? 0 : text.length();
   int size = mTextCachedSizes.get(key);
   if (size != 0) {
     return size;
   }
   size = binarySearch(start, end, sizeTester, availableSpace);
   mTextCachedSizes.put(key, size);
   return size;
 }
 private void handleAddListener(int uid) {
   synchronized (mListeners) {
     if (mClientUids.indexOfKey(uid) >= 0) {
       // Shouldn't be here -- already have this uid.
       Log.w(TAG, "Duplicate add listener for uid " + uid);
       return;
     }
     mClientUids.put(uid, 0);
     if (mNavigating) {
       try {
         mBatteryStats.noteStartGps(uid);
       } catch (RemoteException e) {
         Log.w(TAG, "RemoteException in addListener");
       }
     }
   }
 }
Exemple #13
0
 public void removeItemTemp(int paramInt)
 {
   this.mHasRemovedItem = true;
   int i = getCount();
   int j = paramInt;
   while (true)
   {
     if (j >= i)
       return;
     SparseIntArray localSparseIntArray1 = this.mTempRowMapping;
     SparseIntArray localSparseIntArray2 = this.mTempRowMapping;
     int k = j + 1;
     int m = j + 1;
     int n = localSparseIntArray2.get(k, m);
     localSparseIntArray1.put(j, n);
     j += 1;
   }
 }
  /**
   * Deserializes the map data from a string.
   *
   * @param s The string representation of the map data.
   */
  public void deserialize(String s) {
    // Reset the map
    unmapAll();

    // Parse the new map data from the multi-delimited string
    if (s != null) {
      // Read the input mappings
      String[] pairs = s.split(",");
      for (String pair : pairs) {
        String[] elements = pair.split(":");
        if (elements.length == 2) {
          try {
            int value = Integer.parseInt(elements[0]);
            int key = Integer.parseInt(elements[1]);
            mMap.put(key, value);
          } catch (NumberFormatException ignored) {
          }
        }
      }
    }
  }
    /** Called by CREATOR. */
    private SavedState(Parcel in) {
      // Parcel 'in' has its parent(RecyclerView)'s saved state.
      // To restore it, class loader that loaded RecyclerView is required.
      Parcelable superState = in.readParcelable(RecyclerView.class.getClassLoader());
      this.superState = superState != null ? superState : EMPTY_STATE;

      prevFirstVisiblePosition = in.readInt();
      prevFirstVisibleChildHeight = in.readInt();
      prevScrolledChildrenHeight = in.readInt();
      prevScrollY = in.readInt();
      scrollY = in.readInt();
      childrenHeights = new SparseIntArray();
      final int numOfChildren = in.readInt();
      if (0 < numOfChildren) {
        for (int i = 0; i < numOfChildren; i++) {
          final int key = in.readInt();
          final int value = in.readInt();
          childrenHeights.put(key, value);
        }
      }
    }
Exemple #16
0
 private void mapPagesAndIndexs() {
   if (mPageToChildIndex == null) {
     final int count = getVirtualChildCount();
     mPageToChildIndex = new SparseIntArray();
     final int childcount = getChildCount();
     final SparseIntArray pageToChild = mPageToChildIndex;
     for (int i = 0; i < count; i++) {
       boolean found = false;
       SoftReference<View> soft = pageReferences.get(getPageID(i));
       View fromprovider = provider.getView(i, soft == null ? null : soft.get());
       for (int j = 0; j < childcount; j++) {
         View fromview = getChildAt(j);
         if (fromview == fromprovider) {
           pageToChild.put(i, j);
           found = true;
           j = childcount;
         }
       }
       if (!found) {
         // provider.clearView(i);
       }
     }
   }
 }
 private static int updateHistogramCounter(final SparseIntArray histogram, final int key) {
   final int index = histogram.indexOfKey(key);
   final int count = (index >= 0 ? histogram.get(key) : 0) + 1;
   histogram.put(key, count);
   return count;
 }
Exemple #18
0
  public void removeExtraPageAroundPage(int page) {
    int firstPageInWindow = page;
    if (provider != null) {
      if (mPageToChildIndex == null) {
        mapPagesAndIndexs();
      }
      int pagesPerWindow = provider.pagesPerWindow();
      int childcount = getChildCount();
      int numOfPages = pagesPerWindow * provider.preLoadedSize();
      int startAt = firstPageInWindow - (pagesPerWindow * (provider.preLoadedSize() / 2));
      final int count = getVirtualChildCount();
      int virtualcount = 0;
      final SparseIntArray pageToChild = mPageToChildIndex;
      int istart = startAt - pagesPerWindow;
      if (istart < 0) {
        istart = 0;
      }
      int iend = startAt + numOfPages + pagesPerWindow;
      if (iend > count) {
        iend = count;
      }
      for (int i = istart; i < iend; i++) {
        boolean found = false;
        SoftReference<View> soft = pageReferences.get(getPageID(i));
        View fromprovider = provider.getView(i, soft == null ? null : soft.get());
        for (int j = virtualcount; j < getChildCount(); j++) {
          View fromview = getChildAt(j);
          if (fromview == fromprovider) {
            if (i < startAt || i > (startAt + numOfPages)) {
              pageToChild.put(i, -1);
              removeView(fromprovider);
            } else {
              pageToChild.put(i, j);
              found = true;
            }
            j = childcount;
          }
        }
        if (!found) {
          if (i < startAt || i > (startAt + numOfPages)) {

          } else {
            if (i > firstPageInWindow) {
              addView(fromprovider);
              soft = new SoftReference<View>(fromprovider);

              pageReferences.put(getPageID(i), soft);
              pageToChild.put(i, indexOfChild(fromprovider));
              found = true;
            } else {
              addView(fromprovider, virtualcount++);
              soft = new SoftReference<View>(fromprovider);
              pageReferences.put(getPageID(i), soft);
              pageToChild.put(i, indexOfChild(fromprovider));
              found = true;
            }
          }
        }

        if (!found) {
          // provider.clearView(i);
        }
      }

      provider.onPage(page);
    }
  }
 static {
   int i = 0;
   SpecialKeysMap.put(KeyEvent.KEYCODE_DEL, ++i); // 1
   SpecialKeysMap.put(KeyEvent.KEYCODE_TAB, ++i); // 2
   SpecialKeysMap.put(KeyEvent.KEYCODE_ENTER, 12);
   ++i; // 3 is not used, return is 12 instead
   SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_LEFT, ++i); // 4
   SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_UP, ++i); // 5
   SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, ++i); // 6
   SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_DOWN, ++i); // 7
   SpecialKeysMap.put(KeyEvent.KEYCODE_PAGE_UP, ++i); // 8
   SpecialKeysMap.put(KeyEvent.KEYCODE_PAGE_DOWN, ++i); // 9
   if (Build.VERSION.SDK_INT >= 11) {
     SpecialKeysMap.put(KeyEvent.KEYCODE_MOVE_HOME, ++i); // 10
     SpecialKeysMap.put(KeyEvent.KEYCODE_MOVE_END, ++i); // 11
     SpecialKeysMap.put(KeyEvent.KEYCODE_NUMPAD_ENTER, ++i); // 12
     SpecialKeysMap.put(KeyEvent.KEYCODE_FORWARD_DEL, ++i); // 13
     SpecialKeysMap.put(KeyEvent.KEYCODE_ESCAPE, ++i); // 14
     SpecialKeysMap.put(KeyEvent.KEYCODE_SYSRQ, ++i); // 15
     SpecialKeysMap.put(KeyEvent.KEYCODE_SCROLL_LOCK, ++i); // 16
     ++i; // 17
     ++i; // 18
     ++i; // 19
     ++i; // 20
     SpecialKeysMap.put(KeyEvent.KEYCODE_F1, ++i); // 21
     SpecialKeysMap.put(KeyEvent.KEYCODE_F2, ++i); // 22
     SpecialKeysMap.put(KeyEvent.KEYCODE_F3, ++i); // 23
     SpecialKeysMap.put(KeyEvent.KEYCODE_F4, ++i); // 24
     SpecialKeysMap.put(KeyEvent.KEYCODE_F5, ++i); // 25
     SpecialKeysMap.put(KeyEvent.KEYCODE_F6, ++i); // 26
     SpecialKeysMap.put(KeyEvent.KEYCODE_F7, ++i); // 27
     SpecialKeysMap.put(KeyEvent.KEYCODE_F8, ++i); // 28
     SpecialKeysMap.put(KeyEvent.KEYCODE_F9, ++i); // 29
     SpecialKeysMap.put(KeyEvent.KEYCODE_F10, ++i); // 30
     SpecialKeysMap.put(KeyEvent.KEYCODE_F11, ++i); // 31
     SpecialKeysMap.put(KeyEvent.KEYCODE_F12, ++i); // 21
   }
 }
Exemple #20
0
 /**
  * Load sfx.
  *
  * @param raw the raw
  * @param ID the id
  */
 public void loadSfx(int raw, int ID) {
   // 把资源中的音效加载到指定的ID(播放的时候就对应到这个ID播放就行了)
   mSoundPoolMap.put(ID, mSoundPool.load(mContext, raw, ID));
 }
    private void init() {
      if (mCursor != null) {
        mCursor.close();
      }

      String onlyStarredOfficeHoursSelection =
          "("
              + ScheduleContract.Blocks.BLOCK_TYPE
              + " != '"
              + ScheduleContract.Blocks.BLOCK_TYPE_OFFICE_HOURS
              + "' OR "
              + ScheduleContract.Blocks.NUM_STARRED_SESSIONS
              + ">0)";
      String excludeSandbox =
          "("
              + ScheduleContract.Blocks.BLOCK_TYPE
              + " != '"
              + ScheduleContract.Blocks.BLOCK_TYPE_SANDBOX
              + "')";
      mCursor =
          mContext
              .getContentResolver()
              .query(
                  ScheduleContract.Blocks.CONTENT_URI,
                  BlocksQuery.PROJECTION,
                  ScheduleContract.Blocks.BLOCK_END
                      + " >= ? AND "
                      + onlyStarredOfficeHoursSelection
                      + " AND "
                      + excludeSandbox,
                  new String[] {Long.toString(UIUtils.getCurrentTime(mContext))},
                  ScheduleContract.Blocks.DEFAULT_SORT);

      String displayTimeZone = PrefUtils.getDisplayTimeZone(mContext).getID();

      mSections = new ArrayList<SimpleSectionedListAdapter.Section>();
      mCursor.moveToFirst();
      long previousTime = -1;
      long time;
      mPMap = new SparseIntArray();
      mHeaderPositionMap = new SparseBooleanArray();
      int offset = 0;
      int globalPosition = 0;
      while (!mCursor.isAfterLast()) {
        time = mCursor.getLong(BlocksQuery.BLOCK_START);
        if (!UIUtils.isSameDayDisplay(previousTime, time, mContext)) {
          mBuffer.setLength(0);
          mSections.add(
              new SimpleSectionedListAdapter.Section(
                  mCursor.getPosition(),
                  DateUtils.formatDateRange(
                          mContext,
                          mFormatter,
                          time,
                          time,
                          DateUtils.FORMAT_ABBREV_MONTH
                              | DateUtils.FORMAT_SHOW_DATE
                              | DateUtils.FORMAT_SHOW_WEEKDAY,
                          displayTimeZone)
                      .toString()));
          ++offset;
          mHeaderPositionMap.put(globalPosition, true);
          mPMap.put(globalPosition, offset);
          ++globalPosition;
        }
        mHeaderPositionMap.put(globalPosition, false);
        mPMap.put(globalPosition, offset);
        ++globalPosition;
        previousTime = time;
        mCursor.moveToNext();
      }

      LOGV(TAG, "Leaving init()");
    }
  static {
    COMBINING.put('\u0300', (GRAVE >> 16) | COMBINING_ACCENT);
    COMBINING.put('\u0301', (ACUTE >> 16) | COMBINING_ACCENT);
    COMBINING.put('\u0302', (CIRCUMFLEX >> 16) | COMBINING_ACCENT);
    COMBINING.put('\u0303', (TILDE >> 16) | COMBINING_ACCENT);
    COMBINING.put('\u0308', (UMLAUT >> 16) | COMBINING_ACCENT);

    DEAD.put(ACUTE | 'A', '\u00C1');
    DEAD.put(ACUTE | 'C', '\u0106');
    DEAD.put(ACUTE | 'E', '\u00C9');
    DEAD.put(ACUTE | 'G', '\u01F4');
    DEAD.put(ACUTE | 'I', '\u00CD');
    DEAD.put(ACUTE | 'K', '\u1E30');
    DEAD.put(ACUTE | 'L', '\u0139');
    DEAD.put(ACUTE | 'M', '\u1E3E');
    DEAD.put(ACUTE | 'N', '\u0143');
    DEAD.put(ACUTE | 'O', '\u00D3');
    DEAD.put(ACUTE | 'P', '\u1E54');
    DEAD.put(ACUTE | 'R', '\u0154');
    DEAD.put(ACUTE | 'S', '\u015A');
    DEAD.put(ACUTE | 'U', '\u00DA');
    DEAD.put(ACUTE | 'W', '\u1E82');
    DEAD.put(ACUTE | 'Y', '\u00DD');
    DEAD.put(ACUTE | 'Z', '\u0179');
    DEAD.put(ACUTE | 'a', '\u00E1');
    DEAD.put(ACUTE | 'c', '\u0107');
    DEAD.put(ACUTE | 'e', '\u00E9');
    DEAD.put(ACUTE | 'g', '\u01F5');
    DEAD.put(ACUTE | 'i', '\u00ED');
    DEAD.put(ACUTE | 'k', '\u1E31');
    DEAD.put(ACUTE | 'l', '\u013A');
    DEAD.put(ACUTE | 'm', '\u1E3F');
    DEAD.put(ACUTE | 'n', '\u0144');
    DEAD.put(ACUTE | 'o', '\u00F3');
    DEAD.put(ACUTE | 'p', '\u1E55');
    DEAD.put(ACUTE | 'r', '\u0155');
    DEAD.put(ACUTE | 's', '\u015B');
    DEAD.put(ACUTE | 'u', '\u00FA');
    DEAD.put(ACUTE | 'w', '\u1E83');
    DEAD.put(ACUTE | 'y', '\u00FD');
    DEAD.put(ACUTE | 'z', '\u017A');
    DEAD.put(CIRCUMFLEX | 'A', '\u00C2');
    DEAD.put(CIRCUMFLEX | 'C', '\u0108');
    DEAD.put(CIRCUMFLEX | 'E', '\u00CA');
    DEAD.put(CIRCUMFLEX | 'G', '\u011C');
    DEAD.put(CIRCUMFLEX | 'H', '\u0124');
    DEAD.put(CIRCUMFLEX | 'I', '\u00CE');
    DEAD.put(CIRCUMFLEX | 'J', '\u0134');
    DEAD.put(CIRCUMFLEX | 'O', '\u00D4');
    DEAD.put(CIRCUMFLEX | 'S', '\u015C');
    DEAD.put(CIRCUMFLEX | 'U', '\u00DB');
    DEAD.put(CIRCUMFLEX | 'W', '\u0174');
    DEAD.put(CIRCUMFLEX | 'Y', '\u0176');
    DEAD.put(CIRCUMFLEX | 'Z', '\u1E90');
    DEAD.put(CIRCUMFLEX | 'a', '\u00E2');
    DEAD.put(CIRCUMFLEX | 'c', '\u0109');
    DEAD.put(CIRCUMFLEX | 'e', '\u00EA');
    DEAD.put(CIRCUMFLEX | 'g', '\u011D');
    DEAD.put(CIRCUMFLEX | 'h', '\u0125');
    DEAD.put(CIRCUMFLEX | 'i', '\u00EE');
    DEAD.put(CIRCUMFLEX | 'j', '\u0135');
    DEAD.put(CIRCUMFLEX | 'o', '\u00F4');
    DEAD.put(CIRCUMFLEX | 's', '\u015D');
    DEAD.put(CIRCUMFLEX | 'u', '\u00FB');
    DEAD.put(CIRCUMFLEX | 'w', '\u0175');
    DEAD.put(CIRCUMFLEX | 'y', '\u0177');
    DEAD.put(CIRCUMFLEX | 'z', '\u1E91');
    DEAD.put(GRAVE | 'A', '\u00C0');
    DEAD.put(GRAVE | 'E', '\u00C8');
    DEAD.put(GRAVE | 'I', '\u00CC');
    DEAD.put(GRAVE | 'N', '\u01F8');
    DEAD.put(GRAVE | 'O', '\u00D2');
    DEAD.put(GRAVE | 'U', '\u00D9');
    DEAD.put(GRAVE | 'W', '\u1E80');
    DEAD.put(GRAVE | 'Y', '\u1EF2');
    DEAD.put(GRAVE | 'a', '\u00E0');
    DEAD.put(GRAVE | 'e', '\u00E8');
    DEAD.put(GRAVE | 'i', '\u00EC');
    DEAD.put(GRAVE | 'n', '\u01F9');
    DEAD.put(GRAVE | 'o', '\u00F2');
    DEAD.put(GRAVE | 'u', '\u00F9');
    DEAD.put(GRAVE | 'w', '\u1E81');
    DEAD.put(GRAVE | 'y', '\u1EF3');
    DEAD.put(TILDE | 'A', '\u00C3');
    DEAD.put(TILDE | 'E', '\u1EBC');
    DEAD.put(TILDE | 'I', '\u0128');
    DEAD.put(TILDE | 'N', '\u00D1');
    DEAD.put(TILDE | 'O', '\u00D5');
    DEAD.put(TILDE | 'U', '\u0168');
    DEAD.put(TILDE | 'V', '\u1E7C');
    DEAD.put(TILDE | 'Y', '\u1EF8');
    DEAD.put(TILDE | 'a', '\u00E3');
    DEAD.put(TILDE | 'e', '\u1EBD');
    DEAD.put(TILDE | 'i', '\u0129');
    DEAD.put(TILDE | 'n', '\u00F1');
    DEAD.put(TILDE | 'o', '\u00F5');
    DEAD.put(TILDE | 'u', '\u0169');
    DEAD.put(TILDE | 'v', '\u1E7D');
    DEAD.put(TILDE | 'y', '\u1EF9');
    DEAD.put(UMLAUT | 'A', '\u00C4');
    DEAD.put(UMLAUT | 'E', '\u00CB');
    DEAD.put(UMLAUT | 'H', '\u1E26');
    DEAD.put(UMLAUT | 'I', '\u00CF');
    DEAD.put(UMLAUT | 'O', '\u00D6');
    DEAD.put(UMLAUT | 'U', '\u00DC');
    DEAD.put(UMLAUT | 'W', '\u1E84');
    DEAD.put(UMLAUT | 'X', '\u1E8C');
    DEAD.put(UMLAUT | 'Y', '\u0178');
    DEAD.put(UMLAUT | 'a', '\u00E4');
    DEAD.put(UMLAUT | 'e', '\u00EB');
    DEAD.put(UMLAUT | 'h', '\u1E27');
    DEAD.put(UMLAUT | 'i', '\u00EF');
    DEAD.put(UMLAUT | 'o', '\u00F6');
    DEAD.put(UMLAUT | 't', '\u1E97');
    DEAD.put(UMLAUT | 'u', '\u00FC');
    DEAD.put(UMLAUT | 'w', '\u1E85');
    DEAD.put(UMLAUT | 'x', '\u1E8D');
    DEAD.put(UMLAUT | 'y', '\u00FF');
  }
Exemple #23
0
  @Override
  protected void onPostHandle(
      int requestType,
      Object data,
      boolean status,
      int paramInt2,
      Object paramObject2,
      Object paramObject3) {
    // TODO Auto-generated method stub
    super.onPostHandle(requestType, data, status, paramInt2, paramObject2, paramObject3);
    if (data == null) {
      mLoading.cancel();
      mBReqing = false;
      return;
    }

    ResHeadAndBody rslt = (ResHeadAndBody) data;

    if (mUaMap.size() == 0) {
      List<ExtraEntry> extra = rslt.getHeader().getExtra();
      if (extra != null && extra.size() > 0) {
        for (ExtraEntry en : extra) {
          Logger.LOGD("++extra: " + en.getKey() + ", " + en.getValue());
          mUaMap.put(en.getKey(), en.getValue());
        }
      }
    }

    // gson 将请求的数据,转为了ResponePList数据类型
    ResponePList plist = (ResponePList) rslt.getBody();
    List<PlayItemEntity> pList = plist.getpList();
    // 如果数据空,则页面相关信息不会被变更
    if (pList == null || pList.isEmpty()) {
      mLoading.cancel();
      mBReqing = false;
      return;
    }

    ResponsePager pg = (ResponsePager) rslt.getPage();
    if (pg != null) {
      if (mTotalPage == 0) {
        mTotalPage = pg.getPageCount();

        // 更新 集数分组
        mSetsAdapter.setSetCnt(pg.getCount()); // 总集数
        mSetsAdapter.notifyDataSetChanged();
        mSetsHList.setVisibility(View.VISIBLE);
      }

      mCurPg = pg.getPageIndex();
      if (mHadDataGetArr.indexOfKey(mCurPg) < 0) {
        mHadDataGetArr.put(mCurPg, 1); // 入库,即存在

        ArrayList<Integer> keys = new ArrayList<Integer>();
        for (int i = 0; i < mHadDataGetArr.size(); i++) {
          keys.add(mHadDataGetArr.keyAt(i));
        }

        // 计算 insertIdx,根据带插入的列表的集码对应的位置,进行计算在mData中的插入位置
        Collections.sort(keys);
        int curIdx = keys.indexOf(mCurPg);
        int insertIdx = PAGE_SIZE * curIdx; // [insertIdx, --)

        // 数据入库
        mData.addAll(insertIdx, plist.getpList()); // 在mData中insertIdx之前插入 plist.getpList()

        if (!mBfirstData) mHListView.setSelection(insertIdx);
      }
    }

    if (mBfirstData) {
      mHListView.setClickPos(0);
      mBfirstData = false;
      myPlay(mHListView.getClickPos());
    }

    /////////// 放在底部  每次请求要保存状态,保存状态  /////////////
    saveState(plist.getpList());

    mLoading.cancel();
    mBReqing = false;
  }
Exemple #24
0
  /**
   * binds decoded image from bitmaps array to an opengl resource and stores returned opengl
   * resource id in resources array android_resource_id -> opengl_resource_id
   *
   * @param gl
   * @param resource
   */
  public void bind(GL10 gl, int resource) {

    if (bitmaps.get(resource) == null || bitmaps.get(resource).isRecycled()) {
      System.out.println("image: bind bitmap null or recycled " + resource);
      return;
    } else {
      sizes.put(
          resource, new Size(bitmaps.get(resource).getWidth(), bitmaps.get(resource).getHeight()));
    }

    Size size = sizes.get(resource);

    int[] temp = new int[1];
    gl.glGenTextures(1, temp, 0);
    int id = temp[0];

    // System.out.println ("texture binding id is " + id);

    // int id = next (gl);
    images.put(resource, id);

    System.out.println("image: texture binding id is " + id);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, id);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);

    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);

    int width = (int) size.width;
    int height = (int) size.height;

    if (width != size.width) {
      width += 1;
    }

    if (height != size.height) {
      height += 1;
    }

    width = fix(width);
    height = fix(height);

    Bitmap resize = null;

    if (width != size.width || height != size.height) {
      // resize = Bitmap.createBitmap(bitmaps.get(resource), 0, 0, width, height);
      try {
        resize = Bitmap.createScaledBitmap(bitmaps.get(resource), width, height, false);
        bitmaps.get(resource).recycle();
        debug(
            "scale: scaling from "
                + size.width
                + "x"
                + size.height
                + " to "
                + width
                + "x"
                + height);
        // Bitmap.create
      } catch (OutOfMemoryError e) {

      }
    }

    if (resize != null) {
      GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, resize, 0);
      resize.recycle();
    } else {
      GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmaps.get(resource), 0);
      debug("scale: skipped for " + size.width + "x" + size.height + " image");
    }

    // Bitmap.createBitmap(source, x, y, width, height);

    System.out.println("image: bind success for image " + resource);

    if (bitmaps != null && bitmaps.get(resource) != null) {
      if (!bitmaps.get(resource).isRecycled()) {
        // sizes.put (resource, new Size (bitmaps.get(resource).getWidth (),
        // bitmaps.get(resource).getHeight ()));
        try {
          bitmaps.get(resource).recycle();
          System.out.println("image: putting size for " + resource);
        } catch (Exception e) {
          System.out.println("image: bind recycle unknow error for image " + resource);
        }
      } else {
        System.out.println("image: strange binded image " + resource + " already recycled");
      }
      bitmaps.remove(resource);
      System.out.println("image: removed binded resource " + resource);
    } else {
      System.out.println("image: strange binded image " + resource + " already unset");
    }
    if (world != null) {
      world.loaded(2);
    }
  }
 static {
   TWITTER_ERROR_CODE_MESSAGES.put(32, R.string.error_twitter_32);
   TWITTER_ERROR_CODE_MESSAGES.put(PAGE_NOT_FOUND, R.string.error_twitter_34);
   TWITTER_ERROR_CODE_MESSAGES.put(RATE_LIMIT_EXCEEDED, R.string.error_twitter_88);
   TWITTER_ERROR_CODE_MESSAGES.put(89, R.string.error_twitter_89);
   TWITTER_ERROR_CODE_MESSAGES.put(64, R.string.error_twitter_64);
   TWITTER_ERROR_CODE_MESSAGES.put(130, R.string.error_twitter_130);
   TWITTER_ERROR_CODE_MESSAGES.put(131, R.string.error_twitter_131);
   TWITTER_ERROR_CODE_MESSAGES.put(135, R.string.error_twitter_135);
   TWITTER_ERROR_CODE_MESSAGES.put(139, R.string.error_twitter_139);
   TWITTER_ERROR_CODE_MESSAGES.put(161, R.string.error_twitter_161);
   TWITTER_ERROR_CODE_MESSAGES.put(162, R.string.error_twitter_162);
   TWITTER_ERROR_CODE_MESSAGES.put(172, R.string.error_twitter_172);
   TWITTER_ERROR_CODE_MESSAGES.put(NOT_AUTHORIZED, R.string.error_twitter_179);
   TWITTER_ERROR_CODE_MESSAGES.put(STATUS_IS_DUPLICATE, R.string.error_twitter_187);
   TWITTER_ERROR_CODE_MESSAGES.put(193, R.string.error_twitter_193);
   TWITTER_ERROR_CODE_MESSAGES.put(215, R.string.error_twitter_215);
   HTTP_STATUS_CODE_MESSAGES.put(
       HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED, R.string.error_http_407);
 }
  private void initNavdataStrings() {
    emergencyStringMap = new SparseIntArray(17);

    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_CUTOUT, R.string.CUT_OUT_EMERGENCY);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_MOTORS, R.string.MOTORS_EMERGENCY);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_CAMERA, R.string.CAMERA_EMERGENCY);
    emergencyStringMap.put(
        NavData.ERROR_STATE_EMERGENCY_PIC_WATCHDOG, R.string.PIC_WATCHDOG_EMERGENCY);
    emergencyStringMap.put(
        NavData.ERROR_STATE_EMERGENCY_PIC_VERSION, R.string.PIC_VERSION_EMERGENCY);
    emergencyStringMap.put(
        NavData.ERROR_STATE_EMERGENCY_ANGLE_OUT_OF_RANGE, R.string.TOO_MUCH_ANGLE_EMERGENCY);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_VBAT_LOW, R.string.BATTERY_LOW_EMERGENCY);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_USER_EL, R.string.USER_EMERGENCY);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_ULTRASOUND, R.string.ULTRASOUND_EMERGENCY);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_UNKNOWN, R.string.UNKNOWN_EMERGENCY);
    emergencyStringMap.put(
        NavData.ERROR_STATE_NAVDATA_CONNECTION, R.string.CONTROL_LINK_NOT_AVAILABLE);
    emergencyStringMap.put(NavData.ERROR_STATE_START_NOT_RECEIVED, R.string.START_NOT_RECEIVED);
    emergencyStringMap.put(NavData.ERROR_STATE_ALERT_CAMERA, R.string.VIDEO_CONNECTION_ALERT);
    emergencyStringMap.put(NavData.ERROR_STATE_ALERT_VBAT_LOW, R.string.BATTERY_LOW_ALERT);
    emergencyStringMap.put(NavData.ERROR_STATE_ALERT_ULTRASOUND, R.string.ULTRASOUND_ALERT);
    emergencyStringMap.put(NavData.ERROR_STATE_ALERT_VISION, R.string.VISION_ALERT);
    emergencyStringMap.put(NavData.ERROR_STATE_EMERGENCY_UNKNOWN, R.string.UNKNOWN_EMERGENCY);
  }
Exemple #27
0
 /**
  * prepare sound resource
  *
  * @param sound
  */
 public void sound(int sound) {
   if (config.sound) {
     sounds.put(sound, this.sound.load(getBaseContext(), sound, 1));
   }
 }
 static {
   METADATA_KEYS_TYPE = new SparseIntArray(17);
   // NOTE: if adding to the list below, make sure you increment the array initialization size
   // keys with long values
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, METADATA_TYPE_LONG);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, METADATA_TYPE_LONG);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_DURATION, METADATA_TYPE_LONG);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_YEAR, METADATA_TYPE_LONG);
   // keys with String values
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_ALBUM, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_TITLE, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_ARTIST, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_AUTHOR, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_COMPILATION, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_COMPOSER, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_DATE, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_GENRE, METADATA_TYPE_STRING);
   METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_WRITER, METADATA_TYPE_STRING);
   // keys with Bitmap values
   METADATA_KEYS_TYPE.put(BITMAP_KEY_ARTWORK, METADATA_TYPE_BITMAP);
   // keys with Rating values
   METADATA_KEYS_TYPE.put(RATING_KEY_BY_OTHERS, METADATA_TYPE_RATING);
   METADATA_KEYS_TYPE.put(RATING_KEY_BY_USER, METADATA_TYPE_RATING);
 }
  @Override
  protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);
    if (mCallbacks != null) {
      if (getChildCount() > 0) {
        int firstVisiblePosition = getChildPosition(getChildAt(0));
        int lastVisiblePosition = getChildPosition(getChildAt(getChildCount() - 1));
        for (int i = firstVisiblePosition, j = 0; i <= lastVisiblePosition; i++, j++) {
          if (mChildrenHeights.indexOfKey(i) < 0
              || getChildAt(j).getHeight() != mChildrenHeights.get(i)) {
            mChildrenHeights.put(i, getChildAt(j).getHeight());
          }
        }

        View firstVisibleChild = getChildAt(0);
        if (firstVisibleChild != null) {
          if (mPrevFirstVisiblePosition < firstVisiblePosition) {
            // scroll down
            int skippedChildrenHeight = 0;
            if (firstVisiblePosition - mPrevFirstVisiblePosition != 1) {
              for (int i = firstVisiblePosition - 1; i > mPrevFirstVisiblePosition; i--) {
                if (0 < mChildrenHeights.indexOfKey(i)) {
                  skippedChildrenHeight += mChildrenHeights.get(i);
                } else {
                  // Approximate each item's height to the first visible child.
                  // It may be incorrect, but without this, scrollY will be broken
                  // when scrolling from the bottom.
                  skippedChildrenHeight += firstVisibleChild.getHeight();
                }
              }
            }
            mPrevScrolledChildrenHeight += mPrevFirstVisibleChildHeight + skippedChildrenHeight;
            mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
          } else if (firstVisiblePosition < mPrevFirstVisiblePosition) {
            // scroll up
            int skippedChildrenHeight = 0;
            if (mPrevFirstVisiblePosition - firstVisiblePosition != 1) {
              for (int i = mPrevFirstVisiblePosition - 1; i > firstVisiblePosition; i--) {
                if (0 < mChildrenHeights.indexOfKey(i)) {
                  skippedChildrenHeight += mChildrenHeights.get(i);
                } else {
                  // Approximate each item's height to the first visible child.
                  // It may be incorrect, but without this, scrollY will be broken
                  // when scrolling from the bottom.
                  skippedChildrenHeight += firstVisibleChild.getHeight();
                }
              }
            }
            mPrevScrolledChildrenHeight -= firstVisibleChild.getHeight() + skippedChildrenHeight;
            mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
          } else if (firstVisiblePosition == 0) {
            mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
          }
          if (mPrevFirstVisibleChildHeight < 0) {
            mPrevFirstVisibleChildHeight = 0;
          }
          mScrollY = mPrevScrolledChildrenHeight - firstVisibleChild.getTop();
          mPrevFirstVisiblePosition = firstVisiblePosition;

          mCallbacks.onScrollChanged(mScrollY, mFirstScroll, mDragging);
          if (mFirstScroll) {
            mFirstScroll = false;
          }

          if (mPrevScrollY < mScrollY) {
            // down
            mScrollState = ScrollState.UP;
          } else if (mScrollY < mPrevScrollY) {
            // up
            mScrollState = ScrollState.DOWN;
          } else {
            mScrollState = ScrollState.STOP;
          }
          mPrevScrollY = mScrollY;
        }
      }
    }
  }
 private KeyCodeDescriptionMapper() {
   // Special non-character codes defined in Keyboard
   mKeyCodeMap.put(Constants.CODE_SPACE, R.string.spoken_description_space);
   mKeyCodeMap.put(Constants.CODE_DELETE, R.string.spoken_description_delete);
   mKeyCodeMap.put(Constants.CODE_ENTER, R.string.spoken_description_return);
   mKeyCodeMap.put(Constants.CODE_SETTINGS, R.string.spoken_description_settings);
   mKeyCodeMap.put(Constants.CODE_SHIFT, R.string.spoken_description_shift);
   mKeyCodeMap.put(Constants.CODE_SHORTCUT, R.string.spoken_description_mic);
   mKeyCodeMap.put(Constants.CODE_SWITCH_ALPHA_SYMBOL, R.string.spoken_description_to_symbol);
   mKeyCodeMap.put(Constants.CODE_TAB, R.string.spoken_description_tab);
   mKeyCodeMap.put(Constants.CODE_LANGUAGE_SWITCH, R.string.spoken_description_language_switch);
   mKeyCodeMap.put(Constants.CODE_ACTION_NEXT, R.string.spoken_description_action_next);
   mKeyCodeMap.put(Constants.CODE_ACTION_PREVIOUS, R.string.spoken_description_action_previous);
   mKeyCodeMap.put(Constants.CODE_EMOJI, R.string.spoken_description_emoji);
   // Because the upper-case and lower-case mappings of the following letters is depending on
   // the locale, the upper case descriptions should be defined here. The lower case
   // descriptions are handled in {@link #getSpokenLetterDescriptionId(Context,int)}.
   // U+0049: "I" LATIN CAPITAL LETTER I
   // U+0069: "i" LATIN SMALL LETTER I
   // U+0130: "İ" LATIN CAPITAL LETTER I WITH DOT ABOVE
   // U+0131: "ı" LATIN SMALL LETTER DOTLESS I
   mKeyCodeMap.put(0x0049, R.string.spoken_letter_0049);
   mKeyCodeMap.put(0x0130, R.string.spoken_letter_0130);
 }