Exemplo n.º 1
0
 public virtual void ApplyActionsStyle()
 {
     NotificationActions?.RemoveAllViews();
     if (OpenNotification.HasActions())
     {
         var actions = OpenNotification.RetrieveActions();
         for (int i = 0; i <= actions.Count - 1; i++)
         {
             var        action       = actions[i];
             OpenAction openAction   = new OpenAction(action);
             Button     actionButton = new Button(Application.Context);
             float      weight       = 1f / actions.Count;
             actionButton.LayoutParameters = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, weight);
             SetActionTextColor(actionButton);
             SetActionTag(actionButton, openAction);
             actionButton.Click += ActionButton_Click;
             SetActionButtonGravity(actionButton);
             SetActionButtonTextMaxLines(actionButton);
             SetActionButtonTextTypeface(actionButton);
             SetActionButtonBackground(actionButton);
             SetActionText(actionButton, openAction.Title());
             SetActionTextLowercase(actionButton);
             SetActionIcon(actionButton, openAction);
             AddActionToActionsView(actionButton, i);
         }
     }
 }
Exemplo n.º 2
0
        protected void AddActionToActionsView(Button button, int position)
        {
            Handler looper = new Handler(Looper.MainLooper);

            looper.Post(() =>
            {
                try
                {
                    NotificationActions.AddView(button, position);
                }
                catch (Exception ex)
                {
                    Log.Error("LiveDisplay", "Error adding actions: " + ex);
                }
            });
        }
Exemplo n.º 3
0
        public DocumentDatabase(InMemoryRavenConfiguration configuration, TransportState transportState = null)
        {
            DocumentLock        = new PutSerialLock();
            Name                = configuration.DatabaseName;
            Configuration       = configuration;
            this.transportState = transportState ?? new TransportState();
            ExtensionsState     = new AtomicDictionary <object>();

            using (LogManager.OpenMappedContext("database", Name ?? Constants.SystemDatabase))
            {
                Log.Debug("Start loading the following database: {0}", Name ?? Constants.SystemDatabase);

                initializer = new DocumentDatabaseInitializer(this, configuration);

                initializer.InitializeEncryption();
                initializer.ValidateLicense();

                initializer.SubscribeToDomainUnloadOrProcessExit();
                initializer.ExecuteAlterConfiguration();
                initializer.SatisfyImportsOnce();

                backgroundTaskScheduler = configuration.CustomTaskScheduler ?? TaskScheduler.Default;


                recentTouches = new SizeLimitedConcurrentDictionary <string, TouchedDocumentInfo>(configuration.MaxRecentTouchesToRemember, StringComparer.OrdinalIgnoreCase);

                configuration.Container.SatisfyImportsOnce(this);

                workContext = new WorkContext
                {
                    Database            = this,
                    DatabaseName        = Name,
                    IndexUpdateTriggers = IndexUpdateTriggers,
                    ReadTriggers        = ReadTriggers,
                    TaskScheduler       = backgroundTaskScheduler,
                    Configuration       = configuration,
                    IndexReaderWarmers  = IndexReaderWarmers
                };

                try
                {
                    uuidGenerator = new SequentialUuidGenerator();
                    initializer.InitializeTransactionalStorage(uuidGenerator);
                    lastCollectionEtags = new LastCollectionEtags(TransactionalStorage, WorkContext);
                }
                catch (Exception)
                {
                    if (TransactionalStorage != null)
                    {
                        TransactionalStorage.Dispose();
                    }
                    throw;
                }

                try
                {
                    TransactionalStorage.Batch(actions => uuidGenerator.EtagBase = actions.General.GetNextIdentityValue("Raven/Etag"));

                    // Index codecs must be initialized before we try to read an index
                    InitializeIndexCodecTriggers();
                    initializer.InitializeIndexStorage();

                    Attachments   = new AttachmentActions(this, recentTouches, uuidGenerator, Log);
                    Documents     = new DocumentActions(this, recentTouches, uuidGenerator, Log);
                    Indexes       = new IndexActions(this, recentTouches, uuidGenerator, Log);
                    Maintenance   = new MaintenanceActions(this, recentTouches, uuidGenerator, Log);
                    Notifications = new NotificationActions(this, recentTouches, uuidGenerator, Log);
                    Patches       = new PatchActions(this, recentTouches, uuidGenerator, Log);
                    Queries       = new QueryActions(this, recentTouches, uuidGenerator, Log);
                    Tasks         = new TaskActions(this, recentTouches, uuidGenerator, Log);
                    Transformers  = new TransformerActions(this, recentTouches, uuidGenerator, Log);

                    inFlightTransactionalState = TransactionalStorage.GetInFlightTransactionalState(Documents.Put, Documents.Delete);

                    CompleteWorkContextSetup();

                    prefetcher       = new Prefetcher(workContext);
                    indexingExecuter = new IndexingExecuter(workContext, prefetcher);

                    RaiseIndexingWiringComplete();

                    InitializeTriggersExceptIndexCodecs();
                    SecondStageInitialization();
                    ExecuteStartupTasks();
                    lastCollectionEtags.Initialize();

                    Log.Debug("Finish loading the following database: {0}", configuration.DatabaseName ?? Constants.SystemDatabase);
                }
                catch (Exception)
                {
                    Dispose();
                    throw;
                }
            }
        }
 public NotificationAction[] NotificationActionsForActionPredicate(Func <Models.Action, bool> pred)
 {
     int[] actions = Actions.Where(pred).Select(x => x.ActionId).ToArray();
     return(NotificationActions.Where(x => actions.Contains(x.Id)).ToArray());
 }