Search in sources :

Example 1 with AppListModel

use of ru.playsoftware.j2meloader.applist.AppListModel in project J2ME-Loader by nikita36078.

the class InstallerDialog method onAttach.

@Override
public void onAttach(@NonNull Context context) {
    super.onAttach(context);
    AppListModel appListModel = new ViewModelProvider(requireActivity()).get(AppListModel.class);
    appRepository = appListModel.getAppRepository();
}
Also used : AppListModel(ru.playsoftware.j2meloader.applist.AppListModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 2 with AppListModel

use of ru.playsoftware.j2meloader.applist.AppListModel in project J2ME-Loader by nikita36078.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (FileUtils.isExternalStorageLegacy()) {
        permissionsLauncher.launch(STORAGE_PERMISSIONS);
    }
    appListModel = new ViewModelProvider(this).get(AppListModel.class);
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        Uri uri = null;
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
            uri = intent.getData();
        }
        AppsListFragment fragment = AppsListFragment.newInstance(uri);
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
    }
    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (!preferences.contains(PREF_TOOLBAR)) {
        boolean enable = !ViewConfiguration.get(this).hasPermanentMenuKey();
        preferences.edit().putBoolean(PREF_TOOLBAR, enable).apply();
    }
    boolean warningShown = preferences.getBoolean(PREF_STORAGE_WARNING_SHOWN, false);
    if (!FileUtils.isExternalStorageLegacy() && !warningShown) {
        showScopedStorageDialog();
        preferences.edit().putBoolean(PREF_STORAGE_WARNING_SHOWN, true).apply();
    }
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
Also used : AppsListFragment(ru.playsoftware.j2meloader.applist.AppsListFragment) Intent(android.content.Intent) AppListModel(ru.playsoftware.j2meloader.applist.AppListModel) Uri(android.net.Uri) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 AppListModel (ru.playsoftware.j2meloader.applist.AppListModel)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 AppsListFragment (ru.playsoftware.j2meloader.applist.AppsListFragment)1