use of android.view.LayoutInflater in project photo-picker-plus-android by chute.
the class GridAdapter method onCreateViewHolder.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = null;
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
itemView = layoutInflater.inflate(R.layout.gc_grid_adapter_item, parent, false);
return new ViewHolder(itemView);
}
use of android.view.LayoutInflater in project cw-omnibus by commonsguy.
the class ConstantsFragment method add.
private void add() {
LayoutInflater inflater = getActivity().getLayoutInflater();
View addView = inflater.inflate(R.layout.add_edit, null);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.add_title).setView(addView).setPositiveButton(R.string.ok, this).setNegativeButton(R.string.cancel, null).show();
}
use of android.view.LayoutInflater in project SimplifyReader by chentao0707.
the class CommonImagePickerDetailActivity method initViewsAndEvents.
@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();
}
}
});
}
use of android.view.LayoutInflater in project SimplifyReader by chentao0707.
the class CommonImagePickerListActivity method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
setTitle(getResources().getString(R.string.title_image_picker));
mListViewAdapter = new ListViewDataAdapter<ImageBucket>(new ViewHolderCreator<ImageBucket>() {
@Override
public ViewHolderBase<ImageBucket> createViewHolder(int position) {
return new ViewHolderBase<ImageBucket>() {
ImageView mItemImage;
TextView mItemTitle;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_common_image_picker, null);
mItemImage = ButterKnife.findById(convertView, R.id.list_item_common_image_picker_thumbnail);
mItemTitle = ButterKnife.findById(convertView, R.id.list_item_common_image_picker_title);
return convertView;
}
@Override
public void showData(int position, ImageBucket itemData) {
if (null != itemData) {
String imagePath = itemData.bucketList.get(0).getImagePath();
if (!CommonUtils.isEmpty(imagePath)) {
ImageLoader.getInstance().displayImage("file://" + imagePath, mItemImage, ImageLoaderHelper.getInstance(mContext).getDisplayOptions());
}
int count = itemData.count;
String title = itemData.bucketName;
if (!CommonUtils.isEmpty(title)) {
mItemTitle.setText(title + "(" + count + ")");
}
}
}
};
}
});
mImagePickerListView.setAdapter(mListViewAdapter);
mImagePickerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (null != mListViewAdapter && null != mListViewAdapter.getDataList() && !mListViewAdapter.getDataList().isEmpty() && position < mListViewAdapter.getDataList().size()) {
Bundle extras = new Bundle();
extras.putParcelableArrayList(KEY_BUNDLE_ALBUM_PATH, mListViewAdapter.getDataList().get(position).bucketList);
extras.putString(KEY_BUNDLE_ALBUM_NAME, mListViewAdapter.getDataList().get(position).bucketName);
readyGoForResult(CommonImagePickerDetailActivity.class, IMAGE_PICKER_DETAIL_REQUEST_CODE, extras);
}
}
});
mAlbumLoadTask = new AsyncTask<Void, Void, List<ImageBucket>>() {
@Override
protected void onPreExecute() {
super.onPreExecute();
toggleShowLoading(true, null);
ImagePickerHelper.getHelper().init(mContext);
}
@Override
protected List<ImageBucket> doInBackground(Void... params) {
return ImagePickerHelper.getHelper().getImagesBucketList();
}
@Override
protected void onPostExecute(List<ImageBucket> list) {
toggleShowLoading(false, null);
mListViewAdapter.getDataList().addAll(list);
mListViewAdapter.notifyDataSetChanged();
}
};
mAlbumLoadTask.execute();
}
use of android.view.LayoutInflater in project SimplifyReader by chentao0707.
the class HomeActivity method initializeViews.
@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);
}
});
}
Aggregations