コード例 #1
0
        public void OnPictureTaken(JniObjectReference data, Camera camera)
        {
            Console.WriteLine($"# jonp: data: {data.ToString ()}");
            int length = JniEnvironment.Arrays.GetArrayLength(data);

            if (length == 0)
            {
                return;
            }

            // Note use of `unsafe` code to obtain the underlying Java bytes
            // without copying the entire array between VMs.
            unsafe {
                sbyte *bytes = JniEnvironment.Arrays.GetByteArrayElements(data, isCopy: null);
                JniEnvironment.Arrays.ReleaseByteArrayElements(data, bytes, 0);
            }
        }
コード例 #2
0
 internal void AddPeer(IJavaPeerable value, JniObjectReference reference, IntPtr hash)
 {
     lock (instances) {
         if (!instances.TryGetValue(hash, out var targets))
         {
             targets = new IdentityHashTargets(value);
             instances.Add(hash, targets);
             return;
         }
         bool found = false;
         for (int i = 0; i < targets.Count; ++i)
         {
             IJavaPeerable?target;
             var           wref = targets [i];
             if (ShouldReplaceMapping(wref !, reference, out target))
             {
                 found       = true;
                 targets [i] = IdentityHashTargets.CreateWeakReference(value);
                 break;
             }
             if (JniEnvironment.Types.IsSameObject(value.PeerReference, target !.PeerReference))
             {
                 found = true;
                 if (Logger.LogGlobalRef)
                 {
                     Logger.Log(LogLevel.Info, "monodroid-gref",
                                string.Format("warning: not replacing previous registered handle {0} with handle {1} for key_handle 0x{2}",
                                              target.PeerReference.ToString(), reference.ToString(), hash.ToString("x")));
                 }
             }
         }
         if (!found)
         {
             targets.Add(value);
         }
     }
 }