本文整理汇总了Java中com.github.obsessive.library.adapter.ListViewDataAdapter类的典型用法代码示例。如果您正苦于以下问题:Java ListViewDataAdapter类的具体用法?Java ListViewDataAdapter怎么用?Java ListViewDataAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListViewDataAdapter类属于com.github.obsessive.library.adapter包,在下文中一共展示了ListViewDataAdapter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initViewsAndEvents
import com.github.obsessive.library.adapter.ListViewDataAdapter; //导入依赖的package包/类
@Override
protected void initViewsAndEvents() {
mListViewAdapter = new ListViewDataAdapter<ImagesListEntity>(new ViewHolderCreator<ImagesListEntity>() {
@Override
public ViewHolderBase<ImagesListEntity> createViewHolder(int position) {
return new ViewHolderBase<ImagesListEntity>() {
PLAImageView mItemImage;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_images_list, null);
mItemImage = ButterKnife.findById(convertView, R.id.list_item_images_list_image);
return convertView;
}
@Override
public void showData(int position, ImagesListEntity itemData) {
int width = itemData.getThumbnailWidth();
int height = itemData.getThumbnailHeight();
String imageUrl = itemData.getThumbnailUrl();
if (!CommonUtils.isEmpty(imageUrl)) {
ImageLoader.getInstance().displayImage(imageUrl, mItemImage);
}
mItemImage.setImageWidth(width);
mItemImage.setImageHeight(height);
}
};
}
});
mListView.setOnItemClickListener(this);
mListView.setOnLoadMoreListener(this);
mListView.setAdapter(mListViewAdapter);
mSwipeRefreshLayout.setColorSchemeColors(
getResources().getColor(R.color.gplus_color_1),
getResources().getColor(R.color.gplus_color_2),
getResources().getColor(R.color.gplus_color_3),
getResources().getColor(R.color.gplus_color_4));
mSwipeRefreshLayout.setOnRefreshListener(this);
}
示例2: initViewsAndEvents
import com.github.obsessive.library.adapter.ListViewDataAdapter; //导入依赖的package包/类
@Override
protected void initViewsAndEvents() {
mListViewAdapter = new ListViewDataAdapter<VideosListEntity>(new ViewHolderCreator<VideosListEntity>() {
@Override
public ViewHolderBase<VideosListEntity> createViewHolder(int position) {
return new ViewHolderBase<VideosListEntity>() {
TextView mItemTitle;
ImageView mItemImage;
ImageButton mItemPlay;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_videos_card, null);
mItemTitle = ButterKnife.findById(convertView, R.id.list_item_videos_card_title);
mItemImage = ButterKnife.findById(convertView, R.id.list_item_videos_card_image);
mItemPlay = ButterKnife.findById(convertView, R.id.list_item_videos_card_play);
return convertView;
}
@Override
public void showData(final int position, VideosListEntity itemData) {
if (null != itemData) {
if (!CommonUtils.isEmpty(itemData.getTitle())) {
mItemTitle.setText(CommonUtils.decodeUnicodeStr(itemData.getTitle()));
}
if (!CommonUtils.isEmpty(itemData.getThumbnail_v2())) {
ImageLoader.getInstance().displayImage(itemData.getThumbnail_v2(), mItemImage);
}
mItemPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListViewAdapter) {
if (position >= 0 && position < mListViewAdapter.getDataList().size()) {
mVideosListPresenter.onItemClickListener(position, mListViewAdapter.getDataList().get(position));
}
}
}
});
}
}
};
}
});
mMultiItemRowListAdapter = new MultiItemRowListAdapter(mContext, mListViewAdapter, 1, 0);
mListView.setAdapter(mMultiItemRowListAdapter);
mListView.setOnLoadMoreListener(this);
mSwipeRefreshLayout.setColorSchemeColors(
getResources().getColor(R.color.gplus_color_1),
getResources().getColor(R.color.gplus_color_2),
getResources().getColor(R.color.gplus_color_3),
getResources().getColor(R.color.gplus_color_4));
mSwipeRefreshLayout.setOnRefreshListener(this);
}
示例3: initViewsAndEvents
import com.github.obsessive.library.adapter.ListViewDataAdapter; //导入依赖的package包/类
@Override
protected void initViewsAndEvents() {
mGridViewAdapter = new ListViewDataAdapter<>(new ViewHolderCreator<ImageItem>() {
@Override
public ViewHolderBase<ImageItem> createViewHolder(int position) {
return new ViewHolderBase<ImageItem>() {
ImageView mItemImage;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.grid_item_common_image_picker, null);
mItemImage = ButterKnife.findById(convertView, R.id.grid_item_common_image_picker_image);
return convertView;
}
@Override
public void showData(int position, ImageItem itemData) {
if (null != itemData) {
String imagePath = itemData.getImagePath();
if (!CommonUtils.isEmpty(imagePath)) {
ImageLoader.getInstance().displayImage("file://" + imagePath,
mItemImage, ImageLoaderHelper.getInstance(mContext).getDisplayOptions());
}
}
}
};
}
});
mGridViewAdapter.getDataList().addAll(mGridListData);
commonImagePickerDetailGridView.setAdapter(mGridViewAdapter);
commonImagePickerDetailGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (null != mGridViewAdapter && null != mGridViewAdapter.getDataList() &&
!mGridViewAdapter.getDataList().isEmpty() &&
position < mGridViewAdapter.getDataList().size()) {
Intent intent = new Intent();
intent.putExtra(KEY_BUNDLE_RESULT_IMAGE_PATH,
mGridViewAdapter.getDataList().get(position).getImagePath());
setResult(RESULT_OK, intent);
finish();
}
}
});
}
示例4: initializeViews
import com.github.obsessive.library.adapter.ListViewDataAdapter; //导入依赖的package包/类
@Override
public void initializeViews(List<BaseLazyFragment> fragments, List<NavigationEntity> navigationList) {
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
setTitle(getString(R.string.app_name));
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (null != mNavListAdapter) {
setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
}
}
};
mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
if (null != fragments && !fragments.isEmpty()) {
mViewPager.setEnableScroll(false);
mViewPager.setOffscreenPageLimit(fragments.size());
mViewPager.setAdapter(new VPFragmentAdapter(getSupportFragmentManager(), fragments));
}
mNavListAdapter = new ListViewDataAdapter<NavigationEntity>(new ViewHolderCreator<NavigationEntity>() {
@Override
public ViewHolderBase<NavigationEntity> createViewHolder(int position) {
return new ViewHolderBase<NavigationEntity>() {
ImageView itemIcon;
TextView itemName;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_navigation, null);
itemIcon = ButterKnife.findById(convertView, R.id.list_item_navigation_icon);
itemName = ButterKnife.findById(convertView, R.id.list_item_navigation_name);
return convertView;
}
@Override
public void showData(int i, NavigationEntity navigationEntity) {
itemIcon.setImageResource(navigationEntity.getIconResId());
itemName.setText(navigationEntity.getName());
if (mCurrentMenuCheckedPos == i) {
// checked
itemName.setTextColor(getResources().getColor(mCheckedListItemColorResIds[i]));
} else {
// unchecked
itemName.setTextColor(getResources().getColor(android.R.color.black));
}
}
};
}
});
mNavListView.setAdapter(mNavListAdapter);
mNavListAdapter.getDataList().addAll(navigationList);
mNavListAdapter.notifyDataSetChanged();
setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
mNavListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mCurrentMenuCheckedPos = position;
mNavListAdapter.notifyDataSetChanged();
mDrawerLayout.closeDrawer(Gravity.LEFT);
mViewPager.setCurrentItem(mCurrentMenuCheckedPos, false);
}
});
}