mirror of
https://github.com/yuliskov/SmartTube.git
synced 2025-05-17 11:25:54 +08:00
npe fixes
This commit is contained in:
@ -619,6 +619,10 @@ public class PlayerUIController extends BasePlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleConfirmKey(int keyCode) {
|
private boolean handleConfirmKey(int keyCode) {
|
||||||
|
if (getPlayer() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean controlsShown = getPlayer().isOverlayShown();
|
boolean controlsShown = getPlayer().isOverlayShown();
|
||||||
|
|
||||||
if (KeyHelpers.isConfirmKey(keyCode) && !controlsShown) {
|
if (KeyHelpers.isConfirmKey(keyCode) && !controlsShown) {
|
||||||
|
@ -56,9 +56,16 @@ public class FileUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static File getFile(Context context, String path) {
|
public static File getFile(Context context, String path) {
|
||||||
|
File filesDir = ContextCompat.getExternalFilesDirs(context, null)[0];
|
||||||
|
|
||||||
|
if (filesDir == null) { // storage device is unavailable
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String npath = path == null ? "" : path;
|
String npath = path == null ? "" : path;
|
||||||
String absolutePath = ContextCompat.getExternalFilesDirs(context, null)[0].getPath();
|
String absolutePath = filesDir.getPath();
|
||||||
if (absolutePath.contains("/Android/data")) {
|
if (absolutePath.contains("/Android/data")) {
|
||||||
int index = absolutePath.indexOf("/Android/data");
|
int index = absolutePath.indexOf("/Android/data");
|
||||||
String storage = absolutePath.substring(0, index).concat(npath.length() > 0 ? FILE_PATH_SEPARATOR : "");
|
String storage = absolutePath.substring(0, index).concat(npath.length() > 0 ? FILE_PATH_SEPARATOR : "");
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.liskovsoft.smartyoutubetv2.tv.ui.webbrowser;
|
package com.liskovsoft.smartyoutubetv2.tv.ui.webbrowser;
|
||||||
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.liskovsoft.smartyoutubetv2.tv.R;
|
import com.liskovsoft.smartyoutubetv2.tv.R;
|
||||||
import com.liskovsoft.smartyoutubetv2.tv.ui.common.LeanbackActivity;
|
import com.liskovsoft.smartyoutubetv2.tv.ui.common.LeanbackActivity;
|
||||||
@ -11,11 +10,7 @@ public class WebBrowserActivity extends LeanbackActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
try {
|
// WebBrowserFragment is not a Fragment: ClassCastException or Fragment.InstantiationException
|
||||||
setContentView(R.layout.fragment_webbrowser);
|
setContentView(R.layout.fragment_webbrowser);
|
||||||
} catch (ClassCastException | Fragment.InstantiationException e) { // WebBrowserFragment is not a Fragment
|
|
||||||
e.printStackTrace();
|
|
||||||
finishReally();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user