コード例 #1
0
        public static Date GetDateFromString(string strDate)
        {
            long l = Long.ParseLong(strDate);
            Date d = new Date(l);

            return(d);
        }
コード例 #2
0
ファイル: MainActivity.cs プロジェクト: thatjohnbell/CS235AM
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            string        dbPath;
            List <string> spinList     = new List <string>();
            string        spinSelected = "";

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

            //move db from assets to file system
            dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "TidesDB.s3db");
            if (!File.Exists(dbPath))
            {
                using (Stream inStream = Assets.Open("TidesDB.s3db"))
                    using (Stream outStream = File.Create(dbPath))
                        inStream.CopyTo(outStream);
            }


            //create object from db layer for population
            TideDbAccess tideDb = new TideDbAccess(dbPath);

            //place locales from db into spinner value list and update spinner with values
            foreach (TideDB tide in tideDb.RetrieveLocales())
            {
                spinList.Add(tide.Locale);
                if (spinSelected == "")
                {
                    spinSelected = tide.Locale;
                }
            }
            Spinner spinner  = FindViewById <Spinner>(Resource.Id.SpinSelect);
            var     spinCont = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, spinList);

            spinCont.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = spinCont;
            //store selected item selected
            spinner.ItemSelected += (sender, e) => {
                spinSelected = spinner.GetItemAtPosition(e.Position).ToString();
            };

            //datepicker
            var datePicker = FindViewById <DatePicker>(Resource.Id.datePick);

            datePicker.MinDate = Long.ParseLong(ConvertToUnixTimestamp(tideDb.RetrieveDates(-1)[0].Date).ToString());
            datePicker.MaxDate = Long.ParseLong(ConvertToUnixTimestamp(tideDb.RetrieveDates(1)[0].Date).ToString());



            //do it to it!!
            var button = FindViewById <Button>(Resource.Id.submit);

            button.Click += delegate {
                var go = new Android.Content.Intent(this, typeof(TideList));
                go.PutExtra("Location", spinSelected);
                go.PutExtra("Date", datePicker.DateTime.ToString("yyyy/MM/dd"));
                StartActivity(go);
            };
        }
コード例 #3
0
        private object getAllCallLogs(ContentResolver cr)
        {
            // reading all data in descending order according to DATE
            // String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
            string strOrder = string.Format("{0} desc ", CallLog.Calls.Date);

            Android.Net.Uri callUri = Android.Net.Uri.Parse("content://call_log/calls");
            var             cur     = cr.Query(callUri, null, null, null, strOrder);

            // loop through cursor
            while (cur.MoveToNext())
            {
                string callNumber = cur.GetString(cur
                                                  .GetColumnIndex(CallLog.Calls.Number));
                string callName = cur
                                  .GetString(cur
                                             .GetColumnIndex(CallLog.Calls.CachedName));
                string callDate = cur.GetString(cur
                                                .GetColumnIndex(CallLog.Calls.Date));
                Java.Text.SimpleDateFormat formatter = new Java.Text.SimpleDateFormat(
                    "dd-MMM-yyyy HH:mm");
                string dateString = formatter.Format(new Java.Sql.Date(Long
                                                                       .ParseLong(callDate)));
                string callType = cur.GetString(cur
                                                .GetColumnIndex(CallLog.Calls.Type));
                string isCallNew = cur.GetString(cur
                                                 .GetColumnIndex(CallLog.Calls.New));
                string duration = cur.GetString(cur
                                                .GetColumnIndex(CallLog.Calls.Duration));
                // process log data...
            }
            return(null);
        }
コード例 #4
0
        protected override FilterResults PerformFiltering(ICharSequence constraint)
        {
            // throw new NotImplementedException();

            long          magazinId = Long.ParseLong(constraint.ToString());
            FilterResults results   = new FilterResults();

            if (magazinId > 0)
            {
                JavaList <Product> filterList = new JavaList <Product>();
                for (int i = 0; i < productFilterList.Count; i++)
                {
                    if ((productFilterList.ElementAt <Product>(i).magazinId) == magazinId)
                    {
                        Product product = productFilterList.ElementAt <Product>(i);
                        filterList.Add(product);
                    }
                }

                results.Count  = filterList.Count;
                results.Values = filterList;
            }
            else
            {
                results.Count  = productFilterList.Count;
                results.Values = productFilterList;
            }
            return(results);
        }
コード例 #5
0
 int convertColor(string color)
 {
     if (color.StartsWith("0x"))
     {
         return((int)Long.ParseLong(color.Substring(2), 16));
     }
     return(Color.ParseColor(color));
 }
コード例 #6
0
        public static bool IsPhoneNumberValid(string phoneNumber)
        {
            var clean = GetCleansedPhoneNumber(phoneNumber);

            if (clean.Length == 7 || clean.Length == 10 || clean.Length == 11)
            {
                try
                {
                    var l = Long.ParseLong(clean);
                    return(true);
                }
                catch { }
            }

            return(false);
        }
コード例 #7
0
        private Color ShadeColor(Color color, double percent)
        {
            var    hex   = $"#{(0xFFFFFF & color):6x}";
            var    f     = Long.ParseLong(hex.Substring(1), 16);
            double t     = percent < 0 ? 0 : 255;
            var    p     = percent < 0 ? percent * -1 : percent;
            var    r     = f >> 16;
            var    g     = f >> 8 & 0x00FF;
            var    b     = f & 0x0000FF;
            var    alpha = Color.GetAlphaComponent(color);
            var    red   = (int)(Math.Round((t - r) * p) + r);
            var    green = (int)(Math.Round((t - g) * p) + g);
            var    blue  = (int)(Math.Round((t - b) * p) + b);

            return(Color.Argb(alpha, red, green, blue));
        }
コード例 #8
0
 public static IStorageMetadata ToAbstract(this NativeStorageMetadata @this)
 {
     return(new StorageMetadata(
                bucket: @this.Bucket,
                generation: Long.ParseLong(@this.Generation),
                metaGeneration: Long.ParseLong(@this.MetadataGeneration),
                name: @this.Name,
                path: @this.Path,
                size: @this.SizeBytes,
                cacheControl: @this.CacheControl,
                contentDisposition: @this.ContentDisposition,
                contentEncoding: @this.ContentEncoding,
                contentLanguage: @this.ContentLanguage,
                contentType: @this.ContentType,
                customMetadata: @this.CustomMetadataKeys?.Select(x => (x, @this.GetCustomMetadata(x))).ToDictionary(x => x.Item1, x => x.Item2),
                md5Hash: @this.Md5Hash,
                storageReference: @this.Reference?.ToAbstract(),
                creationTime: DateTimeOffset.FromUnixTimeMilliseconds(@this.CreationTimeMillis),
                updatedTime: DateTimeOffset.FromUnixTimeMilliseconds(@this.UpdatedTimeMillis)));
 }
コード例 #9
0
ファイル: NetFileManager.cs プロジェクト: URK96/GFVPN
        private long strToLong(string value, int iHex, int iDefault)
        {
            long iValue = iDefault;

            if (value == null)
            {
                return(iValue);
            }

            try
            {
                iValue = Long.ParseLong(value, iHex);
            }
            catch (NumberFormatException e)
            {
                e.PrintStackTrace();
            }

            return(iValue);
        }
        string MockBubbleDataObjectDeliveryDate(string data)
        {
            Date date = new Date();
            long codeValue;

            try
            {
                codeValue = Long.ParseLong(data);
            }
            catch (NumberFormatException)
            {
                codeValue = 0;
            }
            catch (ArgumentNullException)
            {
                codeValue = 0;
            }
            catch (OverflowException)
            {
                codeValue = 0;
            }
            return(printDateFormat.Format(AddDays(date, (int)(codeValue % 15))));
        }
コード例 #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            var retriever = new IO.Vov.Vitamio.MediaMetadataRetriever(this);

            try
            {
                path = "";
                if (path == "")
                {
                    // Tell the user to provide an audio file URL.
                    Toast.MakeText(this, "Please edit MediaMetadataRetrieverDemo Activity, " + "and set the path variable to your audio file path." + " Your audio file must be stored on sdcard.", ToastLength.Short).Show();
                    return;
                }
                retriever.SetDataSource(path);
            }
            catch (IllegalArgumentException e)
            {
                e.PrintStackTrace();
            }
            catch (IllegalStateException e)
            {
                e.PrintStackTrace();
            }
            catch (IOException e)
            {
                e.PrintStackTrace();
            }
            long   durationMs = Long.ParseLong(retriever.ExtractMetadata(MediaMetadataRetriever.MetadataKeyDuration));
            string artist     = retriever.ExtractMetadata(MediaMetadataRetriever.MetadataKeyArtist);
            string title      = retriever.ExtractMetadata(MediaMetadataRetriever.MetadataKeyTitle);

            SetContentView(Resource.Layout.media_metadata);
            TextView textView = FindViewById <TextView>(Resource.Id.textView);

            textView.Text = durationMs + "" + artist + title;
        }
コード例 #12
0
        public override void SetDataSource(string filePath)
        {
            _reader.SetDataSource(filePath);

            if (_reader != null)
            {
                _infoMp3.Artist = _reader.ExtractMetadata(MetadataKey.Artist)
                                  ?? _reader.ExtractMetadata(MetadataKey.Author)
                                  ?? _reader.ExtractMetadata(MetadataKey.Composer)
                                  ?? "unknown artist";


                var lastFilePath = filePath.LastIndexOf("/", StringComparison.Ordinal);
                var name         = filePath.Remove(0, lastFilePath + 1).Replace(".mp3", "");

                _infoMp3.NameSong = _reader.ExtractMetadata(MetadataKey.Title)
                                    ?? name;

                long dur     = Long.ParseLong(_reader.ExtractMetadata(MetadataKey.Duration));
                var  seconds = String.ValueOf((dur % 60000) / 1000);
                var  minutes = String.ValueOf((dur / 60000));
                _infoMp3.Duration = minutes + ":" + seconds;
            }
        }
コード例 #13
0
        private void PlayIconVideoOnClick(object sender, EventArgs e)
        {
            try
            {
                if (PlayIconVideo.Tag.ToString() == "Play")
                {
                    MediaMetadataRetriever retriever;
                    if (PathStory.Contains("http"))
                    {
                        StoryVideoView.SetVideoURI(Uri.Parse(PathStory));

                        retriever = new MediaMetadataRetriever();
                        if ((int)Build.VERSION.SdkInt >= 14)
                        {
                            retriever.SetDataSource(PathStory, new Dictionary <string, string>());
                        }
                        else
                        {
                            retriever.SetDataSource(PathStory);
                        }
                    }
                    else
                    {
                        var file = Uri.FromFile(new File(PathStory));
                        StoryVideoView.SetVideoPath(file.Path);

                        retriever = new MediaMetadataRetriever();
                        //if ((int)Build.VERSION.SdkInt >= 14)
                        //    retriever.SetDataSource(file.Path, new Dictionary<string, string>());
                        //else
                        //    retriever.SetDataSource(file.Path);
                        retriever.SetDataSource(file.Path);
                    }
                    StoryVideoView.Start();

                    Duration = Long.ParseLong(retriever.ExtractMetadata(MetadataKey.Duration));
                    retriever.Release();

                    StoriesProgress.Visibility = ViewStates.Visible;
                    StoriesProgress.SetStoriesCount(1);         // <- set stories
                    StoriesProgress.SetStoryDuration(Duration); // <- set a story duration
                    StoriesProgress.StartStories();             // <- start progress

                    PlayIconVideo.Tag = "Stop";
                    PlayIconVideo.SetImageResource(Resource.Drawable.ic_stop_white_24dp);
                }
                else
                {
                    StoriesProgress.Visibility = ViewStates.Gone;
                    StoriesProgress.Pause();

                    StoryVideoView.Pause();

                    PlayIconVideo.Tag = "Play";
                    PlayIconVideo.SetImageResource(Resource.Drawable.ic_play_arrow);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #14
0
            public void OnClick(View view, Sticker sticker, bool fromRecent)
            {
                try
                {
                    //Toast.MakeText(Application.Context, sticker.ToString() + " clicked!", ToastLength.Short)?.Show();
                    var stickerUrl    = sticker.ToString();
                    var Position      = "1";
                    var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

                    switch (TypePage)
                    {
                    case "ChatWindowActivity":
                    {
                        MessageDataExtra m1 = new MessageDataExtra
                        {
                            Id        = unixTimestamp.ToString(),
                            FromId    = UserDetails.UserId,
                            ToId      = ChatWindow.UserId,
                            Media     = stickerUrl,
                            TimeText  = TimeNow,
                            Position  = "right",
                            ModelType = MessageModelType.RightSticker
                        };

                        ChatWindow.MAdapter.DifferList.Add(new AdapterModelsClassMessage
                            {
                                TypeView = MessageModelType.RightSticker,
                                Id       = Long.ParseLong(m1.Id),
                                MesData  = m1
                            });

                        var indexMes = ChatWindow.MAdapter.DifferList.IndexOf(ChatWindow.MAdapter.DifferList.FirstOrDefault(a => a.MesData == m1));
                        if (indexMes > -1)
                        {
                            ChatWindow.MAdapter.NotifyItemInserted(indexMes);
                            ChatWindow.MRecycler.ScrollToPosition(ChatWindow.MAdapter.ItemCount - 1);
                        }

                        if (Methods.CheckConnectivity())
                        {
                            //Sticker Send Function
                            MessageController.SendMessageTask(ChatWindow, ChatWindow.UserId, unixTimestamp.ToString(), "", "", "", stickerUrl, "sticker" + Position).ConfigureAwait(false);
                        }
                        else
                        {
                            Toast.MakeText(ChatWindow, ChatWindow.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                        }
                        break;
                    }

                    case "GroupChatWindowActivity":
                    {
                        MessageDataExtra m1 = new MessageDataExtra
                        {
                            Id        = unixTimestamp.ToString(),
                            FromId    = UserDetails.UserId,
                            GroupId   = GroupActivityView.GroupId,
                            Media     = stickerUrl,
                            TimeText  = TimeNow,
                            Position  = "right",
                            ModelType = MessageModelType.RightSticker
                        };

                        GroupActivityView.MAdapter.DifferList.Add(new AdapterModelsClassMessage
                            {
                                TypeView = MessageModelType.RightSticker,
                                Id       = Long.ParseLong(m1.Id),
                                MesData  = m1
                            });

                        var indexMes = GroupActivityView.MAdapter.DifferList.IndexOf(GroupActivityView.MAdapter.DifferList.FirstOrDefault(a => a.MesData == m1));
                        if (indexMes > -1)
                        {
                            GroupActivityView.MAdapter.NotifyItemInserted(indexMes);
                            GroupActivityView.MRecycler.ScrollToPosition(GroupActivityView.MAdapter.ItemCount - 1);
                        }

                        if (Methods.CheckConnectivity())
                        {
                            //Sticker Send Function
                            GroupMessageController.SendMessageTask(GroupActivityView, GroupActivityView.GroupId, unixTimestamp.ToString(), "", "", "", stickerUrl, "sticker" + Position).ConfigureAwait(false);
                        }
                        else
                        {
                            Toast.MakeText(GroupActivityView, GroupActivityView.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                        }
                        break;
                    }

                    case "PageChatWindowActivity":
                    {
                        MessageDataExtra m1 = new MessageDataExtra
                        {
                            Id        = unixTimestamp.ToString(),
                            FromId    = UserDetails.UserId,
                            PageId    = PageActivityView.PageId,
                            Media     = stickerUrl,
                            TimeText  = TimeNow,
                            Position  = "right",
                            ModelType = MessageModelType.RightSticker
                        };

                        PageActivityView.MAdapter.DifferList.Add(new AdapterModelsClassMessage
                            {
                                TypeView = MessageModelType.RightSticker,
                                Id       = Long.ParseLong(m1.Id),
                                MesData  = m1
                            });

                        var indexMes = PageActivityView.MAdapter.DifferList.IndexOf(PageActivityView.MAdapter.DifferList.FirstOrDefault(a => a.MesData == m1));
                        if (indexMes > -1)
                        {
                            PageActivityView.MAdapter.NotifyItemInserted(indexMes);
                            PageActivityView.MRecycler.ScrollToPosition(PageActivityView.MAdapter.ItemCount - 1);
                        }

                        if (Methods.CheckConnectivity())
                        {
                            //Sticker Send Function
                            PageMessageController.SendMessageTask(PageActivityView, PageActivityView.PageId, PageActivityView.UserId, unixTimestamp.ToString(), "", "", "", stickerUrl, "sticker" + Position).ConfigureAwait(false);
                        }
                        else
                        {
                            Toast.MakeText(PageActivityView, PageActivityView.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                        }
                        break;
                    }

                    case "StoryReplyActivity":
                    {
                        //if (Methods.CheckConnectivity())
                        //{
                        //    //Sticker Send Function
                        //    StoryReplyActivity.SendMess(StoryReplyActivity.UserId, "", "", "", stickerUrl, "sticker" + Position).ConfigureAwait(false);
                        //}
                        //else
                        //{
                        //    Toast.MakeText(StoryReplyActivity, StoryReplyActivity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                        //}
                        break;
                    }
                    }
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }
            }
コード例 #15
0
        public static string GetFilePath(this Uri uri, Context context)
        {
            try
            {
                var isKitKat = Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat;

                // DocumentProvider
                if (isKitKat && DocumentsContract.IsDocumentUri(context, uri))
                {
                    // ExternalStorageProvider
                    if (IsExternalStorageDocument(uri))
                    {
                        var docId = DocumentsContract.GetDocumentId(uri);
                        var split = docId.Split(':');
                        var type  = split[0];

                        return(Environment.GetExternalStoragePublicDirectory(type) + "/" + split[1]);
                    }
                    // DownloadsProvider
                    if (IsDownloadsDocument(uri))
                    {
                        var id         = DocumentsContract.GetDocumentId(uri);
                        var contentUri = ContentUris.WithAppendedId(
                            Uri.Parse("content://downloads/public_downloads"), Long.ParseLong(id));

                        return(GetDataColumn(context, contentUri, null, null));
                    }
                    // MediaProvider
                    if (IsMediaDocument(uri))
                    {
                        var docId = DocumentsContract.GetDocumentId(uri);
                        var split = docId.Split(':');
                        var type  = split[0];

                        Uri contentUri = null;
                        switch (type)
                        {
                        case "image":
                            contentUri = MediaStore.Images.Media.ExternalContentUri;
                            break;

                        case "video":
                            contentUri = MediaStore.Video.Media.ExternalContentUri;
                            break;

                        case "audio":
                            contentUri = MediaStore.Audio.Media.ExternalContentUri;
                            break;
                        }

                        const string selection     = "_id=?";
                        var          selectionArgs = new[]
                        {
                            split[1]
                        };

                        return(GetDataColumn(context, contentUri, selection, selectionArgs));
                    }
                }
                // MediaStore (and general)
                else
                {
                    switch (uri.Scheme)
                    {
                    case "content":
                        return(GetDataColumn(context, uri, null, null));

                    case "file":
                        return(uri.Path);
                    }
                }

                return(null);
            }
            catch (Exception e)
            {
                Debug.WriteLine($"[Uri.GetPath Extension error]\n{e.Message}\n{e.StackTrace}");
                return(null);
            }
        }
コード例 #16
0
        private async Task LoadStory()
        {
            try
            {
                Activity.RunOnUiThread(() =>
                {
                    try
                    {
                        var dataOwner = StoryAdapter.StoryList.FirstOrDefault(a => a.Type == "Your");
                        if (dataOwner == null)
                        {
                            StoryAdapter.StoryList.Insert(0, new FetchStoriesObject.Data()
                            {
                                Avatar   = UserDetails.Avatar,
                                Type     = "Your",
                                Username = Context.GetText(Resource.String.Lbl_YourStory),
                                Owner    = true,
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                });

                if (Methods.CheckConnectivity())
                {
                    int countList = StoryAdapter.StoryList.Count;
                    (int apiStatus, var respond) = await RequestsAsync.Story.FetchStories();

                    if (apiStatus != 200 || !(respond is FetchStoriesObject result) || result.data == null)
                    {
                        Methods.DisplayReportResult(Activity, respond);
                    }
                    else
                    {
                        var respondList = result.data.Count;
                        if (respondList > 0)
                        {
                            foreach (var item in result.data)
                            {
                                var check = StoryAdapter.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                                if (check == null)
                                {
                                    foreach (var item1 in item.Stories)
                                    {
                                        if (item.DurationsList == null)
                                        {
                                            item.DurationsList = new List <long>();
                                        }

                                        var type1 = Methods.AttachmentFiles.Check_FileExtension(item1.MediaFile);
                                        if (type1 != "Video")
                                        {
                                            Glide.With(Context).Load(item1.MediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                            item.DurationsList.Add(10000L);
                                        }
                                        else
                                        {
                                            var fileName = item1.MediaFile.Split('/').Last();
                                            item1.MediaFile = AppTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, item1.MediaFile);

                                            if (Long.ParseLong(item1.Duration) == 0)
                                            {
                                                item1.Duration = AppTools.GetDuration(item1.MediaFile);
                                                item.DurationsList.Add(Long.ParseLong(item1.Duration));
                                            }
                                            else
                                            {
                                                item.DurationsList.Add(Long.ParseLong(item1.Duration));
                                            }
                                        }
                                    }

                                    StoryAdapter.StoryList.Add(item);
                                }
                                else
                                {
                                    foreach (var item2 in item.Stories)
                                    {
                                        if (item.DurationsList == null)
                                        {
                                            item.DurationsList = new List <long>();
                                        }

                                        var type = Methods.AttachmentFiles.Check_FileExtension(item2.MediaFile);
                                        if (type != "Video")
                                        {
                                            Glide.With(Context).Load(item2.MediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                            item.DurationsList.Add(10000L);
                                        }
                                        else
                                        {
                                            var fileName = item2.MediaFile.Split('/').Last();
                                            item2.MediaFile = AppTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, item2.MediaFile);

                                            if (Long.ParseLong(item2.Duration) == 0)
                                            {
                                                item2.Duration = AppTools.GetDuration(item2.MediaFile);
                                                item.DurationsList.Add(Long.ParseLong(item2.Duration));
                                            }
                                            else
                                            {
                                                item.DurationsList.Add(Long.ParseLong(item2.Duration));
                                            }
                                        }
                                    }

                                    check.Stories = item.Stories;
                                }
                            }

                            if (countList > 0)
                            {
                                Activity.RunOnUiThread(() => { StoryAdapter.NotifyItemRangeInserted(countList - 1, StoryAdapter.StoryList.Count - countList); });
                            }
                            else
                            {
                                Activity.RunOnUiThread(() => { StoryAdapter.NotifyDataSetChanged(); });
                            }
                        }
                    }
                }
                else
                {
                    Inflated = EmptyStateLayout.Inflate();
                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click += null;
                        x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                    }

                    Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #17
0
        private void StickerAdapterOnOnItemClick(object sender, StickerRecylerAdapter.AdapterClickEvents adapterClickEvents)
        {
            try
            {
                var stickerUrl    = StickerAdapter.GetItem(adapterClickEvents.Position);
                var unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

                if (Type == "ChatWindowActivity")
                {
                    MessageDataExtra m1 = new MessageDataExtra
                    {
                        Id        = unixTimestamp.ToString(),
                        FromId    = UserDetails.UserId,
                        ToId      = ChatWindow.Userid,
                        Media     = stickerUrl,
                        TimeText  = TimeNow,
                        Position  = "right",
                        ModelType = MessageModelType.RightSticker
                    };

                    ChatWindow.MAdapter.DifferList.Add(new AdapterModelsClassMessage()
                    {
                        TypeView = MessageModelType.RightSticker,
                        Id       = Long.ParseLong(m1.Id),
                        MesData  = m1
                    });

                    var indexMes = ChatWindow.MAdapter.DifferList.IndexOf(ChatWindow.MAdapter.DifferList.FirstOrDefault(a => a.MesData == m1));
                    if (indexMes > -1)
                    {
                        ChatWindow.MAdapter.NotifyItemInserted(indexMes);
                        ChatWindow.MRecycler.ScrollToPosition(ChatWindow.MAdapter.ItemCount - 1);
                    }

                    if (Methods.CheckConnectivity())
                    {
                        //Sticker Send Function
                        MessageController.SendMessageTask(ChatWindow, ChatWindow.Userid, unixTimestamp.ToString(), "", "", "", stickerUrl, "sticker" + adapterClickEvents.Position).ConfigureAwait(false);
                    }
                    else
                    {
                        Toast.MakeText(ChatWindow, ChatWindow.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    }

                    try
                    {
                        var interplator = new FastOutSlowInInterpolator();
                        ChatWindow.ChatStickerButton.Tag = "Closed";

                        ChatWindow.ResetButtonTags();
                        ChatWindow.ChatStickerButton.Drawable.SetTint(Color.ParseColor("#888888"));
                        ChatWindow.TopFragmentHolder.Animate().SetInterpolator(interplator).TranslationY(1200).SetDuration(300);
                        ChatWindow.SupportFragmentManager.BeginTransaction().Remove(ChatWindow.ChatStickersTabBoxFragment).Commit();
                    }
                    catch (Exception exception)
                    {
                        Methods.DisplayReportResultTrack(exception);
                    }
                }
                else if (Type == "GroupChatWindowActivity")
                {
                    MessageDataExtra m1 = new MessageDataExtra
                    {
                        Id        = unixTimestamp.ToString(),
                        FromId    = UserDetails.UserId,
                        GroupId   = GroupActivityView.GroupId,
                        Media     = stickerUrl,
                        TimeText  = TimeNow,
                        Position  = "right",
                        ModelType = MessageModelType.RightSticker
                    };

                    GroupActivityView.MAdapter.DifferList.Add(new AdapterModelsClassMessage()
                    {
                        TypeView = MessageModelType.RightSticker,
                        Id       = Long.ParseLong(m1.Id),
                        MesData  = m1
                    });

                    var indexMes = GroupActivityView.MAdapter.DifferList.IndexOf(GroupActivityView.MAdapter.DifferList.FirstOrDefault(a => a.MesData == m1));
                    if (indexMes > -1)
                    {
                        GroupActivityView.MAdapter.NotifyItemInserted(indexMes);
                        GroupActivityView.MRecycler.ScrollToPosition(GroupActivityView.MAdapter.ItemCount - 1);
                    }

                    if (Methods.CheckConnectivity())
                    {
                        //Sticker Send Function
                        GroupMessageController.SendMessageTask(GroupActivityView, GroupActivityView.GroupId, unixTimestamp.ToString(), "", "", "", stickerUrl, "sticker" + adapterClickEvents.Position).ConfigureAwait(false);
                    }
                    else
                    {
                        Toast.MakeText(GroupActivityView, GroupActivityView.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    }

                    try
                    {
                        var interplator = new FastOutSlowInInterpolator();
                        GroupActivityView.ChatStickerButton.Tag = "Closed";

                        GroupActivityView.ResetButtonTags();
                        GroupActivityView.ChatStickerButton.Drawable.SetTint(Color.ParseColor("#888888"));
                        GroupActivityView.TopFragmentHolder.Animate().SetInterpolator(interplator).TranslationY(1200).SetDuration(300);
                        GroupActivityView.SupportFragmentManager.BeginTransaction().Remove(GroupActivityView.ChatStickersTabBoxFragment).Commit();
                    }
                    catch (Exception exception)
                    {
                        Methods.DisplayReportResultTrack(exception);
                    }
                }
                else if (Type == "PageChatWindowActivity")
                {
                    MessageDataExtra m1 = new MessageDataExtra
                    {
                        Id        = unixTimestamp.ToString(),
                        FromId    = UserDetails.UserId,
                        PageId    = PageActivityView.PageId,
                        Media     = stickerUrl,
                        TimeText  = TimeNow,
                        Position  = "right",
                        ModelType = MessageModelType.RightSticker
                    };

                    PageActivityView.MAdapter.DifferList.Add(new AdapterModelsClassMessage()
                    {
                        TypeView = MessageModelType.RightSticker,
                        Id       = Long.ParseLong(m1.Id),
                        MesData  = m1
                    });

                    var indexMes = PageActivityView.MAdapter.DifferList.IndexOf(PageActivityView.MAdapter.DifferList.FirstOrDefault(a => a.MesData == m1));
                    if (indexMes > -1)
                    {
                        PageActivityView.MAdapter.NotifyItemInserted(indexMes);
                        PageActivityView.MRecycler.ScrollToPosition(PageActivityView.MAdapter.ItemCount - 1);
                    }

                    if (Methods.CheckConnectivity())
                    {
                        //Sticker Send Function
                        PageMessageController.SendMessageTask(PageActivityView, PageActivityView.PageId, PageActivityView.UserId, unixTimestamp.ToString(), "", "", "", stickerUrl, "sticker" + adapterClickEvents.Position).ConfigureAwait(false);
                    }
                    else
                    {
                        Toast.MakeText(PageActivityView, PageActivityView.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    }

                    try
                    {
                        var interplator = new FastOutSlowInInterpolator();
                        PageActivityView.ChatStickerButton.Tag = "Closed";

                        PageActivityView.ResetButtonTags();
                        PageActivityView.ChatStickerButton.Drawable.SetTint(Color.ParseColor("#888888"));
                        PageActivityView.TopFragmentHolder.Animate().SetInterpolator(interplator).TranslationY(1200).SetDuration(300);
                        PageActivityView.SupportFragmentManager.BeginTransaction().Remove(PageActivityView.ChatStickersTabBoxFragment).Commit();
                    }
                    catch (Exception exception)
                    {
                        Methods.DisplayReportResultTrack(exception);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #18
0
        public static MessageDataExtra MessageFilter(string id, MessageData item, MessageModelType modelType, bool showStar = false)
        {
            try
            {
                if (item == null)
                {
                    return(null);
                }

                item.Media ??= "";
                item.Stickers ??= "";

                item.Text ??= "";

                item.Stickers = item.Stickers.Replace(".mp4", ".gif");

                item.Text = Methods.FunString.DecodeString(item.Text);

                item.TimeText = Methods.Time.TimeAgo(int.Parse(item.Time));

                item.ModelType = modelType;

                if (item.FromId == UserDetails.UserId) // right
                {
                    item.Position = "right";
                }
                else if (item.ToId == UserDetails.UserId) // left
                {
                    item.Position = "left";
                }

                if (item.Position == "right" && string.IsNullOrEmpty(item.ChatColor) || item.ChatColor != ChatWindowActivity.MainChatColor)
                {
                    item.ChatColor = ChatWindowActivity.MainChatColor;
                }

                if (showStar && ChatWindowActivity.GetInstance()?.StartedMessageList?.Count > 0)
                {
                    //SqLiteDatabase dbDatabase = new SqLiteDatabase();
                    //item.IsStarted = dbDatabase.IsStartedMessages(item.Id);
                    //dbDatabase.Dispose();
                    var cec = ChatWindowActivity.GetInstance()?.StartedMessageList?.FirstOrDefault(a => a.Id == Long.ParseLong(item.Id));
                    item.IsStarted = cec != null;
                }

                if (modelType == MessageModelType.LeftProduct || modelType == MessageModelType.RightProduct)
                {
                    string imageUrl = item.Product?.ProductClass?.Images[0]?.Image ?? "";
                    var    fileName = imageUrl.Split('/').Last();
                    item.Media = GetFile(id, Methods.Path.FolderDcimImage, fileName, imageUrl);
                }
                else if (modelType == MessageModelType.LeftGif || modelType == MessageModelType.RightGif)
                {
                    //https://media1.giphy.com/media/l0ExncehJzexFpRHq/200.gif?cid=b4114d905d3e926949704872410ec12a&rid=200.gif
                    string imageUrl = "";
                    if (!string.IsNullOrEmpty(item.Stickers))
                    {
                        imageUrl = item.Stickers;
                    }
                    else if (!string.IsNullOrEmpty(item.Media))
                    {
                        imageUrl = item.Media;
                    }
                    else if (!string.IsNullOrEmpty(item.MediaFileName))
                    {
                        imageUrl = item.MediaFileName;
                    }

                    string[] fileName     = imageUrl.Split(new[] { "/", "200.gif?cid=", "&rid=200" }, StringSplitOptions.RemoveEmptyEntries);
                    var      lastFileName = fileName.Last();
                    var      name         = fileName[3] + lastFileName;

                    item.Media = GetFile(id, Methods.Path.FolderDiskGif, name, imageUrl);
                }
                else if (modelType == MessageModelType.LeftText || modelType == MessageModelType.RightText)
                {
                    //return item;
                }
                else if (modelType == MessageModelType.LeftMap || modelType == MessageModelType.RightMap)
                {
                    //return item;
                }
                else if (modelType == MessageModelType.LeftImage || modelType == MessageModelType.RightImage)
                {
                    var fileName = item.Media.Split('/').Last();
                    item.Media = GetFile(id, Methods.Path.FolderDcimImage, fileName, item.Media);
                }
                else if (modelType == MessageModelType.LeftAudio || modelType == MessageModelType.RightAudio)
                {
                    var fileName = item.Media.Split('/').Last();
                    item.Media = GetFile(id, Methods.Path.FolderDcimSound, fileName, item.Media);

                    if (string.IsNullOrEmpty(item.MediaDuration))
                    {
                        item.MediaDuration = Methods.AudioRecorderAndPlayer.GetTimeString(Methods.AudioRecorderAndPlayer.Get_MediaFileDuration(item.Media));
                    }
                }
                else if (modelType == MessageModelType.LeftContact || modelType == MessageModelType.RightContact)
                {
                    if (item.Text.Contains("{&quot;Key&quot;") || item.Text.Contains("{key:") || item.Text.Contains("{key:^qu") || item.Text.Contains("{^key:^qu") || item.Text.Contains("{Key:") || item.Text.Contains("&quot;"))
                    {
                        string[] stringSeparators = { "," };
                        var      name             = item.Text.Split(stringSeparators, StringSplitOptions.None);
                        var      stringName       = name[0].Replace("{key:", "").Replace("{Key:", "").Replace("Value:", "").Replace("{", "").Replace("}", "");
                        var      stringNumber     = name[1].Replace("{key:", "").Replace("{Key:", "").Replace("Value:", "").Replace("{", "").Replace("}", "");
                        item.ContactName   = stringName;
                        item.ContactNumber = stringNumber;
                    }
                }
                else if (modelType == MessageModelType.LeftVideo || modelType == MessageModelType.RightVideo)
                {
                    var fileName = item.Media.Split('/').Last();
                    item.Media = GetFile(id, Methods.Path.FolderDcimVideo, fileName, item.Media);
                    var fileNameWithoutExtension = fileName.Split('.').First();

                    var bitmapImage = Methods.MultiMedia.Retrieve_VideoFrame_AsBitmap(Application.Context, item.Media);
                    if (bitmapImage != null)
                    {
                        item.ImageVideo = Methods.Path.FolderDcimVideo + id + "/" + fileNameWithoutExtension + ".png";
                        Methods.MultiMedia.Export_Bitmap_As_Image(bitmapImage, fileNameWithoutExtension, Methods.Path.FolderDcimVideo + id + "/");
                    }
                    else
                    {
                        item.ImageVideo = "";

                        Glide.With(Application.Context)
                        .AsBitmap()
                        .Load(item.Media)     // or URI/path
                        .Into(new MySimpleTarget(id, item));
                    }
                }
                else if (modelType == MessageModelType.LeftSticker || modelType == MessageModelType.RightSticker)
                {
                    var fileName = item.Media.Split('/').Last();
                    item.Media = GetFile(id, Methods.Path.FolderDiskSticker, fileName, item.Media);
                }
                else if (modelType == MessageModelType.LeftFile || modelType == MessageModelType.RightFile)
                {
                    var fileName = item.Media.Split('/').Last();
                    item.Media = GetFile(id, Methods.Path.FolderDcimFile, fileName, item.Media);
                }

                var db = Mapper.Map <MessageDataExtra>(item);
                return(db);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                var db = Mapper.Map <MessageDataExtra>(item);
                return(db);
            }
        }
コード例 #19
0
        public Android.Net.Uri GetPhotoUriFromContactId(string contactId)
        {
            var person = ContentUris.WithAppendedId(ContactsContract.Contacts.ContentUri, Long.ParseLong(contactId));

            return(Android.Net.Uri.WithAppendedPath(person, ContactsContract.Contacts.Photo.ContentDirectory));
        }
コード例 #20
0
        private async Task LoadStory()
        {
            if (Methods.CheckConnectivity())
            {
                (int apiStatus, var respond) = await RequestsAsync.Story.Get_UserStories();

                if (apiStatus == 200)
                {
                    if (respond is GetUserStoriesObject result)
                    {
                        foreach (var item in result.Stories)
                        {
                            var check = MAdapter.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                            if (check != null)
                            {
                                foreach (var item2 in item.Stories)
                                {
                                    if (item.DurationsList == null)
                                    {
                                        item.DurationsList = new List <long>();
                                    }

                                    //image and video
                                    var mediaFile = !item2.Thumbnail.Contains("avatar") && item2.Videos.Count == 0 ? item2.Thumbnail : item2.Videos[0].Filename;

                                    var type = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                    if (type != "Video")
                                    {
                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                        item.DurationsList.Add(AppSettings.StoryDuration);
                                    }
                                    else
                                    {
                                        var fileName = mediaFile.Split('/').Last();
                                        mediaFile = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                        item.DurationsList.Add(Long.ParseLong(duration));
                                    }
                                }

                                check.Stories = item.Stories;
                            }
                            else
                            {
                                foreach (var item1 in item.Stories)
                                {
                                    if (item.DurationsList == null)
                                    {
                                        item.DurationsList = new List <long>();
                                    }

                                    //image and video
                                    var mediaFile = !item1.Thumbnail.Contains("avatar") && item1.Videos.Count == 0 ? item1.Thumbnail : item1.Videos[0].Filename;

                                    var type1 = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                    if (type1 != "Video")
                                    {
                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                        item.DurationsList.Add(AppSettings.StoryDuration);
                                    }
                                    else
                                    {
                                        var fileName = mediaFile.Split('/').Last();
                                        WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                        item.DurationsList.Add(Long.ParseLong(duration));
                                    }
                                }

                                MAdapter.StoryList.Add(item);
                            }
                        }

                        Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                }
                else
                {
                    Methods.DisplayReportResult(Activity, respond);
                }

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }
コード例 #21
0
        private async Task LoadStory()
        {
            switch (AppSettings.ShowStory)
            {
            case false:
                return;
            }

            if (Methods.CheckConnectivity())
            {
                var checkSection = PostFeedAdapter?.ListDiffer?.FirstOrDefault(a => a.TypeView == PostModelType.Story);
                if (checkSection != null)
                {
                    checkSection.StoryList ??= new ObservableCollection <StoryDataObject>();

                    var(apiStatus, respond) = await RequestsAsync.Story.GetUserStoriesAsync();

                    switch (apiStatus)
                    {
                    case 200:
                    {
                        switch (respond)
                        {
                        case GetUserStoriesObject result:
                            await Task.Factory.StartNew(() =>
                                {
                                    try
                                    {
                                        foreach (var item in result.Stories)
                                        {
                                            var check = checkSection.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                                            if (check != null)
                                            {
                                                foreach (var item2 in item.Stories)
                                                {
                                                    item.DurationsList ??= new List <long>();

                                                    //image and video
                                                    var mediaFile = !item2.Thumbnail.Contains("avatar") && item2.Videos.Count == 0 ? item2.Thumbnail : item2.Videos[0].Filename;

                                                    var type = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                                    if (type != "Video")
                                                    {
                                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                                        item.DurationsList.Add(10000L);
                                                    }
                                                    else
                                                    {
                                                        var fileName = mediaFile.Split('/').Last();
                                                        mediaFile    = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                                        item.DurationsList.Add(Long.ParseLong(duration));
                                                    }
                                                }

                                                check.Stories = item.Stories;
                                            }
                                            else
                                            {
                                                foreach (var item1 in item.Stories)
                                                {
                                                    item.DurationsList ??= new List <long>();

                                                    //image and video
                                                    var mediaFile = !item1.Thumbnail.Contains("avatar") && item1.Videos.Count == 0 ? item1.Thumbnail : item1.Videos[0].Filename;

                                                    var type1 = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                                    if (type1 != "Video")
                                                    {
                                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                                        item.DurationsList.Add(10000L);
                                                    }
                                                    else
                                                    {
                                                        var fileName = mediaFile.Split('/').Last();
                                                        WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                                        item.DurationsList.Add(Long.ParseLong(duration));
                                                    }
                                                }

                                                checkSection.StoryList.Add(item);
                                            }
                                        }
                                        Activity?.RunOnUiThread(() =>
                                        {
                                            try
                                            {
                                                PostFeedAdapter.HolderStory.AboutMore.Visibility = checkSection.StoryList.Count > 4 ? ViewStates.Visible : ViewStates.Invisible;
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e);
                                            }
                                        });
                                    }
                                    catch (Exception e)
                                    {
                                        Methods.DisplayReportResultTrack(e);
                                    }
                                }).ConfigureAwait(false);

                            break;
                        }

                        break;
                    }

                    default:
                        Methods.DisplayReportResult(Activity, respond);
                        break;
                    }
                    var d = new Runnable(() => { PostFeedAdapter.NotifyItemChanged(PostFeedAdapter.ListDiffer.IndexOf(checkSection)); }); d.Run();
                }
            }
            else
            {
                Toast.MakeText(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
            }
        }
コード例 #22
0
        private async void AddStory()
        {
            try
            {
                var modelStory = GlobalContextTabbed.LastStoriesTab.MAdapter;

                string time          = Methods.Time.TimeAgo(DateTime.Now, false);
                int    unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                string time2         = unixTimestamp.ToString();

                var userData = ListUtils.MyProfileList.FirstOrDefault();

                //just pass file_path and type video or image
                var(apiStatus, respond) = await RequestsAsync.Story.Create_Story(DataPost.StoryTitle, DataPost.StoryDescription, DataPost.StoryFilePath, DataPost.StoryFileType);

                if (apiStatus == 200)
                {
                    if (respond is CreateStoryObject result)
                    {
                        Toast.MakeText(GlobalContextTabbed, GlobalContextTabbed.GetText(Resource.String.Lbl_Story_Added), ToastLength.Short).Show();

                        var check = modelStory.StoryList?.FirstOrDefault(a => a.UserId == UserDetails.UserId);
                        if (check != null)
                        {
                            if (DataPost.StoryFileType == "image")
                            {
                                var item = new GetUserStoriesObject.StoryObject.Story()
                                {
                                    UserId      = UserDetails.UserId,
                                    Id          = result.StoryId,
                                    Description = DataPost.StoryDescription,
                                    Title       = DataPost.StoryTitle,
                                    TimeText    = time,
                                    IsOwner     = true,
                                    Expire      = "",
                                    Posted      = time2,
                                    Thumbnail   = DataPost.StoryFilePath,
                                    UserData    = userData,
                                    Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                    Videos      = new List <GetUserStoriesObject.StoryObject.Video>()
                                };

                                if (check.DurationsList == null)
                                {
                                    check.DurationsList = new List <long>()
                                    {
                                        AppSettings.StoryDuration
                                    }
                                }
                                ;
                                else
                                {
                                    check.DurationsList.Add(AppSettings.StoryDuration);
                                }

                                check.Stories.Add(item);
                            }
                            else
                            {
                                var item = new GetUserStoriesObject.StoryObject.Story()
                                {
                                    UserId      = UserDetails.UserId,
                                    Id          = result.StoryId,
                                    Description = DataPost.StoryDescription,
                                    Title       = DataPost.StoryTitle,
                                    TimeText    = time,
                                    IsOwner     = true,
                                    Expire      = "",
                                    Posted      = time2,
                                    Thumbnail   = DataPost.StoryThumbnail,
                                    UserData    = userData,
                                    Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                    Videos      = new List <GetUserStoriesObject.StoryObject.Video>()
                                    {
                                        new GetUserStoriesObject.StoryObject.Video()
                                        {
                                            StoryId  = result.StoryId,
                                            Filename = DataPost.StoryFilePath,
                                            Id       = time2,
                                            Expire   = time2,
                                            Type     = "video",
                                        }
                                    }
                                };

                                var duration = WoWonderTools.GetDuration(DataPost.StoryFilePath);

                                if (check.DurationsList == null)
                                {
                                    check.DurationsList = new List <long>()
                                    {
                                        Long.ParseLong(duration)
                                    }
                                }
                                ;
                                else
                                {
                                    check.DurationsList.Add(Long.ParseLong(duration));
                                }

                                check.Stories.Add(item);
                            }
                        }
                        else
                        {
                            if (DataPost.StoryFileType == "image")
                            {
                                var item = new GetUserStoriesObject.StoryObject
                                {
                                    Type    = "image",
                                    Stories = new List <GetUserStoriesObject.StoryObject.Story>
                                    {
                                        new GetUserStoriesObject.StoryObject.Story()
                                        {
                                            UserId      = UserDetails.UserId,
                                            Id          = result.StoryId,
                                            Description = DataPost.StoryDescription,
                                            Title       = DataPost.StoryTitle,
                                            TimeText    = time,
                                            IsOwner     = true,
                                            Expire      = "",
                                            Posted      = time2,
                                            Thumbnail   = DataPost.StoryFilePath,
                                            UserData    = userData,
                                            Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                            Videos      = new List <GetUserStoriesObject.StoryObject.Video>(),
                                        }
                                    },
                                    UserId                = userData?.UserId,
                                    Username              = userData?.Username,
                                    Email                 = userData?.Email,
                                    FirstName             = userData?.FirstName,
                                    LastName              = userData?.LastName,
                                    Avatar                = userData?.Avatar,
                                    Cover                 = userData?.Cover,
                                    BackgroundImage       = userData?.BackgroundImage,
                                    RelationshipId        = userData?.RelationshipId,
                                    Address               = userData?.Address,
                                    Working               = userData?.Working,
                                    Gender                = userData?.Gender,
                                    Facebook              = userData?.Facebook,
                                    Google                = userData?.Google,
                                    Twitter               = userData?.Twitter,
                                    Linkedin              = userData?.Linkedin,
                                    Website               = userData?.Website,
                                    Instagram             = userData?.Instagram,
                                    WebDeviceId           = userData?.WebDeviceId,
                                    Language              = userData?.Language,
                                    IpAddress             = userData?.IpAddress,
                                    PhoneNumber           = userData?.PhoneNumber,
                                    Timezone              = userData?.Timezone,
                                    Lat                   = userData?.Lat,
                                    Lng                   = userData?.Lng,
                                    About                 = userData?.About,
                                    Birthday              = userData?.Birthday,
                                    Registered            = userData?.Registered,
                                    Lastseen              = userData?.Lastseen,
                                    LastLocationUpdate    = userData?.LastLocationUpdate,
                                    Balance               = userData?.Balance,
                                    Verified              = userData?.Verified,
                                    Status                = userData?.Status,
                                    Active                = userData?.Active,
                                    Admin                 = userData?.Admin,
                                    IsPro                 = userData?.IsPro,
                                    ProType               = userData?.ProType,
                                    School                = userData?.School,
                                    Name                  = userData?.Name,
                                    AndroidMDeviceId      = userData?.AndroidMDeviceId,
                                    ECommented            = userData?.ECommented,
                                    AndroidNDeviceId      = userData?.AndroidMDeviceId,
                                    AvatarFull            = userData?.AvatarFull,
                                    BirthPrivacy          = userData?.BirthPrivacy,
                                    CanFollow             = userData?.CanFollow,
                                    ConfirmFollowers      = userData?.ConfirmFollowers,
                                    CountryId             = userData?.CountryId,
                                    EAccepted             = userData?.EAccepted,
                                    EFollowed             = userData?.EFollowed,
                                    EJoinedGroup          = userData?.EJoinedGroup,
                                    ELastNotif            = userData?.ELastNotif,
                                    ELiked                = userData?.ELiked,
                                    ELikedPage            = userData?.ELikedPage,
                                    EMentioned            = userData?.EMentioned,
                                    EProfileWallPost      = userData?.EProfileWallPost,
                                    ESentmeMsg            = userData?.ESentmeMsg,
                                    EShared               = userData?.EShared,
                                    EVisited              = userData?.EVisited,
                                    EWondered             = userData?.EWondered,
                                    EmailNotification     = userData?.EmailNotification,
                                    FollowPrivacy         = userData?.FollowPrivacy,
                                    FriendPrivacy         = userData?.FriendPrivacy,
                                    GenderText            = userData?.GenderText,
                                    InfoFile              = userData?.InfoFile,
                                    IosMDeviceId          = userData?.IosMDeviceId,
                                    IosNDeviceId          = userData?.IosNDeviceId,
                                    IsFollowing           = userData?.IsFollowing,
                                    IsFollowingMe         = userData?.IsFollowingMe,
                                    LastAvatarMod         = userData?.LastAvatarMod,
                                    LastCoverMod          = userData?.LastCoverMod,
                                    LastDataUpdate        = userData?.LastDataUpdate,
                                    LastFollowId          = userData?.LastFollowId,
                                    LastLoginData         = userData?.LastLoginData,
                                    LastseenStatus        = userData?.LastseenStatus,
                                    LastseenTimeText      = userData?.LastseenTimeText,
                                    LastseenUnixTime      = userData?.LastseenUnixTime,
                                    MessagePrivacy        = userData?.MessagePrivacy,
                                    NewEmail              = userData?.NewEmail,
                                    NewPhone              = userData?.NewPhone,
                                    NotificationSettings  = userData?.NotificationSettings,
                                    NotificationsSound    = userData?.NotificationsSound,
                                    OrderPostsBy          = userData?.OrderPostsBy,
                                    PaypalEmail           = userData?.PaypalEmail,
                                    PostPrivacy           = userData?.PostPrivacy,
                                    Referrer              = userData?.Referrer,
                                    ShareMyData           = userData?.ShareMyData,
                                    ShareMyLocation       = userData?.ShareMyLocation,
                                    ShowActivitiesPrivacy = userData?.ShowActivitiesPrivacy,
                                    TwoFactor             = userData?.TwoFactor,
                                    TwoFactorVerified     = userData?.TwoFactorVerified,
                                    Url                   = userData?.Url,
                                    VisitPrivacy          = userData?.VisitPrivacy,
                                    Vk             = userData?.Vk,
                                    Wallet         = userData?.Wallet,
                                    WorkingLink    = userData?.WorkingLink,
                                    Youtube        = userData?.Youtube,
                                    City           = userData?.City,
                                    Points         = userData?.Points,
                                    DailyPoints    = userData?.DailyPoints,
                                    State          = userData?.State,
                                    Zip            = userData?.Zip,
                                    IsAdmin        = userData?.IsAdmin,
                                    IsBlocked      = userData?.IsBlocked,
                                    MemberId       = userData?.MemberId,
                                    PointDayExpire = userData?.PointDayExpire,
                                    UserPlatform   = userData?.UserPlatform,
                                    Details        = new DetailsUnion()
                                    {
                                        DetailsClass = new Details(),
                                    },
                                };

                                if (item.DurationsList == null)
                                {
                                    item.DurationsList = new List <long>()
                                    {
                                        AppSettings.StoryDuration
                                    }
                                }
                                ;
                                else
                                {
                                    item.DurationsList.Add(AppSettings.StoryDuration);
                                }

                                modelStory.StoryList?.Add(item);
                            }
                            else
                            {
                                var item = new GetUserStoriesObject.StoryObject()
                                {
                                    Type    = "video",
                                    Stories = new List <GetUserStoriesObject.StoryObject.Story>()
                                    {
                                        new GetUserStoriesObject.StoryObject.Story()
                                        {
                                            UserId      = UserDetails.UserId,
                                            Id          = result.StoryId,
                                            Description = DataPost.StoryDescription,
                                            Title       = DataPost.StoryTitle,
                                            TimeText    = time,
                                            IsOwner     = true,
                                            Expire      = "",
                                            Posted      = time2,
                                            Thumbnail   = DataPost.StoryThumbnail,
                                            UserData    = userData,
                                            Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                            Videos      = new List <GetUserStoriesObject.StoryObject.Video>()
                                            {
                                                new GetUserStoriesObject.StoryObject.Video()
                                                {
                                                    StoryId  = result.StoryId,
                                                    Filename = DataPost.StoryFilePath,
                                                    Id       = time2,
                                                    Expire   = time2,
                                                    Type     = "video",
                                                }
                                            }
                                        },
                                    },
                                    UserId                = userData?.UserId,
                                    Username              = userData?.Username,
                                    Email                 = userData?.Email,
                                    FirstName             = userData?.FirstName,
                                    LastName              = userData?.LastName,
                                    Avatar                = userData?.Avatar,
                                    Cover                 = userData?.Cover,
                                    BackgroundImage       = userData?.BackgroundImage,
                                    RelationshipId        = userData?.RelationshipId,
                                    Address               = userData?.Address,
                                    Working               = userData?.Working,
                                    Gender                = userData?.Gender,
                                    Facebook              = userData?.Facebook,
                                    Google                = userData?.Google,
                                    Twitter               = userData?.Twitter,
                                    Linkedin              = userData?.Linkedin,
                                    Website               = userData?.Website,
                                    Instagram             = userData?.Instagram,
                                    WebDeviceId           = userData?.WebDeviceId,
                                    Language              = userData?.Language,
                                    IpAddress             = userData?.IpAddress,
                                    PhoneNumber           = userData?.PhoneNumber,
                                    Timezone              = userData?.Timezone,
                                    Lat                   = userData?.Lat,
                                    Lng                   = userData?.Lng,
                                    About                 = userData?.About,
                                    Birthday              = userData?.Birthday,
                                    Registered            = userData?.Registered,
                                    Lastseen              = userData?.Lastseen,
                                    LastLocationUpdate    = userData?.LastLocationUpdate,
                                    Balance               = userData?.Balance,
                                    Verified              = userData?.Verified,
                                    Status                = userData?.Status,
                                    Active                = userData?.Active,
                                    Admin                 = userData?.Admin,
                                    IsPro                 = userData?.IsPro,
                                    ProType               = userData?.ProType,
                                    School                = userData?.School,
                                    Name                  = userData?.Name,
                                    AndroidMDeviceId      = userData?.AndroidMDeviceId,
                                    ECommented            = userData?.ECommented,
                                    AndroidNDeviceId      = userData?.AndroidMDeviceId,
                                    AvatarFull            = userData?.AvatarFull,
                                    BirthPrivacy          = userData?.BirthPrivacy,
                                    CanFollow             = userData?.CanFollow,
                                    ConfirmFollowers      = userData?.ConfirmFollowers,
                                    CountryId             = userData?.CountryId,
                                    EAccepted             = userData?.EAccepted,
                                    EFollowed             = userData?.EFollowed,
                                    EJoinedGroup          = userData?.EJoinedGroup,
                                    ELastNotif            = userData?.ELastNotif,
                                    ELiked                = userData?.ELiked,
                                    ELikedPage            = userData?.ELikedPage,
                                    EMentioned            = userData?.EMentioned,
                                    EProfileWallPost      = userData?.EProfileWallPost,
                                    ESentmeMsg            = userData?.ESentmeMsg,
                                    EShared               = userData?.EShared,
                                    EVisited              = userData?.EVisited,
                                    EWondered             = userData?.EWondered,
                                    EmailNotification     = userData?.EmailNotification,
                                    FollowPrivacy         = userData?.FollowPrivacy,
                                    FriendPrivacy         = userData?.FriendPrivacy,
                                    GenderText            = userData?.GenderText,
                                    InfoFile              = userData?.InfoFile,
                                    IosMDeviceId          = userData?.IosMDeviceId,
                                    IosNDeviceId          = userData?.IosNDeviceId,
                                    IsFollowing           = userData?.IsFollowing,
                                    IsFollowingMe         = userData?.IsFollowingMe,
                                    LastAvatarMod         = userData?.LastAvatarMod,
                                    LastCoverMod          = userData?.LastCoverMod,
                                    LastDataUpdate        = userData?.LastDataUpdate,
                                    LastFollowId          = userData?.LastFollowId,
                                    LastLoginData         = userData?.LastLoginData,
                                    LastseenStatus        = userData?.LastseenStatus,
                                    LastseenTimeText      = userData?.LastseenTimeText,
                                    LastseenUnixTime      = userData?.LastseenUnixTime,
                                    MessagePrivacy        = userData?.MessagePrivacy,
                                    NewEmail              = userData?.NewEmail,
                                    NewPhone              = userData?.NewPhone,
                                    NotificationSettings  = userData?.NotificationSettings,
                                    NotificationsSound    = userData?.NotificationsSound,
                                    OrderPostsBy          = userData?.OrderPostsBy,
                                    PaypalEmail           = userData?.PaypalEmail,
                                    PostPrivacy           = userData?.PostPrivacy,
                                    Referrer              = userData?.Referrer,
                                    ShareMyData           = userData?.ShareMyData,
                                    ShareMyLocation       = userData?.ShareMyLocation,
                                    ShowActivitiesPrivacy = userData?.ShowActivitiesPrivacy,
                                    TwoFactor             = userData?.TwoFactor,
                                    TwoFactorVerified     = userData?.TwoFactorVerified,
                                    Url                   = userData?.Url,
                                    VisitPrivacy          = userData?.VisitPrivacy,
                                    Vk             = userData?.Vk,
                                    Wallet         = userData?.Wallet,
                                    WorkingLink    = userData?.WorkingLink,
                                    Youtube        = userData?.Youtube,
                                    City           = userData?.City,
                                    Points         = userData?.Points,
                                    DailyPoints    = userData?.DailyPoints,
                                    State          = userData?.State,
                                    Zip            = userData?.Zip,
                                    IsAdmin        = userData?.IsAdmin,
                                    IsBlocked      = userData?.IsBlocked,
                                    MemberId       = userData?.MemberId,
                                    PointDayExpire = userData?.PointDayExpire,
                                    UserPlatform   = userData?.UserPlatform,
                                    Details        = new DetailsUnion()
                                    {
                                        DetailsClass = new Details(),
                                    },
                                };

                                var duration = WoWonderTools.GetDuration(DataPost.StoryFilePath);

                                if (item.DurationsList == null)
                                {
                                    item.DurationsList = new List <long>()
                                    {
                                        Long.ParseLong(duration)
                                    }
                                }
                                ;
                                else
                                {
                                    item.DurationsList.Add(Long.ParseLong(duration));
                                }

                                modelStory.StoryList?.Add(item);
                            }
                        }

                        modelStory.NotifyDataSetChanged();
                        GlobalContextTabbed.LastStoriesTab.ShowEmptyPage();

                        if (SettingsPrefFragment.SSoundControl)
                        {
                            Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("PopNotificationPost.mp3");
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(GlobalContextTabbed, respond);
                }

                RemoveNotification();
            }
            catch (Exception e)
            {
                RemoveNotification();
                Console.WriteLine(e);
            }
        }
コード例 #23
0
        public List <SuBienApp.Models.Calls> GetCallLogs()
        {
            // filter in desc order limit by no
            string querySorter = string.Format("{0} desc ", CallLog.Calls.Date);
            List <SuBienApp.Models.Calls> calls = new List <SuBienApp.Models.Calls>();

            // CallLog.Calls.ContentUri is the path where data is saved
            //ICursor queryData = Android.Content.ContentResolver.Query(CallLog.Calls.ContentUri, null, null, null, querySorter);
            try
            {
                Android.Database.ICursor queryData = ((Activity)Forms.Context).ManagedQuery(CallLog.Calls.ContentUri, null, null, null, querySorter);
                while (queryData.MoveToNext())
                {
                    string callNumber = queryData
                                        .GetString(queryData
                                                   .GetColumnIndex(CallLog.Calls.Number));

                    string callName = queryData
                                      .GetString(queryData
                                                 .GetColumnIndex(CallLog.Calls.CachedName));

                    string callDate = queryData
                                      .GetString(queryData
                                                 .GetColumnIndex(CallLog.Calls.Date));

                    Java.Text.SimpleDateFormat formatter = new Java.Text.SimpleDateFormat(
                        "dd/MMM/yyyy HH:mm");

                    DateTime dateString = Convert.ToDateTime(formatter.Format(new Java.Sql.Date(Long
                                                                                                .ParseLong(callDate))));

                    string callType = queryData
                                      .GetString(queryData
                                                 .GetColumnIndex(CallLog.Calls.Type));

                    string isCallNew = queryData
                                       .GetString(queryData
                                                  .GetColumnIndex(CallLog.Calls.New));

                    string duration = queryData
                                      .GetString(queryData
                                                 .GetColumnIndex(CallLog.Calls.Duration));

                    calls.Add(new SuBienApp.Models.Calls
                    {
                        CallName = callName + " Fecha: " + Convert.ToString(dateString, CultureInfo.InvariantCulture),
                        Number   = callNumber,
                        Date     = dateString,
                        Duration = duration,
                    });
                }
                var lessdays = DateTime.Now.AddDays(-8);
                return(calls.Where(c => c.Date > lessdays).ToList());//.GroupBy(p=> new { p.CachedName,p.Date,p.Duration,p.Number}).Select(p=>new { p.Key.CachedName,p.Key.Date,p.Key.Duration,p.Key.Number}).ToList() ;
            }
            catch (System.Exception ex)
            {
                return(calls);
            }
        }
コード例 #24
0
        private void PlayIconVideoOnClick(object sender, EventArgs e)
        {
            try
            {
                switch (PlayIconVideo?.Tag?.ToString())
                {
                case "Play":
                {
                    MediaMetadataRetriever retriever;
                    if (PathStory.Contains("http"))
                    {
                        StoryVideoView.SetVideoURI(Uri.Parse(PathStory));

                        retriever = new MediaMetadataRetriever();
                        switch ((int)Build.VERSION.SdkInt)
                        {
                        case >= 14:
                            retriever.SetDataSource(PathStory, new Dictionary <string, string>());
                            break;

                        default:
                            retriever.SetDataSource(PathStory);
                            break;
                        }
                    }
                    else
                    {
                        var file = Uri.FromFile(new File(PathStory));
                        StoryVideoView.SetVideoPath(file?.Path);

                        retriever = new MediaMetadataRetriever();
                        //if ((int)Build.VERSION.SdkInt >= 14)
                        //    retriever.SetDataSource(file.Path, new Dictionary<string, string>());
                        //else
                        //    retriever.SetDataSource(file.Path);
                        retriever.SetDataSource(file?.Path);
                    }
                    StoryVideoView.Start();

                    Duration = Long.ParseLong(retriever.ExtractMetadata(MetadataKey.Duration) ?? string.Empty);
                    retriever.Release();

                    StoriesProgress.Visibility = ViewStates.Visible;
                    StoriesProgress.SetStoriesCount(1);         // <- set stories
                    StoriesProgress.SetStoryDuration(Duration); // <- set a story duration
                    StoriesProgress.StartStories();             // <- start progress

                    PlayIconVideo.Tag = "Stop";
                    PlayIconVideo.SetImageResource(Resource.Drawable.ic_stop_white_24dp);
                    break;
                }

                default:
                {
                    StoriesProgress.Visibility = ViewStates.Gone;
                    StoriesProgress.Pause();

                    StoryVideoView.Pause();

                    if (PlayIconVideo != null)
                    {
                        PlayIconVideo.Tag = "Play";
                        PlayIconVideo.SetImageResource(Resource.Drawable.ic_play_arrow);
                    }

                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Methods.DisplayReportResultTrack(ex);
            }
        }
コード例 #25
0
        protected async void LoadDAtaAsync()
        {
            User u = await DbConnection.FetchUserAsync(this.Intent.GetStringExtra("Email"));

            TextView ForName = FindViewById <TextView>(Resource.Id.user_forname);

            ForName.Text = u.ForName;
            TextView SurName = FindViewById <TextView>(Resource.Id.user_surname);

            SurName.Text = u.SurName;
            TextView Email = FindViewById <TextView>(Resource.Id.user_email);

            Email.Text = u.Email;
            TextView Phone = FindViewById <TextView>(Resource.Id.user_phone);

            Phone.Text = u.Phone.ToString();
            TextView Nationality = FindViewById <TextView>(Resource.Id.user_Nationality);

            Nationality.Text = u.Nationality;

            ImageView photo = FindViewById <ImageView>(Resource.Id.user_photo);

            photo.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/User/" + u.Photo));
            LayoutInflater layoutInflaterAndroid = LayoutInflater.From(this);
            View           popup = layoutInflaterAndroid.Inflate(Resource.Layout.HistoryWindowU, null);

            Android.Support.V7.App.AlertDialog.Builder alertDialogbuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
            alertDialogbuilder.SetView(popup);

            var userContent = popup.FindViewById <EditText>(Resource.Id.History_description);

            alertDialogbuilder.SetCancelable(false)
            .SetPositiveButton("Dodaj", async delegate
            {
                HistoryU h = new HistoryU();
                //h.ID = LDbConnection.GetHistoryUser(this).Count;

                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    h.Description  = userContent.Text;
                    h.User         = LDbConnection.GetUser().ID;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchUserHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    h.Description  = userContent.Text;
                    h.User         = LDbConnection.GetCompany().Id;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchCompanyHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                Toast.MakeText(this, "Wysłano", ToastLength.Long).Show();
            }
                               ).SetNegativeButton("Zamknij", async delegate
            {
                HistoryU h = new HistoryU();
                //h.ID = LDbConnection.GetHistoryUser(this).Count;

                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    h.Description  = "Skanowanie Nr: " + LDbConnection.GetHistoryUser().Count;
                    h.User         = LDbConnection.GetUser().ID;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchUserHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    h.Description  = "Skanowanie Nr: " + LDbConnection.GetHistoryUser().Count;
                    h.User         = LDbConnection.GetCompany().Id;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchCompanyHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                alertDialogbuilder.Dispose();
            });
            Android.Support.V7.App.AlertDialog alertDialogAndroid = alertDialogbuilder.Create();
            if (this.Intent.GetBooleanExtra("Show", true))
            {
                alertDialogAndroid.Show();
            }
        }
        public void LocalNotification(string title, string body, int id, DateTime notifyTime, string frecuencia, string tiempo)
        {
            CreateNotificationChannel();
            //long repeateDay = 1000 * 60 * 60 * 24;
            long repeateForMinute = 60000;               // In milliseconds
            long repiteDiario     = 1000 * 60 * 60 * 24; //Cada dia
            long repite12Horas    = 1000 * 60 * 60 * 12; //cada 12 horas
            long tiempoRepeticion = 0;


            if (System.String.Equals(tiempo, "HORAS"))
            {
                if (System.String.Equals(frecuencia, "24"))
                {
                    tiempoRepeticion = repiteDiario;
                    //tiempoRepeticion = repeateForMinute * 2;
                }
                if (System.String.Equals(frecuencia, "12"))
                {
                    tiempoRepeticion = repite12Horas;
                    //tiempoRepeticion = repeateForMinute;
                }
            }
            if (System.String.Equals(tiempo, "DIAS"))
            {
                //tiempoRepeticion = repeateForMinute * 2;
                tiempoRepeticion = repiteDiario * Long.ParseLong(frecuencia);
            }



            long totalMilliSeconds = (long)(notifyTime.ToUniversalTime() - _jan1st1970).TotalMilliseconds;

            if (totalMilliSeconds < JavaSystem.CurrentTimeMillis())
            {
                //totalMilliSeconds = totalMilliSeconds + repeateForMinute;
                totalMilliSeconds = totalMilliSeconds + tiempoRepeticion;
            }

            var intent            = CreateIntent(id);
            var localNotification = new LocalNotification();

            localNotification.Title      = title;
            localNotification.Body       = body;
            localNotification.Id         = id;
            localNotification.NotifyTime = notifyTime;

            if (_notificationIconId != 0)
            {
                localNotification.IconId = _notificationIconId;
            }
            else
            {
                localNotification.IconId = Resource.Drawable.xamagonBlue;
            }

            var serializedNotification = SerializeNotification(localNotification);

            intent.PutExtra(ScheduledAlarmHandler.LocalNotificationKey, serializedNotification);

            Random generator = new Random();

            _randomNumber = generator.Next(100000, 999999).ToString("D6");

            var pendingIntent = PendingIntent.GetBroadcast(Application.Context, Convert.ToInt32(_randomNumber), intent, PendingIntentFlags.Immutable);
            var alarmManager  = GetAlarmManager();

            // alarmManager.SetRepeating(AlarmType.RtcWakeup, totalMilliSeconds, repeateForMinute, pendingIntent); //cada 1 minutoo
            alarmManager.SetRepeating(AlarmType.RtcWakeup, totalMilliSeconds, tiempoRepeticion, pendingIntent); //cada 12 minutos
        }
コード例 #27
0
        private async Task LoadStory()
        {
            if (Methods.CheckConnectivity())
            {
                var checkSection = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.Story);
                if (checkSection != null)
                {
                    if (checkSection.StoryList == null)
                    {
                        checkSection.StoryList = new ObservableCollection <GetUserStoriesObject.StoryObject>();
                    }

                    (int apiStatus, var respond) = await RequestsAsync.Story.Get_UserStories();

                    if (apiStatus == 200)
                    {
                        if (respond is GetUserStoriesObject result)
                        {
                            foreach (var item in result.Stories)
                            {
                                var check = checkSection.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                                if (check != null)
                                {
                                    foreach (var item2 in item.Stories)
                                    {
                                        item.DurationsList ??= new List <long>();

                                        //image and video
                                        var mediaFile = !item2.Thumbnail.Contains("avatar") && item2.Videos.Count == 0 ? item2.Thumbnail : item2.Videos[0].Filename;

                                        var type = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                        if (type != "Video")
                                        {
                                            Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                            item.DurationsList.Add(10000L);
                                        }
                                        else
                                        {
                                            var fileName = mediaFile.Split('/').Last();
                                            mediaFile = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                            var duration = WoWonderTools.GetDuration(mediaFile);
                                            item.DurationsList.Add(Long.ParseLong(duration));
                                        }
                                    }

                                    check.Stories = item.Stories;
                                }
                                else
                                {
                                    foreach (var item1 in item.Stories)
                                    {
                                        item.DurationsList ??= new List <long>();

                                        //image and video
                                        var mediaFile = !item1.Thumbnail.Contains("avatar") && item1.Videos.Count == 0 ? item1.Thumbnail : item1.Videos[0].Filename;

                                        var type1 = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                        if (type1 != "Video")
                                        {
                                            Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                            item.DurationsList.Add(10000L);
                                        }
                                        else
                                        {
                                            var fileName = mediaFile.Split('/').Last();
                                            WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                            var duration = WoWonderTools.GetDuration(mediaFile);
                                            item.DurationsList.Add(Long.ParseLong(duration));
                                        }
                                    }

                                    checkSection.StoryList.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(Activity, respond);
                    }

                    if (checkSection.StoryList.Count > 4)
                    {
                        PostFeedAdapter.HolderStory.AboutMore.Visibility     = ViewStates.Visible;
                        PostFeedAdapter.HolderStory.AboutMoreIcon.Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        PostFeedAdapter.HolderStory.AboutMore.Visibility     = ViewStates.Invisible;
                        PostFeedAdapter.HolderStory.AboutMoreIcon.Visibility = ViewStates.Invisible;
                    }

                    var d = new Runnable(() => { PostFeedAdapter.NotifyItemChanged(PostFeedAdapter.ListDiffer.IndexOf(checkSection)); }); d.Run();
                }
            }
            else
            {
                Toast.MakeText(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }
コード例 #28
0
        //MaX Add
        public string getPathFromUri(Context context, Android.Net.Uri uri)
        {
            if (uri == null)
            {
                return(null);
            }
            // 判斷是否為Android 4.4之後的版本
            bool after44 = (Int32)Build.VERSION.SdkInt >= 19;

            if (after44 && DocumentsContract.IsDocumentUri(context, uri))
            {
                // 如果是Android 4.4之後的版本,而且屬於文件URI
                string authority = uri.Authority;

                // 判斷Authority是否為本地端檔案所使用的
                if ("com.android.externalstorage.documents".Equals(authority))
                {
                    // 外部儲存空間
                    string   docId  = DocumentsContract.GetDocumentId(uri);
                    string[] divide = docId.Split(':');
                    string   type   = divide[0];

                    if ("primary".Equals(type))
                    {
                        return(Android.OS.Environment.ExternalStorageDirectory + "/" + divide[1]);
                    }
                }
                else if ("com.android.providers.downloads.documents".Equals(authority))
                {
                    // 下載目錄
                    string          docId       = DocumentsContract.GetDocumentId(uri);
                    Android.Net.Uri downloadUri = ContentUris.WithAppendedId(Android.Net.Uri.Parse("content://downloads/public_downloads"), Long.ParseLong(docId));
                    return(queryAbsolutePath(context, downloadUri));
                }
                else if ("com.android.providers.media.documents".Equals(authority))
                {
                    // 圖片、影音檔案
                    string          docId    = DocumentsContract.GetDocumentId(uri);
                    string[]        divide   = docId.Split(':');
                    string          type     = divide[0];
                    Android.Net.Uri mediaUri = null;
                    if ("image".Equals(type))
                    {
                        mediaUri = MediaStore.Images.Media.ExternalContentUri;
                    }
                    else if ("video".Equals(type))
                    {
                        mediaUri = MediaStore.Video.Media.ExternalContentUri;
                    }
                    else if ("audio".Equals(type))
                    {
                        mediaUri = MediaStore.Audio.Media.ExternalContentUri;
                    }
                    else
                    {
                        return(null);
                    }
                    mediaUri = ContentUris.WithAppendedId(mediaUri, Long.ParseLong(divide[1]));
                    return(queryAbsolutePath(context, mediaUri));
                }
            }
            else
            {
                // 如果是一般的URI
                string scheme = uri.Scheme;
                string path   = null;
                if ("content".Equals(scheme))
                {
                    // 內容URI
                    path = queryAbsolutePath(context, uri);
                }
                else if ("file".Equals(scheme))
                {
                    // 檔案URI
                    path = uri.Path;
                }
                return(path);
                //return createFileObjFromPath(path, mustCanRead);
            }
            return(null);
        }