Пример #1
0
        /// <summary>
        /// When this returns true the system is able to deal with crypted backup files. If not you have to download the files from http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html and put them in the lib/security folder of all your Java SE 7 or 8 installations
        /// </summary>
        public static bool SystemIsAbleToDealWithEncryptedFiles()
        {
            Java.Update();
            string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[0]);

            return(output.Contains("Strong AES encryption allowed"));
        }
Пример #2
0
        /// <summary>
        /// Performs the testing.
        /// </summary>
        protected override void ExecuteTask()
        {
            bool   hasErrors  = false;
            string pathToJava = null;

            foreach (var project in EnumerateProjects())
            {
                Log(Level.Info, "Testing {0}...", project.Name);
                var outputFolder   = Path.Combine(project.Folder, "bin/" + Configuration);
                var outputFilePath = Path.Combine(outputFolder, project.OutputName);
                if (project.Language == SupportedLanguage.Java)
                {
                    if (pathToJava == null)
                    {
                        pathToJava = Java.GenerateFullPathToRuntime();
                    }
                    hasErrors |= TestWithJUnit(pathToJava, project, outputFilePath);
                }
                else
                {
                    hasErrors |= TestWithNUnit(outputFilePath);
                }
            }
            if (hasErrors)
            {
                throw new BuildException("Tests failed");
            }
        }
Пример #3
0
        private async void chooseJavaButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog()
            {
                Title  = App.GetResourceString("String.Settingwindow.Message.Java.Title"),
                Filter = App.GetResourceString("String.Settingwindow.Message.Java.Filter"),
            };
            if (dialog.ShowDialog() == true)
            {
                Java java = await Java.GetJavaInfoAsync(dialog.FileName);

                if (java != null)
                {
                    javaPathComboBox.Text = java.Path;
                    javaInfoLabel.Content = string.Format(
                        App.GetResourceString("String.Settingwindow.Message.Java.Content"),
                        java.Version, java.Arch);
                }
                else
                {
                    javaPathComboBox.Text = dialog.FileName;
                    await this.ShowMessageAsync(App.GetResourceString("String.Settingwindow.Message.NoJava.Title"),
                                                App.GetResourceString("String.Settingwindow.Message.NoJava.Text"));
                }
            }
        }
 public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object objectValue) {
     //var vp = (ViewPager)container;
     //var chd = container.GetChildAt(position);
     //不能 Dispose, 如果释放了,会在 FinishUpdate 的时候, 报错
     //chd.Dispose();
     //container.RemoveView((View)chd);
 }
Пример #5
0
        public Java.Lang.Object Evaluate(float t, Java.Lang.Object startValue, Java.Lang.Object endValue)
        {
            var start = (PathPoint)startValue;
            var end = (PathPoint)endValue;

            float x, y;
            if (end.Operation == PathPointOperation.Curve)
            {
                float oneMinusT = 1 - t;
                x = oneMinusT * oneMinusT * oneMinusT * start.X +
                    3 * oneMinusT * oneMinusT * t * end.Control0X +
                    3 * oneMinusT * t * t * end.Control1X +
                    t * t * t * end.X;
                y = oneMinusT * oneMinusT * oneMinusT * start.Y +
                    3 * oneMinusT * oneMinusT * t * end.Control0Y +
                    3 * oneMinusT * t * t * end.Control1Y +
                    t * t * t * end.Y;
            }
            else if (end.Operation == PathPointOperation.Line)
            {
                x = start.X + t * (end.X - start.X);
                y = start.Y + t * (end.Y - start.Y);
            }
            else
            {
                x = end.X;
                y = end.Y;
            }
            return PathPoint.MoveTo(x, y);
        }
Пример #6
0
        /**
         * Returns the NGrams of the given word sequence
         *
         * @param wordSequence the word sequence from which to get the buffer
         * @return the NGramBuffer of the word sequence
         */
        private NGramBuffer GetNGramBuffer(WordSequence wordSequence)
        {
            NGramBuffer nGramBuffer = null;
            var         order       = wordSequence.Size;

            if (order > 1)
            {
                nGramBuffer = _loadedNGramBuffers[order - 1].Get(wordSequence); // better
            }
            // when
            // using
            // containsKey

            if (nGramBuffer == null)
            {
                nGramBuffer = LoadNGramBuffer(wordSequence);

                if (nGramBuffer != null)
                {
                    Java.Put(_loadedNGramBuffers[order - 1], wordSequence, nGramBuffer); // optimizable
                }
                // by
                // adding
                // an
                // 'empty'
                // nGramBuffer
            }

            return(nGramBuffer);
        }
Пример #7
0
		public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, global::Android.Text.ISpanned dest, int dstart, int dend)
		{
			var s = source.ToString();
			var d = dest.ToString();
			var proposal = d.Remove(dstart, dend - dstart).Insert(dstart, s.Substring(start, end - start));
			if (_onChangeDelegate(proposal))
				return null;
			else
			{
				var r = new Java.Lang.String(d.Substring(dstart, dend - dstart));
				if (source is ISpanned)
				{
					// This spannable thing here, is needed to copy information about which part of
					// the string is being under composition by the keyboard (or other spans). A
					// spannable string has support for extra information to the string, besides
					// its characters and that information must not be lost!
					var ssb = new SpannableString(r);
					var spannableEnd = (end <= ssb.Length()) ? end : ssb.Length();
					global::Android.Text.TextUtils.CopySpansFrom((ISpanned)source, start, spannableEnd, null, ssb, 0);
					return ssb;
				}
				else
					return r;
			}
		}
Пример #8
0
 public void OnFailure(ICall call, Java.IO.IOException exception)
 {
     if (onFailure != null)
     {
         onFailure(call, exception);
     }
 }
        /// <summary>
        /// Called when the host view is attempting to determine if an item's position has changed. We 
        /// </summary>
        /// <param name="objectValue"></param>
        /// <returns></returns>
        public override int GetItemPosition(Java.Lang.Object objectValue)
        {
            if (objectValue.Equals(Wizard.PreviousStep))
                return PositionUnchanged;

            return PositionNone; //Indicates that the item is no longer present in the adapter.. Forces a screen reload.. causing the updated context data to appear
        }
Пример #10
0
        /**
         * Returns the Hessenberg matrix H of the transform.
         *
         * @return the H matrix
         */
        public RealMatrix getH()
        {
            if (cachedH == null)
            {
                int        m = householderVectors.Length;
                double[][] h = Java.CreateArray <double[][]>(m, m);// new double[m][m];
                for (int i = 0; i < m; ++i)
                {
                    if (i > 0)
                    {
                        // copy the entry of the lower sub-diagonal
                        h[i][i - 1] = householderVectors[i][i - 1];
                    }

                    // copy upper triangular part of the matrix
                    for (int j = i; j < m; ++j)
                    {
                        h[i][j] = householderVectors[i][j];
                    }
                }
                cachedH = MatrixUtils.CreateRealMatrix(h);
            }

            // return the cached matrix
            return(cachedH);
        }
			protected override Filter.FilterResults PerformFiltering (Java.Lang.ICharSequence constraint)
			{
				FilterResults results = new FilterResults();
				if (constraint != null) {
					var searchFor = constraint.ToString ();
Console.WriteLine ("searchFor:" + searchFor);
					var matchList = new List<string>();
					
					// find matches, IndexOf means look for the input anywhere in the items
					// but it isn't case-sensitive by default!
					var matches = from i in customAdapter.AllItems
								where i.IndexOf(searchFor) >= 0
								select i;
	
					foreach (var match in matches) {
						matchList.Add (match);
					}
		
					customAdapter.MatchItems = matchList.ToArray ();
Console.WriteLine ("resultCount:" + matchList.Count);

// not sure if the Java array/FilterResults are used
Java.Lang.Object[] matchObjects;
matchObjects = new Java.Lang.Object[matchList.Count];
for (int i = 0; i < matchList.Count; i++) {
	matchObjects[i] = new Java.Lang.String(matchList[i]);
}

					results.Values = matchObjects;
					results.Count = matchList.Count;
				}
				return results;
			}
Пример #12
0
 public void OnFailure(Request request, Java.IO.IOException exception)
 {
     if (onFailure != null)
     {
         onFailure(request, exception);
     }
 }
Пример #13
0
        public static ObjectAnimator CreateFadeOutAnimation(Java.Lang.Object target, int duration, EventHandler endAnimationHandler)
        {
            ObjectAnimator oa = ObjectAnimator.OfFloat(target, ALPHA, INVISIBLE);
            oa.SetDuration(duration).AnimationEnd += endAnimationHandler;

            return oa;
        }
Пример #14
0
        public MelFilter2(double center, double delta, double[] melPoints)
        {
            var lastIndex  = 0;
            var firstIndex = melPoints.Length;
            var left       = center - delta;
            var right      = center + delta;
            var heights    = new double[melPoints.Length];

            for (var i = 0; i < heights.Length; ++i)
            {
                if (left < melPoints[i] && melPoints[i] <= center)
                {
                    heights[i] = (melPoints[i] - left) / (center - left);
                    firstIndex = Math.Min(i, firstIndex);
                    lastIndex  = i;
                }

                if (center < melPoints[i] && melPoints[i] < right)
                {
                    heights[i] = (right - melPoints[i]) / (right - center);
                    lastIndex  = i;
                }
            }

            _offset  = firstIndex;
            _weights = Java.CopyOfRange(heights, firstIndex, lastIndex + 1);
        }
Пример #15
0
            /**
             * Get the inverse of the decomposed matrix.
             *
             * @return the inverse matrix.
             * @throws SingularMatrixException if the decomposed matrix is singular.
             */
            public RealMatrix getInverse()
            {
                if (!isNonSingular())
                {
                    throw new Exception("SingularMatrixException");
                }

                int m = realEigenvalues.Length;

                double[][] invData = Java.CreateArray <double[][]>(m, m);// new double[m][m];

                for (int i = 0; i < m; ++i)
                {
                    double[] invI = invData[i];
                    for (int j = 0; j < m; ++j)
                    {
                        double invIJ = 0;
                        for (int k = 0; k < m; ++k)
                        {
                            double[] vK = eigenvectors[k].getDataRef();
                            invIJ += vK[i] * vK[j] / realEigenvalues[k];
                        }
                        invI[j] = invIJ;
                    }
                }
                return(MatrixUtils.CreateRealMatrix(invData));
            }
Пример #16
0
        /// <summary>
        /// Used for computing the actual transformations (A and B matrices). These are stored in As and Bs.
        /// </summary>
        /// <param name="regLs">The reg ls.</param>
        /// <param name="regRs">The reg rs.</param>
        private void ComputeMllrTransforms(double[][][][][] regLs, double[][][][] regRs)
        {
            int len;

            for (int c = 0; c < _nrOfClusters; c++)
            {
                As[c] = new float[_loader.NumStreams][][];
                Bs[c] = new float[_loader.NumStreams][];

                for (int i = 0; i < _loader.NumStreams; i++)
                {
                    len      = _loader.VectorLength[i];
                    As[c][i] = Java.CreateArray <float[][]>(len, len); //this.As[c][i] = new float[len][len];
                    Bs[c][i] = new float[len];

                    for (int j = 0; j < len; ++j)
                    {
                        var coef   = new Array2DRowRealMatrix(regLs[c][i][j], false);
                        var solver = new LUDecomposition(coef).getSolver();
                        var vect   = new ArrayRealVector(regRs[c][i][j], false);
                        var aBloc  = solver.solve(vect);

                        for (int k = 0; k < len; ++k)
                        {
                            As[c][i][j][k] = (float)aBloc.getEntry(k);
                        }

                        Bs[c][i][j] = (float)aBloc.getEntry(len);
                    }
                }
            }
        }
		async protected override void OnTextChanged(Java.Lang.ICharSequence text, int start, int lengthBefore, int lengthAfter)
		{
			base.OnTextChanged(text, start, lengthBefore, lengthAfter);
			UpdateCharacterCount(StringUtils.TrimWhiteSpaceAndNewLine(Text));
			if (Validate != null)
			{
				Validate();
			}

			if (Text.Length <= 2 || !Text.Contains("@"))
			{
				if (SuggestionsView != null)
				{
					SuggestionsView.Visibility = ViewStates.Gone;
				}
				return;
			}


			if (Text.Substring(Text.Length - 1) == " " || Text.Substring(Text.Length - 1) == "@")
			{
				SuggestionsView.Visibility = ViewStates.Gone;
				return;
			}

			int startSelection = SelectionStart;

			string selectedWord = "";

			int length = 0;
			foreach (string currentWord in Text.Split(' '))
			{
				Console.WriteLine(currentWord);
				length = length + currentWord.Length + 1;
				if (length > startSelection)
				{
					selectedWord = currentWord;
					break;
				}
			}

			Console.WriteLine("Selected word is: " + selectedWord);

			if (!selectedWord.Contains("@") || selectedWord.IndexOf('@') != 0)
			{
				SuggestionsView.Visibility = ViewStates.Gone;
				return;
			}


			try
			{
				List<User> users = await TenServices.SearchFollowingUsers(selectedWord);
				SuggestionsView.BindDataToView(users);
			}
			catch (RESTError e)
			{
				Console.WriteLine(e.Message);
			}
		}
Пример #18
0
        /// <summary>
        /// Reads the information from the given .ab file
        /// </summary>
        /// <param name="path">The path of the .ab file</param>
        /// <param name="password">The password to use</param>
        /// <returns>The BackupFileInfo instance</returns>
        public static BackupFileInfo FromFile(string path, string password = "******")
        {
            BackupFileInfo result = new BackupFileInfo();

            Java.Update();
            string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", "info", "\"" + path + "\"", password });

            result.magic      = output.Between("Magic: ", "\r\n");
            result.algorithm  = output.Between("Algorithm: ", "\r\n");
            result.compressed = (output.Between("Compressed: ", "\r\n").Contains("1") ? true : false);
            result.version    = (output.Between("Version: ", "\r\n").Contains("1") ? BackupFileVersion.Version1 : BackupFileVersion.Version2);

            BackupFileEncryptedInformation ei = new BackupFileEncryptedInformation();

            if (!output.Contains("Exception") && output.Contains("IV: "))
            {
                ei.iV         = output.Between("IV: ", "\r\n");
                ei.keyBytes   = output.Between("key bytes: ", "\r\n");
                ei.keyFormat  = output.Between("Key format: ", "\r\n");
                ei.mK         = output.Between("MK: ", "\r\n");
                ei.mKAsString = output.Between("MK as string: ", "\r\n");
                ei.mKChecksum = output.Between("MK checksum: ", "\r\n");
                ei.saltBytes  = output.Between("salt bytes: ", "\r\n");
            }
            result.encrytedInformation = ei;

            return(result);
        }
Пример #19
0
 /// <summary>
 ///  Puts the probability into the map.
 /// </summary>
 /// <param name="wordSequence">The tag for the prob.</param>
 /// <param name="logProb">The probability in log math base.</param>
 /// <param name="logBackoff">The backoff probability in log math base.</param>
 private void Put(WordSequence wordSequence, float logProb, float logBackoff)
 {
     // System.out.println("Putting " + wordSequence + " p " + logProb
     // + " b " + logBackoff);
     Java.Put(_map, wordSequence, new Probability(logProb, logBackoff));
     Java.Add(_tokens, wordSequence);
 }
Пример #20
0
        /**
         * Backtraces through the penalty table.  This starts at the "lower right" corner (i.e., the last word of the longer
         * of the reference vs. hypothesis strings) and works its way backwards.
         *
         * @param backtraceTable created from call to createBacktraceTable
         * @return a linked list of Integers representing the backtrace
         */
        LinkedList <Integer> Backtrace(int[,] backtraceTable)
        {
            var list = new LinkedList <Integer>();
            var i    = _referenceItems.Count;
            var j    = _hypothesisItems.Count;

            while ((i >= 0) && (j >= 0))
            {
                Java.Add(list, backtraceTable[i, j]);
                switch (backtraceTable[i, j])
                {
                case Ok:
                    i--;
                    j--;
                    break;

                case Substitution:
                    i--;
                    j--;
                    _substitutions++;
                    break;

                case Insertion:
                    j--;
                    _insertions++;
                    break;

                case Deletion:
                    i--;
                    _deletions++;
                    break;
                }
            }
            return(list);
        }
Пример #21
0
 void FirstLaunch()
 {
     if (!File.Exists("OMCLC\\FirstLaunchInfo.json"))
     {
         Task t = new Task(() =>
         {
             MainWindow.Current.Dispatcher.BeginInvoke((Action) delegate()
             {
                 PreLoadingArea.Visibility = Visibility.Visible;
                 PreLoadingProg.Content    = "搜索Java中...";
             }).Wait();
             Java.SearchJava();
             MainWindow.Current.Dispatcher.BeginInvoke((Action) delegate()
             {
                 if (Java.JavaList.Count == 0)
                 {
                     PreLoadingStatus.SelectedIndex = 1;
                     PreLoadingProg.Content         = "没有搜索到Java,请安装Java后再打开启动器";
                 }
                 else
                 {
                     PreLoadingArea.Visibility = Visibility.Collapsed;
                 }
             }).Wait();
         });
         t.Start();
     }
     else
     {
         Java.LoadFromProfile();
     }
 }
        public override Java.Net.Socket CreateSocket(Java.Net.Socket s, string host, int port, bool autoClose)
        {
            SSLSocket socket = (SSLSocket)_factory.CreateSocket(s, host, port, autoClose);
            socket.SetEnabledProtocols(socket.GetSupportedProtocols());

            return socket;
        }
		/// <summary>
		/// Called after the bitmap is loaded.
		/// </summary>
		/// <param name="result">Result of the DoInBackground function.</param>
		protected override void OnPostExecute(Java.Lang.Object result)
		{
			base.OnPostExecute(result);

			if (IsCancelled)
			{
				result = null;
				Log.Debug("TT", "OnPostExecute - Task Cancelled");
			}
			else
			{
				using (Bitmap bmpResult = result as Bitmap)
				{
					if (_imageViewReference != null && bmpResult != null)
					{
						ImageView imageView = (ImageView)_imageViewReference.Get();

						AsyncImageTask asyncImageTask = GetAsyncImageTask(imageView);

						if(this == asyncImageTask && imageView != null) {
							imageView.SetImageBitmap(bmpResult);
							//							if (!pLRUCache.ContainsKey(path))
							//								pLRUCache.Add(path, bmpResult);
						}
					}
				}
			}
		}
Пример #24
0
 /// <summary>
 /// Private ctor
 /// </summary>
 private ArrayList(Java.Util.IList<object> list, bool isFixedSize, bool isReadOnly, bool isSynchronized)
 {
     this.list = list;
     this.isFixedSize = isFixedSize;
     this.isReadOnly = isReadOnly;
     this.isSynchronized = isSynchronized;
 }
Пример #25
0
        /// <summary>
        /// Computes a bi-linear frequency warped version of the LPC cepstrum from the LPC cepstrum. The recursive algorithm
        /// used is defined in Oppenheim's paper in Proceedings of IEEE, June 1972 The program has been written using g[x,y]
        /// = g_o[x,-y] where g_o is the array used by Oppenheim. To handle the reversed array index the recursion has been
        /// done DOWN the array index.
        /// </summary>
        /// <param name="warp">The warping coefficient. For 16KHz speech 0.6 is good valued..</param>
        /// <param name="nbilincepstra">The number of bilinear cepstral values to be computed from the linear frequencycepstrum.</param>
        /// <returns>A bi-linear frequency warped version of the LPC cepstrum.</returns>
        public double[] GetBilinearCepstra(double warp, int nbilincepstra)
        {
            //double[][] g = new double[nbilincepstra][cepstrumOrder];
            var g = new double[nbilincepstra][];

            // Make a local copy as this gets destroyed
            var lincep = Java.CopyOf(_cepstra, _cepstrumOrder);

            _bilinearCepstra[0]      = lincep[0];
            lincep[0]                = 0;
            g[0][_cepstrumOrder - 1] = lincep[_cepstrumOrder - 1];
            for (var i = 1; i < nbilincepstra; i++)
            {
                g[i][_cepstrumOrder - 1] = 0;
            }

            for (var i = _cepstrumOrder - 2; i >= 0; i--)
            {
                g[0][i] = warp * g[0][i + 1] + lincep[i];
                g[1][i] = (1 - warp * warp) * g[0][i + 1] + warp * g[1][i + 1];
                for (var j = 2; j < nbilincepstra; j++)
                {
                    g[j][i] = warp * (g[j][i + 1] - g[j - 1][i]) + g[j - 1][i + 1];
                }
            }

            for (var i = 1; i <= nbilincepstra; i++)
            {
                _bilinearCepstra[i] = g[i][0];
            }

            return(_bilinearCepstra);
        }
Пример #26
0
        public static Java.Lang.ICharSequence Parse(Context context, IList<IIconModule> modules, Java.Lang.ICharSequence text, View target = null)
        {
            context = context.ApplicationContext;

            // Analyse the text and replace {} blocks with the appropriate character
            // Retain all transformations in the accumulator
            var builder = new SpannableStringBuilder(text);
            RecursivePrepareSpannableIndexes(context, text.ToString(), builder, modules, 0);
            var isAnimated = HasAnimatedSpans(builder);

            // If animated, periodically invalidate the TextView so that the
            // CustomTypefaceSpan can redraw itself
            if (isAnimated)
            {
                if (target == null)
                    throw new ArgumentException("You can't use \"spin\" without providing the target View.");
                if (!(target is IHasOnViewAttachListener))
                    throw new ArgumentException(target.Class.SimpleName + " does not implement " +
                        "HasOnViewAttachListener. Please use IconTextView, IconButton or IconToggleButton.");

                ((IHasOnViewAttachListener)target).SetOnViewAttachListener(new MyListener(target));
            }
            else if (target is IHasOnViewAttachListener)
            {
                ((IHasOnViewAttachListener)target).SetOnViewAttachListener(null);
            }

            return builder;
        }
Пример #27
0
        /// <summary>
        /// Returns the entire set of words, including filler words
        /// </summary>
        /// <returns>the set of all words (as Word objects)</returns>
        private HashSet <Word> GetAllWords()
        {
            if (_allWords == null)
            {
                _allWords = new HashSet <Word>();
                foreach (String spelling in _lm.Vocabulary)
                {
                    Word word = Dictionary.GetWord(spelling);
                    //TODO: For some reason CMUSPHINX adds a filler here
                    if (word != null)
                    {
                        _allWords.Add(word);
                    }
                }

                if (_addFillerWords)
                {
                    Java.AddAll(_allWords, Dictionary.GetFillerWords());
                }
                else if (AddSilenceWord)
                {
                    _allWords.Add(Dictionary.GetSilenceWord());
                }
            }

            return(_allWords);
        }
Пример #28
0
        public static String CleanAsNMToken_ViaJni(
            [ExcelArgument(Name = "InputString",
                           Description = "A general string")] String aInputString
            )
        {
            if (ExcelDnaUtil.IsInFunctionWizard())
            {
                return("In Function Wizard, holding calls to Java");
            }
            if (aInputString == null || aInputString.Length == 0)
            {
                return("");
            }

            String aClassName       = "com/WDataSci/WDS/Util";
            IntPtr aClassID         = Java.FindClassID(aClassName);
            String aMethodName      = "CleanAsNMToken";
            String aSignatureString = "(Ljava/lang/String;)Ljava/lang/String;";

            List <object> cmargs = new List <object> {
                aInputString
            };
            String rv = "Err";

            unsafe {
                IntPtr aMethodID = Java.FindStaticMethodID(aClassID, aMethodName, aSignatureString);
                rv = Java.CallMethod <string>(aMethodID, true, aSignatureString, cmargs);
            }
            cmargs = null;

            return(rv);
        }
        public override Java.Net.Socket CreateSocket(string host, int port, Java.Net.InetAddress localHost, int localPort)
        {
            SSLSocket socket = (SSLSocket)_factory.CreateSocket(host, port, localHost, localPort);
            socket.SetEnabledProtocols(socket.GetSupportedProtocols());

            return socket;
        }
Пример #30
0
 protected override void PublishResults(Java.Lang.ICharSequence constraint, FilterResults results)
 {
     if (results != null && results.Count > 0) {
         nn_adapter.NotifyDataSetChanged ();
     } else {
         nn_adapter.NotifyDataSetInvalidated();
     }
 }
Пример #31
0
 public override void DestroyItem(Android.Views.ViewGroup container, int position, Java.Lang.Object objectValue)
 {
     base.DestroyItem (container, position, objectValue);
     var myview = objectValue as Android.Views.View;
     var viewPager = container.JavaCast<Android.Support.V4.View.ViewPager> ();
     viewPager.RemoveView (myview);
     myview = null;
 }
Пример #32
0
 public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object @object)
 {
     ScaleImageView SIV = views [position];
     container.RemoveView ((View)@object);
     SIV.SetImageBitmap (null);
     views [position] = null;
     bitmaps [position] = null;
 }
Пример #33
0
 public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object objectValue)
 {
     //var vp = (ViewPager)container;
     //var chd = container.GetChildAt(position);
     //���� Dispose, ����ͷ���,���� FinishUpdate ��ʱ��, ����
     //chd.Dispose();
     //container.RemoveView((View)chd);
 }
		public void OnItemClicked(Java.Lang.Object item, Row row){
			if (item is Movie) {
				var movie = (Movie)item;
				var intent = new Intent (this.Activity, typeof(DetailsActivity));
				intent.PutExtra (GetString (Resource.String.movie), Utils.Serialize(movie));
				StartActivity (intent);
			}
		}
Пример #35
0
 void IWebSocketListener.OnFailure(Java.IO.IOException exception, Response response)
 {
     var handler = Failure;
     if (handler != null)
     {
         handler(sender, new FailureEventArgs(exception, response));
     }
 }
Пример #36
0
 public void OnItemSelected(Presenter.ViewHolder itemViewHolder, Java.Lang.Object item,
     RowPresenter.ViewHolder rowViewHolder, Row row)
 {
     if (item is Movie) {
         mBackgroundURI = ((Movie)item).GetBackgroundImageURI ();
         StartBackgroundTimer ();
     }
 }
 public Intent DisplayPDF(Java.IO.File file)
 {
     Intent intent = new Intent (Intent.ActionView);
     Android.Net.Uri filepath = Android.Net.Uri.FromFile (file);
     intent.SetDataAndType (filepath, "application/pdf");
     intent.SetFlags (ActivityFlags.ClearTop);
     return intent;
 }
Пример #38
0
	    internal DateTimeFormatInfo(Java.Util.Locale locale, bool isInvariant = false)
	    {
	        _isInvariant = isInvariant;
	        Locale = locale;

            monthDayPattern = "MMMM dd";
            yearMonthPattern = "yyyy MMMM";
	    }
		public Java.Lang.Object Invoke (Java.Lang.Object proxy, Method method, Java.Lang.Object[] args)
		{
			if (method.Name.Equals ("OnPreferenceTreeClick")) {
				return _listener.OnPreferenceTreeClick ((PreferenceScreen)args [0], (Preference)args [1]);
			} else {
				return null;
			}
		}
Пример #40
0
        public ObjectResult GetObjectResult()
        {
            var java = new Java {
                Id = 8, Name = "Java"
            };

            return(new ObjectResult(java));
        }
		public Java.Lang.Object Apply (Java.Lang.Object p0) {
			IEntityProperty property = (IEntityProperty)p0;
//			if(property.Name().Equals("EmployeeType")) {
//				return new CustomEditor(dataForm, property);
//			}

			return null;
		}
Пример #42
0
 public void RemoveCallbacks(Action action, Java.Lang.Object token)
 {
     var runnable = Java.Lang.Thread.RunnableImplementor.Remove (action);
     if (runnable == null)
         return;
     RemoveCallbacks (runnable, token);
     runnable.Dispose ();
 }
Пример #43
0
        public ViewResult TestView()
        {
            var java = new Java {
                Id = 8, Name = "Java"
            };

            return(View(java));
        }
        /**
         * Compute the hash value of a key
         * @param key key to hash
         * @return hash value of the key
         */
        private static int hashOf(int key)
        {
            //int h = key ^ ((key >>> 20) ^ (key >>> 12));
            int h = key ^ ((Java.TripleShift(key, 20)) ^ (Java.TripleShift(key, 12)));

            //return h ^ (h >>> 7) ^ (h >>> 4);
            return(h ^ (Java.TripleShift(h, 7)) ^ (Java.TripleShift(h, 4)));
        }
Пример #45
0
 /**
  * /// Create the entry point table give the set of all possible entry point units
  *
  * /// @param entryPointCollection the set of possible entry points
  */
 public EntryPointTable(IEnumerable <Unit> entryPointCollection, HMMTree parent)
 {
     _entryPoints = new Dictionary <Unit, EntryPoint>();
     foreach (var unit in entryPointCollection)
     {
         Java.Put(_entryPoints, unit, new EntryPoint(unit, parent));
     }
 }
Пример #46
0
 public static Data FromData(Java.Lang.Object[] data)
 {
     if (data != null && data.Length == 1)
     {
         var json = data[0] as JSONObject;
         return JsonConvert.DeserializeObject<Data>(json.ToString());
     }
     return null;
 }
 public virtual void Notify(Java.Lang.String securityTokenResponse)
 {
     if (id_notify == IntPtr.Zero)
         id_notify = JNIEnv.GetMethodID(class_ref, "notify", "(Ljava/lang/String;)V");
     if (GetType() == ThresholdType)
         JNIEnv.CallVoidMethod(Handle, id_notify, new JValue[] { new JValue(securityTokenResponse) });
     else
         JNIEnv.CallNonvirtualObjectMethod(Handle, ThresholdClass, id_notify, new JValue[] { new JValue(securityTokenResponse) });
 }
Пример #48
0
			protected override int SizeOf(Java.Lang.Object key, Java.Lang.Object value)
			{
				// android.graphics.Bitmap.getByteCount() method isn't currently implemented in Xamarin. Invoke Java method.
				IntPtr classRef = JNIEnv.FindClass("android/graphics/Bitmap");
				var getBytesMethodHandle = JNIEnv.GetMethodID(classRef, "getByteCount", "()I");
				var byteCount = JNIEnv.CallIntMethod(value.Handle, getBytesMethodHandle);

				return byteCount / 1024;
			}
 protected override void OnPostExecute(Java.Lang.Object result)
 {
     drawable = new AsyncDrawable (this, bm);
     if (refer != null && bm != null) {
         ImageView im = (ImageView)refer.Get ();
         if (im != null)
             im.SetImageBitmap (drawable.Bitmap);
     }
 }
Пример #50
0
 /// <summary>
 /// Starts the timer running.
 /// </summary>
 public void Start()
 {
     if (_startTime != 0L)
     {
         _notReliable = true; // start called while timer already running
         this.LogInfo(GetName() + " timer.start() called without a stop()");
     }
     _startTime = Java.CurrentTimeMillis();
 }
Пример #51
0
 public LaunchHandler(string gamepath, Java java, bool isversionIsolation)
 {
     this.GameRootPath     = gamepath;
     this.Java             = java;
     this.VersionIsolation = isversionIsolation;
     versionReader         = new VersionReader(this);
     assetsReader          = new AssetsReader(this);
     argumentsParser       = new ArgumentsParser(this);
 }
Пример #52
0
        private static void PerformTestPartitionSizes(int absoluteBeamWidth, int tokenListSize, bool tokenListLarger)
        {
            var random      = new Random((int)Java.CurrentTimeMillis());
            var partitioner = new Partitioner();

            var parent = new Token(null, 0);
            var tokens = new Token[tokenListSize];

            for (var i = 0; i < tokens.Length; i++)
            {
                var logTotalScore = (float)random.NextDouble();
                tokens[i] = new Token(parent, null, logTotalScore, 0.0f, 0.0f, i);
            }

            var r = partitioner.Partition(tokens, tokens.Length, absoluteBeamWidth);

            if (tokenListLarger)
            {
                Assert.AreEqual(r, absoluteBeamWidth - 1);
            }
            else
            {
                Assert.AreEqual(r, tokenListSize - 1);
            }

            var firstList = new List <Token>();

            if (r >= 0)
            {
                var lowestScore = tokens[r].Score;

                for (var i = 0; i <= r; i++)
                {
                    Assert.IsTrue(tokens[i].Score >= lowestScore);
                    firstList.Add(tokens[i]);
                }
                for (var i = r + 1; i < tokens.Length; i++)
                {
                    Assert.IsTrue(lowestScore > tokens[i].Score);
                }


                firstList.Sort(new ScoreableComparator());

                var secondList = Arrays.AsList(tokens);
                secondList.Sort(new ScoreableComparator());


                for (int i = 0; i < firstList.Count; i++)
                {
                    var t1 = firstList[i];
                    var t2 = secondList[i];
                    Assert.AreEqual(t1, t2);
                }
            }
        }
Пример #53
0
        /**
         * /// Partitions sub-array of tokens around the x-th token by selecting the midpoint of the token array as the pivot.
         * /// Partially solves issues with slow performance on already sorted arrays.
         *
         * /// @param tokens the token array to partition
         * /// @param start      the starting index of the subarray
         * /// @param end      the ending index of the subarray, inclusive
         * /// @return the index of the element around which the array is partitioned
         */
        private int MidPointPartition(Token[] tokens, int start, int end)
        {
            //int middle = (start + end) >>> 1; //TODO: CHECK SEMANTICS
            int   middle = Java.TripleShift((start + end), 1);
            Token temp   = tokens[end];

            SetToken(tokens, end, tokens[middle]);
            SetToken(tokens, middle, temp);
            return(EndPointPartition(tokens, start, end));
        }
Пример #54
0
        public Array2DRowRealMatrix(double[] v)
        {
            int nRows = v.Length;

            data = Java.CreateArray <double[][]>(nRows, 1);//  new double[nRows][1];
            for (int row = 0; row < nRows; row++)
            {
                data[row][0] = v[row];
            }
        }
Пример #55
0
        /// <summary>
        /// Add a word hypothesis to this confusion set.
        /// </summary>
        /// <param name="word">The hypothesis to add.</param>
        public void AddWordHypothesis(WordResult word)
        {
            var wordSet = GetWordSet(word.GetConfidence());

            if (wordSet == null)
            {
                wordSet = new HashSet <WordResult>();
                Java.Put(this, word.GetConfidence(), wordSet);
            }
            wordSet.Add(word);
        }
        private void excuteUsingJavaWithoutJudging()
        {
            Invoke((MethodInvoker) delegate
            {
                lbInfo.Items.Insert(0, "Compiling the code...");
            });
            string error = Java.Compile(SystemFile.GetJavaFilePath());

            if (!string.IsNullOrEmpty(error))
            {
                Invoke((MethodInvoker) delegate
                {
                    lbInfo.Items.Insert(0, Messages.GetErrorType(error));
                    rtbReport.Text = error;
                });
            }
            else
            {
                Invoke((MethodInvoker) delegate
                {
                    lbInfo.Items.Insert(0, "Compiled Successfully !.");
                });
                string[] inputFilePaths  = SystemFile.GetInputFilePaths(SystemFolder.GetTestInDir());
                string[] outputFilePaths = SystemFile.GetOutputFilePaths(SystemFolder.GetTestInDir());
                int      i = 1;
                foreach (string inputFilePath in inputFilePaths)
                {
                    string fileInputContent = SystemFile.GetFileContentText(inputFilePath);
                    Invoke((MethodInvoker) delegate
                    {
                        lbInfo.Items.Insert(0, "Running test " + i + "...");
                    });
                    Result result = Java.Run(fileInputContent);
                    if (result.error.Length > 0)
                    {
                        Invoke((MethodInvoker) delegate
                        {
                            lbInfo.Items.Insert(0, Messages.GetErrorType(result.error.ToString()) + " at test " + i);
                            rtbReport.Text = result.error.ToString();
                        });
                        ErrorTests.Add(inputFilePath);
                        ErrorCount++;
                        i++;
                        continue;
                    }
                    File.WriteAllText(outputFilePaths[i - 1], result.output.ToString().TrimEnd('\n').TrimEnd('\r'));
                    i++;
                    TestedCount++;
                }
                TotalTestCount = inputFilePaths.Length;
                TestedCount   += ErrorCount;
                NotTestedCount = TotalTestCount - TestedCount;
            }
        }
        /// <summary>
        ///Purge all but max number of alternate preceding token hypotheses.
        /// </summary>
        public void Purge()
        {
            int max = _maxEdges - 1;

            foreach (var entry in _viterbiLoserMap.ToList())
            {
                List <Token> list = entry.Value;
                list.Sort(new ScoreableComparator());
                List <Token> newList = list.GetRange(0, list.Count > max ? max : list.Count);
                Java.Put(_viterbiLoserMap, entry.Key, newList);
            }
        }
 public void add(Cluster c)
 {
     if (c.startTime < startTime)
     {
         startTime = c.startTime;
     }
     if (c.endTime > endTime)
     {
         endTime = c.endTime;
     }
     Java.AddAll(elements, c.getElements());
 }
 public void add(Node n)
 {
     if (n.getBeginTime() < startTime)
     {
         startTime = n.getBeginTime();
     }
     if (n.getEndTime() > endTime)
     {
         endTime = n.getEndTime();
     }
     Java.Add(elements, n);
 }
Пример #60
0
        /// <summary>
        /// Called at the start of recognition. Gets the search manager ready to recognize.
        /// </summary>
        public override void StartRecognition()
        {
            this.LogInfo("starting recognition");

            Linguist.StartRecognition();
            _pruner.StartRecognition();
            _scorer.StartRecognition();
            LocalStart();
            if (_startTime == 0.0)
            {
                _startTime = Java.CurrentTimeMillis();
            }
        }