Esempio n. 1
0
		public QuizAdapter (Context context, Category category)
		{
			this.context = context;
			this.category = category;
			quizzes = category.Quizzes;
			viewTypeCount = CalculateViewTypeCount ();
		}
		void StartQuizActivityWithTransition(Activity activity, View toolbar, Category category) {
			var pairs = TransitionHelper.CreateSafeTransitionParticipants(activity, false, new Pair(toolbar, activity.GetString(Resource.String.transition_toolbar)));
			var sceneTransitionAnimation = ActivityOptions.MakeSceneTransitionAnimation(activity, pairs);

			// Start the activity with the participants, animating from one to the other.
			var transitionBundle = sceneTransitionAnimation.ToBundle();
			activity.StartActivity(QuizActivity.GetStartIntent(activity, category), transitionBundle);
		}
		void SetCategoryIcon (Category category, ImageView icon)
		{
			var categoryImageResource = resources.GetIdentifier (IconCategory + category.Id, Drawable, packageName);
			var solved = category.Solved;
			if (solved) {
				var solvedIcon = LoadSolvedIcon (category, categoryImageResource);
				icon.SetImageDrawable (solvedIcon);
			} else {
				icon.SetImageResource (categoryImageResource);
			}
		}
Esempio n. 4
0
		protected AbsQuizView (Context context, Category category) : base (context)
		{
			mCategory = category;
			spacingDouble = Resources.GetDimensionPixelSize (Resource.Dimension.spacing_double);
			minHeightTouchTarget = Resources.GetDimensionPixelSize (Resource.Dimension.min_height_touch_target);
			fastOutSlowInInterpolator = AnimationUtils.LoadInterpolator (Context, Android.Resource.Interpolator.FastOutSlowIn);
			linearOutSlowInInterpolator = AnimationUtils.LoadInterpolator (Context, Android.Resource.Interpolator.LinearOutSlowIn);
			colorAnimationDuration = 400;
			iconAnimationDuration = 300;
			scaleAnimationDuration = 200;
		}
Esempio n. 5
0
		public override void OnCreate (Bundle savedInstanceState)
		{
			var categoryId = Arguments.GetString (Category.TAG);
			category = TopekaDatabaseHelper.GetCategoryWith (Activity, categoryId);
			base.OnCreate (savedInstanceState);
		}
		public ScoreAdapter (Category category)
		{
			this.category = category;
			quizList = this.category.Quizzes;
			count = quizList.Count;
		}
		LayerDrawable LoadSolvedIcon (Category category, int categoryImageResource)
		{
			var done = LoadTintedDoneDrawable ();
			var categoryIcon = LoadTintedCategoryDrawable (category, categoryImageResource);
			var layers = new [] { categoryIcon, done };
			return new LayerDrawable (layers);
		}
		Drawable LoadTintedCategoryDrawable (Category category, int categoryImageResource)
		{
			var categoryIcon = activity.GetDrawable (categoryImageResource);
			TintDrawable (category.Theme.PrimaryColor, ref categoryIcon);
			return categoryIcon;
		}
Esempio n. 9
0
 public static Intent GetStartIntent(Context context, Category category)
 {
     var starter = new Intent(context, typeof(QuizActivity));
     starter.PutExtra(Category.TAG, category.Id);
     return starter;
 }
Esempio n. 10
0
 void InitToolbar(Category category) {
     toolbar = FindViewById<Toolbar>(Resource.Id.toolbar_activity_quiz);
     toolbar.Title = category.Name;
     toolbar.NavigationOnClick += (sender, e) => {
         var view = (View)sender;
         switch (view.Id) {
             case Resource.Id.fab_quiz:
                 StartQuizFromClickOn(view);
                 break;
             case Resource.Id.submitAnswer:
                 SubmitAnswer();
                 break;
             case Resource.Id.quiz_done:
                 FinishAfterTransition();
                 break;
             case Undefined:
                 var contentDescription = view.ContentDescription;
                 if (contentDescription != null && contentDescription == GetString(Resource.String.up)) {
                     OnBackPressed();
                     break;
                 }
                 break;
             default:
                 throw new InvalidOperationException(
                     "OnClick has not been implemented for " + Resources.GetResourceName(view.Id));
         }
     };
     if (savedStateIsPlaying) {
         toolbar.Elevation = 0;
     }
 }
 public static void UpdateCategory(Context context, Category category)
 {
     var writableDatabase = GetDatabase(context);
     var categoryQuery = writableDatabase.Get<CategoryTable>(category.Id);
     categoryQuery.solved = category.Solved.ToString();
     categoryQuery.scores = string.Join(",", category.Scores);
     writableDatabase.Update(categoryQuery);
     var quizzes = category.Quizzes;
     UpdateQuizzes(writableDatabase, quizzes);
 }