use of com.googletest.firebase.perf.testapp.SharedViewModel in project firebase-android-sdk by firebase.
the class DashboardFragment method onCreateView.
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
dashboardViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(DashboardViewModel.class);
View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
final TextView textView = root.findViewById(R.id.text_dashboard);
dashboardViewModel.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_dashboard);
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);
}
});
return root;
}
use of com.googletest.firebase.perf.testapp.SharedViewModel 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;
}
use of com.googletest.firebase.perf.testapp.SharedViewModel in project firebase-android-sdk by firebase.
the class HomeFragment method onCreateView.
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
homeViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(HomeViewModel.class);
View root = inflater.inflate(R.layout.fragment_home, container, false);
final TextView textView = root.findViewById(R.id.text_home);
homeViewModel.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_home);
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);
}
});
return root;
}
Aggregations