@Override decorator on every method that overrides

This marks a method as overriding another method, and makes sure that it
matches the signature of the method it is supposed to be overriding,
otherwise it gives a warning.

Its a bit verbose, but can catch mistakes and save time. And the default
Android profile for Eclipse always adds them automatically...
This commit is contained in:
Hans-Christoph Steiner 2014-02-19 20:01:39 -05:00
parent 301ac10515
commit 888d28aed6
13 changed files with 24 additions and 0 deletions

View File

@ -66,10 +66,12 @@ public interface ProgressListener {
} }
public static final Parcelable.Creator<Event> CREATOR = new Parcelable.Creator<Event>() { public static final Parcelable.Creator<Event> CREATOR = new Parcelable.Creator<Event>() {
@Override
public Event createFromParcel(Parcel in) { public Event createFromParcel(Parcel in) {
return new Event(in.readInt(), in.readInt(), in.readInt(), in.readBundle()); return new Event(in.readInt(), in.readInt(), in.readInt(), in.readBundle());
} }
@Override
public Event[] newArray(int size) { public Event[] newArray(int size) {
return new Event[size]; return new Event[size];
} }

View File

@ -66,6 +66,7 @@ class OldTabManagerImpl extends TabManager {
* and giving it a FrameLayout as a child. This will make the tabs have * and giving it a FrameLayout as a child. This will make the tabs have
* dummy empty contents and then hook them up to our ViewPager. * dummy empty contents and then hook them up to our ViewPager.
*/ */
@Override
public void createTabs() { public void createTabs() {
tabHost = new TabHost(parent, null); tabHost = new TabHost(parent, null);
tabHost.setLayoutParams(new TabHost.LayoutParams( tabHost.setLayoutParams(new TabHost.LayoutParams(
@ -128,12 +129,14 @@ class OldTabManagerImpl extends TabManager {
} }
@Override
public void selectTab(int index) { public void selectTab(int index) {
tabHost.setCurrentTab(index); tabHost.setCurrentTab(index);
if (index == INDEX_CAN_UPDATE) if (index == INDEX_CAN_UPDATE)
removeNotification(1); removeNotification(1);
} }
@Override
public void refreshTabLabel(int index) { public void refreshTabLabel(int index) {
CharSequence text = getLabel(index); CharSequence text = getLabel(index);
@ -166,6 +169,7 @@ class HoneycombTabManagerImpl extends TabManager {
actionBar = parent.getActionBar(); actionBar = parent.getActionBar();
} }
@Override
public void createTabs() { public void createTabs() {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (int i = 0; i < pager.getAdapter().getCount(); i ++) { for (int i = 0; i < pager.getAdapter().getCount(); i ++) {
@ -174,6 +178,7 @@ class HoneycombTabManagerImpl extends TabManager {
actionBar.newTab() actionBar.newTab()
.setText(label) .setText(label)
.setTabListener(new ActionBar.TabListener() { .setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, public void onTabSelected(ActionBar.Tab tab,
FragmentTransaction ft) { FragmentTransaction ft) {
int pos = tab.getPosition(); int pos = tab.getPosition();
@ -193,6 +198,7 @@ class HoneycombTabManagerImpl extends TabManager {
} }
} }
@Override
public void selectTab(int index) { public void selectTab(int index) {
actionBar.setSelectedNavigationItem(index); actionBar.setSelectedNavigationItem(index);
Spinner actionBarSpinner = getActionBarSpinner(); Spinner actionBarSpinner = getActionBarSpinner();
@ -203,6 +209,7 @@ class HoneycombTabManagerImpl extends TabManager {
removeNotification(1); removeNotification(1);
} }
@Override
public void refreshTabLabel(int index) { public void refreshTabLabel(int index) {
CharSequence text = getLabel(index); CharSequence text = getLabel(index);
actionBar.getTabAt(index).setText(text); actionBar.getTabAt(index).setText(text);

View File

@ -255,6 +255,7 @@ public class ApkProvider extends FDroidProvider {
return PROVIDER_NAME; return PROVIDER_NAME;
} }
@Override
protected UriMatcher getMatcher() { protected UriMatcher getMatcher() {
return matcher; return matcher;
} }
@ -323,6 +324,7 @@ public class ApkProvider extends FDroidProvider {
this.orderBy = orderBy; this.orderBy = orderBy;
} }
@Override
public String toString() { public String toString() {
StringBuilder suffix = new StringBuilder(); StringBuilder suffix = new StringBuilder();

View File

@ -266,6 +266,7 @@ public class AppProvider extends FDroidProvider {
return AUTHORITY + "." + PROVIDER_NAME; return AUTHORITY + "." + PROVIDER_NAME;
} }
@Override
protected UriMatcher getMatcher() { protected UriMatcher getMatcher() {
return matcher; return matcher;
} }

View File

@ -72,6 +72,7 @@ public class Repo extends ValueObject {
return name; return name;
} }
@Override
public String toString() { public String toString() {
return address; return address;
} }

View File

@ -234,6 +234,7 @@ public class RepoProvider extends FDroidProvider {
return "RepoProvider"; return "RepoProvider";
} }
@Override
protected UriMatcher getMatcher() { protected UriMatcher getMatcher() {
return matcher; return matcher;
} }

View File

@ -202,6 +202,7 @@ public class NsdHelper {
//in order for it to update the ListView without error //in order for it to update the ListView without error
Handler refresh = new Handler(Looper.getMainLooper()); Handler refresh = new Handler(Looper.getMainLooper());
refresh.post(new Runnable() { refresh.post(new Runnable() {
@Override
public void run() public void run()
{ {
notifyDataSetChanged(); notifyDataSetChanged();

View File

@ -84,6 +84,7 @@ public class SignedRepoUpdater extends RepoUpdater {
return indexFile; return indexFile;
} }
@Override
protected String getIndexAddress() { protected String getIndexAddress() {
return repo.address + "/index.jar?client_version=" + context.getString(R.string.version_name); return repo.address + "/index.jar?client_version=" + context.getString(R.string.version_name);
} }

View File

@ -45,6 +45,7 @@ public class RepoAdapter extends CursorAdapter {
enabledListener = listener; enabledListener = listener;
} }
@Override
public boolean hasStableIds() { public boolean hasStableIds() {
return true; return true;
} }

View File

@ -37,6 +37,7 @@ public class AvailableAppsFragment extends AppListFragment implements
return "Available"; return "Available";
} }
@Override
protected AppListAdapter getAppListAdapter() { protected AppListAdapter getAppListAdapter() {
if (adapter == null) { if (adapter == null) {
final AppListAdapter a = new AvailableAppListAdapter(getActivity(), null); final AppListAdapter a = new AvailableAppListAdapter(getActivity(), null);

View File

@ -62,6 +62,7 @@ public class RepoDetailsFragment extends Fragment {
// best way to go about this... // best way to go about this...
private Repo repo; private Repo repo;
@Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
} }
@ -80,6 +81,7 @@ public class RepoDetailsFragment extends Fragment {
return RepoProvider.Helper.findById(getActivity(), getRepoId()); return RepoProvider.Helper.findById(getActivity(), getRepoId());
} }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
repo = loadRepoDetails(); repo = loadRepoDetails();
@ -346,11 +348,13 @@ public class RepoDetailsFragment extends Fragment {
repoFingerprintView.setTextColor(repoFingerprintColor); repoFingerprintView.setTextColor(repoFingerprintColor);
} }
@Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
} }

View File

@ -20,6 +20,7 @@ public class ApkProviderTest extends FDroidProviderTest<ApkProvider> {
super(ApkProvider.class, ApkProvider.getAuthority()); super(ApkProvider.class, ApkProvider.getAuthority());
} }
@Override
protected String[] getMinimalProjection() { protected String[] getMinimalProjection() {
return new String[] { return new String[] {
ApkProvider.DataColumns.APK_ID, ApkProvider.DataColumns.APK_ID,

View File

@ -25,6 +25,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
getSwappableContext().setResources(new MockCategoryResources()); getSwappableContext().setResources(new MockCategoryResources());
} }
@Override
protected String[] getMinimalProjection() { protected String[] getMinimalProjection() {
return new String[] { return new String[] {
AppProvider.DataColumns.APP_ID, AppProvider.DataColumns.APP_ID,