Search in sources :

Example 1 with ListAdapter

use of com.googletest.firebase.perf.testapp.ListAdapter in project firebase-android-sdk by firebase.

the class NotificationsFragment method onCreateView.

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    notificationsViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NotificationsViewModel.class);
    View root = inflater.inflate(R.layout.fragment_notifications, container, false);
    final TextView textView = root.findViewById(R.id.text_notifications);
    notificationsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {

        @Override
        public void onChanged(@Nullable String s) {
            textView.setText(s);
        }
    });
    // Gif loading for testing
    sharedViewModel = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);
    final ImageView imageView = root.findViewById(R.id.img_notifications);
    sharedViewModel.getImageSrc().observe(getViewLifecycleOwner(), new Observer<String>() {

        @Override
        public void onChanged(String s) {
            Glide.with(requireActivity()).load(s).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(imageView);
        }
    });
    // Recycler View setup
    RecyclerView numbersList = root.findViewById(R.id.rv_fragment_notifications);
    LinearLayoutManager layoutManager = new LinearLayoutManager(requireActivity());
    ListAdapter listAdapter = new ListAdapter(NUM_LIST_ITEMS);
    numbersList.setLayoutManager(layoutManager);
    numbersList.setHasFixedSize(true);
    numbersList.setAdapter(listAdapter);
    return root;
}
Also used : SharedViewModel(com.googletest.firebase.perf.testapp.SharedViewModel) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) ListAdapter(com.googletest.firebase.perf.testapp.ListAdapter) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 ListAdapter (com.googletest.firebase.perf.testapp.ListAdapter)1 SharedViewModel (com.googletest.firebase.perf.testapp.SharedViewModel)1