Java 类android.webkit.DateSorter 实例源码
项目:gaeproxy
文件:HistoryExpandableListAdapter.java
/**
* Constructor.
*
* @param context
* The current context.
* @param cursor
* The data cursor.
* @param dateIndex
* The date index ?
*/
public HistoryExpandableListAdapter(Context context, Cursor cursor,
int dateIndex, int faviconSize) {
mContext = context;
mCursor = cursor;
mDateIndex = dateIndex;
mFaviconSize = faviconSize;
mDateSorter = new DateSorter(mContext);
mIdIndex = cursor.getColumnIndexOrThrow(BaseColumns._ID);
mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
buildMap();
}
项目:gaeproxy
文件:HistoryExpandableListAdapter.java
/**
* Translates from a group position in the ExpandableList to a bin. This is
* necessary because some groups have no history items, so we do not include
* those in the ExpandableList.
*
* @param groupPosition
* Position in the ExpandableList's set of groups
* @return The corresponding bin that holds that group.
*/
private int groupPositionToBin(int groupPosition) {
if (groupPosition < 0 || groupPosition >= DateSorter.DAY_COUNT) {
throw new AssertionError("group position out of range");
}
if (DateSorter.DAY_COUNT == mNumberOfBins || 0 == mNumberOfBins) {
// In the first case, we have exactly the same number of bins
// as our maximum possible, so there is no need to do a
// conversion
// The second statement is in case this method gets called when
// the array is empty, in which case the provided groupPosition
// will do fine.
return groupPosition;
}
int arrayPosition = -1;
while (groupPosition > -1) {
arrayPosition++;
if (mItemMap[arrayPosition] != 0) {
groupPosition--;
}
}
return arrayPosition;
}
项目:zirco-browser
文件:HistoryExpandableListAdapter.java
/**
* Translates from a group position in the ExpandableList to a bin. This is
* necessary because some groups have no history items, so we do not include
* those in the ExpandableList.
* @param groupPosition Position in the ExpandableList's set of groups
* @return The corresponding bin that holds that group.
*/
private int groupPositionToBin(int groupPosition) {
if (groupPosition < 0 || groupPosition >= DateSorter.DAY_COUNT) {
throw new AssertionError("group position out of range");
}
if (DateSorter.DAY_COUNT == mNumberOfBins || 0 == mNumberOfBins) {
// In the first case, we have exactly the same number of bins
// as our maximum possible, so there is no need to do a
// conversion
// The second statement is in case this method gets called when
// the array is empty, in which case the provided groupPosition
// will do fine.
return groupPosition;
}
int arrayPosition = -1;
while (groupPosition > -1) {
arrayPosition++;
if (mItemMap[arrayPosition] != 0) {
groupPosition--;
}
}
return arrayPosition;
}
项目:android-downloadprovider
文件:DateSortedExpandableListAdapter.java
/**
* Determine which group an item belongs to.
* @param childId ID of the child view in question.
* @return int Group position of the containing group.
/* package */ int groupFromChildId(long childId) {
int group = -1;
for (mCursor.moveToFirst(); !mCursor.isAfterLast();
mCursor.moveToNext()) {
if (getLong(mIdIndex) == childId) {
int bin = mDateSorter.getIndex(getLong(mDateIndex));
// bin is the same as the group if the number of bins is the
// same as DateSorter
if (DateSorter.DAY_COUNT == mNumberOfBins) return bin;
// There are some empty bins. Find the corresponding group.
group = 0;
for (int i = 0; i < bin; i++) {
if (mItemMap[i] != 0) group++;
}
break;
}
}
return group;
}
项目:android-downloadprovider
文件:DateSortedExpandableListAdapter.java
/**
* Translates from a group position in the ExpandableList to a bin. This is
* necessary because some groups have no history items, so we do not include
* those in the ExpandableList.
* @param groupPosition Position in the ExpandableList's set of groups
* @return The corresponding bin that holds that group.
*/
private int groupPositionToBin(int groupPosition) {
if (groupPosition < 0 || groupPosition >= DateSorter.DAY_COUNT) {
throw new AssertionError("group position out of range");
}
if (DateSorter.DAY_COUNT == mNumberOfBins || 0 == mNumberOfBins) {
// In the first case, we have exactly the same number of bins
// as our maximum possible, so there is no need to do a
// conversion
// The second statement is in case this method gets called when
// the array is empty, in which case the provided groupPosition
// will do fine.
return groupPosition;
}
int arrayPosition = -1;
while (groupPosition > -1) {
arrayPosition++;
if (mItemMap[arrayPosition] != 0) {
groupPosition--;
}
}
return arrayPosition;
}
项目:ZircoBrowser
文件:HistoryExpandableListAdapter.java
/**
* Translates from a group position in the ExpandableList to a bin. This is
* necessary because some groups have no history items, so we do not include
* those in the ExpandableList.
* @param groupPosition Position in the ExpandableList's set of groups
* @return The corresponding bin that holds that group.
*/
private int groupPositionToBin(int groupPosition) {
if (groupPosition < 0 || groupPosition >= DateSorter.DAY_COUNT) {
throw new AssertionError("group position out of range");
}
if (DateSorter.DAY_COUNT == mNumberOfBins || 0 == mNumberOfBins) {
// In the first case, we have exactly the same number of bins
// as our maximum possible, so there is no need to do a
// conversion
// The second statement is in case this method gets called when
// the array is empty, in which case the provided groupPosition
// will do fine.
return groupPosition;
}
int arrayPosition = -1;
while (groupPosition > -1) {
arrayPosition++;
if (mItemMap[arrayPosition] != 0) {
groupPosition--;
}
}
return arrayPosition;
}
项目:wmc
文件:DateSortedExpandableListAdapter.java
/**
* Determine which group an item belongs to.
* @param childId ID of the child view in question.
* @return int Group position of the containing group.
/* package */ int groupFromChildId(long childId) {
int group = -1;
for (mCursor.moveToFirst(); !mCursor.isAfterLast();
mCursor.moveToNext()) {
if (getLong(mIdIndex) == childId) {
int bin = mDateSorter.getIndex(getLong(mDateIndex));
// bin is the same as the group if the number of bins is the
// same as DateSorter
if (DateSorter.DAY_COUNT == mNumberOfBins) return bin;
// There are some empty bins. Find the corresponding group.
group = 0;
for (int i = 0; i < bin; i++) {
if (mItemMap[i] != 0) group++;
}
break;
}
}
return group;
}
项目:wmc
文件:DateSortedExpandableListAdapter.java
/**
* Translates from a group position in the ExpandableList to a bin. This is
* necessary because some groups have no history items, so we do not include
* those in the ExpandableList.
* @param groupPosition Position in the ExpandableList's set of groups
* @return The corresponding bin that holds that group.
*/
private int groupPositionToBin(int groupPosition) {
if (groupPosition < 0 || groupPosition >= DateSorter.DAY_COUNT) {
throw new AssertionError("group position out of range");
}
if (DateSorter.DAY_COUNT == mNumberOfBins || 0 == mNumberOfBins) {
// In the first case, we have exactly the same number of bins
// as our maximum possible, so there is no need to do a
// conversion
// The second statement is in case this method gets called when
// the array is empty, in which case the provided groupPosition
// will do fine.
return groupPosition;
}
int arrayPosition = -1;
while (groupPosition > -1) {
arrayPosition++;
if (mItemMap[arrayPosition] != 0) {
groupPosition--;
}
}
return arrayPosition;
}
项目:ZicroBrowser
文件:HistoryExpandableListAdapter.java
/**
* Translates from a group position in the ExpandableList to a bin. This is
* necessary because some groups have no history items, so we do not include
* those in the ExpandableList.
* @param groupPosition Position in the ExpandableList's set of groups
* @return The corresponding bin that holds that group.
*/
private int groupPositionToBin(int groupPosition) {
if (groupPosition < 0 || groupPosition >= DateSorter.DAY_COUNT) {
throw new AssertionError("group position out of range");
}
if (DateSorter.DAY_COUNT == mNumberOfBins || 0 == mNumberOfBins) {
// In the first case, we have exactly the same number of bins
// as our maximum possible, so there is no need to do a
// conversion
// The second statement is in case this method gets called when
// the array is empty, in which case the provided groupPosition
// will do fine.
return groupPosition;
}
int arrayPosition = -1;
while (groupPosition > -1) {
arrayPosition++;
if (mItemMap[arrayPosition] != 0) {
groupPosition--;
}
}
return arrayPosition;
}
项目:gaeproxy
文件:HistoryExpandableListAdapter.java
/**
* Split the data in the cursor into several "bins": today, yesterday, last
* 7 days, last month, older.
*/
private void buildMap() {
int[] array = new int[DateSorter.DAY_COUNT];
// Zero out the array.
for (int j = 0; j < DateSorter.DAY_COUNT; j++) {
array[j] = 0;
}
mNumberOfBins = 0;
int dateIndex = -1;
if (mCursor.moveToFirst() && mCursor.getCount() > 0) {
while (!mCursor.isAfterLast()) {
long date = getLong(mDateIndex);
int index = mDateSorter.getIndex(date);
if (index > dateIndex) {
mNumberOfBins++;
if (index == DateSorter.DAY_COUNT - 1) {
// We are already in the last bin, so it will
// include all the remaining items
array[index] = mCursor.getCount()
- mCursor.getPosition();
break;
}
dateIndex = index;
}
array[dateIndex]++;
mCursor.moveToNext();
}
}
mItemMap = array;
}
项目:zirco-browser
文件:HistoryExpandableListAdapter.java
/**
* Constructor.
* @param context The current context.
* @param cursor The data cursor.
* @param dateIndex The date index ?
*/
public HistoryExpandableListAdapter(Context context, OnCheckedChangeListener bookmarksChangeListener, Cursor cursor, int dateIndex, int faviconSize) {
mContext = context;
mBookmarkStarChangeListener = bookmarksChangeListener;
mCursor = cursor;
mDateIndex = dateIndex;
mFaviconSize = faviconSize;
mDateSorter = new DateSorter(mContext);
mIdIndex = cursor.getColumnIndexOrThrow(BaseColumns._ID);
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
buildMap();
}
项目:zirco-browser
文件:HistoryExpandableListAdapter.java
/**
* Split the data in the cursor into several "bins": today, yesterday, last 7 days, last month, older.
*/
private void buildMap() {
int[] array = new int[DateSorter.DAY_COUNT];
// Zero out the array.
for (int j = 0; j < DateSorter.DAY_COUNT; j++) {
array[j] = 0;
}
mNumberOfBins = 0;
int dateIndex = -1;
if (mCursor.moveToFirst() && mCursor.getCount() > 0) {
while (!mCursor.isAfterLast()) {
long date = getLong(mDateIndex);
int index = mDateSorter.getIndex(date);
if (index > dateIndex) {
mNumberOfBins++;
if (index == DateSorter.DAY_COUNT - 1) {
// We are already in the last bin, so it will
// include all the remaining items
array[index] = mCursor.getCount()
- mCursor.getPosition();
break;
}
dateIndex = index;
}
array[dateIndex]++;
mCursor.moveToNext();
}
}
mItemMap = array;
}
项目:android-downloadprovider
文件:DateSortedExpandableListAdapter.java
public DateSortedExpandableListAdapter(Context context, Cursor cursor,
int dateIndex) {
mContext = context;
mDateSorter = new DateSorter(context);
mObservers = new Vector<DataSetObserver>();
mCursor = cursor;
mIdIndex = cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID);
cursor.registerContentObserver(new ChangeObserver());
cursor.registerDataSetObserver(new MyDataSetObserver());
mDateIndex = dateIndex;
buildMap();
}
项目:android-downloadprovider
文件:DateSortedExpandableListAdapter.java
/**
* Set up the bins for determining which items belong to which groups.
*/
private void buildMap() {
// The cursor is sorted by date
// The ItemMap will store the number of items in each bin.
int array[] = new int[DateSorter.DAY_COUNT];
// Zero out the array.
for (int j = 0; j < DateSorter.DAY_COUNT; j++) {
array[j] = 0;
}
mNumberOfBins = 0;
int dateIndex = -1;
if (mCursor.moveToFirst() && mCursor.getCount() > 0) {
while (!mCursor.isAfterLast()) {
long date = getLong(mDateIndex);
int index = mDateSorter.getIndex(date);
if (index > dateIndex) {
mNumberOfBins++;
if (index == DateSorter.DAY_COUNT - 1) {
// We are already in the last bin, so it will
// include all the remaining items
array[index] = mCursor.getCount()
- mCursor.getPosition();
break;
}
dateIndex = index;
}
array[dateIndex]++;
mCursor.moveToNext();
}
}
mItemMap = array;
}
项目:ZircoBrowser
文件:HistoryExpandableListAdapter.java
/**
* Constructor.
* @param context The current context.
* @param cursor The data cursor.
* @param dateIndex The date index ?
*/
public HistoryExpandableListAdapter(Context context, OnCheckedChangeListener bookmarksChangeListener, Cursor cursor, int dateIndex, int faviconSize) {
mContext = context;
mBookmarkStarChangeListener = bookmarksChangeListener;
mCursor = cursor;
mDateIndex = dateIndex;
mFaviconSize = faviconSize;
mDateSorter = new DateSorter(mContext);
mIdIndex = cursor.getColumnIndexOrThrow(BaseColumns._ID);
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
buildMap();
}
项目:ZircoBrowser
文件:HistoryExpandableListAdapter.java
/**
* Split the data in the cursor into several "bins": today, yesterday, last 7 days, last month, older.
*/
private void buildMap() {
int[] array = new int[DateSorter.DAY_COUNT];
// Zero out the array.
for (int j = 0; j < DateSorter.DAY_COUNT; j++) {
array[j] = 0;
}
mNumberOfBins = 0;
int dateIndex = -1;
if (mCursor.moveToFirst() && mCursor.getCount() > 0) {
while (!mCursor.isAfterLast()) {
long date = getLong(mDateIndex);
int index = mDateSorter.getIndex(date);
if (index > dateIndex) {
mNumberOfBins++;
if (index == DateSorter.DAY_COUNT - 1) {
// We are already in the last bin, so it will
// include all the remaining items
array[index] = mCursor.getCount()
- mCursor.getPosition();
break;
}
dateIndex = index;
}
array[dateIndex]++;
mCursor.moveToNext();
}
}
mItemMap = array;
}
项目:wmc
文件:DateSortedExpandableListAdapter.java
public DateSortedExpandableListAdapter(Context context, Cursor cursor,
int dateIndex) {
mContext = context;
mDateSorter = new DateSorter(context);
mObservers = new Vector<DataSetObserver>();
mCursor = cursor;
mIdIndex = cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID);
cursor.registerContentObserver(new ChangeObserver());
cursor.registerDataSetObserver(new MyDataSetObserver());
mDateIndex = dateIndex;
buildMap();
}
项目:wmc
文件:DateSortedExpandableListAdapter.java
/**
* Set up the bins for determining which items belong to which groups.
*/
private void buildMap() {
// The cursor is sorted by date
// The ItemMap will store the number of items in each bin.
int array[] = new int[DateSorter.DAY_COUNT];
// Zero out the array.
for (int j = 0; j < DateSorter.DAY_COUNT; j++) {
array[j] = 0;
}
mNumberOfBins = 0;
int dateIndex = -1;
if (mCursor.moveToFirst() && mCursor.getCount() > 0) {
while (!mCursor.isAfterLast()) {
long date = getLong(mDateIndex);
int index = mDateSorter.getIndex(date);
if (index > dateIndex) {
mNumberOfBins++;
if (index == DateSorter.DAY_COUNT - 1) {
// We are already in the last bin, so it will
// include all the remaining items
array[index] = mCursor.getCount()
- mCursor.getPosition();
break;
}
dateIndex = index;
}
array[dateIndex]++;
mCursor.moveToNext();
}
}
mItemMap = array;
}
项目:ZicroBrowser
文件:HistoryExpandableListAdapter.java
/**
* Constructor.
* @param context The current context.
* @param cursor The data cursor.
* @param dateIndex The date index ?
*/
public HistoryExpandableListAdapter(Context context, OnCheckedChangeListener bookmarksChangeListener, Cursor cursor, int dateIndex, int faviconSize) {
mContext = context;
mBookmarkStarChangeListener = bookmarksChangeListener;
mCursor = cursor;
mDateIndex = dateIndex;
mFaviconSize = faviconSize;
mDateSorter = new DateSorter(mContext);
mIdIndex = cursor.getColumnIndexOrThrow(BaseColumns._ID);
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
buildMap();
}
项目:ZicroBrowser
文件:HistoryExpandableListAdapter.java
/**
* Split the data in the cursor into several "bins": today, yesterday, last 7 days, last month, older.
*/
private void buildMap() {
int[] array = new int[DateSorter.DAY_COUNT];
// Zero out the array.
for (int j = 0; j < DateSorter.DAY_COUNT; j++) {
array[j] = 0;
}
mNumberOfBins = 0;
int dateIndex = -1;
if (mCursor.moveToFirst() && mCursor.getCount() > 0) {
while (!mCursor.isAfterLast()) {
long date = getLong(mDateIndex);
int index = mDateSorter.getIndex(date);
if (index > dateIndex) {
mNumberOfBins++;
if (index == DateSorter.DAY_COUNT - 1) {
// We are already in the last bin, so it will
// include all the remaining items
array[index] = mCursor.getCount()
- mCursor.getPosition();
break;
}
dateIndex = index;
}
array[dateIndex]++;
mCursor.moveToNext();
}
}
mItemMap = array;
}