0

http://cloudinary.com/に保存されている画像でListViewを膨らまそうとしています。イメージのURLはFirebaseデータベースにフィールドとして保存されます。私は同じもののためにピカソクライアントを使用しています。しかし、私のデータベースで気づいているのは、各レコードに保存されているURL Linkが正常に動作しているということです。しかし、自分のコードで同じものを取得しようとすると、URLがnullであることがトーストとして示されます。 他のすべてのレコードが正しくフェッチされ、画像以外は正常に動作しています。PicassoのURLを使用してFirebaseデータベースから画像を読み込むことができません

1)リストビューの初期化とアダプタの設定。ここで私が表示されただけのプレースホルダイメージを:ピカソを使用して画像をダウンロード

HomeSearchActivity.java

@Override 
    protected void onStart() { 

     databaseMember.addValueEventListener(new ValueEventListener() { 
      @Override 
      public void onDataChange(DataSnapshot dataSnapshot) { 

       memberList.clear(); 
       for (DataSnapshot memberSnapshot : dataSnapshot.getChildren()) { 
        Member_Pojo member = memberSnapshot.getValue(Member_Pojo.class); 
        Log.e(TAG, "onDataChange: " + member.getName()); 
        memberList.add(member); 
       } 

       MembersListAdapter adapter = new MembersListAdapter(HomeSearchActivity.this, memberList); 
       listViewHome.setAdapter(adapter); 
      } 

      @Override 
      public void onCancelled(DatabaseError databaseError) { 

      } 
     }); 
     super.onStart(); 
    } 

2)リストビューのためのアダプタクラス

MembersListAdapter.java 


import android.app.Activity; 
import android.support.annotation.NonNull; 
import android.support.annotation.Nullable; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ArrayAdapter; 
import android.widget.ImageView; 
import android.widget.TextView; 

import java.util.List; 

/** 
* Created by Sumeet on 05-07-2017. 
*/ 

public class MembersListAdapter extends ArrayAdapter<Member_Pojo> { 

    private Activity context; 
    // private Context c; 
    private List<Member_Pojo> memberList; 
    // CustomFilter filter; 
    // ArrayList<Member_Pojo> filterlist; 


    public MembersListAdapter(Activity context, List<Member_Pojo> memberList) { 
     super(context, R.layout.home_listview_display, memberList); 
     this.context = context; 
     this.memberList = memberList; 
     //this.filterlist = (ArrayList<Member_Pojo>) memberList; 
    } 

    @NonNull 
    @Override 
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { 
     LayoutInflater inflater = context.getLayoutInflater(); 
     View listViewItem = inflater.inflate(R.layout.home_listview_display, null, true); 

     TextView name_tv = (TextView) listViewItem.findViewById(R.id.tv_name_display); 
     TextView town_tv = (TextView) listViewItem.findViewById(R.id.tv_town_display); 
     TextView id = (TextView) listViewItem.findViewById(R.id.textViewID); 
     ImageView imageView_dp = (ImageView) listViewItem.findViewById(R.id.imageView_dps); 
     Member_Pojo member = memberList.get(position); 

     name_tv.setText(member.getName()); 
     town_tv.setText(member.getTownP()); 
     id.setText(member.getId()); 

     Toast.makeText(context, "URL IS : " + member.getDP_URL(), Toast.LENGTH_SHORT).show(); 
     Toast.makeText(context, "name IS : " + member.getName(), Toast.LENGTH_SHORT).show(); 
     PicassoClient.downloadImage(context, member.getDP_URL(), imageView_dp); 
     imageView_dp.setImageResource(member.getDP_URL()); 

     return listViewItem; 

    } 

} 

3)。私は仮定する理由は、クラスがnull値が渡されることである。(値を渡す前に、ログを使用してみました、そして、それがNULLであった。)

import android.content.Context; 
import android.util.Log; 
import android.widget.ImageView; 

import com.squareup.picasso.Picasso; 

/** 
* Created by Sumeet on 15-07-2017. 
*/ 

public class PicassoClient { 
    public static void downloadImage(Context c, String url, ImageView img) { 
     if (url != null && url.length() > 0) { 
      Picasso.with(c).load(url).placeholder(R.drawable.noimage).into(img); 
      Log.e("myTag", "URL is not null" + url); 
     } else { 
      Picasso.with(c).load(R.drawable.noimage).into(img); 
      Log.e("myTag", "URL is null"); 
     } 
    } 
} 

4)は以下のログ出力

            [ 07-16 15:48:30.305 22740:22740 D/   ] 
               HostConnection::get() New Host Connection established 0x77f95fc15420, tid 22740 
07-16 15:48:30.321 22740-22804/com.example.sumeet.kalwardirectorytry1 D/NetworkSecurityConfig: No Network Security Config specified, using platform default 

                           [ 07-16 15:48:30.379 22740:22803 D/   ] 
                           HostConnection::get() New Host Connection established 0x77f95fc15cc0, tid 22803 
07-16 15:48:30.380 1298-3194/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer 
07-16 15:48:30.381 22740-22803/com.example.sumeet.kalwardirectorytry1 I/OpenGLRenderer: Initialized EGL, version 1.4 
07-16 15:48:30.382 22740-22803/com.example.sumeet.kalwardirectorytry1 D/OpenGLRenderer: Swap behavior 1 
07-16 15:48:30.382 22740-22803/com.example.sumeet.kalwardirectorytry1 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 
07-16 15:48:30.382 22740-22803/com.example.sumeet.kalwardirectorytry1 D/OpenGLRenderer: Swap behavior 0 
07-16 15:48:30.394 1298-3194/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer 
07-16 15:48:30.423 1298-3194/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer 
07-16 15:48:30.511 22740-22740/com.example.sumeet.kalwardirectorytry1 W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 
07-16 15:48:30.724 2898-2898/com.android.inputmethod.latin W/InputMethodService: Window size has been changed. This may cause jankiness of resizing window: -1 -> -2 
07-16 15:48:30.727 2098-2355/system_process I/ActivityManager: Displayed com.example.sumeet.kalwardirectorytry1/.HomeSearchActivity: +2s66ms 
07-16 15:48:30.736 22740-22783/com.example.sumeet.kalwardirectorytry1 D/FA: Connected to remote service 
07-16 15:48:30.736 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Processing queued up service tasks: 2 
07-16 15:48:30.775 2898-2898/com.android.inputmethod.latin I/LatinIME: Starting input. Cursor position = -1,-1 
07-16 15:48:30.776 2898-2898/com.android.inputmethod.latin E/RichInputConnection: Unable to connect to the editor to retrieve text. 
07-16 15:48:30.776 2898-2898/com.android.inputmethod.latin D/RichInputConnection: Will try to retrieve text later. 
07-16 15:48:30.777 2898-2898/com.android.inputmethod.latin I/InputAttributes: InputType.TYPE_NULL is specified 
07-16 15:48:30.827 1298-1298/? W/SurfaceFlinger: couldn't log to binary event log: overflow. 
07-16 15:48:30.829 1298-1298/? W/SurfaceFlinger: couldn't log to binary event log: overflow. 
07-16 15:48:30.919 2098-2355/system_process D/gralloc_ranchu: gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread) 
07-16 15:48:30.940 2898-2898/com.android.inputmethod.latin I/LatinIME: Starting input. Cursor position = 0,0 
07-16 15:48:31.085 1298-1617/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer 
07-16 15:48:31.103 1298-1616/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer 
07-16 15:48:31.123 1298-1616/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer 
07-16 15:48:31.522 4179-4179/com.google.android.gms.unstable W/Binder:4179_2: type=1400 audit(0.0:15): avc: denied { read } for name="/" dev="tmpfs" ino=4097 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0 
07-16 15:48:32.909 3847-4858/com.google.android.gms.persistent W/Conscrypt: Could not set socket write timeout: null 
07-16 15:48:33.178 3847-4858/com.google.android.gms.persistent W/Conscrypt: Could not set socket write timeout: null 
07-16 15:48:33.246 1311-1366/? D/AudioFlinger: mixer(0xebc83900) throttle end: throttle time(18) 
07-16 15:48:33.373 2898-2898/com.android.inputmethod.latin W/InputMethodService: Window size has been changed. This may cause jankiness of resizing window: -1 -> -2 
07-16 15:48:33.609 3847-4858/com.google.android.gms.persistent W/GLSUser: [AppCertManager] IOException while requesting key: 
                      java.io.IOException: Invalid device key response. 
                       at evk.a(:com.google.android.gms:274) 
                       at evk.a(:com.google.android.gms:4238) 
                       at evj.a(:com.google.android.gms:45) 
                       at evd.a(:com.google.android.gms:50) 
                       at evc.a(:com.google.android.gms:104) 
                       at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms:4049) 
                       at ecm.call(:com.google.android.gms:2041) 
                       at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                       at llt.run(:com.google.android.gms:450) 
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
                       at lqc.run(:com.google.android.gms:17) 
                       at java.lang.Thread.run(Thread.java:761) 
07-16 15:48:35.848 22740-22740/com.example.sumeet.kalwardirectorytry1 W/ClassMapper: No setter/field for dp_URL found on class com.example.sumeet.kalwardirectorytry1.Member_Pojo (fields/setters are case sensitive!) 
07-16 15:48:35.851 22740-22740/com.example.sumeet.kalwardirectorytry1 E/myTag: onDataChange: Sumeet 
07-16 15:48:35.852 22740-22740/com.example.sumeet.kalwardirectorytry1 W/ClassMapper: No setter/field for dp_URL found on class com.example.sumeet.kalwardirectorytry1.Member_Pojo (fields/setters are case sensitive!) 
07-16 15:48:35.852 22740-22740/com.example.sumeet.kalwardirectorytry1 E/myTag: onDataChange: Sumeet Shah 
07-16 15:48:35.855 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Inactivity, disconnecting from the service 
07-16 15:48:35.894 22740-22740/com.example.sumeet.kalwardirectorytry1 W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value. 
07-16 15:48:35.912 22740-22740/com.example.sumeet.kalwardirectorytry1 E/myTag: URL is null 
07-16 15:48:35.915 22740-22740/com.example.sumeet.kalwardirectorytry1 E/myTag: URL is null 
07-16 15:48:38.917 3567-22923/? I/ContextCompilationHandl: Compiling grammar for: en-US, type=CONTACT_DIALING 
07-16 15:48:38.922 3567-22923/? I/ContextCompilationHandl: No grammar compilation resources for COMPILER, aborting. 
07-16 15:48:38.922 3567-22923/? I/ContextCompilationHandl: Compiling grammar for: en-US, type=HANDS_FREE_COMMANDS 
07-16 15:48:38.923 3567-22923/? I/ContextCompilationHandl: No grammar compilation resources for COMPILER, aborting. 
07-16 15:48:38.923 3567-22923/? I/ContextCompilationHandl: Compiling grammar for: en-US, type=CONTACT_NAMES 
07-16 15:48:38.927 3567-22923/? I/ContextCompilationHandl: No grammar compilation resources for VOICE_ACTIONS_COMPILER, aborting. 
07-16 15:48:38.928 3567-22923/? I/ContextCompilationHandl: Compiling grammar for: en-US, type=APP_NAMES 
07-16 15:48:38.930 3567-22923/? I/ContextCompilationHandl: No grammar compilation resources for VOICE_ACTIONS_COMPILER, aborting. 
07-16 15:48:38.930 3567-22923/? I/ContextCompilationHandl: Compiling grammar for: en-US, type=MUSIC_NAMES 
07-16 15:48:38.934 3567-22923/? I/ContextCompilationHandl: No grammar compilation resources for VOICE_ACTIONS_COMPILER, aborting. 
07-16 15:48:40.274 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Session started, time: 1485812 
07-16 15:48:40.281 22740-22783/com.example.sumeet.kalwardirectorytry1 I/FA: Tag Manager is not found and thus will not be used 
07-16 15:48:40.288 22740-22783/com.example.sumeet.kalwardirectorytry1 D/FA: Logging event (FE): _s, Bundle[{_o=auto, _sc=HomeSearchActivity, _si=-7738148218987138517}] 
07-16 15:48:40.306 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Using measurement service 
07-16 15:48:40.306 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Connecting to remote service 
07-16 15:48:40.317 22740-22783/com.example.sumeet.kalwardirectorytry1 D/FA: Connected to remote service 
07-16 15:48:40.317 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Processing queued up service tasks: 1 
07-16 15:48:40.335 3533-22811/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=_s,params=Bundle[mParcelledData.dataSize=120] 
07-16 15:48:40.340 3533-22811/com.google.android.gms V/FA-SVC: Saving event, name, data size: _s, 64 
07-16 15:48:40.341 3533-22811/com.google.android.gms V/FA-SVC: Event recorded: Event{appId='com.example.sumeet.kalwardirectorytry1', name='_s', params=Bundle[{_o=auto, _sc=HomeSearchActivity, _si=-7738148218987138517}]} 
07-16 15:48:40.345 3533-22811/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 2374370 
07-16 15:48:40.347 3533-22811/com.google.android.gms V/FA-SVC: Background event processing time, ms: 12 
07-16 15:48:45.335 22740-22783/com.example.sumeet.kalwardirectorytry1 V/FA: Inactivity, disconnecting from the service 
07-16 15:49:27.772 3567-3567/? I/GrammarCompilationSvcCt: #startService for null, APP_NAMES. 
07-16 15:49:27.777 3567-23636/? I/ContextCompilationHandl: Compiling grammar for: en-US, type=APP_NAMES 

Can you Please let me know where am I going wrong on this? Any Help On this is really appreciated. 
あります

答えて

0

ピカソを使用してアダプタに画像をダウンロードして表示することに非常によく似た問題がありました。お試しくださいGlide

私の場合はこの問題を解決しました。

+0

ピカソに問題があるとは思わない、合格した文字列自体にヌル値が表示されているから –

+0

グライドを試しましたか? – Sandy

+0

はい良かったです。私はピカソと最終的に管理:) –

関連する問題