use of androidx.annotation.Nullable in project ETSMobile-Android2 by ApplETS.
the class MoodleWebServiceTest method getValue.
private <T> T getValue(@NonNull LiveData<T> liveData) throws InterruptedException {
final Object[] data = new Object[1];
CountDownLatch latch = new CountDownLatch(1);
Observer<T> observer = new Observer<T>() {
@Override
public void onChanged(@Nullable T o) {
data[0] = o;
latch.countDown();
liveData.removeObserver(this);
}
};
liveData.observeForever(observer);
latch.await(TIME_OUT, TimeUnit.SECONDS);
// noinspection unchecked
return (T) data[0];
}
use of androidx.annotation.Nullable in project AntennaPod by AntennaPod.
the class SpecialThanksFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getListView().setDivider(null);
getListView().setSelector(android.R.color.transparent);
translatorsLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> {
ArrayList<SimpleIconListAdapter.ListItem> translators = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(getContext().getAssets().open("special_thanks.csv"), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
String[] info = line.split(";");
translators.add(new SimpleIconListAdapter.ListItem(info[0], info[1], info[2]));
}
emitter.onSuccess(translators);
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(translators -> setListAdapter(new SimpleIconListAdapter<>(getContext(), translators)), error -> Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show());
}
use of androidx.annotation.Nullable in project AntennaPod by AntennaPod.
the class DownloadStatisticsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.statistics_activity, container, false);
downloadStatisticsList = root.findViewById(R.id.statistics_list);
progressBar = root.findViewById(R.id.progressBar);
listAdapter = new DownloadStatisticsListAdapter(getContext());
downloadStatisticsList.setLayoutManager(new LinearLayoutManager(getContext()));
downloadStatisticsList.setAdapter(listAdapter);
return root;
}
use of androidx.annotation.Nullable in project AntennaPod by AntennaPod.
the class SearchFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.search_fragment, container, false);
setupToolbar(layout.findViewById(R.id.toolbar));
progressBar = layout.findViewById(R.id.progressBar);
recyclerView = layout.findViewById(R.id.recyclerView);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
adapter = new EpisodeItemListAdapter((MainActivity) getActivity());
recyclerView.setAdapter(adapter);
RecyclerView recyclerViewFeeds = layout.findViewById(R.id.recyclerViewFeeds);
LinearLayoutManager layoutManagerFeeds = new LinearLayoutManager(getActivity());
layoutManagerFeeds.setOrientation(RecyclerView.HORIZONTAL);
recyclerViewFeeds.setLayoutManager(layoutManagerFeeds);
adapterFeeds = new FeedSearchResultAdapter((MainActivity) getActivity());
recyclerViewFeeds.setAdapter(adapterFeeds);
emptyViewHandler = new EmptyViewHandler(getContext());
emptyViewHandler.attachToRecyclerView(recyclerView);
emptyViewHandler.setIcon(R.drawable.ic_search);
emptyViewHandler.setTitle(R.string.search_status_no_results);
emptyViewHandler.setMessage(R.string.type_to_search);
EventBus.getDefault().register(this);
chip = layout.findViewById(R.id.feed_title_chip);
chip.setOnCloseIconClickListener(v -> {
getArguments().putLong(ARG_FEED, 0);
searchWithProgressBar();
});
chip.setVisibility((getArguments().getLong(ARG_FEED, 0) == 0) ? View.GONE : View.VISIBLE);
chip.setText(getArguments().getString(ARG_FEED_NAME, ""));
if (getArguments().getString(ARG_QUERY, null) != null) {
search();
}
searchView.setOnQueryTextFocusChangeListener((view, hasFocus) -> {
if (hasFocus) {
showInputMethod(view.findFocus());
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(recyclerView.getWindowToken(), 0);
}
}
});
return layout;
}
use of androidx.annotation.Nullable in project Douya by DreaminginCodeZH.
the class BroadcastFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CustomTabsHelperFragment.attachTo(this);
mResource = BroadcastAndCommentListResource.attachTo(mBroadcastId, mBroadcast, this);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setTitle(getTitle());
activity.setSupportActionBar(mToolbar);
mContainerLayout.setOnClickListener(view -> onFinish());
ViewCompat.setTransitionName(mSharedView, Broadcast.makeTransitionName(mBroadcastId));
// This magically gives better visual effect when the broadcast is partially visible. Using
// setEnterSharedElementCallback() disables this hack when no transition is used to start
// this Activity.
ActivityCompat.setEnterSharedElementCallback(activity, new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
mBroadcastCommentList.scrollToPosition(0);
}
});
mToolbar.setOnDoubleClickListener(view -> {
mBroadcastCommentList.smoothScrollToPosition(0);
return true;
});
mSwipeRefreshLayout.setOnRefreshListener(() -> {
mResource.loadBroadcast();
mResource.loadCommentList(false);
});
mBroadcastCommentList.setHasFixedSize(true);
mBroadcastCommentList.setItemAnimator(new NoChangeAnimationItemAnimator());
mBroadcastCommentList.setLayoutManager(new LinearLayoutManager(activity));
mBroadcastAdapter = new SingleBroadcastAdapter(null, this);
// BroadcastLayout will take care of showing the effective broadcast.
// noinspection deprecation
setBroadcast(mResource.getBroadcast());
mCommentAdapter = new CommentAdapter(mResource.getCommentList(), (parent, itemView, item, position) -> onShowCommentAction(item));
mAdapter = new LoadMoreAdapter(mBroadcastAdapter, mCommentAdapter);
mBroadcastCommentList.setAdapter(mAdapter);
mBroadcastCommentList.addOnScrollListener(new OnVerticalScrollListener() {
public void onScrolledToBottom() {
mResource.loadCommentList(true);
}
});
mSendButton.setOnClickListener(view -> onSendComment());
TooltipUtils.setup(mSendButton);
View.OnLongClickListener sendTooltipListener = mSendButton.getOnLongClickListener();
mSendButton.setOnLongClickListener(view -> {
if (!Settings.LONG_CLICK_TO_SHOW_SEND_COMMENT_ACTIVITY.getValue()) {
return sendTooltipListener.onLongClick(view);
}
onShowSendCommentActivity();
return true;
});
updateSendCommentStatus();
if (savedInstanceState == null) {
if (mShowSendComment) {
TransitionUtils.postAfterTransition(this, this::onShowCommentIme);
}
}
TransitionUtils.setEnterReturnExplode(this);
TransitionUtils.setupTransitionOnActivityCreated(this);
}
Aggregations