Search in sources :

Example 1 with MainActivity

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);
        }
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) SecondaryActivity(org.videolan.vlc.gui.SecondaryActivity) MainActivity(org.videolan.vlc.gui.MainActivity) Activity(android.app.Activity) MainActivity(org.videolan.vlc.gui.MainActivity)

Example 2 with MainActivity

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();
}
Also used : Intent(android.content.Intent) MainActivity(org.videolan.vlc.gui.MainActivity) AudioPlayerActivity(org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity)

Example 3 with MainActivity

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);
        }
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) MainActivity(org.videolan.vlc.gui.MainActivity) SecondaryActivity(org.videolan.vlc.gui.SecondaryActivity) Activity(android.app.Activity)

Example 4 with MainActivity

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;
}
Also used : SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) MainActivity(org.videolan.vlc.gui.MainActivity) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Example 5 with MainActivity

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;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentActivity(android.support.v4.app.FragmentActivity) MainActivity(org.videolan.vlc.gui.MainActivity) Fragment(android.support.v4.app.Fragment) View(android.view.View) ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

MainActivity (org.videolan.vlc.gui.MainActivity)8 Intent (android.content.Intent)4 SharedPreferences (android.content.SharedPreferences)4 ArrayList (java.util.ArrayList)4 Activity (android.app.Activity)2 ComponentName (android.content.ComponentName)2 PackageManager (android.content.pm.PackageManager)2 ResolveInfo (android.content.pm.ResolveInfo)2 Bundle (android.os.Bundle)2 Fragment (android.support.v4.app.Fragment)2 FragmentActivity (android.support.v4.app.FragmentActivity)2 FragmentManager (android.support.v4.app.FragmentManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)2 SecondaryActivity (org.videolan.vlc.gui.SecondaryActivity)2 AudioPlayerActivity (org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity)2 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)2 MediaGroup (org.videolan.vlc.media.MediaGroup)2