InfoWindowAdapter.java:使用或覆盖不推荐使用的API

时间:2018-11-14 16:14:04

标签: java android google-maps google-maps-markers

就像标题一样,我遇到了这个问题,我一直在寻找2小时好的答案,但是我尝试过的答案都不起作用; /

这是课程:

bash -x script.sh
+ IFS=,
+ read -r user store date amount
+ [[ User != \U\s\e\r ]]
+ echo User is different: User
User is different: User
...

我个人认为我不赞成使用某些东西。甚至IDE也没有尖叫我。

这是我的依赖项:

package com.example.michalwolowiec.meetup;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Marker;

import java.util.ArrayList;

public class MeetUpInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
    private final View mWindow;
    private Context context;
    private ArrayList<User> users;

    public MeetUpInfoWindowAdapter(Context context, ArrayList<User> users) {
        this.context = context;
        this.users = users;
        mWindow = LayoutInflater.from(context).inflate(R.layout.event_info_window, null);
    }

    private void renderWindowInfo(Marker marker, View view){
        String title = marker.getTitle();
        TextView titleTextView = view.findViewById(R.id.titleTextView);

        if(!title.equals("")) titleTextView.setText(title);

        String snippet = marker.getSnippet();
        TextView snippetTextView = view.findViewById(R.id.snippetTextView);

        if(!title.equals("")) snippetTextView.setText(snippet);

        //Since markers doesn't have an extra Variable to store images I need to iterate
        //through all users to get the porper photo
        int photo = 0;
        ImageView photoImageView = view.findViewById(R.id.photoImageView);
        for(int i = 0; i < users.size(); i++){
            User user = users.get(i);
            if(title.equals("Username: " + user.getUsername())){
                photo = user.getProfilePhoto();
                break;
            }
        }

        if(photo!=0)
            photoImageView.setImageDrawable(context.getResources().getDrawable(photo));
    }

    @Override
    public View getInfoWindow(Marker marker) {
        renderWindowInfo(marker, mWindow);
        return mWindow;
    }

    @Override
    public View getInfoContents(Marker marker) {
        renderWindowInfo(marker, mWindow);
        return mWindow;
    }
}

我必须添加

  

实现'com.android.support:support-v4:28.0.0'

因为我认为我用于位置的库正在使用它。 顺便说一句。因为我还不是开发人员,所以你们推荐一些适用于android的位置库?

提前谢谢

0 个答案:

没有答案