@Override
    protected void addGroups(Cursor cursor) {

      int count = cursor.getCount();
      if (count == 0) {
        return;
      }

      int groupItemCount = 1;

      CharArrayBuffer currentValue = mBuffer1;
      CharArrayBuffer value = mBuffer2;
      cursor.moveToFirst();
      cursor.copyStringToBuffer(NUMBER_COLUMN_INDEX, currentValue);
      int currentCallType = cursor.getInt(CALL_TYPE_COLUMN_INDEX);
      for (int i = 1; i < count; i++) {
        cursor.moveToNext();
        cursor.copyStringToBuffer(NUMBER_COLUMN_INDEX, value);
        boolean sameNumber = equalPhoneNumbers(value, currentValue);

        // Group adjacent calls with the same number. Make an exception
        // for the latest item if it was a missed call.  We don't want
        // a missed call to be hidden inside a group.
        if (sameNumber && currentCallType != Calls.MISSED_TYPE) {
          groupItemCount++;
        } else {
          if (groupItemCount > 1) {
            addGroup(i - groupItemCount, groupItemCount, false);
          }

          groupItemCount = 1;

          // Swap buffers
          CharArrayBuffer temp = currentValue;
          currentValue = value;
          value = temp;

          // If we have just examined a row following a missed call, make
          // sure that it is grouped with subsequent calls from the same number
          // even if it was also missed.
          if (sameNumber && currentCallType == Calls.MISSED_TYPE) {
            currentCallType = 0; // "not a missed call"
          } else {
            currentCallType = cursor.getInt(CALL_TYPE_COLUMN_INDEX);
          }
        }
      }
      if (groupItemCount > 1) {
        addGroup(count - groupItemCount, groupItemCount, false);
      }
    }
Пример #2
0
 /**
  * Returns a String that holds the current value of the column, optimizing for the case where
  * the value hasn't changed.
  */
 private String getString(String old, String column) {
   int index = mCursor.getColumnIndexOrThrow(column);
   if (old == null) {
     return mCursor.getString(index);
   }
   if (mNewChars == null) {
     mNewChars = new CharArrayBuffer(128);
   }
   mCursor.copyStringToBuffer(index, mNewChars);
   int length = mNewChars.sizeCopied;
   if (length != old.length()) {
     return new String(mNewChars.data, 0, length);
   }
   if (mOldChars == null || mOldChars.sizeCopied < length) {
     mOldChars = new CharArrayBuffer(length);
   }
   char[] oldArray = mOldChars.data;
   char[] newArray = mNewChars.data;
   old.getChars(0, length, oldArray, 0);
   for (int i = length - 1; i >= 0; --i) {
     if (oldArray[i] != newArray[i]) {
       return new String(newArray, 0, length);
     }
   }
   return old;
 }
  @Override
  public void setData(Cursor c) {
    final String imageUrl = c.getString(YANAContract.ArticleTable.PROJ_LIST.IMAGE_URL);
    if (!TextUtils.isEmpty(imageUrl)) {
      mImageLoader.displayImage(imageUrl, mImage);
    }

    final CharArrayBuffer titleBuffer = mTitleBuffer;
    c.copyStringToBuffer(YANAContract.ArticleTable.PROJ_LIST.TITLE, titleBuffer);
    mTitle.setText(titleBuffer.data, 0, titleBuffer.sizeCopied);
  }
Пример #4
0
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
      ViewHolder vh = (ViewHolder) view.getTag();

      cursor.copyStringToBuffer(mTitleIdx, vh.buffer1);
      vh.line1.setText(vh.buffer1.data, 0, vh.buffer1.sizeCopied);

      final int secondUnit = 1000;
      int secs = cursor.getInt(mDurationIdx) / secondUnit;
      if (secs == 0) {
        vh.duration.setText("");
      } else {
        vh.duration.setText(MusicUtils.makeTimeString(context, secs));
      }

      final StringBuilder builder = mBuilder;
      builder.delete(0, builder.length());

      String name = cursor.getString(mAlbumIdx);
      if (name == null || name.equals("<unknown>")) {
        builder.append(mUnknownAlbum);
      } else {
        builder.append(name);
      }
      builder.append('\n');
      name = cursor.getString(mArtistIdx);
      if (name == null || name.equals("<unknown>")) {
        builder.append(mUnknownArtist);
      } else {
        builder.append(name);
      }
      int len = builder.length();
      if (vh.buffer2.length < len) {
        vh.buffer2 = new char[len];
      }
      builder.getChars(0, len, vh.buffer2, 0);
      vh.line2.setText(vh.buffer2, 0, len);

      // Update the checkbox of the item, based on which the user last
      // selected.  Note that doing it this way means we must have the
      // list view update all of its items when the selected item
      // changes.
      final long id = cursor.getLong(mIdIdx);
      vh.radio.setChecked(id == mSelectedId);
      MusicLogUtils.v(
          TAG,
          "Binding id="
              + id
              + " sel="
              + mSelectedId
              + " playing="
              + mPlayingId
              + " cursor="
              + cursor);

      // Likewise, display the "now playing" icon if this item is
      // currently being previewed for the user.
      ImageView iv = vh.play_indicator;
      if (id == mPlayingId) {
        iv.setVisibility(View.VISIBLE);
      } else {
        /// M: if current song is not playing , we don't need the ImageView of play_indicator
        // visible.
        iv.setVisibility(View.GONE);
      }

      /// M:  Show drm lock when necessary @{
      updateDrmLockIcon(vh.drmLock, cursor, id);
    }
Пример #5
0
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
      ViewHolder vh = (ViewHolder) view.getTag();

      cursor.copyStringToBuffer(mTitleIdx, vh.buffer1);
      vh.line1.setText(vh.buffer1.data, 0, vh.buffer1.sizeCopied);

      int secs = cursor.getInt(mDurationIdx) / 1000;
      if (secs == 0) {
        vh.duration.setText("");
      } else {
        vh.duration.setText(MusicUtils.makeTimeString(context, secs));
      }

      final StringBuilder builder = mBuilder;
      builder.delete(0, builder.length());

      String name = cursor.getString(mAlbumIdx);
      if (name == null || name.equals("<unknown>")) {
        builder.append(mUnknownAlbum);
      } else {
        builder.append(name);
      }
      builder.append('\n');
      name = cursor.getString(mArtistIdx);
      if (name == null || name.equals("<unknown>")) {
        builder.append(mUnknownArtist);
      } else {
        builder.append(name);
      }
      int len = builder.length();
      if (vh.buffer2.length < len) {
        vh.buffer2 = new char[len];
      }
      builder.getChars(0, len, vh.buffer2, 0);
      vh.line2.setText(vh.buffer2, 0, len);

      // Update the checkbox of the item, based on which the user last
      // selected.  Note that doing it this way means we must have the
      // list view update all of its items when the selected item
      // changes.
      final long id = cursor.getLong(mIdIdx);
      vh.radio.setChecked(id == mSelectedId);
      MusicLogUtils.v(
          TAG,
          "Binding id="
              + id
              + " sel="
              + mSelectedId
              + " playing="
              + mPlayingId
              + " cursor="
              + cursor);

      // Likewise, display the "now playing" icon if this item is
      // currently being previewed for the user.
      ImageView iv = vh.play_indicator;
      if (id == mPlayingId) {
        iv.setImageResource(R.drawable.indicator_ic_mp_playing_list);
        iv.setVisibility(View.VISIBLE);
      } else {
        iv.setVisibility(View.GONE);
      }

      // Show drm lock when necessary
      iv = vh.drm_lock;
      if (FeatureOption.MTK_DRM_APP) {
        int isDRM = cursor.getInt(mIsDrmIdx);
        int drmMethod = cursor.getInt(mDrmMethodIdx);
        MusicLogUtils.d(TAG, "bindView(" + view + "): isDRM=" + isDRM + ", drmMethod=" + drmMethod);
        try {
          if (isDRM == 1 && drmMethod != DrmStore.DrmMethod.METHOD_FL) {
            if (mDrmClient.checkRightsStatus(
                    ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id),
                    DrmStore.Action.PLAY)
                == DrmStore.RightsStatus.RIGHTS_VALID) {
              iv.setImageResource(com.mediatek.internal.R.drawable.drm_green_lock);
            } else {
              iv.setImageResource(com.mediatek.internal.R.drawable.drm_red_lock);
            }
            iv.setVisibility(View.VISIBLE);
          } else {
            iv.setVisibility(View.GONE);
          }
        } catch (Exception ex) {
          MusicLogUtils.e(TAG, "bindView: ", ex);
          iv.setVisibility(View.GONE);
        }
      } else {
        iv.setVisibility(View.GONE);
      }
    }
Пример #6
0
 public void bindViewToMediaListItem(View paramView, Context paramContext, Cursor paramCursor, long paramLong)
 {
   ViewHolder localViewHolder = (ViewHolder)paramView.getTag();
   Document localDocument = localViewHolder.document;
   TrackListAdapter localTrackListAdapter = this;
   Cursor localCursor1 = paramCursor;
   localTrackListAdapter.populateDocumentFromCursor(localDocument, localCursor1);
   int i = this.mTitleIdx;
   CharArrayBuffer localCharArrayBuffer1 = localViewHolder.titleBuffer;
   Cursor localCursor2 = paramCursor;
   CharArrayBuffer localCharArrayBuffer2 = localCharArrayBuffer1;
   localCursor2.copyStringToBuffer(i, localCharArrayBuffer2);
   StatefulShadowTextView localStatefulShadowTextView1 = localViewHolder.title;
   char[] arrayOfChar = localViewHolder.titleBuffer.data;
   int j = localViewHolder.titleBuffer.sizeCopied;
   localStatefulShadowTextView1.setText(arrayOfChar, 0, j);
   boolean bool1 = this.mSongList instanceof SharedSongList;
   boolean bool2;
   label183: int n;
   label226: label248: boolean bool3;
   label277: boolean bool4;
   if (localViewHolder.contextMenu != null)
   {
     if (bool1)
       localViewHolder.contextMenu.setVisibility(4);
   }
   else
   {
     bool2 = isShowingNowPlaying();
     if (localViewHolder.play_indicator != null)
     {
       bool2 = false;
       if (canShowPlaybackIndicator())
       {
         if (!bool2)
           break label787;
         int k = paramCursor.getPosition();
         int m = this.mCurrentPlayPosition;
         if (k == m)
           break label781;
         bool2 = true;
         if ((!bool2) && (((this.mSongList instanceof PlaylistSongList)) || ((this.mSongList instanceof SelectedSongList))))
           bool2 = false;
       }
       PlayingIndicator localPlayingIndicator = localViewHolder.play_indicator;
       if (!bool2)
         break label839;
       n = 0;
       localPlayingIndicator.setVisibility(n);
       if (!bool2)
         break label846;
       localViewHolder.title.setTypeface(null, 1);
     }
     if (!UIStateManager.getInstance().isStreamingEnabled())
     {
       int i1 = this.mIsLocalIdx;
       if (paramCursor.getInt(i1) == 0)
         break label859;
     }
     bool3 = true;
     localViewHolder.isAvailable = bool3;
     int i2 = this.mHasRemoteIdx;
     if (paramCursor.getInt(i2) == 0)
       break label865;
     bool4 = true;
     label304: localViewHolder.hasRemote = bool4;
     StatefulShadowTextView localStatefulShadowTextView2 = localViewHolder.title;
     boolean bool5 = true;
     localStatefulShadowTextView2.setPrimaryAndOnline(bool5, bool3);
     if (localViewHolder.duration != null)
     {
       StatefulShadowTextView localStatefulShadowTextView3 = localViewHolder.duration;
       boolean bool6 = true;
       localStatefulShadowTextView3.setPrimaryAndOnline(bool6, bool3);
     }
     if (localViewHolder.artist != null)
     {
       StatefulShadowTextView localStatefulShadowTextView4 = localViewHolder.artist;
       boolean bool7 = false;
       localStatefulShadowTextView4.setPrimaryAndOnline(bool7, bool3);
     }
     if (localViewHolder.album != null)
     {
       StatefulShadowTextView localStatefulShadowTextView5 = localViewHolder.album;
       boolean bool8 = true;
       localStatefulShadowTextView5.setPrimaryAndOnline(bool8, bool3);
     }
     if (localViewHolder.year != null)
     {
       StatefulShadowTextView localStatefulShadowTextView6 = localViewHolder.year;
       boolean bool9 = true;
       localStatefulShadowTextView6.setPrimaryAndOnline(bool9, bool3);
     }
     if ((localViewHolder.year != null) && (this.mYearIdx >= 0))
     {
       int i3 = this.mYearIdx;
       int i4 = paramCursor.getInt(i3);
       if (i4 <= 0)
         break label871;
       StatefulShadowTextView localStatefulShadowTextView7 = localViewHolder.year;
       String str1 = Integer.toString(i4);
       localStatefulShadowTextView7.setText(str1);
       localViewHolder.year.setVisibility(0);
     }
     label504: if (localViewHolder.album != null)
     {
       StatefulShadowTextView localStatefulShadowTextView8 = localViewHolder.album;
       String str2 = localViewHolder.document.getAlbumName();
       localStatefulShadowTextView8.setText(str2);
     }
     if (localViewHolder.artist != null)
     {
       if (!this.mShowTrackArtist)
         break label883;
       StatefulShadowTextView localStatefulShadowTextView9 = localViewHolder.artist;
       String str3 = localViewHolder.document.getArtistName();
       localStatefulShadowTextView9.setText(str3);
       localViewHolder.artist.setVisibility(0);
     }
     label584: if (localViewHolder.duration != null)
     {
       int i5 = this.mDurationIdx;
       int i6 = paramCursor.getInt(i5) / 1000;
       StatefulShadowTextView localStatefulShadowTextView10 = localViewHolder.duration;
       Context localContext = getContext();
       long l1 = i6;
       String str4 = MusicUtils.makeTimeString(localContext, l1);
       localStatefulShadowTextView10.setText(str4);
     }
     if (localViewHolder.icon != null)
     {
       if ((this.mShowAlbumArt) && (!bool1))
         break label896;
       localViewHolder.icon.setVisibility(8);
     }
     label676: if (bool2)
     {
       if (!isInInfiniteMixMode())
         break label985;
       int i7 = paramCursor.getCount();
       int i8 = paramCursor.getPosition();
       ViewUtils.fadeViewForPosition(paramView, i7, i8, 4);
     }
   }
   while (true)
   {
     if (!this.mEditMode)
       break label995;
     int i9 = paramView.getPaddingLeft();
     int i10 = paramView.getPaddingTop();
     int i11 = paramView.getPaddingRight();
     int i12 = paramView.getPaddingBottom();
     Drawable localDrawable = this.mDragHandleBG;
     paramView.setBackgroundDrawable(localDrawable);
     paramView.setPadding(i9, i10, i11, i12);
     return;
     localViewHolder.contextMenu.setVisibility(0);
     break;
     label781: bool2 = false;
     break label183;
     label787: if (this.mCurrentAudioId == null)
       break label183;
     int i13 = this.mAudioIdIdx;
     long l2 = paramCursor.getLong(i13);
     long l3 = this.mCurrentAudioId.getId();
     if (l2 == l3);
     for (bool2 = true; ; bool2 = false)
       break;
     label839: n = 8;
     break label226;
     label846: localViewHolder.title.setTypeface(null, 0);
     break label248;
     label859: bool3 = false;
     break label277;
     label865: bool4 = false;
     break label304;
     label871: localViewHolder.year.setVisibility(4);
     break label504;
     label883: localViewHolder.artist.setVisibility(8);
     break label584;
     label896: localViewHolder.icon.setVisibility(0);
     localViewHolder.icon.setAvailable(bool3);
     if (!TextUtils.isEmpty(localViewHolder.document.getArtUrl()))
     {
       AsyncAlbumArtImageView localAsyncAlbumArtImageView1 = localViewHolder.icon;
       String str5 = localViewHolder.document.getArtUrl();
       localAsyncAlbumArtImageView1.setExternalAlbumArt(str5);
       break label676;
     }
     AsyncAlbumArtImageView localAsyncAlbumArtImageView2 = localViewHolder.icon;
     long l4 = localViewHolder.document.getAlbumId();
     localAsyncAlbumArtImageView2.setAlbumId(l4, null, null);
     break label676;
     label985: ViewUtils.setAlpha(paramView, 1.0F);
   }
   label995: paramView.setBackgroundDrawable(null);
 }
 public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
   mDatabaseCursor.copyStringToBuffer(columnIndex, buffer);
 }