Example usage for android.widget AdapterView getItemAtPosition

List of usage examples for android.widget AdapterView getItemAtPosition

Introduction

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

Prototype

public Object getItemAtPosition(int position) 

Source Link

Document

Gets the data associated with the specified position in the list.

Usage

From source file:it.uniroma2.foundme.studente.RegistrationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);
    context = this;
    btSignUp = (Button) findViewById(R.id.btSignUp);

    etNewUser = (EditText) findViewById(R.id.etNewUser);
    etNewPass1 = (EditText) findViewById(R.id.etNewPass);
    etNewPass2 = (EditText) findViewById(R.id.etNewPass2);
    etNewMail = (EditText) findViewById(R.id.etNewMail);
    etNewMail2 = (EditText) findViewById(R.id.etNewMail2);
    etNewId = (EditText) findViewById(R.id.etNewId);
    spDept = (Spinner) findViewById(R.id.spDept);

    final ArrayAdapter<CharSequence> adapter = createFromResource(this, R.array.Departments,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spDept.setAdapter(adapter);/*from  w w  w  . ja v a2  s  .  c  o m*/

    spDept.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        protected Adapter initializedAdapter = null;

        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            if (initializedAdapter != parentView.getAdapter()) {
                initializedAdapter = parentView.getAdapter();
                return;
            }

            Dept = parentView.getItemAtPosition(position).toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parentView) {
            //
        }
    });

    btSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            NewUser = etNewUser.getText().toString();
            NewPass1 = etNewPass1.getText().toString();
            NewPass2 = etNewPass2.getText().toString();
            NewMail = etNewMail.getText().toString();
            NewMail2 = etNewMail2.getText().toString();
            NewId = etNewId.getText().toString();

            if (checkPlayServices()) {
                gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
                if (!checkLoginData(NewPass1, NewPass2, NewMail, NewMail2, Dept)) {
                    Toast.makeText(getApplicationContext(), Variables_it.FILL_FIELD, Toast.LENGTH_LONG).show();
                } else {
                    try {
                        manageRegistration(NewUser, NewPass1, NewMail, NewId, Dept);
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    });

}

From source file:com.orange.datavenue.DatasourceListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Log.d(TAG_NAME, "onViewCreated()");

    if (mDatasourceAdapter == null) {
        mDatasourceAdapter = new DatasourceAdapter(getActivity(), R.layout.datasource_item, R.id.name,
                mDatasources);//  w w  w.j  a v a  2  s.  c  o  m
        setListAdapter(mDatasourceAdapter);
        getDatasources();
    }

    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG_NAME, "onClick()");
            Model.instance.currentDatasource = (Datasource) parent.getItemAtPosition(position);

            ((DatasourceActivity) getActivity()).changeLayout(DatasourceActivity.MODE_DETAIL);
        }
    });

    getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG_NAME, "onItemLongClick()");
            Model.instance.currentDatasource = (Datasource) parent.getItemAtPosition(position);
            mSelected = position;
            getListView().setItemChecked(mSelected, true);
            mActionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(mActionModeCallback);
            return true;
        }
    });

}

From source file:com.esprit.droidcon.corruption.RelationListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;/* w  ww  .  j ava 2 s  . c o  m*/
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Relation Avec Le Cityoen");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

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

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(RelationListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(RelationListActivity.this, RelationListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:com.mstoyanov.music_lessons.ScheduleFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.lessons_list:
        Cursor cursor = (Cursor) parent.getItemAtPosition(position);
        int studentId = cursor.getInt(cursor.getColumnIndex("studentID"));
        lessonId = cursor.getInt(cursor.getColumnIndex("_id"));
        String firstName = cursor.getString(cursor.getColumnIndex("firstName"));
        String lastName = cursor.getString(cursor.getColumnIndex("lastName"));
        if (dualPane) {
            selectionArgs_delete[0] = String.valueOf(lessonId);

            lessonsList.setItemChecked(position, true);
            selectedLesson = position;/*from   w w w  .ja va2  s  . c om*/

            selectionArgs_actions[0] = String.valueOf(studentId);

            firstNameLabel.setText("First Name");
            firstNameTextView.setText(firstName);
            lastNameLabel.setText("Last Name");
            lastNameTextView.setText(lastName);

            getLoaderManager().restartLoader(ACTIONS_LOADER, null, this);
        } else {
            Intent intent = new Intent(getActivity(), LessonDetailsActivity.class);
            intent.putExtra("LESSON_ID", lessonId);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
        break;
    case R.id.actions_list:
        Actions action = actions.get(position);
        switch (action.getType()) {
        case Actions.ACTION_CALL:
            Uri callUri = Uri.parse("tel:" + action.getData());
            Intent intent = new Intent(Intent.ACTION_CALL, callUri);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        case Actions.ACTION_EMAIL:
            intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { action.getData() });
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        case Actions.ACTION_SMS:
            Uri smsUri = Uri.parse("sms:" + action.getData());
            intent = new Intent(Intent.ACTION_VIEW, smsUri);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        default:
            throw new IllegalArgumentException("Invalid action type: " + action.getType());
        }
        break;
    default:
        throw new IllegalArgumentException("Invalid parentId: " + parent.getId());
    }
}

From source file:com.esprit.droidcon.corruption.AutreListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;/*from  w w  w. j  a  va2  s.  c  om*/
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Autre");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

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

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(AutreListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(AutreListActivity.this, AutreListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:org.kei.android.phone.cellhistory.fragments.GeolocationFragment.java

@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int pos, final long id) {
    final String newP = parent.getItemAtPosition(pos).toString();
    final String oldP = prefs.getString(PreferencesGeolocation.PREFS_KEY_CURRENT_PROVIDER,
            PreferencesGeolocation.PREFS_DEFAULT_CURRENT_PROVIDER);
    if (!oldP.equals(newP)) {
        final Editor editor = prefs.edit();
        editor.putString(PreferencesGeolocation.PREFS_KEY_CURRENT_PROVIDER, newP);
        editor.commit();// w w  w .  ja va 2  s  .  c om
        app.getProviderCtx().clear();
        getActivity().startService(new Intent(getActivity(), ProviderService.class));
    }
}

From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    String value = parent.getItemAtPosition(pos).toString();
    String[] parts = value.split("\\+");
    String country = parts[0].substring(0, parts[0].indexOf("(")).trim();
    countryCode = parts[1].substring(0, parts[1].indexOf(")")).trim();
    Toast.makeText(parent.getContext(), "Country is " + country + ", code is: " + countryCode,
            Toast.LENGTH_LONG).show();//from  w  ww.j  a  v a 2s .  c  om
}

From source file:com.example.meetingapp.ShowResultsFragment.java

private void displayResults() {
    mAdapter = new ResultAdapter(getActivity(), R.layout.result_list_item, mNearbyPlaces);

    mResultsList.setOnItemClickListener(new OnItemClickListener() {
        @Override// w  w  w.  j  av  a  2s  .  co m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            LocationParcel selection = (LocationParcel) parent.getItemAtPosition(position);

            mState.putResult(selection);
            mStateCallback.putState(mState);

            mCallback.showResult(selection);
        }
    });
    mResultsList.setAdapter(mAdapter);

    SetPhotoTask task = new SetPhotoTask();
    task.execute();
}

From source file:com.rowland.movies.ui.fragments.MainFragment.java

public void onListPopUp(View anchor) {
    // This a sample dat to fill our ListView
    List<ListPopupMenu> menuItem = new ArrayList<>();
    menuItem.add(new ListPopupMenu(R.drawable.ic_popular_black_48dp, "Popular"));
    menuItem.add(new ListPopupMenu(R.drawable.ic_rated_black_48dp, "Highest Rated"));
    menuItem.add(new ListPopupMenu(R.drawable.ic_favourite_black_48dp, "Favourite"));
    menuItem.add(new ListPopupMenu(R.drawable.ic_overview_black_48dp, "Credits"));
    // Initialise our adapter
    ListPopupWindowAdapter mListPopUpAdapter = new ListPopupWindowAdapter(getActivity().getApplicationContext(),
            menuItem);//w w w.j a va2  s  . com
    // Initialise our ListPopupWindow instance
    final ListPopupWindow pop = new ListPopupWindow(getActivity().getApplicationContext());
    // Configure ListPopupWindow properties
    pop.setAdapter(mListPopUpAdapter);
    // Set the view below/above which ListPopupWindow dropdowns
    pop.setAnchorView(anchor);
    // Setting this enables window to be dismissed by click outside ListPopupWindow
    pop.setModal(true);
    // Set the background color
    pop.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.apptheme_transparent)));
    // Set the selector color
    pop.setListSelector(new ColorDrawable(getResources().getColor(R.color.apptheme_accent_teal)));
    // Sets the width of the ListPopupWindow
    pop.setContentWidth((int) this.mPopupMaxWidth);
    // Sets the Height of the ListPopupWindow
    pop.setHeight(ListPopupWindow.WRAP_CONTENT);
    // Set up a click listener for the ListView items
    pop.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // Dismiss the LisPopupWindow when a list item is clicked
            pop.dismiss();
            // The overflow menu selected
            String menuName = ((ListPopupMenu) adapterView.getItemAtPosition(position)).getName();
            // Switch to the right ViewPager element at given position
            switch (menuName) {
            case "Popular":
                mViewPager.setCurrentItem(0, true);
                break;
            case "Highest Rated":
                mViewPager.setCurrentItem(1, true);
                break;
            case "Favourite":
                mViewPager.setCurrentItem(2, true);
                break;
            case "Credits":
                onShowCreditsDialog();
                break;
            default:
                mViewPager.setCurrentItem(0, true);
                break;
            }
        }
    });
    pop.show();
}

From source file:com.esprit.droidcon.corruption.SiteWebListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;/*  w ww . j  av  a  2 s .  c o m*/
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Site Web");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(SiteWebListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(SiteWebListActivity.this, SiteWebListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}