Skip to content

Commit

Permalink
Fix for image loading in notifications for Android cqr/PlayerHater#35
Browse files Browse the repository at this point in the history
  • Loading branch information
rockykitamura committed Jan 29, 2017
1 parent fe94575 commit 34917de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,12 @@ https://github.com/pouriaMaleki/cordova-plugin-playerhater/commit/c33862e3b078e6
MEDIA_STOPPED : 4
MEDIA_LOADING : 5
MEDIA_COMPLETED : 6


## Android specific

Add the following in `build-extras.gradle` in `platforms/android/` to support Image URL in Notification

dependencies {
compile 'com.squareup.picasso:picasso:2.3.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import android.os.Build;
import android.view.KeyEvent;
import android.widget.RemoteViews;
import android.os.Looper;
import android.os.Handler;

import com.squareup.picasso.Picasso;
import org.prx.playerhater.BroadcastReceiver;
import de.radiosaw.radiosawiphone.R;
import org.prx.playerhater.Song;
Expand Down Expand Up @@ -199,9 +202,18 @@ protected void setImageViewResource(int id, int resourceId) {
}
}

protected void setImageViewUri(int id, Uri contentUri) {
protected void setImageViewUri(int id, final Uri contentUri) {
if (mNotificationView != null && contentUri != null) {
mNotificationView.setImageViewUri(id, contentUri);
// mNotificationView.setImageViewUri(id, contentUri);
Handler uiHandler = new Handler(Looper.getMainLooper());
uiHandler.post(new Runnable(){
@Override
public void run() {
Picasso.with(getContext()).load(contentUri.toString())
.into(mNotificationView, id, NOTIFICATION_NU, getNotification());
}
});
}

}
}

0 comments on commit 34917de

Please sign in to comment.