Search in sources :

Example 1 with LayoutInflater

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);
}
Also used : LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 2 with LayoutInflater

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();
}
Also used : AlertDialog(android.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) View(android.view.View)

Example 3 with LayoutInflater

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();
            }
        }
    });
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) Intent(android.content.Intent) GridView(android.widget.GridView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) ImageItem(com.github.obsessive.library.picker.ImageItem) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator)

Example 4 with LayoutInflater

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();
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ImageBucket(com.github.obsessive.library.picker.ImageBucket) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) List(java.util.List) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator)

Example 5 with LayoutInflater

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);
        }
    });
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) HomeView(com.github.obsessive.simplifyreader.view.HomeView) TextView(android.widget.TextView) ListView(android.widget.ListView) NavigationEntity(com.github.obsessive.simplifyreader.bean.NavigationEntity) VPFragmentAdapter(com.github.obsessive.simplifyreader.ui.adpter.VPFragmentAdapter) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator)

Aggregations

LayoutInflater (android.view.LayoutInflater)1227 View (android.view.View)743 TextView (android.widget.TextView)570 ImageView (android.widget.ImageView)242 ViewGroup (android.view.ViewGroup)127 Context (android.content.Context)123 ListView (android.widget.ListView)115 LinearLayout (android.widget.LinearLayout)102 AdapterView (android.widget.AdapterView)94 RecyclerView (android.support.v7.widget.RecyclerView)87 Intent (android.content.Intent)81 DialogInterface (android.content.DialogInterface)74 AlertDialog (android.app.AlertDialog)71 FrameLayout (android.widget.FrameLayout)48 TypedArray (android.content.res.TypedArray)43 OnClickListener (android.view.View.OnClickListener)40 Button (android.widget.Button)40 Bundle (android.os.Bundle)39 Activity (android.app.Activity)38 AlertDialog (android.support.v7.app.AlertDialog)37