Repository: square/leakcanary
File: leakcanary-android/src/main/java/com/squareup/leakcanary/internal/DisplayLeakActivity.java (Java)

Code before:
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              adapter.toggleRow(position);
            }
          });
          invalidateOptionsMenu();
          getActionBar().setDisplayHomeAsUpEnabled(true);
          actionButton.setVisibility(VISIBLE);
          actionButton.setText(R.string.leak_canary_delete);
          actionButton.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {
              Leak visibleLeak = getVisibleLeak();
              File heapDumpFile = visibleLeak.heapDump.heapDumpFile;
              File resultFile = visibleLeak.resultFile;
              boolean resultDeleted = resultFile.delete();
              if (!resultDeleted) {
                CanaryLog.d("Could not delete result file %s", resultFile.getPath());
              }
              boolean heapDumpDeleted = heapDumpFile.delete();
              if (!heapDumpDeleted) {
                CanaryLog.d("Could not delete heap dump file %s", heapDumpFile.getPath());
              }
              visibleLeakRefKey = null;
              leaks.remove(visibleLeak);
              updateUi();
            }
          });
        }
        HeapDump heapDump = visibleLeak.heapDump;
        adapter.update(result.leakTrace, heapDump.referenceKey, heapDump.referenceName);
        String size = formatShortFileSize(this, result.retainedHeapSize);
        String className = classSimpleName(result.className);
        setTitle(getString(R.string.leak_canary_class_has_leaked, className, size));
      }
    } else {
      if (listAdapter instanceof LeakListAdapter) {
        ((LeakListAdapter) listAdapter).notifyDataSetChanged();
      } else {
        LeakListAdapter adapter = new LeakListAdapter();
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            visibleLeakRefKey = leaks.get(position).heapDump.referenceKey;
            updateUi();
          }
        });
        invalidateOptionsMenu();
        setTitle(getString(R.string.leak_canary_leak_list_title, getPackageName()));
        getActionBar().setDisplayHomeAsUpEnabled(false);
        actionButton.setText(R.string.leak_canary_delete_all);

Review comment (suggestion):
`@Override` should be inlined. I'll format the file after merging.


Code after:
    final Leak visibleLeak = getVisibleLeak();
    if (visibleLeak == null) {
      visibleLeakRefKey = null;
    }

    ListAdapter listAdapter = listView.getAdapter();
    // Reset to defaults
    listView.setVisibility(VISIBLE);
    failureView.setVisibility(GONE);

    if (visibleLeak != null) {
      AnalysisResult result = visibleLeak.result;
      if (result.failure != null) {
        listView.setVisibility(GONE);
        failureView.setVisibility(VISIBLE);
        failureView.setText(
            getString(R.string.leak_canary_failure_report) + Log.getStackTraceString(
                result.failure));
        setTitle(R.string.leak_canary_analysis_failed);
        invalidateOptionsMenu();
        getActionBar().setDisplayHomeAsUpEnabled(true);
        actionButton.setVisibility(VISIBLE);
        actionButton.setText(R.string.leak_canary_delete);
        actionButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            deleteVisibleLeak();
          }
        });
        listView.setAdapter(null);
      } else {
        final DisplayLeakAdapter adapter;
        if (listAdapter instanceof DisplayLeakAdapter) {
          adapter = (DisplayLeakAdapter) listAdapter;
        } else {
          adapter = new DisplayLeakAdapter();
          listView.setAdapter(adapter);
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              adapter.toggleRow(position);
            }
          });
          invalidateOptionsMenu();
          getActionBar().setDisplayHomeAsUpEnabled(true);
          actionButton.setVisibility(VISIBLE);
          actionButton.setText(R.string.leak_canary_delete);
          actionButton.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {
              deleteVisibleLeak();
            }