@Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    PrefsUtility.applyTheme(this);

    if (getActionBar() != null) {
      getActionBar().setHomeButtonEnabled(true);
      getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean solidblack =
        PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences)
                == PrefsUtility.AppearanceTheme.NIGHT;

    if (solidblack) getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));

    final Intent intent = getIntent();

    mUrl = intent.getDataString();

    if (mUrl == null) {
      finish();
      return;
    }

    final Matcher matchImgur = LinkHandler.imgurAlbumPattern.matcher(mUrl);
    final String albumId;

    if (matchImgur.find()) {
      albumId = matchImgur.group(2);
    } else {
      Log.e("AlbumListingActivity", "URL match failed");
      revertToWeb();
      return;
    }

    Log.i("AlbumListingActivity", "Loading URL " + mUrl + ", album id " + albumId);

    final ProgressBar progressBar =
        new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);

    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(progressBar);

    ImgurAPI.getAlbumInfo(
        this,
        albumId,
        Constants.Priority.IMAGE_VIEW,
        0,
        new GetAlbumInfoListener() {

          @Override
          public void onFailure(
              final RequestFailureType type,
              final Throwable t,
              final StatusLine status,
              final String readableMessage) {
            Log.e("AlbumListingActivity", "getAlbumInfo call failed: " + type);

            if (status != null) Log.e("AlbumListingActivity", "status was: " + status.toString());
            if (t != null) Log.e("AlbumListingActivity", "exception was: ", t);

            // It might be a single image, not an album

            ImgurAPI.getImageInfo(
                AlbumListingActivity.this,
                albumId,
                Constants.Priority.IMAGE_VIEW,
                0,
                new GetImageInfoListener() {
                  @Override
                  public void onFailure(
                      final RequestFailureType type,
                      final Throwable t,
                      final StatusLine status,
                      final String readableMessage) {
                    Log.e("AlbumListingActivity", "Image info request also failed: " + type);
                    revertToWeb();
                  }

                  @Override
                  public void onSuccess(final ImgurAPI.ImageInfo info) {
                    Log.i("AlbumListingActivity", "Link was actually an image.");
                    LinkHandler.onLinkClicked(AlbumListingActivity.this, info.urlOriginal);
                    finish();
                  }

                  @Override
                  public void onNotAnImage() {
                    Log.i("AlbumListingActivity", "Not an image either");
                    revertToWeb();
                  }
                });
          }

          @Override
          public void onSuccess(final ImgurAPI.AlbumInfo info) {
            Log.i("AlbumListingActivity", "Got album, " + info.images.size() + " image(s)");

            AndroidApi.UI_THREAD_HANDLER.post(
                new Runnable() {
                  @Override
                  public void run() {

                    if (info.title != null && !info.title.trim().isEmpty()) {
                      OptionsMenuUtility.fixActionBar(
                          AlbumListingActivity.this, "Imgur album: " + info.title);
                    } else {
                      OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, "Imgur album");
                    }

                    layout.removeAllViews();

                    final ListView listView = new ListView(AlbumListingActivity.this);
                    listView.setAdapter(new AlbumAdapter(info));
                    layout.addView(listView);

                    listView.setOnItemClickListener(
                        new AdapterView.OnItemClickListener() {
                          @Override
                          public void onItemClick(
                              final AdapterView<?> parent,
                              final View view,
                              final int position,
                              final long id) {

                            LinkHandler.onLinkClicked(
                                AlbumListingActivity.this, info.images.get(position).urlOriginal);
                          }
                        });
                  }
                });
          }
        });

    setContentView(layout);
  }
 @Override
 public void onBackPressed() {
   if (General.onBackPressed()) super.onBackPressed();
 }