use of androidx.annotation.Nullable in project fresco by facebook.
the class DraweeScaleTypeFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_drawee_scale_type, container, false);
final ImageUriProvider imageUriProvider = sampleUris();
final Uri uri1 = imageUriProvider.createSampleUri(ImageUriProvider.ImageSize.M, ImageUriProvider.Orientation.LANDSCAPE);
final Uri uri2 = imageUriProvider.createSampleUri(ImageUriProvider.ImageSize.M, ImageUriProvider.Orientation.PORTRAIT);
mDraweeTop1 = (SimpleDraweeView) view.findViewById(R.id.drawee_view_top_1);
mDraweeTop2 = (SimpleDraweeView) view.findViewById(R.id.drawee_view_top_2);
mDraweeMain = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
mSpinner = (Spinner) view.findViewById(R.id.spinner);
mDraweeTop1.setImageURI(uri1);
mDraweeTop1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeMainDraweeUri(uri1);
}
});
mDraweeTop2.setImageURI(uri2);
mDraweeTop2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeMainDraweeUri(uri2);
}
});
changeMainDraweeUri(uri1);
final SimpleScaleTypeAdapter adapter = SimpleScaleTypeAdapter.createForAllScaleTypes();
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
final SimpleScaleTypeAdapter.Entry spinnerEntry = (SimpleScaleTypeAdapter.Entry) adapter.getItem(position);
changeMainDraweeScaleType(spinnerEntry.scaleType, spinnerEntry.focusPoint);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
mSpinner.setSelection(0);
return view;
}
use of androidx.annotation.Nullable in project Tusky by Vavassor.
the class NotificationsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_timeline_notifications, container, false);
// from inflater to silence warning
@NonNull Context context = inflater.getContext();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
boolean showNotificationsFilterSetting = preferences.getBoolean("showNotificationsFilter", true);
// Clear notifications on filter visibility change to force refresh
if (showNotificationsFilterSetting != showNotificationsFilter)
notifications.clear();
showNotificationsFilter = showNotificationsFilterSetting;
// Setup the SwipeRefreshLayout.
swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
recyclerView = rootView.findViewById(R.id.recyclerView);
progressBar = rootView.findViewById(R.id.progressBar);
statusView = rootView.findViewById(R.id.statusView);
appBarOptions = rootView.findViewById(R.id.appBarOptions);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
loadNotificationsFilter();
// Setup the RecyclerView.
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAccessibilityDelegateCompat(new ListStatusAccessibilityDelegate(recyclerView, this, (pos) -> {
NotificationViewData notification = notifications.getPairedItemOrNull(pos);
// We support replies only for now
if (notification instanceof NotificationViewData.Concrete) {
return ((NotificationViewData.Concrete) notification).getStatusViewData();
} else {
return null;
}
}));
recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
StatusDisplayOptions statusDisplayOptions = new StatusDisplayOptions(preferences.getBoolean("animateGifAvatars", false), accountManager.getActiveAccount().getMediaPreviewEnabled(), preferences.getBoolean("absoluteTimeView", false), preferences.getBoolean("showBotOverlay", true), preferences.getBoolean("useBlurhash", true), CardViewMode.NONE, preferences.getBoolean("confirmReblogs", true), preferences.getBoolean("confirmFavourites", false), preferences.getBoolean(PrefKeys.WELLBEING_HIDE_STATS_POSTS, false), preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false));
adapter = new NotificationsAdapter(accountManager.getActiveAccount().getAccountId(), dataSource, statusDisplayOptions, this, this, this);
alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
recyclerView.setAdapter(adapter);
topLoading = false;
bottomLoading = false;
bottomId = null;
updateAdapter();
Button buttonClear = rootView.findViewById(R.id.buttonClear);
buttonClear.setOnClickListener(v -> confirmClearNotifications());
buttonFilter = rootView.findViewById(R.id.buttonFilter);
buttonFilter.setOnClickListener(v -> showFilterMenu());
if (notifications.isEmpty()) {
swipeRefreshLayout.setEnabled(false);
sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1);
} else {
progressBar.setVisibility(View.GONE);
}
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
updateFilterVisibility();
return rootView;
}
use of androidx.annotation.Nullable in project CustomActivityOnCrash by Ereza.
the class CustomActivityOnCrash method getErrorActivityClassWithIntentFilter.
/**
* INTERNAL method used to get the first activity with an intent-filter <action android:name="cat.ereza.customactivityoncrash.ERROR" />,
* If there is no activity with that intent filter, this returns null.
*
* @param context A valid context. Must not be null.
* @return A valid activity class, or null if no suitable one is found
*/
@SuppressWarnings("unchecked")
@Nullable
private static Class<? extends Activity> getErrorActivityClassWithIntentFilter(@NonNull Context context) {
Intent searchedIntent = new Intent().setAction(INTENT_ACTION_ERROR_ACTIVITY).setPackage(context.getPackageName());
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(searchedIntent, PackageManager.GET_RESOLVED_FILTER);
if (resolveInfos.size() > 0) {
ResolveInfo resolveInfo = resolveInfos.get(0);
try {
return (Class<? extends Activity>) Class.forName(resolveInfo.activityInfo.name);
} catch (ClassNotFoundException e) {
// Should not happen, print it to the log!
Log.e(TAG, "Failed when resolving the error activity class via intent filter, stack trace follows!", e);
}
}
return null;
}
use of androidx.annotation.Nullable in project CustomActivityOnCrash by Ereza.
the class CustomActivityOnCrash method getBuildDateAsString.
/**
* INTERNAL method that returns the build date of the current APK as a string, or null if unable to determine it.
*
* @param context A valid context. Must not be null.
* @param dateFormat DateFormat to use to convert from Date to String
* @return The formatted date, or "Unknown" if unable to determine it.
*/
@Nullable
private static String getBuildDateAsString(@NonNull Context context, @NonNull DateFormat dateFormat) {
long buildDate;
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
ZipFile zf = new ZipFile(ai.sourceDir);
// If this failed, try with the old zip method
ZipEntry ze = zf.getEntry("classes.dex");
buildDate = ze.getTime();
zf.close();
} catch (Exception e) {
buildDate = 0;
}
if (buildDate > 312764400000L) {
return dateFormat.format(new Date(buildDate));
} else {
return null;
}
}
use of androidx.annotation.Nullable in project kdeconnect-android by KDE.
the class MprisNowPlayingFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (activityMprisBinding == null) {
activityMprisBinding = MprisNowPlayingBinding.inflate(inflater);
mprisControlBinding = activityMprisBinding.mprisControl;
String targetPlayerName = "";
Intent activityIntent = requireActivity().getIntent();
activityIntent.getStringExtra("player");
activityIntent.removeExtra("player");
if (TextUtils.isEmpty(targetPlayerName)) {
if (savedInstanceState != null) {
targetPlayerName = savedInstanceState.getString("targetPlayer");
}
}
deviceId = requireArguments().getString(MprisPlugin.DEVICE_ID_KEY);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
String interval_time_str = prefs.getString(getString(R.string.mpris_time_key), getString(R.string.mpris_time_default));
final int interval_time = Integer.parseInt(interval_time_str);
BackgroundService.RunCommand(requireContext(), service -> service.addConnectionListener(connectionReceiver));
connectToPlugin(targetPlayerName);
performActionOnClick(mprisControlBinding.loopButton, p -> {
switch(p.getLoopStatus()) {
case "None":
p.setLoopStatus("Track");
break;
case "Track":
p.setLoopStatus("Playlist");
break;
case "Playlist":
p.setLoopStatus("None");
break;
}
});
performActionOnClick(mprisControlBinding.playButton, MprisPlugin.MprisPlayer::playPause);
performActionOnClick(mprisControlBinding.shuffleButton, p -> p.setShuffle(!p.getShuffle()));
performActionOnClick(mprisControlBinding.prevButton, MprisPlugin.MprisPlayer::previous);
performActionOnClick(mprisControlBinding.rewButton, p -> targetPlayer.seek(interval_time * -1));
performActionOnClick(mprisControlBinding.ffButton, p -> p.seek(interval_time));
performActionOnClick(mprisControlBinding.nextButton, MprisPlugin.MprisPlayer::next);
performActionOnClick(mprisControlBinding.stopButton, MprisPlugin.MprisPlayer::stop);
mprisControlBinding.volumeSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
BackgroundService.RunCommand(requireContext(), service -> {
if (targetPlayer == null)
return;
targetPlayer.setVolume(seekBar.getProgress());
});
}
});
positionSeekUpdateRunnable = () -> {
Context context = getContext();
// Fragment was already detached
if (context == null)
return;
BackgroundService.RunCommand(context, service -> {
if (targetPlayer != null) {
mprisControlBinding.positionSeek.setProgress((int) (targetPlayer.getPosition()));
}
positionSeekUpdateHandler.removeCallbacks(positionSeekUpdateRunnable);
positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 1000);
});
};
positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 200);
mprisControlBinding.positionSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean byUser) {
mprisControlBinding.progressTextview.setText(milisToProgress(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
positionSeekUpdateHandler.removeCallbacks(positionSeekUpdateRunnable);
}
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
BackgroundService.RunCommand(requireContext(), service -> {
if (targetPlayer != null) {
targetPlayer.setPosition(seekBar.getProgress());
}
positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 200);
});
}
});
mprisControlBinding.nowPlayingTextview.setSelected(true);
}
return activityMprisBinding.getRoot();
}
Aggregations