Search in sources :

Example 61 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SmartMesh_Android by SmartMeshFoundation.

the class FaceUtils method bindFaceToGridView.

/**
 * @param pageCount     Total number of pages
 * @param isGif         Group is a GIF
 * @param faceIds       The item resource files array
 * @param pageItemCount Total number of items per page
 *                      Binding expression images to the corresponding item
 */
private void bindFaceToGridView(int pageCount, final boolean isGif, Integer[] faceIds, String[] faceNameIds, final int pageItemCount) {
    ArrayList<GridView> pageViews = new ArrayList<>();
    GridView gridView;
    for (int i = 0; i < pageCount; i++) {
        gridView = new GridView(mContext);
        // GIF group four big expressions in a row, or buy into six small expression
        gridView.setNumColumns(isGif ? 4 : 6);
        gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
        gridView.setHorizontalSpacing(isGif ? 15 : 10);
        gridView.setVerticalSpacing(isGif ? 15 : 10);
        gridView.setGravity(Gravity.CENTER);
        gridView.setSelector(R.drawable.scrollview_item_bg);
        gridView.setPadding(0, 10, 0, 10);
        gridView.setAdapter(new ChatFaceAdapter(faceIds, faceNameIds, mContext, i, isGif));
        final int page = i;
        gridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (itemListener != null) {
                    // pageItemCount-1 In order to take off to delete the item
                    if (isGif) {
                        // Click on the GIF need to send out directly
                        itemListener.onItemListener(page, (page * pageItemCount) + position, isGif, false);
                    } else {
                        itemListener.onItemListener(page, page * (pageItemCount - 1) + position, isGif, position == pageItemCount - 1);
                    }
                }
            }
        });
        pageViews.add(gridView);
    }
    mViewPager.setAdapter(new ChatFacePagerAdapter(pageViews));
    indicator.setViewPager(mViewPager);
}
Also used : ChatFaceAdapter(com.lingtuan.firefly.chat.adapter.ChatFaceAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 62 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SmartMesh_Android by SmartMeshFoundation.

the class SelectContactUI method initSearchData.

/**
 *  Initializes the search related
 */
private void initSearchData(View headerView) {
    searchResultLayout = (LinearLayout) findViewById(R.id.contact_search_bg);
    searchResultLayout.setOnClickListener(this);
    searchListLayout = (FrameLayout) findViewById(R.id.contact_search_list_bg);
    mSearchListView = (ListView) findViewById(R.id.contact_search_lv);
    mSearchListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            UserBaseVo baseVo = mSearchAdapter.getItem(arg2);
            if (isMultipleChoice) {
                // multi-select
                if (baseVo.isCantChecked()) {
                    return;
                }
                baseVo.setChecked(!baseVo.isChecked());
                mSearchAdapter.notifyDataSetChanged();
                mNewContactListAdapter.notifyDataSetChanged();
                if (baseVo.isChecked()) {
                    final ImageView imageView = new ImageView(SelectContactUI.this);
                    imageView.setTag(baseVo.getLocalId());
                    imageView.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            clickSelectVo(imageView);
                        }
                    });
                    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Utils.dip2px(SelectContactUI.this, 40), Utils.dip2px(SelectContactUI.this, 40));
                    lp.setMargins(Utils.dip2px(SelectContactUI.this, 10), Utils.dip2px(SelectContactUI.this, 5), 0, 0);
                    mHorizontalScrollViewContent.addView(imageView, lp);
                    NextApplication.displayCircleImage(imageView, baseVo.getThumb());
                    selectList.add(baseVo);
                    new Handler().postDelayed(new Runnable() {

                        public void run() {
                            mHorizontalScrollView.smoothScrollTo(mHorizontalScrollViewContent.getChildCount() * Utils.dip2px(SelectContactUI.this, 50), 0);
                        }
                    }, 0);
                    if (hasSelectList == null && !mFinishBtn.isEnabled()) {
                        mFinishBtn.setEnabled(true);
                    }
                    if (hasSelectList != null) {
                        // Over the selected user data
                        hasSelectList.add(baseVo);
                    }
                } else {
                    int count = mHorizontalScrollViewContent.getChildCount();
                    for (int i = 0; i < count; i++) {
                        View imageView = mHorizontalScrollViewContent.getChildAt(i);
                        if (baseVo.getLocalId().equals(imageView.getTag())) {
                            mHorizontalScrollViewContent.removeViewAt(i);
                            break;
                        }
                    }
                    for (int i = 0; i < selectList.size(); i++) {
                        if (selectList.get(i).getLocalId().equals(baseVo.getLocalId())) {
                            selectList.remove(i);
                            break;
                        }
                    }
                    if (hasSelectList == null && selectList.size() <= 0) {
                        if (mFinishBtn.isEnabled()) {
                            mFinishBtn.setEnabled(false);
                        }
                    }
                    if (hasSelectList != null) {
                        // Over the selected user data
                        int hasSelectCount = hasSelectList.size();
                        for (int i = 0; i < hasSelectCount; i++) {
                            UserBaseVo vo = hasSelectList.get(i);
                            if (vo.getLocalId().equals(baseVo.getLocalId())) {
                                hasSelectList.remove(i);
                                break;
                            }
                        }
                    }
                }
            } else {
                InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mInputSearch.getWindowToken(), 0);
                clickSingleItem(baseVo);
            }
        }
    });
    mEmpty = (LinearLayout) findViewById(R.id.empty);
    mSearchListView.setEmptyView(mEmpty);
    mInTextView = (TextView) headerView.findViewById(R.id.include_friends_search_text);
    mInputSearch = (EditText) findViewById(R.id.include_friends_search_content);
    mInputSearchLayout = (LinearLayout) findViewById(R.id.include_friends_search_content_bg);
    mInputSearchCancel = (TextView) findViewById(R.id.include_friends_search_cancel);
    mInputSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public synchronized void afterTextChanged(Editable s) {
            if (s != null) {
                friendFilterList.clear();
                if (s.toString().length() <= 0) {
                    searchListLayout.setVisibility(View.GONE);
                    searchResultLayout.setOnClickListener(SelectContactUI.this);
                } else {
                    searchListLayout.setVisibility(View.VISIBLE);
                    searchResultLayout.setOnClickListener(null);
                    String searchString = s.toString().toUpperCase();
                    if (curSearchTask != null && curSearchTask.getStatus() != AsyncTask.Status.FINISHED) {
                        try {
                            curSearchTask.cancel(true);
                        } catch (Exception e) {
                        }
                    }
                    curSearchTask = new SearchListTask();
                    curSearchTask.execute(searchString);
                }
            } else {
                searchListLayout.setVisibility(View.GONE);
                searchResultLayout.setOnClickListener(SelectContactUI.this);
            }
        }
    });
    mInputSearchCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            hideSearch();
        }
    });
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Handler(android.os.Handler) InputMethodManager(android.view.inputmethod.InputMethodManager) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnClickListener(android.view.View.OnClickListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 63 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project GomoTest by suReZj.

the class ImagesFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.gallery, null);
    Cursor cur = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.Images.Media.DATA, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATE_TAKEN, MediaStore.Images.Media.SIZE }, MediaStore.Images.Media.BUCKET_ID + " = ?", new String[] { String.valueOf(getArguments().getInt("bucket")) }, MediaStore.Images.Media.DATE_MODIFIED + " DESC");
    final List<GridItem> images = new ArrayList<GridItem>(cur.getCount());
    if (cur != null) {
        if (cur.moveToFirst()) {
            while (!cur.isAfterLast()) {
                images.add(new GridItem(cur.getString(1), cur.getString(0), cur.getString(2), cur.getLong(3)));
                cur.moveToNext();
            }
        }
        cur.close();
    }
    GridView grid = (GridView) v.findViewById(R.id.grid);
    grid.setAdapter(new GalleryAdapter(getActivity(), images));
    grid.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ((SelectPictureActivity) getActivity()).imageSelected(images.get(position).path, images.get(position).imageTaken, images.get(position).imageSize);
        }
    });
    return v;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) GridView(android.widget.GridView) Cursor(android.database.Cursor) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 64 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project android_packages_apps_DU-Tweaks by DirtyUnicorns.

the class NotificationLightSettings method onCreateDialog.

/**
 * Utility classes and supporting methods
 */
@Override
public Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final Dialog dialog;
    switch(id) {
        case DIALOG_APPS:
            final ListView list = new ListView(getActivity());
            list.setAdapter(mPackageAdapter);
            builder.setTitle(R.string.heads_up_blacklist_choose_app);
            builder.setView(list);
            dialog = builder.create();
            list.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    // Add empty application definition, the user will be able to edit it later
                    PackageItem info = (PackageItem) parent.getItemAtPosition(position);
                    addCustomApplicationPref(info.packageName);
                    dialog.cancel();
                }
            });
            break;
        default:
            dialog = null;
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) PackageItem(com.dirtyunicorns.tweaks.preferences.PackageListAdapter.PackageItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 65 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project android_packages_apps_DU-Tweaks by DirtyUnicorns.

the class IconPickerActivity method getIconPackDialog.

private Dialog getIconPackDialog(Context context) {
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View view = inflater.inflate(R.layout.dialog_iconpack, null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    final IconPackageAdapter adapter = new IconPackageAdapter(this);
    final ListView listView = (ListView) view.findViewById(R.id.iconpack_list);
    final Dialog dialog;
    adapter.load();
    dialog = builder.setTitle(getString(R.string.icon_pack_picker_dialog_title)).setView(view).setOnCancelListener(this).setNegativeButton(android.R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onCancel(dialog);
        }
    }).create();
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ResolveInfo info = adapter.getItem(position);
            String packageName = info.activityInfo.packageName;
            Intent intent = new Intent();
            intent.setClassName("com.android.settings", "com.dirtyunicorns.tweaks.IconPackGridActivity");
            intent.putExtra("icon_package_name", packageName);
            dialog.dismiss();
            startActivityForResult(intent, ICON_PACK_ICON_RESULT);
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ResolveInfo(android.content.pm.ResolveInfo) ListView(android.widget.ListView) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)241 AdapterView (android.widget.AdapterView)238 View (android.view.View)237 ListView (android.widget.ListView)188 TextView (android.widget.TextView)135 ImageView (android.widget.ImageView)86 Intent (android.content.Intent)68 OnClickListener (android.view.View.OnClickListener)44 SuppressLint (android.annotation.SuppressLint)32 LayoutInflater (android.view.LayoutInflater)32 AlertDialog (android.app.AlertDialog)27 DialogInterface (android.content.DialogInterface)27 GridView (android.widget.GridView)26 ArrayAdapter (android.widget.ArrayAdapter)24 Bundle (android.os.Bundle)23 Dialog (android.app.Dialog)22 ArrayList (java.util.ArrayList)21 Paint (android.graphics.Paint)17 File (java.io.File)17 AbsListView (android.widget.AbsListView)16