20251129_163631_757
This commit is contained in:
@@ -48,6 +48,7 @@ public class NetworkBackgroundDialog extends AlertDialog {
|
|||||||
private Handler mUiHandler;
|
private Handler mUiHandler;
|
||||||
String previewFilePath;
|
String previewFilePath;
|
||||||
String previewFileUrl;
|
String previewFileUrl;
|
||||||
|
String downloadSavedPath;
|
||||||
|
|
||||||
// 按钮点击回调接口(Java7 接口实现)
|
// 按钮点击回调接口(Java7 接口实现)
|
||||||
public interface OnDialogClickListener {
|
public interface OnDialogClickListener {
|
||||||
@@ -89,8 +90,8 @@ public class NetworkBackgroundDialog extends AlertDialog {
|
|||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_IMAGE_LOAD_SUCCESS:
|
case MSG_IMAGE_LOAD_SUCCESS:
|
||||||
// 图片加载成功,获取文件路径并设置背景
|
// 图片加载成功,获取文件路径并设置背景
|
||||||
previewFilePath = (String) msg.obj;
|
downloadSavedPath = (String) msg.obj;
|
||||||
setBackgroundFromPath(previewFilePath);
|
previewBackground(downloadSavedPath);
|
||||||
break;
|
break;
|
||||||
case MSG_IMAGE_LOAD_FAILED:
|
case MSG_IMAGE_LOAD_FAILED:
|
||||||
// 图片加载失败,设置默认背景
|
// 图片加载失败,设置默认背景
|
||||||
@@ -191,7 +192,7 @@ public class NetworkBackgroundDialog extends AlertDialog {
|
|||||||
* 根据文件路径设置 BackgroundView 背景(主线程调用)
|
* 根据文件路径设置 BackgroundView 背景(主线程调用)
|
||||||
* @param filePath 图片文件路径
|
* @param filePath 图片文件路径
|
||||||
*/
|
*/
|
||||||
private void setBackgroundFromPath(String filePath) {
|
private void previewBackground(String filePath) {
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
try {
|
try {
|
||||||
File imageFile = new File(filePath);
|
File imageFile = new File(filePath);
|
||||||
@@ -258,7 +259,6 @@ public class NetworkBackgroundDialog extends AlertDialog {
|
|||||||
ImageDownloader.getInstance(mContext).downloadImage(previewFileUrl, new ImageDownloader.DownloadCallback(){
|
ImageDownloader.getInstance(mContext).downloadImage(previewFileUrl, new ImageDownloader.DownloadCallback(){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String savePath) {
|
public void onSuccess(String savePath) {
|
||||||
ToastUtils.show("下载成功:" + savePath);
|
|
||||||
// 发送消息到主线程,携带图片路径
|
// 发送消息到主线程,携带图片路径
|
||||||
Message successMsg = mUiHandler.obtainMessage(MSG_IMAGE_LOAD_SUCCESS, savePath);
|
Message successMsg = mUiHandler.obtainMessage(MSG_IMAGE_LOAD_SUCCESS, savePath);
|
||||||
mUiHandler.sendMessage(successMsg);
|
mUiHandler.sendMessage(successMsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user