public TaskAdapter(Activity context, JavaList<TaskModel> tasks)
 {
     m_Context = context;
     m_Tasks = tasks;
     m_UncheckedColor = m_Context.Resources.GetColor(Settings.DarkTheme ? Resource.Color.white : Resource.Color.actionbar_maincolor_darkgray);
     m_CheckedColor = m_Context.Resources.GetColor(Settings.CheckedColor);
 }
        /// <summary>
        /// Gets the ListView items.
        /// </summary>
        /// <returns>
        /// The get items.
        /// </returns>
        private IList<IDictionary<string, object>> _GetItems()
        {
            var item1 = new JavaDictionary<string, object>();
            item1.Add(TitleKey, "FileExplorer");
            item1.Add(DetailsKey, "12312");

            var item2 = new JavaDictionary<string, object>();
            item2.Add(TitleKey, "Author");
            item2.Add(DetailsKey, "Alexander Matsibarov (macasun)");

            var item3 = new JavaDictionary<string, object>();
            item3.Add(TitleKey, "Email");
            item3.Add(DetailsKey, "*****@*****.**");

            var item4 = new JavaDictionary<string, object>();
            item4.Add(TitleKey, "Copyrights");
            item4.Add(DetailsKey, "2013");

            var item5 = new JavaDictionary<string, object>();
            item5.Add(TitleKey, "Application description");
            item5.Add(DetailsKey, "FileExplorer application for iOS and Android");

            var coll = new JavaList<IDictionary<string, object>>();
            coll.Add(item1);
            coll.Add(item2);
            coll.Add(item3);
            coll.Add(item4);
            coll.Add(item5);
            return coll;
        }
        public DragNDropSimpleAdapter(Context context, JavaList<IDictionary<string, object>> data, int resource, string[] @from, int[] to, int handler)
            : base(context, data, resource, @from, to)
        {
            DragHandler = handler;
            _position = new int[data.Count];

            for (var i = 0; i < data.Count; ++i) _position[i] = i;
        }
示例#4
0
        public virtual bool RemoveAll(JavaList collection)
        {
            bool ret = false;

            foreach (Java.Lang.Object item in collection)
            {
                ret |= Remove(item);
            }
            return(ret);
        }
示例#5
0
        public virtual bool AddAll(int location, JavaList collection)
        {
            int  pos = location;
            bool ret = false;

            foreach (Java.Lang.Object item in collection)
            {
                ret |= Add(pos++, item);
            }
            return(ret);
        }
示例#6
0
 public virtual bool ContainsAll(JavaList collection)
 {
     foreach (Java.Lang.Object item in collection)
     {
         if (!Contains(item))
         {
             return(false);
         }
     }
     return(true);
 }
示例#7
0
        public virtual bool RetainAll(JavaList collection)
        {
            bool ret = false;

            for (int i = 0; i < Count; i++)
            {
                var item = Get(i);
                if (!collection.Contains(item))
                {
                    Remove(item);
                    ret = true;
                    i--;
                }
            }
            return(ret);
        }
示例#8
0
        public static IntPtr ToLocalJniHandle(IList items)
        {
            if (items == null)
            {
                return(IntPtr.Zero);
            }

            var c = items as JavaList;

            if (c != null)
            {
                return(JNIEnv.ToLocalJniHandle(c));
            }

            using (c = new JavaList(items))
                return(JNIEnv.ToLocalJniHandle(c));
        }
示例#9
0
        void TestNonJavaObjectGenerics(TextView textview)
        {
            var adapter = new Android.Widget.ArrayAdapter <NonJavaObject> (this, textview.Id);
            var item    = new NonJavaObject();

            adapter.Add(item);
            textview.Text += "\n\n" + adapter.GetItem(0).ToString();

            var coll = new JavaDictionary <NonJavaObject, NonJavaObject> ();

            coll.Add(item, item);
            if (!object.ReferenceEquals(item, coll [item]))
            {
                throw new InvalidOperationException("Unable to lookup non-java.lang.Object item in JavaDictionary!");
            }

#if BXC_2147
            Log.Info("*jonp*", "A1");
            var jl1 = new Android.Runtime.JavaList <object>();
            Log.Info("*jonp*", "A2");
            var v1 = new Dictionary <string, object>();
            Log.Info("*jonp*", "A3");
            v1.Add("szLongName", "Bla.pdf");
            Log.Info("*jonp*", "A4");
            jl1.Add(v1);
            Log.Info("*jonp*", "A5");
            var vo1 = jl1 [0];
            Log.Info("*jonp*", "A6={0}", vo1);

            var jl2 = new Android.Runtime.JavaList();
            Log.Info("*jonp*", "B2");
            var v2 = new Dictionary <string, object>();
            Log.Info("*jonp*", "B3");
            v2.Add("szLongName", "Bla.pdf");
            Log.Info("*jonp*", "B4");
            jl2.Add(v2);
            Log.Info("*jonp*", "B5");
            var _vo2 = jl2 [0];                             // Exception
            Log.Info("*jonp*", "B6={0} [{1}]", _vo2, _vo2 != null ? _vo2.GetType().FullName : "<null>");
            var vo2 = (Dictionary <string, object>)jl2 [0]; // Exception
            Log.Info("*jonp*", "B7={0}", vo2);
#endif
        }
示例#10
0
        public static IList FromJniHandle(IntPtr handle, JniHandleOwnership transfer)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            IJavaObject inst = Java.Lang.Object.PeekObject(handle);

            if (inst == null)
            {
                inst = new JavaList(handle, transfer);
            }
            else
            {
                JNIEnv.DeleteRef(handle, transfer);
            }

            return((IList)inst);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            var data = new JavaList<IDictionary<string, object>>();
            for (var i = 0; i < 10; ++i)
                data.Add(new JavaDictionary<string, object>
                    {
                        {"text", "Test " + i},
                        {"icon", Android.Resource.Drawable.ButtonStarBigOn},
                    });

            var listView = FindViewById<DragNDropListView.DragNDropListView>(Android.Resource.Id.List);
            listView.Adapter = new DragNDropSimpleAdapter(
                this, data, Resource.Layout.dnd_list_item,
                new[] { "text", "icon"},
                new[] { Resource.Id.text, Resource.Id.handler },
                Resource.Id.handler);
        }
示例#12
0
 public virtual bool Add(JavaList collection)
 {
     return AddAll (0, collection);
 }
示例#13
0
        public static IntPtr ToLocalJniHandle(IList items)
        {
            if (items == null)
                return IntPtr.Zero;

            var c = items as JavaList;
            if (c != null)
                return JNIEnv.ToLocalJniHandle (c);

            using (c = new JavaList (items))
                return JNIEnv.ToLocalJniHandle (c);
        }
示例#14
0
 public virtual bool Add(JavaList collection)
 {
     return(AddAll(0, collection));
 }
示例#15
0
 public virtual bool AddAll(int location, JavaList collection)
 {
     int pos = location;
     bool ret = false;
     foreach (Java.Lang.Object item in collection)
         ret |= Add (pos++, item);
     return ret;
 }
示例#16
0
 public virtual bool RemoveAll(JavaList collection)
 {
     bool ret = false;
     foreach (Java.Lang.Object item in collection)
         ret |= Remove (item);
     return ret;
 }
示例#17
0
 public virtual bool ContainsAll(JavaList collection)
 {
     foreach (Java.Lang.Object item in collection)
         if (!Contains (item))
             return false;
     return true;
 }
 public ClearedTaskAdapter(Activity context, JavaList<ClearedTaskModel> tasks)
 {
     m_Context = context;
     m_Tasks = tasks;
 }
示例#19
0
 public virtual bool AddAll(int location, JavaList collection)
 {
     throw new NotImplementedException();
 }
        private void ReloadData(int startId)
        {
            m_AllTasks.Clear();
            foreach(var task in DataManager.GetTasks(Settings.SortBy))
            {
                m_AllTasks.Add(task);
            }

            #if DEBUG
            if(m_AllTasks.Count == 0)
            {
                m_AllTasks = new JavaList<TaskModel>();
                foreach (var item in m_FakeData)
                {
                    var task = new TaskModel {Task = item};
                    task.ID = DataManager.SaveTask(task);
                    m_AllTasks.Add(task);
                }
            }
            #endif
            RunOnUiThread(() =>
            {
                ListAdapter = new TaskAdapter(this, m_AllTasks);
                if (ListView.Visibility == ViewStates.Gone)
                {
                    ListView.Visibility = ViewStates.Visible;
                    ListView.StartAnimation(AnimationUtils.LoadAnimation(this, Resource.Animation.fadein));
                }
            });

            SetChecks();

            SetActionBar();

            if (startId == 0)
                    return;

            var firstTask = m_AllTasks.FirstOrDefault(t => t.ID == startId);
            if(firstTask == null)
                return;

            var itemIndex = m_AllTasks.IndexOf(firstTask);
            RunOnUiThread(()=> ListView.SetSelection(itemIndex));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            SetContentView (Resource.Layout.SoundFontDetails);

            var sf = Intent.GetStringExtra ("soundfont");

            var model = ApplicationModel.Instance;

            var mod = model.Database.Modules.First (m => m.Name == sf);
            var sfFile = model.Files.FirstOrDefault (p => p.Value == mod.Name).Key;
            if (!File.Exists (sfFile)) {
                Toast.MakeText (this, string.Format ("SoundFont file '{0}' was not found. Details not shown", sfFile), ToastLength.Long).Show ();
            } else {
                var sf2 = new SoundFont (new MemoryStream (File.ReadAllBytes (sfFile)));

                var infoList = new JavaList<IDictionary<string,object>> ();
                var map = mod.Instrument.Maps.First ();

                var labels = new string [] {"BankName", "FileName", "Author", "Copyright", "Comments", "Created", "SFVersion", "ROMVersion", "WaveTableEngine", "Tools", "TargetProduct", "DataROM"};
                var values = new string [] {
                    mod.Name,
                    sfFile,
                    sf2.FileInfo.Author,
                    sf2.FileInfo.Copyright,
                    sf2.FileInfo.Comments,
                    sf2.FileInfo.SoundFontVersion == null ? null : string.Format ("{0}.{1}", sf2.FileInfo.SoundFontVersion.Major, sf2.FileInfo.SoundFontVersion.Minor),
                    sf2.FileInfo.ROMVersion == null ? null : string.Format ("{0}.{1}", sf2.FileInfo.ROMVersion.Major, sf2.FileInfo.ROMVersion.Minor),
                    sf2.FileInfo.CreationDate,
                    sf2.FileInfo.WaveTableSoundEngine,
                    sf2.FileInfo.Tools,
                    sf2.FileInfo.TargetProduct,
                    sf2.FileInfo.DataROM,
                    };
                for (int i = 0; i < labels.Length; i++) {
                    var items = new JavaDictionary<string,object> ();
                    items.Add ("text1", labels [i]);
                    items.Add ("text2", values [i]);
                    infoList.Add (items);
                }

                var bankList = new JavaList<IDictionary<string,object>> ();
                foreach (var p in map.Programs) {
                    foreach (var b in p.Banks) {
                        var items = new JavaDictionary<string,object> ();
                        items.Add ("text1", string.Format ("{0:D03}.{1:D03}.{2:D03}", p.Index, b.Msb, b.Lsb));
                        items.Add ("text2", b.Name);
                        bankList.Add (items);
                    }
                }

                var fromKeys = new string [] {"text1", "text2"};
                var toIds = new int [] { Resource.Id.soundFontDetailFileInfoLabel, Resource.Id.soundFontDetailFileInfoValue };

                var lvfi = FindViewById<ListView> (Resource.Id.soundFontDetailsFileInfo);
                lvfi.Adapter = new SimpleAdapter (this, infoList, Resource.Layout.SoundFontFileInfoItem, fromKeys, toIds);

                var lvbanks = FindViewById<ListView> (Resource.Id.soundFontDetailsBankList);
                lvbanks.Adapter = new SimpleAdapter (this, bankList, Resource.Layout.SoundFontFileInfoItem, fromKeys, toIds);
            }
        }
        public ItemAdapter PopulateItems(Activity activity, int resourceId, int textsomething)
        {
            if (itemLock == false)
            {
                JavaList<ItemSingle> activeItems = new JavaList<ItemSingle>();
                if (item != null)
                {

                    System.Collections.IEnumerator itemEnum = item.GetEnumerator();
                    itemEnum.Reset();
                    int i = 0;
                    while (itemEnum.MoveNext())
                    {
                        Item active = (Item)itemEnum.Current;
                        activeItems.Add(new ItemSingle(active.No_,active.Description,active.Unit_List_Price,active.Unit_Price,active.Sales_Unit_of_Measure,i));
                        i++;
                    }
                }
                ItemAdapter items = new ItemAdapter(activity, resourceId, textsomething, activeItems);
                return items;
            }
            else
            {
                return null;
            }
        }
示例#23
0
 public virtual bool RetainAll(JavaList collection)
 {
     bool ret = false;
     for (int i = 0; i < Count; i++) {
         var item = Get (i);
         if (!collection.Contains (item)) {
             Remove (item);
             ret = true;
             i--;
         }
     }
     return ret;
 }
示例#24
0
 public virtual bool RetainAll(JavaList collection)
 {
     throw new NotImplementedException();
 }
示例#25
0
        public static IList FromJniHandle(IntPtr handle, JniHandleOwnership transfer)
        {
            if (handle == IntPtr.Zero)
                return null;

            IJavaObject inst = Java.Lang.Object.PeekObject (handle);
            if (inst == null)
                inst = new JavaList (handle, transfer);
            else
                JNIEnv.DeleteRef (handle, transfer);

            return (IList) inst;
        }
			public void AddItems (JavaList<Item> ret)
			{
				items = new List<Item> (ret);
				NotifyDataSetChanged ();
			}
示例#27
0
		void LoadChildrenImpl (string parentId, Result result)
		{
			LogHelper.Debug (Tag, "OnLoadChildren: parentMediaId=", parentId);

			var mediaItems = new JavaList<MediaBrowser.MediaItem> ();

			if (MediaIDHelper.MediaIdRoot == parentId) {
				LogHelper.Debug (Tag, "OnLoadChildren.ROOT");
				mediaItems.Add (new MediaBrowser.MediaItem (
					new MediaDescription.Builder ()
					.SetMediaId (MediaIDHelper.MediaIdMusicsByGenre)
					.SetTitle (GetString (Resource.String.browse_genres))
					.SetIconUri (Android.Net.Uri.Parse ("android.resource://" +
					"com.example.android.mediabrowserservice/drawable/ic_by_genre"))
					.SetSubtitle (GetString (Resource.String.browse_genre_subtitle))
					.Build (), MediaItemFlags.Browsable
				));

			} else if (MediaIDHelper.MediaIdMusicsByGenre == parentId) {
				LogHelper.Debug (Tag, "OnLoadChildren.GENRES");
				foreach (var genre in musicProvider.Genres) {
					var item = new MediaBrowser.MediaItem (
						           new MediaDescription.Builder ()
						.SetMediaId (MediaIDHelper.CreateBrowseCategoryMediaID (MediaIDHelper.MediaIdMusicsByGenre, genre))
						.SetTitle (genre)
						.SetSubtitle (GetString (Resource.String.browse_musics_by_genre_subtitle, genre))
						.Build (), MediaItemFlags.Browsable
					           );
					mediaItems.Add (item);
				}
			} else if (parentId.StartsWith (MediaIDHelper.MediaIdMusicsByGenre)) {
				var genre = MediaIDHelper.GetHierarchy (parentId) [1];
				LogHelper.Debug (Tag, "OnLoadChildren.SONGS_BY_GENRE  genre=", genre);
				foreach (var track in musicProvider.GetMusicsByGenre(genre)) {
					var hierarchyAwareMediaID = MediaIDHelper.CreateMediaID (
						                            track.Description.MediaId, MediaIDHelper.MediaIdMusicsByGenre, genre);
					var trackCopy = new MediaMetadata.Builder (track)
						.PutString (MediaMetadata.MetadataKeyMediaId, hierarchyAwareMediaID)
						.Build ();
					var bItem = new MediaBrowser.MediaItem (
						            trackCopy.Description, MediaItemFlags.Playable);
					mediaItems.Add (bItem);
				}
			} else {
				LogHelper.Warn (Tag, "Skipping unmatched parentMediaId: ", parentId);
			}
			LogHelper.Debug (Tag, "OnLoadChildren sending ", mediaItems.Count,
				" results for ", parentId);
			result.SendResult (mediaItems);
		}
示例#28
0
 /// <summary>
 /// Returns a list of Product objects that describe the products (including current price) associated with the specified list of Purchasables.
 /// </summary>
 /// <param name="purchasables">One or more string IDs that identify the products to be returned.</param>
 /// <returns>The list of Product objects.</returns>
 public async Task<IList<Product>> RequestProductListAsync(params string[] purchasables)
 {
     var list = new JavaList<Purchasable>();
     foreach (var purchasable in purchasables)
     {
         list.Add(new Purchasable(purchasable));
     }
     return await RequestProductListAsync(list);
 }
        public CustomerAdapter PopulateCustomers(Activity activity, int resourceId, int textsomething)
        {
            if (customersLock == false)
            {

                CustomerAdapter custs = null;//,new List<CustomerSingle>());
                JavaList<CustomerSingle> custsList = new JavaList<CustomerSingle>();
                if (customers != null)
                {
                    System.Collections.IEnumerator custEnum = customers.GetEnumerator();
                    custEnum.Reset();
                    int i = 0;
                    while (custEnum.MoveNext())
                    {
                        Customer active = (Customer)custEnum.Current;
                        custsList.Add(new CustomerSingle(active.No_, active.Name, active.Address, i));
                        i++;
                    }
                }
                custs = new CustomerAdapter(activity, resourceId, textsomething, custsList);
                return custs;
            }
            else
            {
                return null;
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            SetTheme(Settings.ThemeSetting == 0 ? Resource.Style.MyTheme : Resource.Style.MyThemeDark);

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.History);

            m_AllTasks = new JavaList<ClearedTaskModel>();
            ActionBar = FindViewById<ActionBar.ActionBar>(Resource.Id.actionbar);
            ActionBar.TitleRaw = Resource.String.completed_tasks;
            ActionBar.CurrentActivity = this;
            AddHomeAction();
            RegisterForContextMenu(ListView);

            var saveState = LastNonConfigurationInstance as SaveStateHistory;
            if (saveState != null)
            {
                m_AllTasks = new JavaList<ClearedTaskModel>(saveState.Tasks);
                RunOnUiThread(() => ListAdapter = new ClearedTaskAdapter(this, m_AllTasks));
                RunOnUiThread(() => ListView.SetSelection(saveState.LastPosition));
                ListView.Visibility = ViewStates.Visible;
            }
            else
            {
                FlurryAgent.OnPageView();
                FlurryAgent.LogEvent("HistoryActivity");
                ReloadData(0);
            }

            SetupMainActionBar();
        }
 public String WriteOrder(JavaList<ItemSingle> items, CustomerSingle customer)
 {
     SalesHeader header = new SalesHeader();
     header.Sell_To_Customer_No = customer.no;
     RootSalesHeader root = new RootSalesHeader();
     List<Lines> lines = new List<Lines>();
     foreach (var item in items)
     {
         Lines line = new Lines();
         line.No = item.no;
         line.Quantity = Convert.ToDecimal(item.quantity);
         line.Line_Discount_Pct = Convert.ToDecimal(item.discount);
         lines.Add(line);
     }
     header.Lines = lines.ToArray();
     root.SalesHeader.Lines.SetValue(header,0);
     return _Service.CreateSalesOrder(ref root);
 }
        protected override void OnCreate(Bundle bundle)
        {
            SetTheme(Settings.ThemeSetting == 0 ? Resource.Style.MyTheme : Resource.Style.MyThemeDark);

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            m_OriginalTheme = Settings.ThemeSetting;
            m_OriginalAccent = Settings.ThemeAccent;

            Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);

            m_AllTasks = new JavaList<TaskModel>();
            m_EditTaskPosition = 0;

            m_AddButton = FindViewById<ImageButton>(Resource.Id.button_add_task);
            m_MicrophoneButton = FindViewById<ImageButton>(Resource.Id.button_microphone);
            m_TaskEditText = FindViewById<EditText>(Resource.Id.edit_text_new_task);

            ActionBar = FindViewById<ActionBar.ActionBar>(Resource.Id.actionbar);

            //ActionBar.BackgroundDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_background_blue);
            //ActionBar.ItemBackgroundDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_btn_blue);
            //ActionBar.SeparatorColor = Resources.GetColor(Resource.Color.actionbar_separatorcolor_blue);
            ActionBar.Title = "Tasks";
            ActionBar.CurrentActivity = this;
            ActionBar.SetHomeLogo(Resource.Drawable.ic_launcher);
            RegisterForContextMenu(ListView);

            m_TaskEditText.SetOnEditorActionListener(this);

            ListView.ChoiceMode = ChoiceMode.Multiple;

            m_AddButton.Click += (sender, args) => AddNewTask();

            m_AddButton.SetImageResource(Settings.ThemeSetting == 0 ? Resource.Drawable.ic_action_add : Resource.Drawable.ic_action_add_dark);
            m_MicrophoneButton.SetImageResource(Settings.ThemeSetting == 0 ? Resource.Drawable.ic_action_microphone : Resource.Drawable.ic_action_microphone_dark);

            m_AddButton.SetBackgroundResource(Settings.ImageButtonDrawable);
            m_MicrophoneButton.SetBackgroundResource(Settings.ImageButtonDrawable);

            // remove speech if it doesn't exist
            var activities =PackageManager.QueryIntentActivities(new Intent(RecognizerIntent.ActionRecognizeSpeech), 0);
            if (activities.Count == 0)
            {
                m_MicrophoneButton.Visibility = ViewStates.Gone;
            }
            else
            {
                m_MicrophoneButton.Click += (sender, args) => StartVoiceRecognitionActivity();
            }

            m_TextToSpeech = new TextToSpeech(this, this);

            var saveState = LastNonConfigurationInstance as SaveState;
            if (saveState != null)
            {
                m_AllTasks = new JavaList<TaskModel>(saveState.Tasks);
                ListView.Visibility = ViewStates.Visible;
                RunOnUiThread(() => ListAdapter = new TaskAdapter(this, m_AllTasks));
                RunOnUiThread(() => ListView.SetSelection(saveState.LastPosition));
                SetChecks();
                m_TaskEditText.Text = saveState.NewTaskText;
                m_Editing = saveState.Editing;
                m_EditTaskPosition = saveState.EditIndex;
            }
            else
            {
                FlurryAgent.OnPageView();
                FlurryAgent.LogEvent("MainActivity");
                ReloadData(0);
            }

            SetActionBar();
            try
            {
                if(Intent.GetBooleanExtra("CameFromWidget", false))
                {
                    FocusMainText();
                    return;
                }

                if(Intent.Action == TaskWidgetProvider.UpdateIntent)

                if (Intent.ActionSend != Intent.Action || Intent.Type == null)
                    return;

                if ("text/plain" != Intent.Type)
                    return;

                var sharedText = Intent.GetStringExtra(Intent.ExtraText);
                if (!string.IsNullOrEmpty(sharedText))
                {
                    m_TaskEditText.Text = sharedText;
                    m_Editing = false;
                    SetActionBar();
                }
            }
            finally
            {
                var version = Resources.GetString(Resource.String.VersionNumber);
                if (Settings.CurrentVersionNumber != version)
                {
                    Settings.CurrentVersionNumber = version;
                    PopUpHelpers.ShowOKPopup(this, Resource.String.update_title, Resource.String.update_message, (ok)=>{ });
                }
            }
        }