Skip to content

Commit

Permalink
[android] set wallpaper action non-blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
gubatron committed May 8, 2017
1 parent 74a20bb commit 52c4e13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,5 @@
<string name="fullscreen">fullscreen</string>
<string name="size">Size</string>
<string name="date">Date</string>
<string name="your_android_wall_paper_will_change">Your Android wallpaper will change in a few seconds</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.frostwire.android.R;
import com.frostwire.android.core.FileDescriptor;
import com.frostwire.android.core.Constants;
import com.frostwire.android.gui.services.Engine;
import com.frostwire.android.gui.util.UIUtils;
import com.frostwire.android.gui.views.MenuAction;

Expand All @@ -45,16 +46,21 @@ public SetAsWallpaperMenuAction(Context context, FileDescriptor fd) {
}

@Override
protected void onClick(Context context) {
protected void onClick(final Context context) {
if (fd.fileType != Constants.FILE_TYPE_PICTURES) {
return;
}

try {
Bitmap bitmap = BitmapFactory.decodeFile(fd.filePath);
WallpaperManager.getInstance(context).setBitmap(bitmap);
} catch (Throwable e) {
UIUtils.showShortMessage(context, R.string.failed_to_set_wallpaper);
}
UIUtils.showShortMessage(context, R.string.your_android_wall_paper_will_change);
Engine.instance().getThreadPool().submit(new Runnable() {
@Override
public void run() {
try {
Bitmap bitmap = BitmapFactory.decodeFile(fd.filePath);
WallpaperManager.getInstance(context).setBitmap(bitmap);
} catch (Throwable e) {
UIUtils.showShortMessage(context, R.string.failed_to_set_wallpaper);
}
}
});
}
}

0 comments on commit 52c4e13

Please sign in to comment.