use of androidx.annotation.VisibleForTesting in project fresco by facebook.
the class BasePool method trimToNothing.
/**
* Gets rid of all free values in the pool At the end of this method, mFreeSpace will be zero
* (reflecting that there are no more free values in the pool). mUsedSpace will however not be
* reset, since that's a reflection of the values that were allocated via the pool, but are in use
* elsewhere
*/
@VisibleForTesting
void trimToNothing() {
final List<Bucket<V>> bucketsToTrim;
synchronized (this) {
if (mPoolParams.fixBucketsReinitialization) {
bucketsToTrim = refillBuckets();
} else {
bucketsToTrim = new ArrayList<>(mBuckets.size());
final SparseIntArray inUseCounts = new SparseIntArray();
for (int i = 0; i < mBuckets.size(); ++i) {
final Bucket<V> bucket = Preconditions.checkNotNull(mBuckets.valueAt(i));
if (bucket.getFreeListSize() > 0) {
bucketsToTrim.add(bucket);
}
inUseCounts.put(mBuckets.keyAt(i), bucket.getInUseCount());
}
legacyInitBuckets(inUseCounts);
}
// free up the stats
mFree.reset();
logStats();
}
// the pool parameters 'may' have changed.
onParamsChanged();
// This is true even for a concurrent trim() call
for (int i = 0; i < bucketsToTrim.size(); ++i) {
final Bucket<V> bucket = bucketsToTrim.get(i);
while (true) {
// what happens if we run into an exception during the recycle. I'm going to ignore
// these exceptions for now, and let the GC handle the rest of the to-be-recycled-bitmaps
// in its usual fashion
V item = bucket.pop();
if (item == null) {
break;
}
free(item);
}
}
}
use of androidx.annotation.VisibleForTesting in project ETSMobile-Android2 by ApplETS.
the class MoodleViewModel method filterAssignmentCourses.
/**
* Filter courses by removing the courses with no assignment
*
* @param assignmentCourses
* @return filtered courses
*/
@VisibleForTesting
List<MoodleAssignmentCourse> filterAssignmentCourses(List<MoodleAssignmentCourse> assignmentCourses) {
List<MoodleAssignmentCourse> filteredCourses = new ArrayList<>();
for (MoodleAssignmentCourse course : assignmentCourses) {
int nbAssignments = course.getAssignments().size();
if (nbAssignments != 0) {
/*
Si les devoirs antérieurs ne doivent pas être affichés, ceux-ci ne doivent pas être
pris en compte.
*/
if (!isDisplayPastAssignments()) {
for (MoodleAssignment assignment : course.getAssignments()) {
Date dueDate = assignment.getDueDateObj();
Date currentDate = new Date();
if (dueDate.before(currentDate))
nbAssignments--;
}
}
// Ajout du cours si celui-ci contient des devoirs
if (nbAssignments != 0)
filteredCourses.add(course);
}
}
return filteredCourses;
}
use of androidx.annotation.VisibleForTesting in project android-testing by googlesamples.
the class ContactsActivity method createResultData.
@VisibleForTesting
static Intent createResultData(String phoneNumber) {
final Intent resultData = new Intent();
resultData.putExtra(KEY_PHONE_NUMBER, phoneNumber);
return resultData;
}
use of androidx.annotation.VisibleForTesting in project quickstart-android by firebase.
the class MainActivity method buildDeepLink.
// [END on_create]
/**
* Build a Firebase Dynamic Link.
* https://firebase.google.com/docs/dynamic-links/android/create#create-a-dynamic-link-from-parameters
*
* @param deepLink the deep link your app will open. This link must be a valid URL and use the
* HTTP or HTTPS scheme.
* @param minVersion the {@code versionCode} of the minimum version of your app that can open
* the deep link. If the installed app is an older version, the user is taken
* to the Play store to upgrade the app. Pass 0 if you do not
* require a minimum version.
* @return a {@link Uri} representing a properly formed deep link.
*/
@VisibleForTesting
public Uri buildDeepLink(@NonNull Uri deepLink, int minVersion) {
String uriPrefix = getString(R.string.dynamic_links_uri_prefix);
// Set dynamic link parameters:
// * URI prefix (required)
// * Android Parameters (required)
// * Deep link
// [START build_dynamic_link]
DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance().createDynamicLink().setDomainUriPrefix(uriPrefix).setAndroidParameters(new DynamicLink.AndroidParameters.Builder().setMinimumVersion(minVersion).build()).setLink(deepLink);
// Build the dynamic link
DynamicLink link = builder.buildDynamicLink();
// Return the dynamic link as a URI
return link.getUri();
}
use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.
the class MetadataRetriever method retrieveMetadata.
@VisibleForTesting
static /* package */
ListenableFuture<TrackGroupArray> retrieveMetadata(Context context, MediaItem mediaItem, Clock clock) {
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory().setMp4ExtractorFlags(Mp4Extractor.FLAG_READ_MOTION_PHOTO_METADATA | Mp4Extractor.FLAG_READ_SEF_DATA);
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(context, extractorsFactory);
return retrieveMetadata(mediaSourceFactory, mediaItem, clock);
}
Aggregations