Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ActivityDataList);

            mRef            = Intent.GetStringExtra("ref");
            mName           = Intent.GetStringExtra("name");
            mIsSelectedForm = Intent.GetBooleanExtra("selected", false);
            mRead           = Intent.GetBooleanExtra("read", false);
            mEdit           = Intent.GetBooleanExtra("edit", false);
            mDelete         = Intent.GetBooleanExtra("delete", false);

            mContainer = FindViewById <LinearLayout>(Resource.Id.Container);

            mSwipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeLayoutDataList);
            mSwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueBright, Android.Resource.Color.HoloBlueDark, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloRedLight);
            mSwipeRefreshLayout.Refresh += mSwipeRefreshLayout_Refresh;

            mDataList = FindViewById <ListView>(Resource.Id.ListView);
            if (mRead || mIsSelectedForm)
            {
                mDataList.ItemClick += MDataList_ItemClick;
            }
            if (mDelete)
            {
                mDataList.ItemLongClick += MDataList_ItemLongClick;
            }

            mFloatingActionButton            = FindViewById <FloatingActionButton>(Resource.Id.Fab);
            mFloatingActionButton.Visibility = mEdit ? ViewStates.Visible : ViewStates.Invisible;
            mFloatingActionButton.Click     += Fab_Click;

            mEemptyList = FindViewById <TextView>(Resource.Id.ViewEmpty);

            mToolbar       = FindViewById <SupportToolbar>(Resource.Id.Toolbar);
            mToolbar.Title = mName;
            SetSupportActionBar(mToolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);

            mSearchLinearLayout           = FindViewById <LinearLayout>(Resource.Id.Search);
            mSearchEditText               = FindViewById <EditText>(Resource.Id.etSearch);
            mSearchButton                 = FindViewById <Button>(Resource.Id.btnSearch);
            mSearchButton.Click          += MSearchButton_Click;
            mSearchEditText.EditorAction += MSearchEditText_EditorAction;;

            mSearchLinearLayout.Alpha = 0;
            mContainer.BringToFront();

            mListDataSet = new List <string>();
            mListDataSet.Add("Установить/снять пометку на удаление");
            ArrayAdapter <string> mListAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mListDataSet);

            AlertDialog.Builder mAlertDialog = new AlertDialog.Builder(this)
                                               .SetTitle("Выберите действие:")
                                               .SetAdapter(mListAdapter, OnSelectAction);
            mDialog = mAlertDialog.Create();

            UpdateList();
        }
Exemplo n.º 2
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Create your application here
			SetContentView(Resource.Layout.produtos);

			edPesquisa = FindViewById<TextView>(Resource.Id.edtpesquisa);
			lstProdutoView = FindViewById<ListView> (Resource.Id.ListaProduto);
			mContainer = FindViewById<LinearLayout>(Resource.Id.llContainer);
			mProgressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);
			mCabecalhoProduto = FindViewById<TextView> (Resource.Id.txxCabecalhoProduto);

			mWorker = new BackgroundWorker();

			edPesquisa.Alpha = 0;

			mContainer.BringToFront ();
			mProgressBar.BringToFront ();

			mProgressBar.Visibility = ViewStates.Visible;

			mUrl = new Uri("http://192.168.0.103/rest1/getprodutos.php?nome=VINHO");

			mClient = new WebClient();
			mClient.DownloadDataAsync(mUrl);
			mClient.DownloadDataCompleted += mClient_DownloadDataCompleted;

			mCabecalhoProduto.Click += MCabecalhoProduto_Click;
			edPesquisa.TextChanged += edPesquisa_TextChange;

		
		}
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            if (IsInitialized)
            {
                return;
            }

            base.OnViewCreated(view, savedInstanceState);

            TagEdit.Hint = AppSettings.LocalizationManager.GetText(LocalizationKeys.Hashtag);
            TagEdit.SetFilters(new IInputFilter[] { new TextInputFilter(TextInputFilter.TagFilter), new InputFilterLengthFilter(40) });
            TagLabel.Text    = AppSettings.LocalizationManager.GetText(LocalizationKeys.Hashtag);
            Title.Hint       = AppSettings.LocalizationManager.GetText(LocalizationKeys.EnterPostTitle);
            Description.Hint = AppSettings.LocalizationManager.GetText(LocalizationKeys.EnterPostDescription);
            PostButton.Text  = AppSettings.LocalizationManager.GetText(LocalizationKeys.PublishButtonText);
            PageTitle.Text   = AppSettings.LocalizationManager.GetText(LocalizationKeys.PostSettings);

            PageTitle.Typeface   = Style.Semibold;
            Title.Typeface       = Style.Regular;
            Description.Typeface = Style.Regular;
            PostButton.Typeface  = Style.Semibold;
            TagLabel.Typeface    = Style.Regular;

            PostButton.Click  += OnPost;
            PostButton.Enabled = true;

            TopPanel.BringToFront();

            LocalTagsList.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
            LocalTagsAdapter.Click += LocalTagsAdapterClick;
            LocalTagsList.SetAdapter(LocalTagsAdapter);
            LocalTagsList.AddItemDecoration(new ListItemDecoration((int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 15, Resources.DisplayMetrics)));

            var client = App.MainChain == KnownChains.Steem ? App.SteemClient : App.GolosClient;

            _tagPickerFacade = new TagPickerFacade(_localTagsAdapter.LocalTags);
            _tagPickerFacade.SetClient(client);
            _tagPickerFacade.SourceChanged += TagPickerFacadeOnSourceChanged;

            _postSearchTagsAdapter = new PostSearchTagsAdapter(_tagPickerFacade);

            TagsList.SetLayoutManager(new LinearLayoutManager(Activity));
            _postSearchTagsAdapter.Click += OnTagsAdapterClick;
            TagsList.SetAdapter(_postSearchTagsAdapter);

            TagLabel.Click            += TagLabelOnClick;
            TagEdit.TextChanged       += OnTagOnTextChanged;
            TagEdit.KeyboardDownEvent += HideTagsList;
            TagEdit.OkKeyEvent        += HideTagsList;
            ClearEdit.Click           += (sender, args) => TagEdit.Text = string.Empty;

            BackButton.Click += OnBack;
            RootLayout.Click += OnRootLayoutClick;

            Timer = new Timer(OnTimer);
            Model = new PreparePostModel(AppSettings.User.UserInfo, AppSettings.AppInfo.GetModel());
        }
Exemplo n.º 4
0
        private static void Initialize(FrameLayout rootView)
        {
            var layoutParent = new LinearLayout(_activity.ApplicationContext);

            _layoutCenter = new LinearLayout(_activity.ApplicationContext);
            _layoutImage  = new LinearLayout(_activity.ApplicationContext);

            var layoutParentParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            layoutParent.LayoutParameters = layoutParentParameters;
            layoutParent.SetBackgroundDrawable(_activity.Resources.GetDrawable(Resource.Drawable.loading_overlay));

            var layoutCenterParameters = new LinearLayout.LayoutParams(-2, 0);

            layoutCenterParameters.Weight = 1.0f;
            layoutCenterParameters.SetMargins(0, 0, 0, 0);
            layoutCenterParameters.Gravity = GravityFlags.CenterVertical;

            var layoutImageParameters = new LinearLayout.LayoutParams(-1, -1);

            layoutCenterParameters.Weight = 1.0f;
            layoutCenterParameters.SetMargins(0, 0, 0, 0);

            _layoutCenter.LayoutParameters = layoutCenterParameters;
            _layoutCenter.SetBackgroundColor(Android.Graphics.Color.White);

            _layoutImage.LayoutParameters = layoutImageParameters;

            _layoutCenter.AddView(_layoutImage);
            layoutParent.AddView(_layoutCenter);

            rootView.AddView(layoutParent, layoutParentParameters);
            layoutParent.BringToFront();

            _layoutCenter.ClearAnimation();
            _layoutImage.SetBackgroundDrawable(null);

            if (_car == null)
            {
                _colorToUse = _activity.Resources.GetColor(Resource.Color.company_color);
                _car        = DrawHelper.ApplyThemeColorToImage(Resource.Drawable.taxi_progress, true, new SizeF(52, 20), Android.Graphics.Color.Argb(255, 0, 122, 255), new System.Drawing.Point(25, 10));
            }

            var displaySize  = _activity.Resources.DisplayMetrics;
            var windowHeight = (int)(_car.Width * 1.5f);

            _windowSize = new Size(displaySize.WidthPixels, windowHeight);

            var _radius = _car.Width * 1.3f;

            _zoneCircle = new RectF((_windowSize.Width * 0.5f) - _radius / 2f, (_windowSize.Height * 0.5f) - _radius / 2f, (_windowSize.Width * 0.5f) + _radius / 2f, (_windowSize.Height * 0.5f) + _radius / 2f);

            StartAnimationLoop(layoutParent);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            mListView  = FindViewById <ListView>(Resource.Id.listView);
            mSearch    = FindViewById <EditText>(Resource.Id.etSearch);
            mContainer = FindViewById <LinearLayout>(Resource.Id.llContainer);

            txtHeaderFirstName        = FindViewById <TextView>(Resource.Id.txtHeaderFirstName);
            txtHeaderFirstName.Click += TxtHeaderFirstName_Click;

            txtHeaderLastName        = FindViewById <TextView>(Resource.Id.txtHeaderLastName);
            txtHeaderLastName.Click += TxtHeaderLastName_Click;

            txtHeaderAge        = FindViewById <TextView>(Resource.Id.txtHeaderAge);
            txtHeaderAge.Click += TxtHeaderAge_Click;

            txtHeaderGender        = FindViewById <TextView>(Resource.Id.txtHeaderGender);
            txtHeaderGender.Click += TxtHeaderGender_Click;

            mSearch.Alpha = 0;
            mContainer.BringToFront();
            mSearch.TextChanged += MSearch_TextChanged;

            mFriends = new List <Friend>
            {
                new Friend {
                    FirstName = "Bob", LastName = "Smith", Age = "33", Gender = "Male"
                },
                new Friend {
                    FirstName = "Tom", LastName = "Smith", Age = "45", Gender = "Male"
                },
                new Friend {
                    FirstName = "Julie", LastName = "Smith", Age = "2020", Gender = "Unknown"
                },
                new Friend {
                    FirstName = "Molly", LastName = "Smith", Age = "21", Gender = "Female"
                },
                new Friend {
                    FirstName = "Joe", LastName = "Lopez", Age = "22", Gender = "Male"
                },
                new Friend {
                    FirstName = "Ruth", LastName = "White", Age = "81", Gender = "Female"
                },
                new Friend {
                    FirstName = "Sally", LastName = "Johnson", Age = "54", Gender = "Female"
                }
            };

            adapter           = new FriendsAdapter(this, Resource.Layout.row_friend, mFriends);
            mListView.Adapter = adapter;
        }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _repository   = new AccountRepository("accounts");
            _cryptService = new CryptService();
            _fileService  = new FileService();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity2);
            mListView  = FindViewById <ListView>(Resource.Id.listView);
            mSearch    = FindViewById <EditText>(Resource.Id.etSearch);
            mContainer = FindViewById <LinearLayout>(Resource.Id.llContainer);

            nameHeader       = FindViewById <TextView>(Resource.Id.txtNameHeader);
            passwordHeader   = FindViewById <TextView>(Resource.Id.txtPasswordHeader);
            createDateHeader = FindViewById <TextView>(Resource.Id.txtCreateDateHeader);

            nameHeader.Click       += NameHeaderOnClick;
            passwordHeader.Click   += PasswordHeaderOnClick;
            createDateHeader.Click += CreateDateHeaderOnClick;

            mSearch.Alpha = 0;
            mContainer.BringToFront();
            mSearch.TextChanged += mSearch_TextChanged;

            mAccounts = new List <Account>();
            //mAccounts.Add(new Account { Name = "Mail", Password = "******", CreateDate = DateTime.Now.AddDays(12) });
            //mAccounts.Add(new Account { Name = "Yandex", Password = "******", CreateDate = DateTime.Now });
            //mAccounts.Add(new Account { Name = "GitHub", Password = "******", CreateDate = DateTime.Now.AddDays(4) });
            //mAccounts.Add(new Account { Name = "Vk.com", Password = "******", CreateDate = DateTime.Now.AddDays(-9) });
            //mAccounts.Add(new Account { Name = "Compane", Password = "******", CreateDate = DateTime.Now.AddDays(-6) });
            //mAccounts.Add(new Account { Name = "NGTU", Password = "******", CreateDate = DateTime.Now.AddDays(7) });
            //mAccounts.Add(new Account { Name = "Пропуск", Password = "******", CreateDate = DateTime.Now });
            //mAccounts.Add(new Account { Name = "Сигнализация", Password = "******", CreateDate = DateTime.Now.AddDays(1) });
            //mAccounts.Add(new Account { Name = "Апаче", Password = "******", CreateDate = DateTime.Now.AddDays(3) });
            //mAccounts.Add(new Account { Name = "Тест", Password = "******", CreateDate = DateTime.Now.AddDays(-12) });

            mAccounts = _repository.GetItems().ToList();
            foreach (var mAccount in mAccounts)
            {
                mAccount.Password = _cryptService.DecryptText(mAccount.Password, "test");
            }


            mAdapter          = new AccountsAdapter(this, Resource.Layout.row_account, mAccounts.OrderBy(a => a.Name).ToList());
            mListView.Adapter = mAdapter;

            mListView.ItemClick += MListViewOnItemClick;


            RegisterForContextMenu(mListView);
        }
Exemplo n.º 7
0
        private void oncreate()
        {
            int position = Intent.GetIntExtra("mtDataPos", 177);

            mountainsRepository = new MountainsService();
            if (position == 177)
            {
                ViewHolder();
                mSearch.TextChanged            += mSearch_TextChanged;
                mListView.FastScrollEnabled     = true;
                mListView.ScrollingCacheEnabled = false;
                mMountains     = mountainsRepository.GetAllMountains();
                mMountainsTemp = mMountains.ToList();
                mSearch.Alpha  = 0;
                mContainer.BringToFront();
                mAdapter          = new MountainsAdapter(this, Resource.Layout.ml_model, mMountains);
                mListView.Adapter = mAdapter;
                ItemClickMethod();
            }
            else
            {
                ViewHolder();
                mSearch.TextChanged            += mSearch_TextChanged;
                mListView.ScrollingCacheEnabled = false;
                mListView.FastScrollEnabled     = true;
                mMountains           = mountainsRepository.GetAllMountains();
                mMountainsTemp       = mMountains.ToList();
                mListView.ItemClick += mListView_ItemClick;
                mSearch.Alpha        = 0;
                mContainer.BringToFront();
                mAdapter          = new MountainsAdapter(this, Resource.Layout.ml_model, mMountains);
                mListView.Adapter = mAdapter;
                ItemClickMethod();
                OpenDetailActivitys(position);
            }
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            mListView  = FindViewById <ListView>(Resource.Id.friendsView);
            mSearch    = FindViewById <EditText>(Resource.Id.mSearch);
            mContainer = FindViewById <LinearLayout>(Resource.Id.Container);

            mHeaderFirstName = FindViewById <TextView>(Resource.Id.txtHeaderFirstName);
            mHeaderLastName  = FindViewById <TextView>(Resource.Id.txtHeaderLastName);
            mHeaderAge       = FindViewById <TextView>(Resource.Id.txtHeaderAge);
            mHeaderGender    = FindViewById <TextView>(Resource.Id.txtHeaderGender);

            mHeaderFirstName.Click += mHeaderFirstName_Click;
            mHeaderLastName.Click  += mHeaderLastName_Click;
            mHeaderAge.Click       += mHeaderAge_Click;
            mHeaderGender.Click    += mHeaderGender_Click;

            mSearch.Alpha        = 0;
            mSearch.TextChanged += mSearch_TextChanged;
            mContainer.BringToFront();

            mItems = new List <Person>();
            mItems.Add(new Person()
            {
                FirstName = "Marian", LastName = "Kowal", Age = "20", Gender = "M"
            });
            mItems.Add(new Person()
            {
                FirstName = "Janusz", LastName = "Liśc", Age = "29", Gender = "M"
            });
            mItems.Add(new Person()
            {
                FirstName = "Grażyna", LastName = "Bąk", Age = "32", Gender = "K"
            });

            adapter = new ListViewAdapter(this, mItems, Resource.Layout.listview_row);

            mListView.Adapter = adapter;


            mListView.ItemClick += mListView_ItemClick;
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.pager_item);

            mListView = FindViewById<ListView>(Resource.Id.listView);
            mListView = FindViewById<ListView>(Resource.Id.listView);
            mSearch = FindViewById<EditText>(Resource.Id.etSearch);
            mConteiner = FindViewById<LinearLayout>(Resource.Id.llContainer);

            mTxtNProduktu = FindViewById<TextView>(Resource.Id.txtNProduktu);
            mTxtOProduktu = FindViewById<TextView>(Resource.Id.txtOProduktu);


            mTxtNProduktu.Click += mTxtNProduktu_Click;
            mTxtOProduktu.Click += mTxtOProduktu_Click;




            mSearch.Alpha = 0;
            mConteiner.BringToFront();


            mSearch.TextChanged += mSearch_TextChanged; ;



            mProdukt = new List<Produkt>();
            mProdukt.Add(new Produkt { NProduktu = "Produkt", OProduktu = "5", Opis = "zajebisty produkt", Obraz = "blank" });
            mProdukt.Add(new Produkt { NProduktu = "Produkt1", OProduktu = "6", Opis = "jest moc", Obraz = "blank" });
            mProdukt.Add(new Produkt { NProduktu = "Produkt2", OProduktu = "5", Opis = "super", Obraz = "blank" });
            mProdukt.Add(new Produkt { NProduktu = "Produkt3", OProduktu = "4", Opis = "niezle", Obraz = "blank" });
            mProdukt.Add(new Produkt { NProduktu = "Produkt4", OProduktu = "3", Opis = "kapa", Obraz = "blank" });
            mProdukt.Add(new Produkt { NProduktu = "Produkt5", OProduktu = "2", Opis = "moze byc", Obraz = "blank" });
            mProdukt.Add(new Produkt { NProduktu = "Produkt6", OProduktu = "1", Opis = "okej", Obraz = "blank" });

            mAdapter = new ProduktAdapter(this, Resource.Layout.row_produkt, mProdukt);
            mListView.Adapter = mAdapter;

        }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle bundle)
        {
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("");

            float staticDensity = 2.55f;
            float deviceDenstiy = Resources.DisplayMetrics.Density;

            factor = deviceDenstiy / staticDensity;
            base.OnCreate(bundle);
            ParseXML();
            if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.Lollipop)
            {
                aSamples.Remove(aSamples.First(x => x.Title == "PDFViewer"));
            }
            SetContentView(Resource.Layout.HomeScreen);
            ActionBar.Hide();
            listView = FindViewById <GridView>(Resource.Id.List);
            context  = mainActivity = this;

            listView.Adapter    = new HomeScreenAdapter(this, aSamples);
            listView.ItemClick += OnListItemClick;

            var manager = this.GetSystemService(Context.TelephonyService)
                          as TelephonyManager;

            isTablet = GetDeviceType(this);
            if (isTablet)
            {
                listView.SetNumColumns(2);
                isTablet = true;
            }
            else
            {
                listView.SetNumColumns(1);
                isTablet = false;
            }

            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            drawer        = FindViewById <LinearLayout>(Resource.Id.left_drawer);
            imageView     = FindViewById <ImageView>(Resource.Id.navDrawIcon);
            productpage   = FindViewById <LinearLayout>(Resource.Id.productpagelayout);
            documentation = FindViewById <LinearLayout>(Resource.Id.documentlayout);
            whatsNew      = FindViewById <LinearLayout>(Resource.Id.whatsnewlayout);
            TextView versionText = FindViewById <TextView>(Resource.Id.versionText);

            versionText.Text = versionText.Text + Resources.GetString(Resource.String.version);
            drawer.BringToFront();
            int width = Resources.DisplayMetrics.WidthPixels * 3 / 4;

            if (isTablet)
            {
                width = Int32.Parse((Resources.DisplayMetrics.WidthPixels * 0.5f).ToString());
            }

            drawer.LayoutParameters.Width = (int)width;

            imageView.Click += delegate
            {
                mDrawerLayout.OpenDrawer(GravityCompat.Start);
            };

            productpage.Click += delegate
            {
                goToUrl("https://www.syncfusion.com/products/xamarin");
            };

            documentation.Click += delegate
            {
                goToUrl("https://help.syncfusion.com/xamarin-android/introduction/overview");
            };

            whatsNew.Click += delegate
            {
                goToUrl("https://www.syncfusion.com/products/whatsnew/xamarin-android");
            };
        }
Exemplo n.º 11
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            if (IsInitialized)
            {
                return;
            }

            base.OnViewCreated(view, savedInstanceState);

            _tag.Hint         = AppSettings.LocalizationManager.GetText(LocalizationKeys.AddHashtag);
            _title.Hint       = AppSettings.LocalizationManager.GetText(LocalizationKeys.EnterPostTitle);
            _description.Hint = AppSettings.LocalizationManager.GetText(LocalizationKeys.EnterPostDescription);
            _postButton.Text  = AppSettings.LocalizationManager.GetText(LocalizationKeys.PublishButtonText);
            _pageTitle.Text   = AppSettings.LocalizationManager.GetText(LocalizationKeys.PostSettings);

            _pageTitle.Typeface   = Style.Semibold;
            _title.Typeface       = Style.Regular;
            _description.Typeface = Style.Regular;
            _postButton.Typeface  = Style.Semibold;

            _postButton.Click  += OnPost;
            _postButton.Enabled = true;

            _topPanel.BringToFront();

            _localTagsList.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
            LocalTagsAdapter.Click += LocalTagsAdapterClick;
            _localTagsList.SetAdapter(LocalTagsAdapter);
            _localTagsList.AddItemDecoration(new ListItemDecoration((int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 15, Resources.DisplayMetrics)));

            _tagsList.SetLayoutManager(new LinearLayoutManager(Activity));
            Presenter.SourceChanged += PresenterSourceChanged;
            TagsAdapter.Click       += OnTagsAdapterClick;
            _tagsList.SetAdapter(TagsAdapter);

            _tag.TextChanged       += OnTagOnTextChanged;
            _tag.KeyboardDownEvent += HideTagsList;
            _tag.OkKeyEvent        += HideTagsList;
            _tag.FocusChange       += OnTagOnFocusChange;

            _topMarginTagsLayout.Click += OnTagsLayoutClick;
            _backButton.Click          += OnBack;
            _rootLayout.Click          += OnRootLayoutClick;

            _timer = new Timer(OnTimer);
            _model = new PreparePostModel(BasePresenter.User.UserInfo);
            SetPostingTimer();

            if (_editPost != null)
            {
                SetEditPost();
            }

            if (_media?.Count > 1 || _editPost?.Media.Length > 1)
            {
                _photos.Visibility           = ViewStates.Visible;
                _previewContainer.Visibility = ViewStates.Gone;
                _photos.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
                _photos.SetAdapter(GalleryAdapter);
                _photos.AddItemDecoration(new ListItemDecoration((int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 10, Resources.DisplayMetrics)));
            }
            else
            {
                _photos.Visibility           = ViewStates.Gone;
                _previewContainer.Visibility = ViewStates.Visible;
                var margin       = (int)BitmapUtils.DpToPixel(15, Resources);
                var layoutParams = new RelativeLayout.LayoutParams(Resources.DisplayMetrics.WidthPixels - margin * 2, Resources.DisplayMetrics.WidthPixels - margin * 2);
                layoutParams.SetMargins(margin, 0, margin, margin);
                _previewContainer.LayoutParameters = layoutParams;
                _preview.CornerRadius = BitmapUtils.DpToPixel(5, Resources);
                if (_media != null)
                {
                    _preview.SetImageUri(Uri.Parse(_media[0].Path), _media[0].Parameters);
                }
                else if (_editPost != null)
                {
                    _ratioBtn.Visibility = _rotateBtn.Visibility = ViewStates.Gone;
                    var url = _editPost.Media[0].Thumbnails.Mini;
                    Picasso.With(Activity).Load(url)
                    .Resize(_previewContainer.LayoutParameters.Width, _previewContainer.LayoutParameters.Height)
                    .Into(_preview);
                }
                _preview.Touch   += PreviewOnTouch;
                _ratioBtn.Click  += RatioBtnOnClick;
                _rotateBtn.Click += RotateBtnOnClick;
            }

            SearchTextChanged();
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.layoutvideo);
            instancia    = this;
            linkactual   = Intent.GetStringExtra("link");
            indiceactual = int.Parse(Intent.GetStringExtra("posactual"));
            clientesillo = new TcpClient("localhost", 1024);
            video        = FindViewById <SurfaceView>(Resource.Id.videoView1);
            playpause    = FindViewById <ImageView>(Resource.Id.imageView4);

            siguiente = FindViewById <ImageView>(Resource.Id.imageView3);
            var ll4 = FindViewById <LinearLayout>(Resource.Id.linearLayout9);
            var listviewlistareproduccion = FindViewById <ListView>(Resource.Id.listView5);

            listabuscador = FindViewById <ListView>(Resource.Id.listView2);
            var botonlistareproduccion = FindViewById <ImageView>(Resource.Id.imageView20);

            anterior = FindViewById <ImageView>(Resource.Id.imageView5);
            playpause.SetBackgroundResource(Resource.Drawable.pausebutton2);
            var botonmenu           = FindViewById <ImageView>(Resource.Id.imageView7);
            var botonfastsearcher   = FindViewById <ImageView>(Resource.Id.imageView13);
            var terminobuscarrapido = FindViewById <EditText>(Resource.Id.edittext2);
            var botonenfastsearcher = FindViewById <ImageView>(Resource.Id.imageView19);

            listaa        = FindViewById <ListView>(Resource.Id.listView1);
            botonminimize = FindViewById <ImageView>(Resource.Id.botonminimize);

            var activarmenu = FindViewById <ImageView>(Resource.Id.imageView12);

            layoutmenues = FindViewById <LinearLayout>(Resource.Id.linearLayout8);
            var botonyoutube = FindViewById <ImageView>(Resource.Id.imageView11);

            ll1 = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            var ll3 = FindViewById <LinearLayout>(Resource.Id.laprra);

            textbox   = FindViewById <EditText>(Resource.Id.editText1);
            adelantar = FindViewById <ImageView>(Resource.Id.imageView2);
            var layoutbuscador = FindViewById <LinearLayout>(Resource.Id.linearLayout6);

            atrazar           = FindViewById <ImageView>(Resource.Id.imageView6);
            portada           = FindViewById <ImageView>(Resource.Id.imageView8);
            titulo            = FindViewById <TextView>(Resource.Id.textView1);
            barraprogreso     = FindViewById <SeekBar>(Resource.Id.progressBar1);
            listaa.Visibility = ViewStates.Invisible;
            listviewlistareproduccion.Visibility = ViewStates.Invisible;
            holder = video.Holder;
            holder.AddCallback(this);

            string[] items = Directory.GetFiles(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/");

            titulo.Selected = true;
            playlistas.Clear();

            for (int i = 0; i < items.Length; i++)

            {
                playlistas.Add(System.IO.Path.GetFileNameWithoutExtension(items[i]));
            }
            var adaptadol = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, playlistas);

            var parcelable = listviewlistareproduccion.OnSaveInstanceState();

            listviewlistareproduccion.Adapter = adaptadol;
            listviewlistareproduccion.OnRestoreInstanceState(parcelable);

            ll4.Visibility            = ViewStates.Invisible;
            layoutbuscador.Visibility = ViewStates.Invisible;
            layoutmenues.Visibility   = ViewStates.Invisible;

            ll1.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));
            ll3.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));
            ll4.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));
            layoutmenues.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));
            listviewlistareproduccion.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));
            layoutbuscador.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));
            listaa.SetBackgroundColor(Android.Graphics.Color.ParseColor("#323538"));

            mainmenu_Offline.gettearinstancia().envideo = true;
            botonminimize.Visibility = ViewStates.Gone;
            if (linkactual.Trim().Length > 1)
            {
                new Thread(() =>
                {
                    buscaryreproducir();
                }).Start();
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                dialogoprogreso = new ProgressDialog(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                dialogoprogreso.SetCanceledOnTouchOutside(false);
                dialogoprogreso.SetCancelable(false);
                dialogoprogreso.SetTitle("Cargando...");
                dialogoprogreso.SetMessage("Por favor espere");
                dialogoprogreso.Show();
            }
            else
            {
                primeravez = false;
            }

            ll1.BringToFront();

            ll1.BringToFront();

            ll1.BringToFront();


            Thread proces = new Thread(new ThreadStart(cargardesdecache));
            proces.Start();

            layoutbuscador.Click += delegate
            {
            };

            layoutmenues.Click += delegate
            {
            };
            ll4.Click += delegate
            {
            };
            ll1.Click += delegate
            {
            };
            ll3.Click += delegate
            {
            };

            textbox.KeyPress += (aaxx, e) =>
            {
                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    // Code executed when the enter key is pressed down

                    if (buscando == false)
                    {
                        clasesettings.recogerbasura();
                        Thread process = new Thread(new ThreadStart(buscar));
                        process.Start();
                    }
                }
                else
                {
                    e.Handled = false;
                }
            };

            listviewlistareproduccion.ItemClick += (delegado, aasdsa) =>
            {
                if (playlistas.Count > 0)
                {
                    if (File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + playlistas[aasdsa.Position]).Split('$')[0].Split(';').ToList().Count >= 1 && File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + playlistas[aasdsa.Position]).Split('$')[0].Split(';')[0].Trim() != "")
                    {
                        Intent internado = new Intent(this, typeof(Reproducirlistadialog));
                        internado.PutExtra("ip", "localhost");
                        internado.PutExtra("nombrelista", playlistas[aasdsa.Position]);
                        internado.PutExtra("index", aasdsa.Position.ToString());
                        StartActivity(internado);
                    }
                    else
                    {
                        Toast.MakeText(this, "La lista esta vacia", ToastLength.Long).Show();
                    }
                }
            };
            botonlistareproduccion.Click += delegate
            {
                animar(botonlistareproduccion);
                if (listviewlistareproduccion.Visibility == ViewStates.Visible)
                {
                    listviewlistareproduccion.Visibility = ViewStates.Invisible;
                }
                else
                {
                    listviewlistareproduccion.BringToFront();
                    listviewlistareproduccion.Visibility = ViewStates.Visible;
                    ll4.Visibility            = ViewStates.Invisible;
                    listaa.Visibility         = ViewStates.Invisible;
                    layoutbuscador.Visibility = ViewStates.Invisible;
                    animar2(listviewlistareproduccion);
                }
            };

            botonenfastsearcher.Click += delegate
            {
                animar(botonenfastsearcher);

                termino = terminobuscarrapido.Text;
                new Thread(() => { buscaryabrir(); }).Start();
                Toast.MakeText(this, "Buscando resultados...", ToastLength.Long).Show();
            };


            botonfastsearcher.Click += delegate
            {
                animar(botonfastsearcher);
                if (ll4.Visibility == ViewStates.Visible)
                {
                    ll4.Visibility = ViewStates.Invisible;
                }
                else
                {
                    ll4.Visibility                       = ViewStates.Visible;
                    listaa.Visibility                    = ViewStates.Invisible;
                    layoutbuscador.Visibility            = ViewStates.Invisible;
                    listviewlistareproduccion.Visibility = ViewStates.Invisible;
                    animar2(ll4);
                }
            };


            listabuscador.ItemClick += (easter, sender) =>
            {
                if (linkeses.Count > 0)
                {
                    if (sender.Position >= 0)
                    {
                        Intent intentar = new Intent(this, typeof(customdialogact));

                        intentar.PutExtra("ipadress", "localhost");

                        intentar.PutExtra("imagen", @"https://i.ytimg.com/vi/" + linkeses[sender.Position].Split('=')[1] + "/hqdefault.jpg");
                        intentar.PutExtra("url", linkeses[sender.Position]);
                        intentar.PutExtra("titulo", nombreses[sender.Position]);
                        intentar.PutExtra("color", "DarkGray");
                        StartActivity(intentar);
                    }
                }
            };

            Clouding_service.gettearinstancia().musicaplayer.Completion += delegate
            {
                if (this != null)
                {
                    playpause.SetBackgroundResource(Resource.Drawable.playbutton2);
                }

                mainmenu_Offline.gettearinstancia().siguiente();
                ///  clientesillo.Client.Send(Encoding.Default.GetBytes("next()"));
            };

            Thread proc = new Thread(new ThreadStart(ponerporciento));
            proc.Start();
            Thread proc2 = new Thread(new ThreadStart(receptor));
            proc2.Start();
            activarmenu.Click += delegate
            {
                animar(activarmenu);
                if (layoutmenues.Visibility == ViewStates.Visible)
                {
                    menuabierto = false;
                    layoutbuscador.Visibility = ViewStates.Invisible;
                    listaa.Visibility         = ViewStates.Invisible;
                    animar7(layoutmenues);
                    ll4.Visibility = ViewStates.Invisible;
                    listviewlistareproduccion.Visibility = ViewStates.Invisible;
                }
                else
                {
                    menuabierto             = true;
                    layoutmenues.Visibility = ViewStates.Visible;
                    animar3(layoutmenues);
                }
            };

            botonyoutube.Click += delegate
            {
                animar(botonyoutube);
                if (layoutbuscador.Visibility == ViewStates.Visible)
                {
                    layoutbuscador.Visibility = ViewStates.Invisible;
                }
                else
                {
                    listviewlistareproduccion.Visibility = ViewStates.Invisible;
                    ll4.Visibility            = ViewStates.Invisible;
                    listaa.Visibility         = ViewStates.Invisible;
                    layoutbuscador.Visibility = ViewStates.Visible;
                    animar2(layoutbuscador);
                }
            };
            listaa.ItemClick += (sender, easter) =>
            {
                if (lapara.Count > 0)
                {
                    Intent intentoo = new Intent(this, typeof(deletedialogact));

                    intentoo.PutExtra("index", easter.Position.ToString());
                    intentoo.PutExtra("color", "DarkGray");
                    intentoo.PutExtra("titulo", lapara[easter.Position]);
                    intentoo.PutExtra("ipadress", "localhost");
                    intentoo.PutExtra("url", laparalink[easter.Position]);
                    intentoo.PutExtra("imagen", @"https://i.ytimg.com/vi/" + laparalink[easter.Position].Split('=')[1] + "/hqdefault.jpg");
                    StartActivity(intentoo);
                }
            };
            botonminimize.Click += delegate
            {
                if (menuabierto)
                {
                    layoutmenues.Visibility = ViewStates.Visible;
                }
                else
                {
                    layoutmenues.Visibility = ViewStates.Invisible;
                }
                botonminimize.Visibility = ViewStates.Gone;
                ll1.Visibility           = ViewStates.Visible;
                ll3.Visibility           = ViewStates.Visible;
                videofullscreen          = false;
            };
            siguiente.Click += delegate
            {
                animar(siguiente);
                clientesillo.Client.Send(Encoding.Default.GetBytes("next()"));
            };
            anterior.Click += delegate
            {
                animar(anterior);
                clientesillo.Client.Send(Encoding.Default.GetBytes("back()"));
            };



            atrazar.Click += delegate
            {
                animar(atrazar);
                Clouding_service.gettearinstancia().musicaplayer.SeekTo(Convert.ToInt32(Clouding_service.gettearinstancia().musicaplayer.CurrentPosition - Clouding_service.gettearinstancia().musicaplayer.Duration * 0.10));
            };
            adelantar.Click += delegate
            {
                animar(adelantar);
                Clouding_service.gettearinstancia().musicaplayer.SeekTo(Convert.ToInt32(Clouding_service.gettearinstancia().musicaplayer.CurrentPosition + Clouding_service.gettearinstancia().musicaplayer.Duration * 0.10));
            };


            botonmenu.Click += delegate
            {
                animar(botonmenu);
                listaa.BringToFront();
                if (listaa.Visibility == ViewStates.Visible)
                {
                    listaa.Visibility = ViewStates.Invisible;
                }
                else
                {
                    listviewlistareproduccion.Visibility = ViewStates.Invisible;
                    ll4.Visibility            = ViewStates.Invisible;
                    layoutbuscador.Visibility = ViewStates.Invisible;
                    listaa.Visibility         = ViewStates.Visible;
                    animar2(listaa);
                }
                listaa.BringToFront();
            };
            barraprogreso.ProgressChanged += (aa, aaaa) =>
            {
                if (aaaa.FromUser)
                {
                    Clouding_service.gettearinstancia().musicaplayer.SeekTo(aaaa.Progress);
                }
            };

            video.Touch += (aa, aaaa) =>
            {
                if (aaaa.Event.Action == MotionEventActions.Up)
                {
                    if (!videofullscreen)
                    {
                        ll1.Visibility = ViewStates.Invisible;
                        listviewlistareproduccion.Visibility = ViewStates.Invisible;
                        ll3.Visibility            = ViewStates.Invisible;
                        layoutbuscador.Visibility = ViewStates.Invisible;
                        listaa.Visibility         = ViewStates.Invisible;
                        layoutmenues.Visibility   = ViewStates.Invisible;
                        ll4.Visibility            = ViewStates.Invisible;
                        botonminimize.Visibility  = ViewStates.Visible;
                        videofullscreen           = true;
                    }
                    else
                    {
                        if (menuabierto)
                        {
                            layoutmenues.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            layoutmenues.Visibility = ViewStates.Invisible;
                        }
                        botonminimize.Visibility = ViewStates.Gone;
                        ll1.Visibility           = ViewStates.Visible;
                        ll3.Visibility           = ViewStates.Visible;
                        videofullscreen          = false;
                    }
                }
            };

            // Create your application here
            playpause.Click += delegate
            {
                animar(playpause);
                if (Clouding_service.gettearinstancia().musicaplayer.IsPlaying == true)
                {
                    playpause.SetBackgroundResource(Resource.Drawable.playbutton2);

                    Clouding_service.gettearinstancia().musicaplayer.Pause();
                }
                else

                {
                    playpause.SetBackgroundResource(Resource.Drawable.pausebutton2);
                    Clouding_service.gettearinstancia().musicaplayer.Start();
                }
            };
        }
Exemplo n.º 13
0
        public void buscaryreproducir(bool invoked = false)
        {
            /*
             *       var   videoinfoss = DownloadUrlResolver.GetDownloadUrls(linkactual, false);
             *
             *          VideoInfo video2 = videoinfoss.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);
             *          VideoInfo video3 = videoinfoss.First(info => info.VideoType == VideoType.Mp4 && info.Resolution ==0);
             */

            if (!mainmenu_Offline.gettearinstancia().contienevideo || invoked)
            {
                //////////////////////////////////////////////////////cuando no es un video
                var    videito    = Client.For(YouTube.Default);
                var    videoo     = videito.GetAllVideosAsync(linkactual);
                var    resultados = videoo.Result;
                var    title      = resultados.First().Title.Replace("- YouTube", "");
                string video2     = resultados.First(info => info.Resolution == 360 && info.AudioFormat == AudioFormat.Aac).GetUriAsync().Result;

                string video3 = "";
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
                {
                    video3 = resultados.First(info => info.Resolution == -1 && info.AudioFormat == AudioFormat.Aac).GetUriAsync().Result;
                }
                else
                {
                    video3 = resultados.First(info => info.Resolution == 240 && info.AudioFormat == AudioFormat.Aac).GetUriAsync().Result;
                }

                //clasesettings.guardarsetting("cquerry", "data()>" + title.Replace('>', ' ') + ">" + linkactual.Replace('>', ' '));
                string imagensilla = "https://i.ytimg.com/vi/" + linkactual.Split('=')[1] + "/mqdefault.jpg";
                var    imgurl      = imagensilla;
                downloadurlmp3 = video3;
                RunOnUiThread(() => portada.SetImageBitmap(GetImageBitmapFromUrl(imagensilla)));

                RunOnUiThread(() => {
                    titulo.Text = title;
                    /// video.SetFitsSystemWindows(true);

                    //Clouding_service.gettearinstancia().musicaplayer.SetVideoURI(Android.Net.Uri.Parse(video2));


                    Clouding_service.gettearinstancia().musicaplayer.Reset();


                    Clouding_service.gettearinstancia().musicaplayer = Android.Media.MediaPlayer.Create(this, Android.Net.Uri.Parse(video2));

#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                    Clouding_service.gettearinstancia().musicaplayer.SetAudioStreamType(Android.Media.Stream.Music);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                    Clouding_service.gettearinstancia().musicaplayer.SetWakeMode(this, WakeLockFlags.Partial);
                    Clouding_service.gettearinstancia().musicaplayer.SetDisplay(null);
                    Clouding_service.gettearinstancia().musicaplayer.SetDisplay(holder);
                    Clouding_service.gettearinstancia().musicaplayer.Prepared += delegate
                    {
                        if (clasesettings.gettearvalor("progresovideoactual") != "")
                        {
                            Clouding_service.gettearinstancia().musicaplayer.SeekTo(int.Parse(clasesettings.gettearvalor("progresovideoactual")));
                            clasesettings.guardarsetting("progresovideoactual", "");
                        }
                    };

                    Clouding_service.gettearinstancia().musicaplayer.Completion += delegate
                    {
                        mainmenu_Offline.gettearinstancia().RunOnUiThread(() =>
                        {
                            mainmenu_Offline.gettearinstancia().adelante.PerformClick();
                        });
                    };
                    Clouding_service.gettearinstancia().musicaplayer.Start();

                    // video.RequestFocus();

                    playpause.SetBackgroundResource(Resource.Drawable.pausebutton2);
                    ll1.BringToFront();
                    encontro = true;
                    if (primeravez)
                    {
                        dialogoprogreso.Dismiss();
                        primeravez = false;
                    }
                });
            }
            else
            {
                ////////////////////////////////////////////////////////////////cuando ya es un video de por si :V
                Clouding_service.gettearinstancia().musicaplayer.Prepare();
                RunOnUiThread(() => {
                    mainmenu_Offline.gettearinstancia().RunOnUiThread(() => {
                        titulo.Text = mainmenu_Offline.gettearinstancia().label.Text;
                    });
                    portada.SetImageBitmap(GetImageBitmapFromUrl("https://i.ytimg.com/vi/" + mainmenu_Offline.gettearinstancia().linkactual.Split('=')[1] + "/mqdefault.jpg"));

                    playpause.SetBackgroundResource(Resource.Drawable.pausebutton2);
                    /// video.SetFitsSystemWindows(true);

                    //Clouding_service.gettearinstancia().musicaplayer.SetVideoURI(Android.Net.Uri.Parse(video2));



                    Clouding_service.gettearinstancia().musicaplayer.SetDisplay(holder);
                    Clouding_service.gettearinstancia().musicaplayer.Start();

                    /*     Clouding_service.gettearinstancia().musicaplayer.Completion += delegate
                     *   {
                     *       mainmenu_Offline.gettearinstancia().RunOnUiThread(() =>
                     *       {
                     *           mainmenu_Offline.gettearinstancia().adelante.PerformClick();
                     *       });
                     *   };*/
                    //  Clouding_service.gettearinstancia().musicaplayer.Start();

                    // video.RequestFocus();

                    playpause.SetBackgroundResource(Resource.Drawable.pausebutton2);
                    ll1.BringToFront();
                    encontro = true;
                    if (primeravez)
                    {
                        dialogoprogreso.Dismiss();
                        primeravez = false;
                    }
                });
            }
        }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            if (IsInitialized)
            {
                return;
            }

            base.OnViewCreated(view, savedInstanceState);

            _pageTitle.Text          = AppSettings.LocalizationManager.GetText(LocalizationKeys.PlagiarismTitle);
            _guidelines.Text         = AppSettings.LocalizationManager.GetText(LocalizationKeys.GuidelinesForPlagiarism);
            _cancelPublishing.Text   = AppSettings.LocalizationManager.GetText(LocalizationKeys.CancelPublishing);
            _continuePublishing.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.ContinuePublishing);

            _pageTitle.Typeface             = Style.Semibold;
            _guidelines.Typeface            = Style.Semibold;
            _plagiarismTitle.Typeface       = Style.Regular;
            _plagiarismDescription.Typeface = Style.Regular;
            _cancelPublishing.Typeface      = Style.Semibold;
            _continuePublishing.Typeface    = Style.Semibold;

            guidelinesUri = Android.Net.Uri.Parse(Constants.Guide);

            _topPanel.BringToFront();

            _backButton.Click += (sender, e) => { ((BaseActivity)Activity).OnBackPressed(); };
            _rootLayout.Click += (sender, e) => { ((BaseActivity)Activity).HideKeyboard(); };

            _guidelines.Click += OpenGuidelines;

            _cancelPublishing.Click   += CancelPublishing;
            _continuePublishing.Click += ContinuePublishing;

            if (media.Count > 1)
            {
                _photos.Visibility           = ViewStates.Visible;
                _previewContainer.Visibility = ViewStates.Gone;
                _photos.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));
                _photos.SetAdapter(adapter);
                _photos.AddItemDecoration(new ListItemDecoration((int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 10, Resources.DisplayMetrics)));
            }
            else
            {
                _photos.Visibility           = ViewStates.Gone;
                _previewContainer.Visibility = ViewStates.Visible;
                _preview.ClipToOutline       = true;

                var margin = (int)BitmapUtils.DpToPixel(15, Resources);

                if (media[0].PreparedBitmap != null)
                {
                    var previewSize  = BitmapUtils.CalculateImagePreviewSize(media[0].Parameters, Style.ScreenWidth - margin * 2);
                    var layoutParams = new RelativeLayout.LayoutParams(previewSize.Width, previewSize.Height);
                    layoutParams.SetMargins(margin, 0, margin, margin);
                    _previewContainer.LayoutParameters = layoutParams;

                    _preview.SetImageBitmap(media[0].PreparedBitmap);
                }
            }

            var similarText    = AppSettings.LocalizationManager.GetText(LocalizationKeys.SimilarPhoto).ToLower();
            var photoText      = AppSettings.LocalizationManager.GetText(LocalizationKeys.Photo).ToLower();
            var plagiarismText = string.Empty;

            CustomClickableSpan clickableSpan;
            SpannableString     spannableTitle;

            if (model.PlagiarismUsername == AppSettings.User.Login)
            {
                plagiarismText = AppSettings.LocalizationManager.GetText(LocalizationKeys.SelfPlagiarism, similarText);

                clickableSpan        = new CustomClickableSpan();
                clickableSpan.Click += OpenSimilar;

                spannableTitle = SpannableText(plagiarismText, similarText, clickableSpan);
                _plagiarismTitle.SetText(spannableTitle, TextView.BufferType.Spannable);
                _plagiarismDescription.Visibility = ViewStates.Gone;
            }
            else
            {
                var author = $"@{model.PlagiarismUsername}";
                plagiarismText = AppSettings.LocalizationManager.GetText(LocalizationKeys.PhotoPlagiarism, similarText, author);

                spannableTitle = new SpannableString(plagiarismText);
                var similarIndex = plagiarismText.IndexOf(similarText, StringComparison.Ordinal);
                clickableSpan = new CustomClickableSpan();
                var authorIndex     = plagiarismText.IndexOf(author, StringComparison.Ordinal);
                var clickableAuthor = new CustomClickableSpan();

                clickableSpan.Click   += OpenSimilar;
                clickableAuthor.Click += OpenProfile;

                spannableTitle.SetSpan(new ForegroundColorSpan(Resources.GetColor(Resource.Color.rgb255_34_5)), similarIndex, similarIndex + similarText.Length, 0);
                spannableTitle.SetSpan(clickableSpan, similarIndex, similarIndex + similarText.Length, SpanTypes.ExclusiveExclusive);

                spannableTitle.SetSpan(new ForegroundColorSpan(Resources.GetColor(Resource.Color.rgb255_34_5)), authorIndex, authorIndex + author.Length, 0);
                spannableTitle.SetSpan(clickableAuthor, authorIndex, authorIndex + author.Length, SpanTypes.ExclusiveExclusive);
                _plagiarismTitle.SetText(spannableTitle, TextView.BufferType.Spannable);

                var descriptionText = AppSettings.LocalizationManager.GetText(LocalizationKeys.PlagiarismDescription, photoText);

                var clickablePhoto = new CustomClickableSpan();
                clickablePhoto.Click += OpenSimilar;

                var spannableDescription = SpannableText(descriptionText, photoText, clickablePhoto);
                _plagiarismDescription.Visibility = ViewStates.Visible;
                _plagiarismDescription.SetText(spannableDescription, TextView.BufferType.Spannable);
                _plagiarismDescription.MovementMethod = new LinkMovementMethod();
            }

            _plagiarismTitle.MovementMethod = new LinkMovementMethod();
        }
Exemplo n.º 15
0
        // charge les nouvelles vues losqu'on fait tourner le carousel
        void ViewPager.IOnPageChangeListener.OnPageScrolled(int position, float positionOffset, int positionOffsetPixels)
        {
            if (positionOffset >= 0f && positionOffset <= 1f)
            {
                positionOffset = positionOffset * positionOffset;
                cur            = getRootView(position);
                next           = getRootView(position + 1);
                prev           = getRootView(position - 1);
                nextnext       = getRootView(position + 2);
                prevprev       = getRootView(position - 2);
                nextnextnext   = getRootView(position + 3);
                prevprevprev   = getRootView(position - 3);

                if (cur != null)
                {
                    ViewHelper.SetAlpha(cur, maxAlpha - 0.5f * positionOffset);

                    float val = 1 - 0.3f * positionOffset;
                    if (val < 0.7f)
                    {
                        val = 0.7f;
                    }
                    ViewHelper.SetScaleX(cur, val);
                    ViewHelper.SetScaleY(cur, val);
                }
                if (next != null)
                {
                    ViewHelper.SetAlpha(next, minAlpha + 20.0f * positionOffset);


                    float y = 0.7f + 0.3f * positionOffset;
                    if (y > 1.0f)
                    {
                        y = 1.0f;
                    }
                    ViewHelper.SetScaleY(next, y);
                    ViewHelper.SetScaleX(next, y);
                }
                if (prev != null)
                {
                    ViewHelper.SetAlpha(prev, minAlpha + 20.0f * positionOffset);
                }
                if (prevprev != null)
                {
                    ViewHelper.SetScaleX(prevprev, 0.7f);
                    ViewHelper.SetScaleY(prevprev, 0.7f);
                }

                if (nextnext != null)
                {
                    //ViewHelper.SetScaleY(nextnext, 0.7f);
                    ViewHelper.SetAlpha(nextnext, minAlpha);
                    ViewHelper.SetRotationY(nextnext, -minDegree);

                    ViewHelper.SetScaleX(nextnext, 0.7f);
                    ViewHelper.SetScaleY(nextnext, 0.7f);
                    next.BringToFront();
                }
                if (prevprevprev != null)
                {
                    ViewHelper.SetScaleX(prevprevprev, 0.7f);
                    ViewHelper.SetScaleY(prevprevprev, 0.7f);
                }
                if (nextnextnext != null)
                {
                    ViewHelper.SetScaleX(nextnextnext, 0.7f);
                    ViewHelper.SetScaleY(nextnextnext, 0.7f);
                }
                if (cur != null)
                {
                    ViewHelper.SetRotationY(cur, 0);
                }

                if (next != null)
                {
                    ViewHelper.SetRotationY(next, -minDegree);
                }
                if (prev != null)
                {
                    ViewHelper.SetRotationY(prev, minDegree);
                }


                /*To animate it properly we must understand swipe direction
                 * this code adjusts the rotation according to direction.
                 */
                if (swipedLeft)
                {
                    if (next != null)
                    {
                        ViewHelper.SetRotationY(next, -minDegree + minDegree * positionOffset);
                    }
                    if (cur != null)
                    {
                        ViewHelper.SetRotationY(cur, 0 + minDegree * positionOffset);
                    }
                }
                else
                {
                    if (next != null)
                    {
                        ViewHelper.SetRotationY(next, -minDegree + minDegree * positionOffset);
                    }
                    if (cur != null)
                    {
                        ViewHelper.SetRotationY(cur, 0 + minDegree * positionOffset);
                    }
                }
            }
            if (positionOffset >= 1f)
            {
                ViewHelper.SetAlpha(cur, maxAlpha);
            }
        }