Search in sources :

Example 1 with AdapterView

use of android.widget.AdapterView in project MaterialEverywhere by antoniolg.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setActionBarIcon(R.drawable.ic_ab_drawer);
    GridView gridView = (GridView) findViewById(R.id.gridView);
    gridView.setAdapter(new GridViewAdapter());
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String url = (String) view.getTag();
            DetailActivity.launch(HomeActivity.this, view.findViewById(R.id.image), url);
        }
    });
    drawer = (DrawerLayout) findViewById(R.id.drawer);
    drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
}
Also used : AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 2 with AdapterView

use of android.widget.AdapterView in project cw-omnibus by commonsguy.

the class IcsListPopupWindow method buildDropDown.

private int buildDropDown() {
    ViewGroup dropDownView;
    int otherHeights = 0;
    if (mDropDownList == null) {
        Context context = mContext;
        mDropDownList = new DropDownListView(context, !mModal);
        if (mDropDownListHighlight != null) {
            mDropDownList.setSelector(mDropDownListHighlight);
        }
        mDropDownList.setAdapter(mAdapter);
        mDropDownList.setOnItemClickListener(mItemClickListener);
        mDropDownList.setFocusable(true);
        mDropDownList.setFocusableInTouchMode(true);
        mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (position != -1) {
                    DropDownListView dropDownList = mDropDownList;
                    if (dropDownList != null) {
                        dropDownList.mListSelectionHidden = false;
                    }
                }
            }

            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        mDropDownList.setOnScrollListener(mScrollListener);
        if (mItemSelectedListener != null) {
            mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
        }
        dropDownView = mDropDownList;
        View hintView = mPromptView;
        if (hintView != null) {
            // if an hint has been specified, we accomodate more space for it and
            // add a text view in the drop down menu, at the bottom of the list
            LinearLayout hintContainer = new LinearLayout(context);
            hintContainer.setOrientation(LinearLayout.VERTICAL);
            LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f);
            switch(mPromptPosition) {
                case POSITION_PROMPT_BELOW:
                    hintContainer.addView(dropDownView, hintParams);
                    hintContainer.addView(hintView);
                    break;
                case POSITION_PROMPT_ABOVE:
                    hintContainer.addView(hintView);
                    hintContainer.addView(dropDownView, hintParams);
                    break;
                default:
                    break;
            }
            // measure the hint's height to find how much more vertical space
            // we need to add to the drop down's height
            int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST);
            int heightSpec = MeasureSpec.UNSPECIFIED;
            hintView.measure(widthSpec, heightSpec);
            hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams();
            otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
            dropDownView = hintContainer;
        }
        mPopup.setContentView(dropDownView);
    } else {
        dropDownView = (ViewGroup) mPopup.getContentView();
        final View view = mPromptView;
        if (view != null) {
            LinearLayout.LayoutParams hintParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            otherHeights = view.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
        }
    }
    // getMaxAvailableHeight() subtracts the padding, so we put it back
    // to get the available height for the whole window
    int padding = 0;
    Drawable background = mPopup.getBackground();
    if (background != null) {
        background.getPadding(mTempRect);
        padding = mTempRect.top + mTempRect.bottom;
        // background so that content will line up.
        if (!mDropDownVerticalOffsetSet) {
            mDropDownVerticalOffset = -mTempRect.top;
        }
    }
    // Max height available on the screen for a popup.
    boolean ignoreBottomDecorations = mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
    final int maxHeight = /*mPopup.*/
    getMaxAvailableHeight(mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations);
    if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
        return maxHeight + padding;
    }
    final int listContent = /*mDropDownList.*/
    measureHeightOfChildren(MeasureSpec.UNSPECIFIED, 0, -1, /*ListView.NO_POSITION*/
    maxHeight - otherHeights, -1);
    // the popup if it is not needed
    if (listContent > 0)
        otherHeights += padding;
    return listContent + otherHeights;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout)

Example 3 with AdapterView

use of android.widget.AdapterView in project UltimateAndroid by cymcsg.

the class SnackbarListViewSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.snack_bar_activity_list_sample);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final ListView listView = (ListView) findViewById(android.R.id.list);
    List<String> data = new ArrayList<String>();
    for (int i = 0; i < 25; i++) {
        data.add(String.format("Item %d", (i + 1)));
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SnackbarManager.show(Snackbar.with(SnackbarListViewSampleActivity.this).text(String.format("Item %d pressed", (position + 1))).actionLabel("Close").actionColor(Color.parseColor("#FF8A80")).duration(Snackbar.SnackbarDuration.LENGTH_LONG).attachToAbsListView(listView));
        }
    });
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with AdapterView

use of android.widget.AdapterView 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 5 with AdapterView

use of android.widget.AdapterView 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)

Aggregations

AdapterView (android.widget.AdapterView)650 View (android.view.View)626 ListView (android.widget.ListView)393 TextView (android.widget.TextView)325 Intent (android.content.Intent)171 ImageView (android.widget.ImageView)166 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)135 ArrayAdapter (android.widget.ArrayAdapter)73 ArrayList (java.util.ArrayList)67 ViewGroup (android.view.ViewGroup)60 AbsListView (android.widget.AbsListView)57 GridView (android.widget.GridView)55 Bundle (android.os.Bundle)52 Spinner (android.widget.Spinner)49 LinearLayout (android.widget.LinearLayout)47 OnClickListener (android.view.View.OnClickListener)44 RecyclerView (android.support.v7.widget.RecyclerView)39 SuppressLint (android.annotation.SuppressLint)37 DialogInterface (android.content.DialogInterface)37 Context (android.content.Context)30