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