@Override
  protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content)
        .setSystemUiVisibility(
            findViewById(android.R.id.content).getSystemUiVisibility()
                | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    // as we use an icon from Android-Iconics via xml we add the IconicsLayoutInflater
    // https://github.com/mikepenz/Android-Iconics
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_collapsible);

    // style our ui
    new MaterializeBuilder().withActivity(this).build();

    // create our FastAdapter
    fastItemAdapter = new FastItemAdapter<>();
    fastItemAdapter.withSelectable(true);

    // get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(fastItemAdapter);

    // fill with some sample data
    List<IItem> items = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
      if (i % 10 == 0) {
        ExpandableItem expandableItem =
            new ExpandableItem().withName("Test " + i).withIdentifier(100 + 1);

        // add subitems so we can showcase the collapsible functionality
        List<IItem> subItems = new LinkedList<>();
        for (int ii = 1; ii <= 5; ii++) {
          subItems.add(new SampleItem().withName("-- Test " + ii).withIdentifier(1000 + ii));
        }
        expandableItem.withSubItems(subItems);

        items.add(expandableItem);
      } else {
        items.add(new SampleItem().withName("Test " + i).withIdentifier(100 + i));
      }
    }
    fastItemAdapter.add(items);

    // restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);

    // set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
  }
 private CustomThemeHelper(
     Context context,
     SparseIntArray customAttrs,
     int textColorPrimaryOriginal,
     int textColorPrimaryOverridden) {
   this.customAttrs = customAttrs;
   this.mappingKeys = new int[customAttrs.size()];
   this.mappingValues = new int[customAttrs.size()];
   this.textColorPrimaryOriginal = textColorPrimaryOriginal;
   this.textColorPrimaryOverridden = textColorPrimaryOverridden;
   this.resources = context.getResources();
   this.inflater = LayoutInflater.from(context);
   LayoutInflaterCompat.setFactory(inflater, this);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    Intent data = getIntent();
    earthWallpaper = (EarthWallpaper) data.getExtras().getSerializable(WALLPAPER_OBJECT);
    // setTheme(R.style.AppTheme_NoActionBar);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
      setTheme(R.style.AppTheme_NoActionBar);
    }
    setContentView(R.layout.activity_wallpaper);

    downloadDialog = new BaseDialog(this).getDownloadDialog();

    if (!downloadDir.exists()) {
      boolean created = downloadDir.mkdir();
      Log.d("WallpaperActivity", "Download directory didn't exist : creation -> " + created);
    }

    if (!Preferences.exists()) Preferences.init(this);

    downloadDir = new File(Preferences.getInstance().getWallpaperDownloadDirectory());

    rootLayout = (CoordinatorLayout) findViewById(R.id.wallpaper_coordinator_root);
    collapsingToolbarLayout =
        (CollapsingToolbarLayout) findViewById(R.id.wallpaper_collapsing_toolbar);
    // collapsingToolbarLayout.setExpandedTitleTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
    collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.FullscreenTextPreview);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_details_view);
    toolbar.setTitle(earthWallpaper.getFormattedWallpaperTitle());
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // set and load the appbar image
    appBarImage = (ImageView) findViewById(R.id.wall_preview);
    Picasso.with(this).load(earthWallpaper.getWallThumbUrl()).into(appBarImage);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      appBarImage.setTransitionName(data.getExtras().getString(IMAGE_TRANSITION_NAME));
      // toolbar.setTransitionName(data.getExtras().getString(TEXT_TRANSITION_NAME));
    }

    // assigning the information to the views
    cityTextView = (TextView) findViewById(R.id.details_location_text);
    if (earthWallpaper.getWallpaperRegion() == null) {
      cityTextView.setText(R.string.details_unknown);
    } else {
      cityTextView.setText(earthWallpaper.getWallpaperRegion());
    }
    countryTextView = (TextView) findViewById(R.id.details_country_text);
    if (earthWallpaper.getWallpaperCountry() == null) {
      countryTextView.setText(R.string.details_unknown);
    } else {
      countryTextView.setText(earthWallpaper.getWallpaperCountry());
    }
    coordinatesTextView = (TextView) findViewById(R.id.details_coords_text);
    coordinatesTextView.setText(getFormattedCoordinates());

    // setting the google maps layout stuff
    googleMapsLayout = (RelativeLayout) findViewById(R.id.gmaps_nav_layout);
    googleMapsLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent googleMaps =
                new Intent(Intent.ACTION_VIEW, Uri.parse(earthWallpaper.getGoogleMapsUrl()));
            startActivity(googleMaps);
          }
        });
    googleMapsHintTextView = (TextView) findViewById(R.id.details_gmaps_link_icon_text);
    googleMapsHintTextView.setText(earthWallpaper.getGoogleMapsTitle());

    final int[] c = {0};
    attributionLayout = (RelativeLayout) findViewById(R.id.details_attribution_layout);
    attributionLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            c[0]++;
            if (c[0] >= 20) unlock = true;
          }
        });

    attributionTextView = (TextView) findViewById(R.id.details_attribution_text);
    if (earthWallpaper.getWallpaperAttribution() == null) {
      attributionTextView.setText(R.string.details_unknown);
    } else {
      attributionTextView.setText(earthWallpaper.getWallpaperAttribution());
    }

    shareLinkLayout = (RelativeLayout) findViewById(R.id.share_link_layout);
    shareLinkLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShow();
          }
        });

    shareLinkTextView = (TextView) findViewById(R.id.details_share_link_text);
    shareLinkTextView.setText(earthWallpaper.getShareUrl());

    // inflating the fab menu and it's entries
    floatingActionMenu = (FloatingActionMenu) findViewById(R.id.details_fab_menu);
    floatingActionMenu.setClosedOnTouchOutside(true);

    floatingActionShare = (FloatingActionButton) findViewById(R.id.fab_item_share);
    floatingActionShare.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_share_variant)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionShare.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShare();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionApply = (FloatingActionButton) findViewById(R.id.fab_item_apply);
    floatingActionApply.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_check)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionApply.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Snackbar.make(rootLayout, "Applying is coming soon!", Snackbar.LENGTH_SHORT).show();
            onSetAsWallpaper();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionArchive = (FloatingActionButton) findViewById(R.id.fab_item_archive);
    if (Preferences.getInstance().isFavorite(earthWallpaper)) {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart_outline)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(
          getResources().getString(R.string.fab_menu_item_remove_archive));
    } else {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(getResources().getString(R.string.fab_menu_item_archive));
    }
    floatingActionArchive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(false);

            if (Preferences.getInstance().isFavorite(earthWallpaper)) {
              Preferences.getInstance().removeFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_removed, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            } else {
              Preferences.getInstance().addFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart_outline)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_remove_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_added, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            }
          }
        });

    floatingActionDownload = (FloatingActionButton) findViewById(R.id.fab_item_download);
    floatingActionDownload.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_download)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionDownload.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
            if (Preferences.getInstance().canWriteExternalStorage()) {
              new DownloadWallpaperTask(
                      WallpaperActivityPre.this,
                      Preferences.getInstance().getWallpaperDownloadDir(),
                      earthWallpaper)
                  .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, unlock);
            } else {
              Preferences.getInstance()
                  .requestExternalStoragePermission(
                      WallpaperActivityPre.this, WallpaperActivityPre.this, false);
            }
          }
        });

    // EarthView.withGoogle().getEarthWallpaper(earthWallpaper.getWallpaperId(), this);
    new DownloadHighResImage(this, earthWallpaper, this)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    setTypefaces();
  }