Search in sources :

Example 11 with Fragment

use of androidx.fragment.app.Fragment in project android by owncloud.

the class FolderPickerActivity method getListOfFilesFragment.

protected OCFileListFragment getListOfFilesFragment() {
    Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(FolderPickerActivity.TAG_LIST_OF_FOLDERS);
    if (listOfFiles != null) {
        return (OCFileListFragment) listOfFiles;
    }
    Timber.e("Access to unexisting list of files fragment!!");
    return null;
}
Also used : OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) Fragment(androidx.fragment.app.Fragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment)

Example 12 with Fragment

use of androidx.fragment.app.Fragment in project android by owncloud.

the class BaseActivity method dismissLoadingDialog.

/**
 * Dismiss loading dialog
 */
public void dismissLoadingDialog() {
    Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
    if (frag == null) {
        return;
    }
    Timber.d("dismiss loading dialog");
    LoadingDialog loading = (LoadingDialog) frag;
    loading.dismiss();
}
Also used : LoadingDialog(com.owncloud.android.ui.dialog.LoadingDialog) Fragment(androidx.fragment.app.Fragment)

Example 13 with Fragment

use of androidx.fragment.app.Fragment in project android by owncloud.

the class FileMenuFilter method anyFileVideoPreviewing.

private boolean anyFileVideoPreviewing() {
    final FragmentActivity activity = (FragmentActivity) mContext;
    Fragment secondFragment = activity.getSupportFragmentManager().findFragmentByTag(TAG_SECOND_FRAGMENT);
    boolean videoPreviewing = false;
    if (secondFragment instanceof PreviewVideoFragment) {
        for (int i = 0; !videoPreviewing && i < mFiles.size(); i++) {
            videoPreviewing = ((PreviewVideoFragment) secondFragment).getFile().equals(mFiles.get(i));
        }
    }
    return videoPreviewing;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreviewVideoFragment(com.owncloud.android.ui.preview.PreviewVideoFragment) Fragment(androidx.fragment.app.Fragment) PreviewVideoFragment(com.owncloud.android.ui.preview.PreviewVideoFragment)

Example 14 with Fragment

use of androidx.fragment.app.Fragment in project banner by youth5201314.

the class Vp2FragmentRecyclerviewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vp2_fragment_recyclerview);
    ButterKnife.bind(this);
    viewPager2.setAdapter(new FragmentStateAdapter(this) {

        @NonNull
        @Override
        public Fragment createFragment(int position) {
            if (position == 0) {
                return BannerListFragment.newInstance(position);
            } else if (position == 1) {
                return BlankFragment.newInstance();
            } else {
                return BannerFragment.newInstance();
            }
        }

        @Override
        public int getItemCount() {
            return 3;
        }
    });
    new TabLayoutMediator(mTabLayout, viewPager2, (tab, position) -> {
        tab.setText("页面" + position);
    }).attach();
    mBanner.addBannerLifecycleObserver(this).setAdapter(new ImageAdapter(DataBean.getTestData())).setIntercept(false).setIndicator(new CircleIndicator(this));
}
Also used : R(com.test.banner.R) Bundle(android.os.Bundle) TabLayout(com.google.android.material.tabs.TabLayout) ButterKnife(butterknife.ButterKnife) NonNull(androidx.annotation.NonNull) TabLayoutMediator(com.test.banner.util.TabLayoutMediator) CircleIndicator(com.youth.banner.indicator.CircleIndicator) ViewPager2(androidx.viewpager2.widget.ViewPager2) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) BindView(butterknife.BindView) DataBean(com.test.banner.bean.DataBean) Fragment(androidx.fragment.app.Fragment) Banner(com.youth.banner.Banner) ImageAdapter(com.test.banner.adapter.ImageAdapter) ImageAdapter(com.test.banner.adapter.ImageAdapter) NonNull(androidx.annotation.NonNull) CircleIndicator(com.youth.banner.indicator.CircleIndicator) TabLayoutMediator(com.test.banner.util.TabLayoutMediator) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) Fragment(androidx.fragment.app.Fragment)

Example 15 with Fragment

use of androidx.fragment.app.Fragment in project kdeconnect-android by KDE.

the class MprisNowPlayingFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (activityMprisBinding == null) {
        activityMprisBinding = MprisNowPlayingBinding.inflate(inflater);
        mprisControlBinding = activityMprisBinding.mprisControl;
        String targetPlayerName = "";
        Intent activityIntent = requireActivity().getIntent();
        activityIntent.getStringExtra("player");
        activityIntent.removeExtra("player");
        if (TextUtils.isEmpty(targetPlayerName)) {
            if (savedInstanceState != null) {
                targetPlayerName = savedInstanceState.getString("targetPlayer");
            }
        }
        deviceId = requireArguments().getString(MprisPlugin.DEVICE_ID_KEY);
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
        String interval_time_str = prefs.getString(getString(R.string.mpris_time_key), getString(R.string.mpris_time_default));
        final int interval_time = Integer.parseInt(interval_time_str);
        BackgroundService.RunCommand(requireContext(), service -> service.addConnectionListener(connectionReceiver));
        connectToPlugin(targetPlayerName);
        performActionOnClick(mprisControlBinding.loopButton, p -> {
            switch(p.getLoopStatus()) {
                case "None":
                    p.setLoopStatus("Track");
                    break;
                case "Track":
                    p.setLoopStatus("Playlist");
                    break;
                case "Playlist":
                    p.setLoopStatus("None");
                    break;
            }
        });
        performActionOnClick(mprisControlBinding.playButton, MprisPlugin.MprisPlayer::playPause);
        performActionOnClick(mprisControlBinding.shuffleButton, p -> p.setShuffle(!p.getShuffle()));
        performActionOnClick(mprisControlBinding.prevButton, MprisPlugin.MprisPlayer::previous);
        performActionOnClick(mprisControlBinding.rewButton, p -> targetPlayer.seek(interval_time * -1));
        performActionOnClick(mprisControlBinding.ffButton, p -> p.seek(interval_time));
        performActionOnClick(mprisControlBinding.nextButton, MprisPlugin.MprisPlayer::next);
        performActionOnClick(mprisControlBinding.stopButton, MprisPlugin.MprisPlayer::stop);
        mprisControlBinding.volumeSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                BackgroundService.RunCommand(requireContext(), service -> {
                    if (targetPlayer == null)
                        return;
                    targetPlayer.setVolume(seekBar.getProgress());
                });
            }
        });
        positionSeekUpdateRunnable = () -> {
            Context context = getContext();
            // Fragment was already detached
            if (context == null)
                return;
            BackgroundService.RunCommand(context, service -> {
                if (targetPlayer != null) {
                    mprisControlBinding.positionSeek.setProgress((int) (targetPlayer.getPosition()));
                }
                positionSeekUpdateHandler.removeCallbacks(positionSeekUpdateRunnable);
                positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 1000);
            });
        };
        positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 200);
        mprisControlBinding.positionSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean byUser) {
                mprisControlBinding.progressTextview.setText(milisToProgress(progress));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                positionSeekUpdateHandler.removeCallbacks(positionSeekUpdateRunnable);
            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                BackgroundService.RunCommand(requireContext(), service -> {
                    if (targetPlayer != null) {
                        targetPlayer.setPosition(seekBar.getProgress());
                    }
                    positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 200);
                });
            }
        });
        mprisControlBinding.nowPlayingTextview.setSelected(true);
    }
    return activityMprisBinding.getRoot();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) MprisNowPlayingBinding(org.kde.kdeconnect_tp.databinding.MprisNowPlayingBinding) Uri(android.net.Uri) Intent(android.content.Intent) ArrayUtils(org.apache.commons.lang3.ArrayUtils) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) Drawable(android.graphics.drawable.Drawable) MenuItem(android.view.MenuItem) R(org.kde.kdeconnect_tp.R) SeekBar(android.widget.SeekBar) Handler(android.os.Handler) Toast(android.widget.Toast) Menu(android.view.Menu) Fragment(androidx.fragment.app.Fragment) View(android.view.View) AdapterView(android.widget.AdapterView) PreferenceManager(android.preference.PreferenceManager) ContextCompat(androidx.core.content.ContextCompat) NetworkPacket(org.kde.kdeconnect.NetworkPacket) Log(android.util.Log) MalformedURLException(java.net.MalformedURLException) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) MprisControlBinding(org.kde.kdeconnect_tp.databinding.MprisControlBinding) ViewGroup(android.view.ViewGroup) BackgroundService(org.kde.kdeconnect.BackgroundService) ArrayAdapter(android.widget.ArrayAdapter) List(java.util.List) Nullable(androidx.annotation.Nullable) SharedPreferences(android.content.SharedPreferences) Message(android.os.Message) ActivityNotFoundException(android.content.ActivityNotFoundException) Bitmap(android.graphics.Bitmap) BaseLinkProvider(org.kde.kdeconnect.Backends.BaseLinkProvider) VideoUrlsHelper(org.kde.kdeconnect.Helpers.VideoUrlsHelper) BaseLink(org.kde.kdeconnect.Backends.BaseLink) Context(android.content.Context) SeekBar(android.widget.SeekBar) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) Nullable(androidx.annotation.Nullable)

Aggregations

Fragment (androidx.fragment.app.Fragment)262 FragmentTransaction (androidx.fragment.app.FragmentTransaction)57 Bundle (android.os.Bundle)49 FragmentManager (androidx.fragment.app.FragmentManager)42 DialogFragment (androidx.fragment.app.DialogFragment)24 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 Intent (android.content.Intent)22 View (android.view.View)22 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18