Example usage for android.widget AdapterView getAdapter

List of usage examples for android.widget AdapterView getAdapter

Introduction

In this page you can find the example usage for android.widget AdapterView getAdapter.

Prototype

public abstract T getAdapter();

Source Link

Document

Returns the adapter currently associated with this widget.

Usage

From source file:org.dmfs.webcal.fragments.CalendarItemFragment.java

@Override
public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
    Cursor cursor = (Cursor) listView.getAdapter().getItem(position);

    Time start = new Time(cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TIMZONE)));
    start.set(cursor.getLong(cursor.getColumnIndex(WebCalReaderContract.Events.DTSTART)));
    start.allDay = cursor.getInt(cursor.getColumnIndex(WebCalReaderContract.Events.IS_ALLDAY)) != 0;

    Time end = new Time(cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TIMZONE)));
    end.set(cursor.getLong(cursor.getColumnIndex(WebCalReaderContract.Events.DTEND)));
    end.allDay = start.allDay;/*from   w  w w . ja v a  2s .c o m*/

    Event event = new Event(start, end,
            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TITLE)),
            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.DESCRIPTION)),
            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.LOCATION)));

    EventsPreviewActivity.show(getActivity(), event, mCalendarName, mIcon, mTitle);
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Inflate the dagvergunning koopman fragment and initialize the view elements and its handlers
 * @param inflater/*w  w w.j  av  a2  s . c  o  m*/
 * @param container
 * @param savedInstanceState
 * @return
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mainView = inflater.inflate(R.layout.dagvergunning_fragment_koopman, container, false);

    // bind the elements to the view
    ButterKnife.bind(this, mainView);

    // Create an onitemclick listener that will catch the clicked koopman from the autocomplete
    // lists (not using butterknife here because it does not support for @OnItemClick on
    // AutoCompleteTextView: https://github.com/JakeWharton/butterknife/pull/242
    AdapterView.OnItemClickListener autoCompleteItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor koopman = (Cursor) parent.getAdapter().getItem(position);

            // select the koopman and update the fragment
            selectKoopman(koopman.getInt(koopman.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ID)),
                    KOOPMAN_SELECTION_METHOD_HANDMATIG);
        }
    };

    // create the custom cursor adapter that will query for an erkenningsnummer and show an autocomplete list
    ErkenningsnummerAdapter searchErkenningAdapter = new ErkenningsnummerAdapter(getContext());
    mErkenningsnummerEditText.setAdapter(searchErkenningAdapter);
    mErkenningsnummerEditText.setOnItemClickListener(autoCompleteItemClickListener);

    // create the custom cursor adapter that will query for a sollicitatienummer and show an autocomplete list
    SollicitatienummerAdapter searchSollicitatieAdapter = new SollicitatienummerAdapter(getContext());
    mSollicitatienummerEditText.setAdapter(searchSollicitatieAdapter);
    mSollicitatienummerEditText.setOnItemClickListener(autoCompleteItemClickListener);

    // disable uppercasing of the button text
    mScanBarcodeButton.setTransformationMethod(null);
    mScanNfcTagButton.setTransformationMethod(null);

    // get the aanwezig values from a resource array with aanwezig values
    mAanwezigKeys = getResources().getStringArray(R.array.array_aanwezig_key);

    // populate the aanwezig spinner from a resource array with aanwezig titles
    ArrayAdapter<CharSequence> aanwezigAdapter = ArrayAdapter.createFromResource(getContext(),
            R.array.array_aanwezig_title, android.R.layout.simple_spinner_dropdown_item);
    aanwezigAdapter.setDropDownViewResource(android.R.layout.simple_list_item_activated_1);
    mAanwezigSpinner.setAdapter(aanwezigAdapter);

    return mainView;
}

From source file:com.massivcode.androidmusicplayer.activities.MainActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    switch (parent.getId()) {
    // Songs ListView  ?  :   ?
    case R.id.songs_listView: {
        ArrayList<Long> list = (ArrayList) MusicInfoLoadUtil.getSelectedSongPlaylist(MainActivity.this,
                (Cursor) parent.getAdapter().getItem(position));
        Intent intent = new Intent(MainActivity.this, MusicService.class);
        intent.setAction(MusicService.ACTION_PLAY);
        intent.putExtra("list", list);
        intent.putExtra("position", 0);
        startService(intent);//w  ww. jav  a  2s . com
        break;
    }

    //  ???  ?  :  ??  ?
    case R.id.current_playlistView: {
        Intent intent = new Intent(MainActivity.this, MusicService.class);
        intent.setAction(MusicService.ACTION_PLAY_SELECTED);
        intent.putExtra("position", position);
        startService(intent);
        break;
    }

    }

}

From source file:com.pizidea.imagepicker.ui.ImagesGridFragment.java

/**
 * ListView//from  w ww  .j a va 2 s .  co m
 */
private void createPopupFolderList(int width, int height) {
    mFolderPopupWindow = new ListPopupWindow(mContext);
    //mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mFolderPopupWindow.setAdapter(mImageSetAdapter);
    mFolderPopupWindow.setContentWidth(width);
    mFolderPopupWindow.setWidth(width);
    mFolderPopupWindow.setHeight(height * 5 / 8);
    mFolderPopupWindow.setAnchorView(mFooterView);
    mFolderPopupWindow.setModal(true);

    mFolderPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            backgroundAlpha(1f);
        }
    });

    mFolderPopupWindow.setAnimationStyle(R.style.popupwindow_anim_style);

    mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            mImageSetAdapter.setSelectIndex(i);
            androidImagePicker.setCurrentSelectedImageSetPosition(i);

            final int index = i;
            final AdapterView tempAdapterView = adapterView;

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mFolderPopupWindow.dismiss();

                    ImageSet imageSet = (ImageSet) tempAdapterView.getAdapter().getItem(index);
                    if (null != imageSet) {
                        mAdapter.refreshData(imageSet.imageItems);
                        btnDir.setText(imageSet.name);

                    }
                    // scroll to the top
                    mGridView.smoothScrollToPosition(0);

                }
            }, 100);

        }
    });

}

From source file:uk.org.crimetalk.fragments.ArticleListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    // If should load in a local browser, load in a local browser
    if (mLoadInBrowser || PreferenceUtils.getLoadInBrowser(getActivity())) {

        final Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(((ArticleListItem) parent.getAdapter().getItem(position)).getLink()));

        startActivity(intent);/*  www .  ja  va  2s. co  m*/

        return;

    }

    // Otherwise, load in a native content viewer
    final Intent intent = new Intent(getActivity(), ArticleContentActivity.class);
    intent.putExtra(ArticleContentActivity.ARG_LIST_ITEM,
            (ArticleListItem) parent.getAdapter().getItem(position));

    startActivity(intent);

}

From source file:org.secu3.android.ParamActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    adapter = (ParamItemsAdapter) parent.getAdapter();
    if (adapter != null) {
        this.position = position;
        BaseParamItem i = (BaseParamItem) adapter.getItem(position);
        if (i instanceof ParamItemInteger) {
            dialog = new CustomNumberPickerIntegerDialog();
            dialog.setValid(isValid);//  w ww . ja v a  2 s  .c om
            ((CustomNumberPickerIntegerDialog) dialog.setId(i.getNameId()))
                    .setRange(((ParamItemInteger) i).getValue(), ((ParamItemInteger) i).getMinValue(),
                            ((ParamItemInteger) i).getMaxValue(), ((ParamItemInteger) i).getStepValue())
                    .setOnCustomNumberPickerAcceptListener(this).show(getSupportFragmentManager(), i.getName());
        } else if (i instanceof ParamItemFloat) {
            dialog = new CustomNumberPickerFloatDialog();
            dialog.setValid(isValid);
            ((CustomNumberPickerFloatDialog) dialog.setId(i.getNameId()))
                    .setRange(((ParamItemFloat) i).getValue(), ((ParamItemFloat) i).getMinValue(),
                            ((ParamItemFloat) i).getMaxValue(), ((ParamItemFloat) i).getStepValue())
                    .setFormat(((ParamItemFloat) i).getFormat()).setOnCustomNumberPickerAcceptListener(this)
                    .show(getSupportFragmentManager(), i.getName());
        } else if (i instanceof ParamItemBoolean) {
            adapter.setValue(String.valueOf(!((ParamItemBoolean) i).getValue()), position);
            onItemChange(i.getNameId());
        } else if (i instanceof ParamItemString) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(i.getName());
            final EditText input = new EditText(this);
            bluetoothSecurityFlags = i.getNameId();
            input.setText(((ParamItemString) i).getValue());
            switch (bluetoothSecurityFlags) {
            case R.string.secur_par_bluetooth_name_title:
                input.setInputType(InputType.TYPE_CLASS_TEXT);
                break;
            case R.string.secur_par_bluetooth_pass_title:
                input.setInputType(InputType.TYPE_CLASS_NUMBER);
                break;
            }
            builder.setView(input);
            builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    bluetoothSecurityValue = input.getText().toString();
                    onItemChange(bluetoothSecurityFlags);
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
        }
    }
}

From source file:com.tunessoft_lab.fbLogin.FBLoginActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());

    callbackManager = CallbackManager.Factory.create();

    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

        @Override//from www  . j  av a  2  s.  com
        public void onSuccess(LoginResult loginResult) {

            updateUI();

            mPrefs = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
            editor = mPrefs.edit();
            editor.putString("access_token", loginResult.getAccessToken().getToken());
            editor.putString("user_id", loginResult.getAccessToken().getUserId());
            editor.commit();

        }

        @Override
        public void onCancel() {
            if (pendingAction != PendingAction.NONE) {
                showAlert();
                pendingAction = PendingAction.NONE;
            }
            updateUI();
        }

        @Override
        public void onError(FacebookException exception) {
            if (pendingAction != PendingAction.NONE && exception instanceof FacebookAuthorizationException) {
                showAlert();
                pendingAction = PendingAction.NONE;
            }
            updateUI();
        }

        private void showAlert() {
            new AlertDialog.Builder(FBLoginActivity.this).setTitle(R.string.cancelled)
                    .setMessage(R.string.permission_not_granted).setPositiveButton(R.string.ok, null).show();
        }

    });

    shareDialog = new ShareDialog(this);
    shareDialog.registerCallback(callbackManager, shareCallback);

    if (savedInstanceState != null) {
        String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY);
        pendingAction = PendingAction.valueOf(name);
    }

    setContentView(R.layout.main);

    gridOfPhotos = (GridView) findViewById(R.id.gridphoto);
    spin = (ProgressBar) findViewById(R.id.load);
    spin2 = (ProgressBar) findViewById(R.id.load2);
    loadPhotos = (Button) findViewById(R.id.btn_loadPhoto);
    loadMorePhotos = (Button) findViewById(R.id.btn_loadMorePhoto);

    handler = new Handler();

    mContext = this;

    arrPhotos = new ArrayList<getPhotos>();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            updateUI();
        }
    };

    loadPhotos.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            mPrefs = getSharedPreferences("MyPref", MODE_PRIVATE);
            String access_token = mPrefs.getString("access_token", null);

            if (access_token != null) {

                if (hasPhotoPermission()) {

                    getPhotosData gd = new getPhotosData();
                    gd.execute();

                    loadMorePhotos.setVisibility(View.VISIBLE);
                } else {

                    LoginManager.getInstance().logInWithReadPermissions(FBLoginActivity.this,
                            Arrays.asList(PHOTO_PERMISSION));

                }

            }

        }
    });

    loadMorePhotos.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            mPrefs = getSharedPreferences("MyPref", MODE_PRIVATE);
            String access_token = mPrefs.getString("access_token", null);

            if (access_token != null) {

                if (hasPhotoPermission()) {

                    loadMorePhotos ld = new loadMorePhotos();
                    ld.execute();
                }
            } else {

                LoginManager.getInstance().logInWithReadPermissions(FBLoginActivity.this,
                        Arrays.asList(PHOTO_PERMISSION));

            }

        }
    });

    profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture);
    greeting = (TextView) findViewById(R.id.greeting);

    canPresentShareDialog = ShareDialog.canShow(ShareLinkContent.class);

    canPresentShareDialogWithPhotos = ShareDialog.canShow(SharePhotoContent.class);

    gridOfPhotos.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            PhotosAdapter pa = (PhotosAdapter) parent.getAdapter();
            getPhotos gp = (getPhotos) pa.getItem(position);

            String name = gp.getPhotoSource();
            try {
                if (!name.isEmpty()) {
                    Intent i = new Intent(getApplicationContext(), OnGridImageClick.class);
                    i.putExtra("IMAGE_URL", name);
                    startActivity(i);
                }

            } catch (Exception e) {
                Log.e("GridView", e.getMessage());
            }
        }
    });

    EndlessScrollListener s = new EndlessScrollListener(gridOfPhotos);
    gridOfPhotos.setOnScrollListener(s);

}

From source file:com.mgfypy.imagelibrary.ui.ImagesGridFragment.java

/**
 * ListView/*from   w w w .j  a v  a2s .  c om*/
 */
private void createPopupFolderList(int width, int height) {
    mFolderPopupWindow = new ListPopupWindow(mContext);
    //mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mFolderPopupWindow.setAdapter(mImageSetAdapter);
    mFolderPopupWindow.setContentWidth(width);
    mFolderPopupWindow.setWidth(width);
    mFolderPopupWindow.setHeight(height * 5 / 8);
    mFolderPopupWindow.setAnchorView(mFooterView);
    mFolderPopupWindow.setModal(true);

    mFolderPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            backgroundAlpha(1f);
        }
    });

    mFolderPopupWindow.setAnimationStyle(R.style.popupwindow_anim_style);

    mFolderPopupWindow.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            mImageSetAdapter.setSelectIndex(i);
            androidImagePicker.setCurrentSelectedImageSetPosition(i);

            final int index = i;
            final AdapterView tempAdapterView = adapterView;

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mFolderPopupWindow.dismiss();

                    ImageSet imageSet = (ImageSet) tempAdapterView.getAdapter().getItem(index);
                    if (null != imageSet) {
                        mAdapter.refreshData(imageSet.imageItems);
                        btnDir.setText(imageSet.name);

                    }
                    // scroll to the top
                    mGridView.smoothScrollToPosition(0);

                }
            }, 100);

        }
    });

}

From source file:com.jesjimher.bicipalma.MesProperesActivity.java

public boolean onItemLongClick(final AdapterView<?> parent, final View v, final int position, final long id) {
    final CharSequence[] items = getResources().getTextArray(R.array.menu_contextual);
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    final ResultadoBusqueda rb = (ResultadoBusqueda) parent.getAdapter().getItem(position);

    b.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            dialog.dismiss();/*from w ww.  j  a  va 2s  .  c  o  m*/
            switch (item) {
            case 0:
                onItemClick(parent, v, position, id);
                break;
            case 1:
                //TODO: Pasar a GMaps la versin localizada de "Current location" para que haga l la bsqueda de origen
                String latlongactual = lBest.getLatitude() + "," + lBest.getLongitude();
                String latlongdestino = rb.getEstacion().getLoc().getLatitude() + ","
                        + rb.getEstacion().getLoc().getLongitude();
                Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(
                        "http://maps.google.com/maps?saddr=" + latlongactual + "&daddr=" + latlongdestino));
                startActivity(intent);
                break;
            }
        }
    });
    AlertDialog alert = b.create();
    alert.show();

    return true;
}

From source file:tv.acfun.video.CommentsActivity.java

private void initCommentsBar() {
    mCommentBar = findViewById(R.id.comments_bar);
    mBtnSend = (ImageButton) findViewById(R.id.comments_send_btn);
    mCommentText = (EditText) findViewById(R.id.comments_edit);
    mBtnEmotion = findViewById(R.id.comments_emotion_btn);
    mEmotionGrid = (GridView) findViewById(R.id.emotions);
    mBtnSend.setOnClickListener(this);
    mBtnEmotion.setOnClickListener(this);
    mEmotionGrid.setAdapter(mEmotionAdapter);
    mEmotionGrid.setOnItemClickListener(new OnItemClickListener() {

        @Override/* w  w  w.j  a  va 2  s  .  c  o  m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            int index = mCommentText.getSelectionEnd();
            Editable text = mCommentText.getText();
            String emotion = parent.getItemAtPosition(position).toString();
            text.insert(index, emotion);
            EmotionView v = (EmotionView) parent.getAdapter().getView(position, null, null);
            Drawable drawable = TextViewUtils.convertViewToDrawable(v);
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2);
            text.setSpan(new ImageSpan(drawable), index, index + emotion.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

    });
}