Search in sources :

Example 56 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project twicalico by moko256.

the class BaseListFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view;
    FragmentActivity activity = getActivity();
    if (activity instanceof HasRefreshLayoutInterface) {
        view = inflater.inflate(R.layout.fragment_base_list, container, false);
    } else {
        view = inflater.inflate(R.layout.fragment_base_list_refreshable, container, false);
        swipeRefreshLayout = view.findViewById(R.id.srl);
        swipeRefreshLayout.setColorSchemeResources(R.color.color_primary);
    }
    if (activity instanceof HasNotifiableAppBar) {
        adapterDataObserver = new RecyclerView.AdapterDataObserver() {

            @Override
            public void onItemRangeInserted(int positionStart, int itemCount) {
                if (positionStart == 0) {
                    ((HasNotifiableAppBar) requireActivity()).requestAppBarCollapsed();
                }
            }
        };
    }
    recyclerView = view.findViewById(R.id.TLlistView);
    recyclerView.setLayoutManager(initializeRecyclerViewLayoutManager());
    recyclerView.addOnScrollListener(new LoadScrollListener(recyclerView.getLayoutManager(), this));
    return view;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 57 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project IITB-App by wncc.

the class Utils method changeTheme.

public static void changeTheme(SettingsFragment fragment, boolean darkTheme) {
    isDarkTheme = darkTheme;
    FragmentActivity fragmentActivity = fragment.getActivity();
    fragmentActivity.setTheme(darkTheme ? R.style.AppThemeDark : R.style.AppTheme);
    // Set background color of activity
    fragmentActivity.findViewById(R.id.drawer_layout).setBackgroundColor(getAttrColor(fragmentActivity, R.attr.themeColor));
    // Put in a new settings fragment
    Fragment newFragment = new SettingsFragment();
    newFragment.setArguments(fragment.getArguments());
    FragmentManager fm = fragmentActivity.getSupportFragmentManager();
    fm.popBackStack();
    FragmentTransaction ft = fm.beginTransaction();
    ft.addToBackStack(getTag(fragment));
    ft.replace(R.id.framelayout_for_fragment, newFragment, getTag(fragment)).commit();
}
Also used : SettingsFragment(app.insti.fragment.SettingsFragment) FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) FragmentTransaction(androidx.fragment.app.FragmentTransaction) TransitionTargetFragment(app.insti.fragment.TransitionTargetFragment) Fragment(androidx.fragment.app.Fragment) EventFragment(app.insti.fragment.EventFragment) SettingsFragment(app.insti.fragment.SettingsFragment) BodyFragment(app.insti.fragment.BodyFragment) UserFragment(app.insti.fragment.UserFragment)

Example 58 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project IITB-App by wncc.

the class MainActivity method openEventFragment.

/**
 * Open the event fragment from the provided id
 */
private void openEventFragment(String id) {
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    final FragmentActivity self = this;
    retrofitInterface.getEvent(Utils.getSessionIDHeader(), id).enqueue(new EmptyCallback<Event>() {

        @Override
        public void onResponse(Call<Event> call, Response<Event> response) {
            Utils.openEventFragment(response.body(), self);
        }
    });
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Event(app.insti.api.model.Event) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 59 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project J2ME-Loader by nikita36078.

the class AppsListFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    FragmentActivity activity = requireActivity();
    int itemId = item.getItemId();
    if (itemId == R.id.action_about) {
        AboutDialogFragment aboutDialogFragment = new AboutDialogFragment();
        aboutDialogFragment.show(getChildFragmentManager(), "about");
    } else if (itemId == R.id.action_profiles) {
        Intent intentProfiles = new Intent(activity, ProfilesActivity.class);
        startActivity(intentProfiles);
    } else if (item.getItemId() == R.id.action_settings) {
        startActivity(new Intent(activity, SettingsActivity.class));
        return true;
    } else if (itemId == R.id.action_help) {
        HelpDialogFragment helpDialogFragment = new HelpDialogFragment();
        helpDialogFragment.show(getChildFragmentManager(), "help");
    } else if (itemId == R.id.action_donate) {
        Intent donationsIntent = new Intent(activity, DonationsActivity.class);
        startActivity(donationsIntent);
    } else if (itemId == R.id.action_save_log) {
        try {
            LogUtils.writeLog();
            Toast.makeText(activity, R.string.log_saved, Toast.LENGTH_SHORT).show();
        } catch (IOException e) {
            e.printStackTrace();
            Toast.makeText(activity, R.string.error, Toast.LENGTH_SHORT).show();
        }
    } else if (itemId == R.id.action_exit_app) {
        activity.finish();
    } else if (itemId == R.id.action_sort) {
        showSortDialog();
    }
    return false;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) ProfilesActivity(ru.playsoftware.j2meloader.config.ProfilesActivity) Intent(android.content.Intent) SQLiteDiskIOException(android.database.sqlite.SQLiteDiskIOException) IOException(java.io.IOException) AboutDialogFragment(ru.playsoftware.j2meloader.info.AboutDialogFragment) HelpDialogFragment(ru.playsoftware.j2meloader.info.HelpDialogFragment) SettingsActivity(ru.playsoftware.j2meloader.settings.SettingsActivity)

Example 60 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project J2ME-Loader by nikita36078.

the class InstallerDialog method installApp.

private void installApp(String path, Uri uri) {
    final FragmentActivity activity = requireActivity();
    installer = new AppInstaller(path, uri, activity.getApplication(), appRepository);
    btnClose.setOnClickListener(v -> {
        installer.deleteTemp();
        installer.clearCache();
        dismiss();
    });
    Single.create(installer::loadInfo).subscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MidletInfoObserver());
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)185 Test (org.junit.Test)71 Intent (android.content.Intent)25 Bundle (android.os.Bundle)19 View (android.view.View)11 Config (org.robolectric.annotation.Config)11 TextView (android.widget.TextView)10 Before (org.junit.Before)10 BroadcastReceiver (android.content.BroadcastReceiver)8 Fragment (androidx.fragment.app.Fragment)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Activity (android.app.Activity)7 Resources (android.content.res.Resources)7 FragmentManager (androidx.fragment.app.FragmentManager)7 IntentFilter (android.content.IntentFilter)6 UserHandle (android.os.UserHandle)6 Preference (androidx.preference.Preference)6 SwitchPreference (androidx.preference.SwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 Tile (com.android.settingslib.drawer.Tile)6