Merge pull request #363 from veyndan/diamond

Replace explicit type with diamond operator
This commit is contained in:
Josephine Lim 2017-03-02 18:37:14 +10:00 committed by GitHub
commit 9a6dd2e97e
16 changed files with 43 additions and 43 deletions

View file

@ -122,7 +122,7 @@ public class CommonsApplication extends Application {
if (maxMem < 48L * 1024L * 1024L) {
// Cache only one bitmap if VM memory is too small (such as Nexus One);
Log.d("Commons", "Skipping bitmap cache; max mem is: " + maxMem);
imageCache = new LruCache<String, Bitmap>(1);
imageCache = new LruCache<>(1);
} else {
int cacheSize = (int) (maxMem / (1024 * 8));
Log.d("Commons", "Bitmap cache size " + cacheSize + " from max mem " + maxMem);

View file

@ -11,7 +11,7 @@ import java.util.Map;
import java.util.Set;
public class LicenseList {
Map<String, fr.free.nrw.commons.License> licenses = new HashMap<String, fr.free.nrw.commons.License>();
Map<String, fr.free.nrw.commons.License> licenses = new HashMap<>();
Resources res;
private static String XMLNS_LICENSE = "https://www.mediawiki.org/wiki/Extension:UploadWizard/xmlns/licenses";

View file

@ -27,11 +27,11 @@ public class Media implements Parcelable {
};
protected Media() {
this.categories = new ArrayList<String>();
this.descriptions = new HashMap<String, String>();
this.categories = new ArrayList<>();
this.descriptions = new HashMap<>();
}
private HashMap<String, Object> tags = new HashMap<String, Object>();
private HashMap<String, Object> tags = new HashMap<>();
public Object getTag(String key) {
return tags.get(key);

View file

@ -46,8 +46,8 @@ public class MediaDataExtractor {
*/
public MediaDataExtractor(String filename, LicenseList licenseList) {
this.filename = filename;
categories = new ArrayList<String>();
descriptions = new HashMap<String, String>();
categories = new ArrayList<>();
descriptions = new HashMap<>();
fetched = false;
processed = false;
this.licenseList = licenseList;
@ -251,7 +251,7 @@ public class MediaDataExtractor {
// Texts are wrapped in things like {{en|foo} or {{en|1=foo bar}}.
// Text outside those wrappers is stuffed into a 'default' faux language key if present.
private Map<String, String> getMultilingualText(Node parentNode) throws IOException {
Map<String, String> texts = new HashMap<String, String>();
Map<String, String> texts = new HashMap<>();
StringBuilder localText = new StringBuilder();
NodeList nodes = parentNode.getChildNodes();

View file

@ -33,7 +33,7 @@ public class CacheController {
}
public void cacheCategory() {
List<String> pointCatList = new ArrayList<String>();
List<String> pointCatList = new ArrayList<>();
if (MwVolleyApi.GpsCatExists.getGpsCatExists() == true) {
pointCatList.addAll(MwVolleyApi.getGpsCat());
Log.d(TAG, "Categories being cached: " + pointCatList);
@ -47,7 +47,7 @@ public class CacheController {
//Convert decLatitude and decLongitude to a coordinate offset range
convertCoordRange();
pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus);
List<String> displayCatList = new ArrayList<String>();
List<String> displayCatList = new ArrayList<>();
Log.d(TAG, "Points found in quadtree: " + Arrays.asList(pointsFound));
if (pointsFound.length != 0) {

View file

@ -66,14 +66,14 @@ public class CategorizationFragment extends Fragment {
protected HashMap<String, ArrayList<String>> categoriesCache;
private ArrayList<String> selectedCategories = new ArrayList<String>();
private ArrayList<String> selectedCategories = new ArrayList<>();
// LHS guarantees ordered insertions, allowing for prioritized method A results
private final Set<String> results = new LinkedHashSet<String>();
private final Set<String> results = new LinkedHashSet<>();
PrefixUpdater prefixUpdaterSub;
MethodAUpdater methodAUpdaterSub;
private final ArrayList<String> titleCatItems = new ArrayList<String>();
private final ArrayList<String> titleCatItems = new ArrayList<>();
final CountDownLatch mergeLatch = new CountDownLatch(1);
private ContentProviderClient client;
@ -161,7 +161,7 @@ public class CategorizationFragment extends Fragment {
* @return a list containing recent categories
*/
protected ArrayList<String> recentCatQuery() {
ArrayList<String> items = new ArrayList<String>();
ArrayList<String> items = new ArrayList<>();
try {
Cursor cursor = client.query(
@ -189,16 +189,16 @@ public class CategorizationFragment extends Fragment {
*/
protected ArrayList<String> mergeItems() {
Set<String> mergedItems = new LinkedHashSet<String>();
Set<String> mergedItems = new LinkedHashSet<>();
Log.d(TAG, "Calling APIs for GPS cats, title cats and recent cats...");
List<String> gpsItems = new ArrayList<String>();
List<String> gpsItems = new ArrayList<>();
if (MwVolleyApi.GpsCatExists.getGpsCatExists()) {
gpsItems.addAll(MwVolleyApi.getGpsCat());
}
List<String> titleItems = new ArrayList<String>(titleCatQuery());
List<String> recentItems = new ArrayList<String>(recentCatQuery());
List<String> titleItems = new ArrayList<>(titleCatQuery());
List<String> recentItems = new ArrayList<>(recentCatQuery());
//Await results of titleItems, which is likely to come in last
try {
@ -216,7 +216,7 @@ public class CategorizationFragment extends Fragment {
Log.d(TAG, "Adding recent items: " + recentItems);
//Needs to be an ArrayList and not a List unless we want to modify a big portion of preexisting code
ArrayList<String> mergedItemsList = new ArrayList<String>(mergedItems);
ArrayList<String> mergedItemsList = new ArrayList<>(mergedItems);
Log.d(TAG, "Merged item list: " + mergedItemsList);
return mergedItemsList;
@ -230,8 +230,8 @@ public class CategorizationFragment extends Fragment {
protected void setCatsAfterAsync(ArrayList<String> categories, String filter) {
if (getActivity() != null) {
ArrayList<CategoryItem> items = new ArrayList<CategoryItem>();
HashSet<String> existingKeys = new HashSet<String>();
ArrayList<CategoryItem> items = new ArrayList<>();
HashSet<String> existingKeys = new HashSet<>();
for (CategoryItem item : categoriesAdapter.getItems()) {
if (item.selected) {
items.add(item);
@ -279,7 +279,7 @@ public class CategorizationFragment extends Fragment {
prefixUpdaterSub = new PrefixUpdater(this) {
@Override
protected ArrayList<String> doInBackground(Void... voids) {
ArrayList<String> result = new ArrayList<String>();
ArrayList<String> result = new ArrayList<>();
try {
result = super.doInBackground();
latch.await();
@ -299,7 +299,7 @@ public class CategorizationFragment extends Fragment {
Log.d(TAG, "Prefix result: " + result);
String filter = categoriesFilter.getText().toString();
ArrayList<String> resultsList = new ArrayList<String>(results);
ArrayList<String> resultsList = new ArrayList<>(results);
categoriesCache.put(filter, resultsList);
Log.d(TAG, "Final results List: " + resultsList);
@ -421,8 +421,8 @@ public class CategorizationFragment extends Fragment {
ArrayList<CategoryItem> items;
if(savedInstanceState == null) {
items = new ArrayList<CategoryItem>();
categoriesCache = new HashMap<String, ArrayList<String>>();
items = new ArrayList<>();
categoriesCache = new HashMap<>();
} else {
items = savedInstanceState.getParcelableArrayList("currentCategories");
categoriesCache = (HashMap<String, ArrayList<String>>) savedInstanceState.getSerializable("categoriesCache");

View file

@ -82,7 +82,7 @@ public class MethodAUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
//otherwise if user has typed something in that isn't in cache, search API for matching categories
MWApi api = CommonsApplication.createMWApi();
ApiResult result;
ArrayList<String> categories = new ArrayList<String>();
ArrayList<String> categories = new ArrayList<>();
//URL https://commons.wikimedia.org/w/api.php?action=query&format=xml&list=search&srwhat=text&srenablerewrites=1&srnamespace=14&srlimit=10&srsearch=
try {
@ -109,7 +109,7 @@ public class MethodAUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
}
Log.d(TAG, "Found categories from Method A search, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<String>(filterYears(categories));
ArrayList<String> filteredItems = new ArrayList<>(filterYears(categories));
return filteredItems;
}
}

View file

@ -82,17 +82,17 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
protected ArrayList<String> doInBackground(Void... voids) {
//If user hasn't typed anything in yet, get GPS and recent items
if(TextUtils.isEmpty(filter)) {
ArrayList<String> mergedItems = new ArrayList<String>(catFragment.mergeItems());
ArrayList<String> mergedItems = new ArrayList<>(catFragment.mergeItems());
Log.d(TAG, "Merged items, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<String>(filterYears(mergedItems));
ArrayList<String> filteredItems = new ArrayList<>(filterYears(mergedItems));
return filteredItems;
}
//if user types in something that is in cache, return cached category
if(catFragment.categoriesCache.containsKey(filter)) {
ArrayList<String> cachedItems = new ArrayList<String>(catFragment.categoriesCache.get(filter));
ArrayList<String> cachedItems = new ArrayList<>(catFragment.categoriesCache.get(filter));
Log.d(TAG, "Found cache items, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<String>(filterYears(cachedItems));
ArrayList<String> filteredItems = new ArrayList<>(filterYears(cachedItems));
return filteredItems;
}
@ -100,7 +100,7 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
//URL: https://commons.wikimedia.org/w/api.php?action=query&list=allcategories&acprefix=filter&aclimit=25
MWApi api = CommonsApplication.createMWApi();
ApiResult result;
ArrayList<String> categories = new ArrayList<String>();
ArrayList<String> categories = new ArrayList<>();
try {
result = api.action("query")
.param("list", "allcategories")
@ -120,7 +120,7 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
}
Log.d(TAG, "Found categories from Prefix search, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<String>(filterYears(categories));
ArrayList<String> filteredItems = new ArrayList<>(filterYears(categories));
return filteredItems;
}
}

View file

@ -45,7 +45,7 @@ public class ContributionsActivity
private MediaDetailPagerFragment mediaDetails;
private UploadService uploadService;
private boolean isUploadServiceConnected;
private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<DataSetObserver>();
private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<>();
private String CONTRIBUTION_SELECTION = "";
/*
This sorts in the following order:

View file

@ -92,7 +92,7 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
ArrayList<ApiResult> uploads = result.getNodes("/api/query/logevents/item");
Log.d("Commons", uploads.size() + " results!");
ArrayList<ContentValues> imageValues = new ArrayList<ContentValues>();
ArrayList<ContentValues> imageValues = new ArrayList<>();
for(ApiResult image: uploads) {
String filename = image.getString("@title");
if(fileExists(contentProviderClient, filename)) {

View file

@ -32,7 +32,7 @@ public class CategoryImagesLoader extends AsyncTaskLoader<List<Media>>{
@Override
public List<Media> loadInBackground() {
ArrayList<Media> mediaList = new ArrayList<Media>();
ArrayList<Media> mediaList = new ArrayList<>();
ApiResult result;
try {
result = app.getApi().action("query")

View file

@ -108,7 +108,7 @@ public class MediaDetailFragment extends Fragment {
index = getArguments().getInt("index");
initialListTop = 0;
}
categoryNames = new ArrayList<String>();
categoryNames = new ArrayList<>();
categoryNames.add(getString(R.string.detail_panel_cats_loading));
final View view = inflater.inflate(R.layout.fragment_media_detail, container, false);

View file

@ -21,7 +21,7 @@ public class ModifierSequence {
public ModifierSequence(Uri mediaUri) {
this.mediaUri = mediaUri;
modifiers = new ArrayList<PageModifier>();
modifiers = new ArrayList<>();
}
public ModifierSequence(Uri mediaUri, JSONObject data) {

View file

@ -21,7 +21,7 @@ public class NearbyPlaces {
}
else {
try {
places = new ArrayList<Place>();
places = new ArrayList<>();
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

View file

@ -249,7 +249,7 @@ public class MultipleShareActivity
if(intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
if(photosList == null) {
photosList = new ArrayList<Contribution>();
photosList = new ArrayList<>();
ArrayList<Uri> urisList = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
for(int i=0; i < urisList.size(); i++) {
Contribution up = new Contribution();

View file

@ -42,7 +42,7 @@ public class MwVolleyApi {
public MwVolleyApi(Context context) {
this.context = context;
categorySet = new HashSet<String>();
categorySet = new HashSet<>();
}
public static List<String> getGpsCat() {
@ -50,7 +50,7 @@ public class MwVolleyApi {
}
public static void setGpsCat(List cachedList) {
categoryList = new ArrayList<String>();
categoryList = new ArrayList<>();
categoryList.addAll(cachedList);
Log.d(TAG, "Setting GPS cats from cache: " + categoryList.toString());
}
@ -236,7 +236,7 @@ public class MwVolleyApi {
}
}
categoryList = new ArrayList<String>(categorySet);
categoryList = new ArrayList<>(categorySet);
builder.replace(builder.length() - 1, builder.length(), "");
return builder.toString();
}