@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    settings = ((OsmandApplication) getApplication()).getSettings();
    if (downloadListIndexThread == null) {
      downloadListIndexThread = new DownloadIndexListThread(this);
    }
    // recreation upon rotation is prevented in manifest file
    CustomTitleBar titleBar =
        new CustomTitleBar(
            this, R.string.local_index_download, R.drawable.tab_download_screen_icon);
    setContentView(R.layout.download_index);
    titleBar.afterSetContentView();

    downloadFileHelper = new DownloadFileHelper(this);
    findViewById(R.id.DownloadButton)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                downloadFilesCheckFreeVersion();
              }
            });

    updateLoadedFiles();

    filterText = (EditText) findViewById(R.id.search_box);
    textWatcher =
        new TextWatcher() {
          @Override
          public void afterTextChanged(Editable s) {}

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            DownloadIndexAdapter adapter = ((DownloadIndexAdapter) getExpandableListAdapter());
            if (adapter != null) {
              adapter.getFilter().filter(s);
            }
          }
        };
    filterText.addTextChangedListener(textWatcher);
    final Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {
      final String filter = intent.getExtras().getString(FILTER_KEY);
      if (filter != null) {
        filterText.setText(filter);
      }
    }

    if (downloadListIndexThread.getCachedIndexFiles() != null) {
      setListAdapter(new DownloadIndexAdapter(downloadListIndexThread.getCachedIndexFiles()));
    } else {
      downloadIndexList();
    }
    if (Version.isFreeVersion(this) && settings.checkFreeDownloadsNumberZero()) {
      Builder msg = new AlertDialog.Builder(this);
      msg.setTitle(R.string.free_version_title);
      msg.setMessage(
          getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "", ""));
      msg.show();
    }
  }