Search in sources :

Example 1 with RoomFinderRoom

use of de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom in project TumCampusApp by TCA-Team.

the class RoomFinderActivity method onSearchFinished.

@Override
protected void onSearchFinished(Optional<List<RoomFinderRoom>> result) {
    if (!result.isPresent()) {
        if (NetUtils.isConnected(this)) {
            showErrorLayout();
        } else {
            showNoInternetLayout();
        }
        return;
    }
    List<RoomFinderRoom> searchResult = result.get();
    if (searchResult.isEmpty()) {
        list.setAdapter(new NoResultsAdapter(this));
    } else {
        adapter = new RoomFinderListAdapter(this, searchResult);
        list.setAdapter(adapter);
    }
    showLoadingEnded();
}
Also used : RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) NoResultsAdapter(de.tum.in.tumcampusapp.component.other.generic.adapter.NoResultsAdapter)

Example 2 with RoomFinderRoom

use of de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom in project TumCampusApp by TCA-Team.

the class RoomFinderListAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    ViewHolder holder;
    View convertView = view;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.list_roomfinder_item, parent, false);
        holder = new ViewHolder();
        holder.tvRoomTitle = convertView.findViewById(R.id.startup_actionbar_title);
        holder.tvBuildingTitle = convertView.findViewById(R.id.building);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    RoomFinderRoom room = infoList.get(position);
    // Setting all values in listView
    holder.tvRoomTitle.setText(room.getInfo());
    holder.tvBuildingTitle.setText(room.getAddress());
    return convertView;
}
Also used : RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) TextView(android.widget.TextView) View(android.view.View)

Example 3 with RoomFinderRoom

use of de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom in project TumCampusApp by TCA-Team.

the class BarrierFreeFacilitiesActivity method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    RoomFinderRoom facility = facilities.get(position);
    recents.insert(new Recent(facility.toString(), RecentsDao.ROOMS));
    // Start detail activity
    Intent intent = new Intent(this, RoomFinderDetailsActivity.class);
    intent.putExtra(RoomFinderDetailsActivity.EXTRA_ROOM_INFO, facility);
    startActivity(intent);
}
Also used : Recent(de.tum.in.tumcampusapp.component.other.general.model.Recent) RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) Intent(android.content.Intent)

Example 4 with RoomFinderRoom

use of de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom in project TumCampusApp by TCA-Team.

the class BarrierFreeFacilitiesActivity method onLoadInBackground.

@Override
protected Optional<List<RoomFinderRoom>> onLoadInBackground(Void... arg) {
    showLoadingStart();
    List<RoomFinderRoom> result;
    TUMCabeClient cabeClient = TUMCabeClient.getInstance(this);
    try {
        switch(selectedFacilityPage) {
            case 0:
                // Nearby staff - need to fetch building id first
                Optional<String> buildingId = locationManager.getBuildingIDFromCurrentLocation();
                if (buildingId.isPresent()) {
                    result = cabeClient.getListOfNearbyFacilities(buildingId.get());
                } else {
                    return Optional.absent();
                }
                break;
            case 1:
                result = cabeClient.getListOfToilets();
                break;
            case 2:
                result = cabeClient.getListOfElevators();
                break;
            default:
                return Optional.absent();
        }
    } catch (IOException e) {
        Utils.log(e);
        return Optional.absent();
    }
    if (result == null) {
        return Optional.absent();
    }
    return Optional.of(result);
}
Also used : RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) TUMCabeClient(de.tum.in.tumcampusapp.api.app.TUMCabeClient) IOException(java.io.IOException)

Example 5 with RoomFinderRoom

use of de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom in project TumCampusApp by TCA-Team.

the class RoomFinderActivity method getRecents.

/**
 * Reconstruct recents from String
 */
private List<RoomFinderRoom> getRecents() {
    List<Recent> recentList = recentsDao.getAll(RecentsDao.ROOMS);
    List<RoomFinderRoom> roomList = new ArrayList<>(recentList.size());
    for (Recent r : recentList) {
        try {
            roomList.add(RoomFinderRoom.Companion.fromRecent(r));
        } catch (IllegalArgumentException ignore) {
        }
    }
    return roomList;
}
Also used : Recent(de.tum.in.tumcampusapp.component.other.general.model.Recent) RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) ArrayList(java.util.ArrayList)

Aggregations

RoomFinderRoom (de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom)6 Recent (de.tum.in.tumcampusapp.component.other.general.model.Recent)2 Intent (android.content.Intent)1 View (android.view.View)1 TextView (android.widget.TextView)1 TUMCabeClient (de.tum.in.tumcampusapp.api.app.TUMCabeClient)1 NoResultsAdapter (de.tum.in.tumcampusapp.component.other.generic.adapter.NoResultsAdapter)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1