Skip to content

Commit 1516c00

Browse files
committed
BackupAndRestoreHelper: small refactor
1 parent c53dda5 commit 1516c00

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/misc/BackupAndRestoreHelper.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import android.net.Uri;
99
import android.os.Build.VERSION;
1010
import android.provider.OpenableColumns;
11-
import android.widget.Toast;
1211

1312
import com.liskovsoft.sharedutils.helpers.DateHelper;
1413
import com.liskovsoft.sharedutils.helpers.FileHelpers;
15-
import com.liskovsoft.sharedutils.rx.RxHelper;
14+
import com.liskovsoft.sharedutils.helpers.MessageHelpers;
1615
import com.liskovsoft.smartyoutubetv2.common.R;
1716
import com.liskovsoft.smartyoutubetv2.common.app.presenters.settings.BackupSettingsPresenter;
17+
import com.liskovsoft.smartyoutubetv2.common.misc.MediaServiceManager.OnError;
1818
import com.liskovsoft.smartyoutubetv2.common.misc.MotherActivity.OnResult;
1919
import com.liskovsoft.smartyoutubetv2.common.prefs.GeneralData;
2020

@@ -164,7 +164,7 @@ public void handleIncomingZip(Intent intent) {
164164
unpackTempZip(
165165
zipUri,
166166
() -> BackupSettingsPresenter.instance(mContext).showLocalRestoreDialogApi30(),
167-
() -> Toast.makeText(mContext, "Failed to restore backup", Toast.LENGTH_SHORT).show()
167+
error -> MessageHelpers.showLongMessage(mContext, "Failed to restore backup: " + error.getMessage())
168168
);
169169
}
170170

@@ -192,9 +192,9 @@ public void unpackTempZip(File tempZip) {
192192
tempZip.delete();
193193
}
194194

195-
private void unpackTempZip(Uri zipUri, Runnable onSuccess, Runnable onError) {
195+
private void unpackTempZip(Uri zipUri, Runnable onSuccess, OnError onError) {
196196
if (zipUri == null) {
197-
Toast.makeText(mContext, "No ZIP received", Toast.LENGTH_SHORT).show();
197+
MessageHelpers.showLongMessage(mContext, "No ZIP received");
198198
return;
199199
}
200200

@@ -207,7 +207,7 @@ private void unpackTempZip(Uri zipUri, Runnable onSuccess, Runnable onError) {
207207
} catch (Exception ex) {
208208
ex.printStackTrace();
209209
if (onError != null) {
210-
onError.run();
210+
onError.onError(ex);
211211
}
212212
}
213213
}
@@ -248,6 +248,7 @@ private void copyUriToDir(Uri uri, File targetDir) {
248248

249249
} catch (Exception e) {
250250
e.printStackTrace();
251+
throw new IllegalStateException("Failed to copyUriToDir", e);
251252
}
252253
}
253254

@@ -267,6 +268,7 @@ private void copyUriToFile(Uri uri, File outFile) {
267268

268269
} catch (Exception e) {
269270
e.printStackTrace();
271+
throw new IllegalStateException("Failed to copyUriToFile", e);
270272
}
271273
}
272274

0 commit comments

Comments
 (0)