android - Unable to load profile image and header background from URL -


i followed this tutorial step step when want load profile image , header background nothing displayed. added internet permission , wifi on , initialized drawerimageloader. problem be?

main activity:

import android.net.uri; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.view; import android.widget.imageview;  import com.mikepenz.materialdrawer.drawerbuilder; import com.mikepenz.materialdrawer.accountheader; import com.mikepenz.materialdrawer.accountheaderbuilder; import com.mikepenz.materialdrawer.model.profiledraweritem; import com.mikepenz.materialdrawer.model.interfaces.iprofile;  import com.bumptech.glide.glide;   public class mainactivity extends appcompatactivity {;  toolbar toolbar;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);    new drawerbuilder().withactivity(this).build();    accountheader headerresult = new accountheaderbuilder()             .withactivity(this)             .addprofiles(                     new profiledraweritem().withname("mike    penz").withemail("mikepenz@gmail.com").withicon(uri.   parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"))             )             .withonaccountheaderlistener(new    accountheader.onaccountheaderlistener() {                 @override                 public boolean onprofilechanged(view view, iprofile profile,    boolean currentprofile) {                    return false;                 }             })             .build();    new drawerbuilder()             .withactivity(this)             .withaccountheader(headerresult)             .build();    imageview view = headerresult.getheaderbackgroundview();   glide.with(this).load("www.api.androidhive.info/images/nav-menu-header-   bg.jpg").into(view);   }    } 

custom activity:

import android.app.application; import android.content.context; import android.graphics.drawable.drawable; import android.net.uri; import android.widget.imageview;  import com.bumptech.glide.glide; import com.mikepenz.iconics.iconicsdrawable; import com.mikepenz.materialdrawer.util.abstractdrawerimageloader; import com.mikepenz.materialdrawer.util.drawerimageloader; import com.mikepenz.materialdrawer.util.draweruiutils;  /**  * created mikepenz on 27.03.15.  *  */ public class customapplication extends application {  @override public void oncreate() {     super.oncreate();      /*     //initialize , create image loader logic     drawerimageloader.init(new abstractdrawerimageloader() {         @override         public void set(imageview imageview, uri uri, drawable placeholder)     {     picasso.with(imageview.getcontext()).load(uri).placeholder(placeholder)    .into(imageview);         }         @override         public void cancel(imageview imageview) {             picasso.with(imageview.getcontext()).cancelrequest(imageview);         }     });     */      //initialize , create image loader logic     drawerimageloader.init(new abstractdrawerimageloader() {         @override         public void set(imageview imageview, uri uri, drawable placeholder,     string tag) {    glide.with(imageview.getcontext()).load(uri)   .placeholder(placeholder).into(imageview);         }          @override         public void cancel(imageview imageview) {             glide.clear(imageview);         }          @override         public drawable placeholder(context ctx, string tag) {             //define different placeholders different imageview targets             //default tags accessible via drawerimageloader.tags             if (drawerimageloader.tags.profile.name().equals(tag)) {                 return draweruiutils.getplaceholder(ctx);             } else if   (drawerimageloader.tags.account_header.name().equals(tag)) {                 return new iconicsdrawable(ctx).icontext("   ").backgroundcolorres(com.mikepenz.materialdrawer.r.color.primary) .sizedp(56);             } else if ("customurlitem".equals(tag)) {                 return new iconicsdrawable(ctx).icontext("  ").backgroundcolorres(r.color.md_red_500).sizedp(56);             }              //we use default 1             //drawerimageloader.tags.profile_drawer_item.name()              return super.placeholder(ctx, tag);         }     }); } } 

manifest:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ir.techend.yusof.ghaza">  <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.write_external_storage"/>  <application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:roundicon="@mipmap/ic_launcher_round"     android:supportsrtl="true"     android:theme="@style/apptheme">     <activity         android:name=".mainactivity"         android:label="@string/app_name"         android:theme="@style/apptheme">         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> </manifest> 

please remove duplicated

new drawerbuilder().withactivity(this).build(); 

which have in mainactivity, must .build() 1 drawer (and in cases .append() one)

the code of drawer make sure not 2 drawerlayout's inflated.

in addition checked url header image. 1 not exist. (http://www.api.androidhive.info/images/nav-menu-header-bg.jpg returns 404)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -