Exemplo n.º 1
0
            public int hashCode()
            {
                int hash = 37;

                ClassDef def = _defRef.get();

                QuercusClass parent = null;

                if (_parentRef != null)
                {
                    parent = _parentRef.get();
                }

                if (def != null)
                {
                    hash = 65521 * hash + def.hashCode();
                }

                if (parent != null)
                {
                    hash = 65521 * hash + parent.hashCode();
                }

                return(hash);
            }
Exemplo n.º 2
0
        /// <summary>
        /// @brief
        /// </summary>
        /// <param name="resId">
        /// @return </param>
        public virtual float getDimension(int resId)
        {
            Context context = mContext.get();

            if (null == context)
            {
                throw new System.InvalidOperationException("Context is null");
            }
            return(context.Resources.getDimension(resId));
        }
Exemplo n.º 3
0
        // void setVolume(SapaApp sapaApp, int volume) {
        // try {
        // boolean wasMaxVolume = isMaxVolume(sapaApp);
        // boolean wasMinVolume = isMinVolume(sapaApp);
        // setConfiguration(sapaApp, volume);
        // boolean isMaxVolume = isMaxVolume(sapaApp);
        // boolean isMinVolume = isMinVolume(sapaApp);
        //
        // if (wasMaxVolume && !isMaxVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_UP,
        // R.drawable.ctrl_btn_volume_up_default, true);
        // } else if (isMaxVolume && !wasMaxVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_UP,
        // R.drawable.ctrl_btn_volume_up_disabled, false);
        // }
        //
        // if (wasMinVolume && !isMinVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_DOWN,
        // R.drawable.ctrl_btn_volume_down_default, true);
        // } else if (isMinVolume && !wasMinVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_DOWN,
        // R.drawable.ctrl_btn_volume_down_disabled, false);
        // }
        //
        // this.mSapaAppService.changeAppInfo(mAppInfoList.get(sapaApp.getInstanceId()));
        //
        // showVolume(volume);
        // } catch (SapaConnectionNotSetException e) {
        // Log.w(TAG,
        // "State of application could not be changed due to connection exception");
        // }
        //

        private bool isVisibieView(SapaApp sapaApp)
        {
            if (mActivity != null && mActivity.get() != null && mActivity.get().VisibleApp != null && mActivity.get().VisibleApp.App != null && mActivity.get().VisibleApp.App.InstanceId != null && sapaApp != null && mActivity.get().VisibleApp.App.InstanceId.Equals(sapaApp.InstanceId) == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        private static bool CheckInitialized(MemberName member)
        {
            Class defc = member.DeclaringClass;
            WeakReference <Thread> @ref = EnsureInitialized.INSTANCE.Get(defc);

            if (@ref == null)
            {
                return(true);                // the final state
            }
            Thread clinitThread = @ref.get();

            // Somebody may still be running defc.<clinit>.
            if (clinitThread == Thread.CurrentThread)
            {
                // If anybody is running defc.<clinit>, it is this thread.
                if (UNSAFE.shouldBeInitialized(defc))
                {
                    // Yes, we are running it; keep the barrier for now.
                    return(false);
                }
            }
            else
            {
                // We are in a random thread.  Block.
                UNSAFE.ensureClassInitialized(defc);
            }
            assert(!UNSAFE.shouldBeInitialized(defc));
            // put it into the final state
            EnsureInitialized.INSTANCE.Remove(defc);
            return(true);
        }
Exemplo n.º 5
0
 private void unregisterRepository(Key location)
 {
     WeakReference<Repository> oldRef = cacheMap.GetValue(location);
     cacheMap.Remove(location);
     Repository oldDb = oldRef != null ? oldRef.get() : null;
     if (oldDb != null)
         oldDb.Dispose();
 }
Exemplo n.º 6
0
        private void registerRepository(Key location, Repository db)
        {
            db.IncrementOpen();
            WeakReference<Repository> newRef = new WeakReference<Repository>(db);
            WeakReference<Repository> oldRef = cacheMap.put(location, newRef);
            Repository oldDb = oldRef != null ? oldRef.get() : null;
            if (oldDb != null)
                oldDb.Dispose();

        }
Exemplo n.º 7
0
 internal static Raster GetCachedRaster(ColorModel cm, int w, int h)
 {
     lock (typeof(GradientPaintContext))
     {
         if (cm == CachedModel)
         {
             if (Cached != null)
             {
                 Raster ras = (Raster)Cached.get();
                 if (ras != null && ras.Width >= w && ras.Height >= h)
                 {
                     Cached = null;
                     return(ras);
                 }
             }
         }
         return(cm.CreateCompatibleWritableRaster(w, h));
     }
 }
Exemplo n.º 8
0
        public bool equals(Object o)
        {
            if (!(o instanceof DefinitionKey))
            {
                return(false);
            }

            DefinitionKey key = (DefinitionKey)o;

            QuercusPage page    = _includePageRef.get();
            QuercusPage keyPage = key._includePageRef.get();

            if (page == null || keyPage == null)
            {
                return(false);
            }

            return(_crc == key._crc && page.equals(keyPage));
        }
Exemplo n.º 9
0
 protected void onPostExecute(Bitmap bitmap)
 {
     if (imageViewReference != null && bitmap != null)
     {
         final ImageView imageView = imageViewReference.get();
         if (imageView != null)
         {
             imageView.setImageBitmap(bitmap);
         }
     }
 }
Exemplo n.º 10
0
        private Repository openRepository(Key location, bool mustExist)
        {
            WeakReference<Repository> @ref = cacheMap.GetValue(location);
            Repository db = @ref != null ? @ref.get() : null;

            if (db == null)
            {
                lock (lockFor(location))
                {
                    @ref = cacheMap.GetValue(location);
                    db = @ref != null ? @ref.get() : null;
                    if (db == null)
                    {
                        db = location.open(mustExist);
                        @ref = new WeakReference<Repository>(db);
                        cacheMap.AddOrReplace(location, @ref);
                    }
                }
            }

            db.IncrementOpen();
            return db;
        }
Exemplo n.º 11
0
 protected internal override void onResume()
 {
     Log.d(TAG, "onResume");
     base.onResume();
     if (mService != null && mService.get() != null)
     {
         try
         {
             updateVolumeTextView(mService.get().getVolumeText(mVisibleAppInfo));
             if (mVisibleAppInfo != null)
             {
                 MainActivity.this.CurrentState = MainActivity.this.mVisibleAppInfo.App;
             }
         }
         catch (System.NullReferenceException)
         {
             ;
         }
     }
     else
     {
         updateVolumeTextView("Service, not ready");
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// @brief TODO
        /// </summary>
        /// <param name="packageName"> </param>
        /// <param name="instanceId"> </param>
        /// <param name="mode"> </param>
        public virtual void openSapaAppActivity(string packageName, string instanceId, int mode)
        {
            if (mActiveApp == null || !mActiveApp.App.InstanceId.Equals(instanceId))
            {
                FcContextStateChanged listener = mListener.get();
                if (listener != null)
                {
                    listener.onActivityFinished();
                }
                Log.d(TAG, "Open Sapa app");
                if (!startSapaActivity(instanceId, mode))
                {
                    return;
                }
                if (!sendSapaSwitchBroadcast(packageName, instanceId))
                {
                    return;
                }

                finishCurrentActivity(packageName);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Tells whether or not the given byte array is a legal replacement value
        /// for this encoder.
        ///
        /// <para> A replacement is legal if, and only if, it is a legal sequence of
        /// bytes in this encoder's charset; that is, it must be possible to decode
        /// the replacement into one or more sixteen-bit Unicode characters.
        ///
        /// </para>
        /// <para> The default implementation of this method is not very efficient; it
        /// should generally be overridden to improve performance.  </para>
        /// </summary>
        /// <param name="repl">  The byte array to be tested
        /// </param>
        /// <returns>  <tt>true</tt> if, and only if, the given byte array
        ///          is a legal replacement value for this encoder </returns>
        public virtual bool IsLegalReplacement(sbyte[] repl)
        {
            WeakReference <CharsetDecoder> wr = CachedDecoder;
            CharsetDecoder dec = null;

            if ((wr == null) || ((dec = wr.get()) == null))
            {
                dec = Charset().NewDecoder();
                dec.OnMalformedInput(CodingErrorAction.REPORT);
                dec.OnUnmappableCharacter(CodingErrorAction.REPORT);
                CachedDecoder = new WeakReference <CharsetDecoder>(dec);
            }
            else
            {
                dec.Reset();
            }
            ByteBuffer  bb = ByteBuffer.Wrap(repl);
            CharBuffer  cb = CharBuffer.Allocate((int)(bb.Remaining() * dec.MaxCharsPerByte()));
            CoderResult cr = dec.Decode(bb, cb, true);

            return(!cr.Error);
        }
Exemplo n.º 14
0
 /// <summary>
 /// This method is responsible for setting buttons state according to current state.
 /// </summary>
 private void setButtonsState()
 {
     if (this.mService != null && mService.get() != null)
     {
         try
         {
             if (this.mService.get().Playing)
             {
                 mPlayButton.Visibility = View.GONE;
                 mStopButton.Visibility = View.VISIBLE;
             }
             else
             {
                 mPlayButton.Visibility = View.VISIBLE;
                 mStopButton.Visibility = View.GONE;
             }
         }
         catch (System.NullReferenceException)
         {
             ;
         }
     }
 }
Exemplo n.º 15
0
            public override bool Equals(Object obj)
            {
                Class intf1, intf2;

                return(this == obj || obj != null && obj.GetType() == typeof(Key2) && (intf1 = get()) != null && intf1 == ((Key2)obj).get() && (intf2 = Ref2.get()) != null && intf2 == ((Key2)obj).Ref2.get());
            }