Маркер карты Google с Fresco для проблемы Android на Oreo - PullRequest
0 голосов
/ 10 октября 2018

Я попытался отобразить изображения в маркере карты Google, используя SimpleDraweeView через URI, но отображается только отрисовка.

Мой SimpleDraweeView прекрасно работает из другой операции, и я вижу изображения

, нопри использовании маркера карты он не показывает никаких изображений Uri, которые отображаются только на Oreo (8), он работал нормально с версией до 8 Я пытался использовать контроллер drawee та же проблема

Пожалуйста, проверьте и сообщите

спасибо

MapActivity.class

public void markProjects() {
    View marker = ((LayoutInflater) 
getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
 inflate(R.layout.custom_marker_layout, null);

    for (int i = 0; i < userResult.size(); i++) {
        final UserModel fillMapModel = userResult.get(i);
        double lon = fillMapModel.getLongitude();
        double lat = fillMapModel.getLatitude();
        LatLng latlng = new LatLng(lat, lon);
        int pinId;
        if (myProfile.getIdUser().
 equals(Integer.toString(fillMapModel.getIdUser())))
            pinId = R.drawable.my_pin;
        else
            pinId = R.drawable.user_pin;


        String titleSub;
        String fullName;
        if (!fillMapModel.getFullName().equals(""))
            fullName = fillMapModel.getFullName();
        else

            fullName = fillMapModel.getFirstName() + " " + fillMapModel.getLastName();

        if (fullName.length() < 26)
            titleSub = fullName;
        else
            titleSub = fullName.substring(0, 25) + "...";


        mMap.addMarker(new MarkerOptions()
                .position(latlng)
                .title(titleSub)
                .icon(BitmapDescriptorFactory.fromBitmap(createDrawableFromView(marker, fillMapModel.getImage()))));


        mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
            public void onInfoWindowClick(Marker marker) {
                openProjectDetails(marker);

            }

        });
        mOverlayMap.setVisibility(View.GONE);
    }
}

public Bitmap createDrawableFromView(View view, String url) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
    view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
    view.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
    SimpleDraweeView image = (SimpleDraweeView) view.findViewById(R.id.user_image);
    if (!url.equals("0") && !url.equals("")) {
        image.setImageURI(Uri.parse(url));
    } else {
        image.setImageResource(R.drawable.user_pin_pic);
    }
    view.buildDrawingCache();
    Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);

    return bitmap;
}

activity_maps.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.AppBarLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <fragment
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".ui.MapActivity"
            class="com.inmob.chatin.fragment.MySupportMapFragment"/>

        <com.inmob.chatin.views.OverlayMyMap
            android:id="@+id/mapOverLayView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:background="@color/dark_light_transparent"
            android:visibility="gone" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:gravity="center_vertical"
            android:layout_alignParentRight="true"
            android:orientation="vertical"
            android:paddingBottom="50dp"
            android:layout_marginBottom="20dp">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_button_my_location"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"

         android:layout_marginBottom="@dimen/codelab_fab_margin_bottom"
                android:layout_marginRight="@dimen/codelab_fab_margin_right"
                android:paddingTop="@dimen/codelab_fab_padding_bottom"
                android:src="@drawable/current_location"
                app:backgroundTint="@color/white"
                app:fabSize="normal" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_button_draw"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"

  android:layout_marginBottom="@dimen/codelab_fab_margin_bottom"
                android:layout_marginRight="@dimen/codelab_fab_margin_right"
                android:paddingBottom="@dimen/codelab_fab_padding_bottom"
                android:src="@drawable/map_pen"
                app:backgroundTint="@color/colorPrimary"
                app:fabSize="normal" />

        </LinearLayout>

    </RelativeLayout>

</LinearLayout>

</RelativeLayout>

custom_marker_layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
    android:layout_width="94dp"
    android:layout_height="94dp"
    android:src="@drawable/user_pin" />

<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/user_image"
    android:layout_width="90dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="1dp"
    android:layout_marginTop="6dp"
    fresco:actualImageScaleType="focusCrop"
    fresco:fadeDuration="300"
    fresco:placeholderImage="@color/colorAccent"
    fresco:placeholderImageScaleType="fitCenter"
    fresco:roundAsCircle="true"
    fresco:roundingBorderWidth="2dp"
    fresco:viewAspectRatio="1.33" />
    </RelativeLayout>

Gradle

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
useLibrary 'org.apache.http.legacy'

sourceSets.main {
    jniLibs.srcDir 'libs'
    jni.srcDirs = [] //disable automatic ndk-build call
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/libjingle_peerconnection.jar')

implementation project(":simple-crop-image-lib")
implementation project(":autobahn")
//compile project(":xmpp")
implementation project(":xmpplibrary")

implementation project(":linkedin-sdk")
implementation('com.facebook.fresco:fresco:0.13.0+') {
    exclude group: 'com.parse.bolts', module: 'bolts-applinks'
    exclude module: 'bolts-android'
    exclude group: 'com.parse.bolts', module: 'bolts-tasks'
}




implementation('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true
}
implementation 'com.googlecode.libphonenumber:libphonenumber:8.7.1'
implementation group: 'com.nineoldandroids', name: 'library', version: 
'2.4.0'
implementation 'com.android.support:multidex:1.0.1'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'link.fls:swipestack:0.3.0'
implementation 'com.nispok:snackbar:2.11.0'
implementation 'com.facebook.android:facebook-android-sdk:4.26.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-plus:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'it.sephiroth.android.library.easing:android-easing:1.0.3'
implementation 'com.romainpiel.shimmer:library:1.4.0'
implementation 'com.tonicartos:stickygridheaders:1.0.1'
implementation 'com.github.chrisbanes.photoview:library:1.2.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
implementation 'org.glassfish:javax.annotation:10.0-b28'
implementation 'com.google.android.gms:play-services-analytics:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

версия ниже 8: version below 8

версия 8: version 8

...