Search in sources :

Example 1 with TourItem

use of com.example.alphatour.oggetti.TourItem in project AlphaTour by Frank99DG.

the class TourAdapter method getView.

@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_search_dashboard, parent, false);
    }
    ImageView tourImage = convertView.findViewById(R.id.imagePlaceZoneElement);
    TextView tourText = convertView.findViewById(R.id.displayPlaceZoneElement);
    TourItem tourItem = getItem(position);
    if (tourItem != null) {
        tourImage.setImageResource(tourItem.getTourImage());
        tourText.setText(tourItem.getTourText());
    }
    return convertView;
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) TourItem(com.example.alphatour.oggetti.TourItem) NonNull(androidx.annotation.NonNull)

Example 2 with TourItem

use of com.example.alphatour.oggetti.TourItem in project AlphaTour by Frank99DG.

the class DashboardActivity method inputSearchClick.

private void inputSearchClick() {
    inputSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            TourItem clickedItem = (TourItem) parent.getItemAtPosition(position);
            String clickedTourText = clickedItem.getTourText();
            db.collection("Elements").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {

                @Override
                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                    if (!queryDocumentSnapshots.isEmpty()) {
                        // lista elementi
                        List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
                        for (DocumentSnapshot d : listDocument) {
                            ElementString element = d.toObject(ElementString.class);
                            if (clickedTourText.equals(element.getTitle())) {
                                Intent intent = new Intent(DashboardActivity.this, ModifyObjectActivity.class);
                                intent.putExtra("data", element.getQrData());
                                String dashboardFlag = "1";
                                intent.putExtra("dashboardFlag", dashboardFlag);
                                startActivity(intent);
                                inputSearch.setText(null);
                                break;
                            }
                        }
                    }
                }
            });
            db.collection("Zones").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {

                @Override
                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                    if (!queryDocumentSnapshots.isEmpty()) {
                        // lista zone
                        List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
                        for (DocumentSnapshot d : listDocument) {
                            Zone zone = d.toObject(Zone.class);
                            if (clickedTourText.equals(zone.getName())) {
                                Intent intent = new Intent(DashboardActivity.this, ModifyZoneActivity.class);
                                intent.putExtra("idPlace", zone.getIdPlace());
                                intent.putExtra("Zone", zone.getName());
                                String dashboardFlag = "1";
                                intent.putExtra("dashboardFlag", dashboardFlag);
                                startActivity(intent);
                                inputSearch.setText(null);
                                break;
                            }
                        }
                    }
                }
            });
            db.collection("Places").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {

                @Override
                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                    if (!queryDocumentSnapshots.isEmpty()) {
                        // lista luoghi
                        List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
                        for (DocumentSnapshot d : listDocument) {
                            Place place = d.toObject(Place.class);
                            if (clickedTourText.equals(place.getName())) {
                                Intent intent = new Intent(DashboardActivity.this, ModifyPlaceActivity.class);
                                intent.putExtra("Place", place.getName());
                                String dashboardFlag = "1";
                                intent.putExtra("dashboardFlag", dashboardFlag);
                                startActivity(intent);
                                inputSearch.setText(null);
                                break;
                            }
                        }
                    }
                }
            });
        }
    });
}
Also used : Zone(com.example.alphatour.oggetti.Zone) Intent(android.content.Intent) ElementString(com.example.alphatour.oggetti.ElementString) View(android.view.View) AdapterView(android.widget.AdapterView) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) TourItem(com.example.alphatour.oggetti.TourItem) QuerySnapshot(com.google.firebase.firestore.QuerySnapshot) QueryDocumentSnapshot(com.google.firebase.firestore.QueryDocumentSnapshot) DocumentSnapshot(com.google.firebase.firestore.DocumentSnapshot) AdapterView(android.widget.AdapterView) OnSuccessListener(com.google.android.gms.tasks.OnSuccessListener) ElementString(com.example.alphatour.oggetti.ElementString) Place(com.example.alphatour.oggetti.Place)

Aggregations

TextView (android.widget.TextView)2 TourItem (com.example.alphatour.oggetti.TourItem)2 Intent (android.content.Intent)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageView (android.widget.ImageView)1 NonNull (androidx.annotation.NonNull)1 ElementString (com.example.alphatour.oggetti.ElementString)1 Place (com.example.alphatour.oggetti.Place)1 Zone (com.example.alphatour.oggetti.Zone)1 OnSuccessListener (com.google.android.gms.tasks.OnSuccessListener)1 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)1 DocumentSnapshot (com.google.firebase.firestore.DocumentSnapshot)1 QueryDocumentSnapshot (com.google.firebase.firestore.QueryDocumentSnapshot)1 QuerySnapshot (com.google.firebase.firestore.QuerySnapshot)1