/// <summary> /// Utility method that displays permissions from a map containing group name and /// list of permission descriptions. /// </summary> /// <remarks> /// Utility method that displays permissions from a map containing group name and /// list of permission descriptions. /// </remarks> private void displayPermissions(bool dangerous) { java.util.Map <string, string> permInfoMap = dangerous ? mDangerousMap : mNormalMap; android.widget.LinearLayout permListView = dangerous ? mDangerousList : mNonDangerousList; permListView.removeAllViews(); java.util.Set <string> permInfoStrSet = permInfoMap.keySet(); foreach (string loopPermGrpInfoStr in Sharpen.IterableProxy.Create(permInfoStrSet )) { java.lang.CharSequence grpLabel = getGroupLabel(loopPermGrpInfoStr); //guaranteed that grpLabel wont be null since permissions without groups //will belong to the default group if (localLOGV) { android.util.Log.i(TAG, "Adding view group:" + grpLabel + ", desc:" + permInfoMap .get(loopPermGrpInfoStr)); } permListView.addView(getPermissionItemView(grpLabel, java.lang.CharSequenceProxy.Wrap (permInfoMap.get(loopPermGrpInfoStr)), dangerous)); } }
protected internal override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); ContentView = R.layout.activity_realm_basic_example; rootLayout = ((LinearLayout)findViewById(R.id.container)); rootLayout.removeAllViews(); // These operations are small enough that // we can generally safely run them on the UI thread. // Open the default realm for the UI thread. realm = Realm.getInstance(this); basicCRUD(realm); basicQuery(realm); basicLinkQuery(realm); // More complex operations can be executed on another thread. new AsyncTaskAnonymousInnerClassHelper(this) .execute(); }
protected internal override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); ContentView = R.layout.activity_modules_example; rootLayout = ((LinearLayout)findViewById(R.id.container)); rootLayout.removeAllViews(); // The default Realm instance implicitly knows about all classes in the realmModuleAppExample Android Studio // module. This does not include the classes from the realmModuleLibraryExample AS module so a Realm using this // configuration would know about the following classes: { Cow, Pig, Snake, Spider } RealmConfiguration defaultConfig = (new RealmConfiguration.Builder(this)).build(); // It is possible to extend the default schema by adding additional Realm modules using setModule(). This can // also be Realm modules from libraries. The below Realm contains the following classes: { Cow, Pig, Snake, // Spider, Cat, Dog } RealmConfiguration farmAnimalsConfig = (new RealmConfiguration.Builder(this)).name("farm.realm").setModules(Realm.DefaultModule, new DomesticAnimalsModule()).build(); // Or you can completely replace the default schema. // This Realm contains the following classes: { Elephant, Lion, Zebra, Snake, Spider } RealmConfiguration exoticAnimalsConfig = (new RealmConfiguration.Builder(this)).name("exotic.realm").setModules(new ZooAnimalsModule(), new CreepyAnimalsModule()).build(); // Multiple Realms can be open at the same time showStatus("Opening multiple Realms"); Realm defaultRealm = Realm.getInstance(defaultConfig); Realm farmRealm = Realm.getInstance(farmAnimalsConfig); Realm exoticRealm = Realm.getInstance(exoticAnimalsConfig); // Objects can be added to each Realm independantly showStatus("Create objects in the default Realm"); defaultRealm.executeTransaction(new TransactionAnonymousInnerClassHelper(this)); showStatus("Create objects in the farm Realm"); farmRealm.executeTransaction(new TransactionAnonymousInnerClassHelper2(this)); showStatus("Create objects in the exotic Realm"); exoticRealm.executeTransaction(new TransactionAnonymousInnerClassHelper3(this)); // You can copy objects between Realms showStatus("Copy objects between Realms"); showStatus("Number of pigs on the farm : " + farmRealm.@where(typeof(Pig)).count()); showStatus("Copy pig from defaultRealm to farmRealm"); Pig defaultPig = defaultRealm.@where(typeof(Pig)).findFirst(); farmRealm.beginTransaction(); farmRealm.copyToRealm(defaultPig); farmRealm.commitTransaction(); showStatus("Number of pigs on the farm : " + farmRealm.@where(typeof(Pig)).count()); // Each Realm is restricted to only accept the classes in their schema. showStatus("Trying to add an unsupported class"); defaultRealm.beginTransaction(); try { defaultRealm.createObject(typeof(Elephant)); } catch (RealmException expected) { showStatus("This throws a :" + expected.ToString()); } finally { defaultRealm.cancelTransaction(); } // And Realms in library projects are independent from Realms in the app code showStatus("Interacting with library code that uses Realm internally"); int animals = 5; Zoo libraryZoo = new Zoo(this); libraryZoo.open(); showStatus("Adding animals: " + animals); libraryZoo.addAnimals(5); showStatus("Number of animals in the library Realm:" + libraryZoo.NoOfAnimals); libraryZoo.close(); // Remember to close all open Realms defaultRealm.close(); farmRealm.close(); exoticRealm.close(); }
protected internal override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); ContentView = R.layout.activity_modules_example; rootLayout = ((LinearLayout) findViewById(R.id.container)); rootLayout.removeAllViews(); // The default Realm instance implicitly knows about all classes in the realmModuleAppExample Android Studio // module. This does not include the classes from the realmModuleLibraryExample AS module so a Realm using this // configuration would know about the following classes: { Cow, Pig, Snake, Spider } RealmConfiguration defaultConfig = (new RealmConfiguration.Builder(this)).build(); // It is possible to extend the default schema by adding additional Realm modules using setModule(). This can // also be Realm modules from libraries. The below Realm contains the following classes: { Cow, Pig, Snake, // Spider, Cat, Dog } RealmConfiguration farmAnimalsConfig = (new RealmConfiguration.Builder(this)).name("farm.realm").setModules(Realm.DefaultModule, new DomesticAnimalsModule()).build(); // Or you can completely replace the default schema. // This Realm contains the following classes: { Elephant, Lion, Zebra, Snake, Spider } RealmConfiguration exoticAnimalsConfig = (new RealmConfiguration.Builder(this)).name("exotic.realm").setModules(new ZooAnimalsModule(), new CreepyAnimalsModule()).build(); // Multiple Realms can be open at the same time showStatus("Opening multiple Realms"); Realm defaultRealm = Realm.getInstance(defaultConfig); Realm farmRealm = Realm.getInstance(farmAnimalsConfig); Realm exoticRealm = Realm.getInstance(exoticAnimalsConfig); // Objects can be added to each Realm independantly showStatus("Create objects in the default Realm"); defaultRealm.executeTransaction(new TransactionAnonymousInnerClassHelper(this)); showStatus("Create objects in the farm Realm"); farmRealm.executeTransaction(new TransactionAnonymousInnerClassHelper2(this)); showStatus("Create objects in the exotic Realm"); exoticRealm.executeTransaction(new TransactionAnonymousInnerClassHelper3(this)); // You can copy objects between Realms showStatus("Copy objects between Realms"); showStatus("Number of pigs on the farm : " + farmRealm.@where(typeof(Pig)).count()); showStatus("Copy pig from defaultRealm to farmRealm"); Pig defaultPig = defaultRealm.@where(typeof(Pig)).findFirst(); farmRealm.beginTransaction(); farmRealm.copyToRealm(defaultPig); farmRealm.commitTransaction(); showStatus("Number of pigs on the farm : " + farmRealm.@where(typeof(Pig)).count()); // Each Realm is restricted to only accept the classes in their schema. showStatus("Trying to add an unsupported class"); defaultRealm.beginTransaction(); try { defaultRealm.createObject(typeof(Elephant)); } catch (RealmException expected) { showStatus("This throws a :" + expected.ToString()); } finally { defaultRealm.cancelTransaction(); } // And Realms in library projects are independent from Realms in the app code showStatus("Interacting with library code that uses Realm internally"); int animals = 5; Zoo libraryZoo = new Zoo(this); libraryZoo.open(); showStatus("Adding animals: " + animals); libraryZoo.addAnimals(5); showStatus("Number of animals in the library Realm:" + libraryZoo.NoOfAnimals); libraryZoo.close(); // Remember to close all open Realms defaultRealm.close(); farmRealm.close(); exoticRealm.close(); }