use of org.videolan.vlc.gui.MainActivity in project vlc-android by videolan.
the class VideoGridFragment method onClick.
@Override
public void onClick(View v, int position, MediaLibraryItem item) {
final MediaWrapper media = (MediaWrapper) item;
if (mActionMode != null) {
item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
mAdapter.updateSelectionCount(item.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
mAdapter.notifyItemChanged(position, VideoListAdapter.UPDATE_SELECTION);
invalidateActionMode();
return;
}
final Activity activity = getActivity();
if (media instanceof MediaGroup) {
final String title = media.getTitle().substring(media.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
((MainActivity) activity).showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
} else {
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
if (settings.getBoolean("force_play_all", false)) {
final List<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(activity, playList, mAdapter.getListWithPosition(playList, position));
} else {
playVideo(media, false);
}
}
}
use of org.videolan.vlc.gui.MainActivity in project vlc-android by videolan.
the class VideoPlayerActivity method switchToAudioMode.
public void switchToAudioMode(boolean showUI) {
if (mService == null)
return;
mSwitchingView = true;
// Show the MainActivity if it is not in background.
if (showUI) {
Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class);
startActivity(i);
} else
mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true).apply();
exitOK();
}
use of org.videolan.vlc.gui.MainActivity in project vlc-android by GeoffreyMetais.
the class VideoGridFragment method onClick.
@Override
public void onClick(View v, int position, MediaLibraryItem item) {
final MediaWrapper media = (MediaWrapper) item;
if (mActionMode != null) {
item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
mAdapter.updateSelectionCount(item.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
mAdapter.notifyItemChanged(position, Constants.UPDATE_SELECTION);
invalidateActionMode();
return;
}
final Activity activity = getActivity();
if (media instanceof MediaGroup) {
final String title = media.getTitle().substring(media.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
((MainActivity) activity).getNavigator().showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
} else {
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
if (settings.getBoolean("force_play_all", false)) {
final List<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(activity, playList, mAdapter.getListWithPosition(playList, position));
} else {
playVideo(media, false);
}
}
}
use of org.videolan.vlc.gui.MainActivity in project vlc-android by videolan.
the class ExtensionsManager method updateAvailableExtensions.
private List<ExtensionListing> updateAvailableExtensions(Context context) {
androidAutoInstalled = isAndroidAutoInstalled(context);
PackageManager pm = context.getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(ACTION_EXTENSION), PackageManager.GET_META_DATA);
List<ExtensionListing> extensions = new ArrayList<>();
for (ResolveInfo resolveInfo : resolveInfos) {
ExtensionListing extension = new ExtensionListing();
extension.componentName(new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name));
Bundle metaData = resolveInfo.serviceInfo.metaData;
if (metaData != null) {
extension.compatible(metaData.getInt(KEY_PROTOCOL_VERSION) == PROTOCOLE_VERSION);
if (!extension.compatible())
continue;
String title = metaData.getString(KEY_LISTING_TITLE);
extension.title(title != null ? title : resolveInfo.loadLabel(pm).toString());
extension.description(metaData.getString(KEY_DESCRIPTION));
String settingsActivity = metaData.getString(KEY_SETTINGS_ACTIVITY);
if (!TextUtils.isEmpty(settingsActivity)) {
extension.settingsActivity(ComponentName.unflattenFromString(resolveInfo.serviceInfo.packageName + "/" + settingsActivity));
}
extension.androidAutoEnabled(metaData.getBoolean(KEY_ANDROID_AUTO_ENABLED, false));
extension.menuIcon(metaData.getInt(KEY_MENU_ICON, 0));
extensions.add(extension);
}
}
SharedPreferences settings = Settings.INSTANCE.getInstance(context);
deleteUnusedExtensionPreferences(extensions, settings);
if (context instanceof MainActivity && ((MainActivity) context).currentIdIsExtension()) {
if (previousExtensionIsEnabled(context)) {
String lastExtensionTitle = settings.getString("current_extension_name", null);
for (int i = 0; i < extensions.size(); ++i) {
if (TextUtils.equals(extensions.get(i).title(), lastExtensionTitle)) {
((MainActivity) context).setCurrentFragmentId(i);
settings.edit().putInt("fragment_id", i).apply();
break;
}
}
} else {
((MainActivity) context).setCurrentFragmentId(-1);
settings.edit().putInt("fragment_id", -1).apply();
}
}
synchronized (mExtensions) {
mExtensions.clear();
mExtensions.addAll(extensions);
}
return extensions;
}
use of org.videolan.vlc.gui.MainActivity in project vlc-android by videolan.
the class BaseBrowserFragment method goBack.
public boolean goBack() {
final FragmentActivity activity = getActivity();
if (activity == null)
return false;
if (!mRoot) {
final FragmentManager fm = activity.getSupportFragmentManager();
final String tag = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName();
if (!activity.getSupportFragmentManager().popBackStackImmediate() && activity instanceof MainActivity)
((MainActivity) activity).showFragment(this instanceof NetworkBrowserFragment ? R.id.nav_network : R.id.nav_directories);
final Fragment current = fm.findFragmentByTag(tag);
final View view = current != null ? current.getView() : null;
if (view != null)
view.setVisibility(View.VISIBLE);
}
return !mRoot;
}
Aggregations