{ return new Api(); } @Module public final class DataModule { @Provides @Singleton public Api provideApi() { return new Api(); } } @Module public final class DebugDataModule { @Provides @Singleton Api provideApi() { return new DebugApi(); //Very heavy contains tons of dependecy like STETHO. } }
{ return new Api(); } @Module public final class DataModule { @Provides @Singleton public Api provideApi() { return new Api(); } } @Module public final class DebugDataModule { @Provides @Singleton Api provideApi() { return new DebugApi(); //Very heavy contains tons of dependecy like STETHO. } }
{ return new Api(); } @Module public final class DataModule { @Provides @Singleton public Api provideApi() { return new Api(); } } @Module public final class DebugDataModule { @Provides @Singleton Api provideApi() { return new DebugApi(); //Very heavy contains tons of dependecy like STETHO. } }
View convertView, ViewGroup parent ) { Contact contact = getItem(position); LayoutInflater inflater = LayoutInflater.from(getContext()); // This line is wrong, we're inflating a new view always instead of only if it's null. // For demonstration purposes, we will leave this here to show the resulting jank. convertView = inflater.inflate(R.layout.item_contact, parent, false); TextView contactName = (TextView) convertView.findViewById(R.id.contact_name); ImageView contactImage = (ImageView) convertView.findViewById(R.id.contact_image); contactName.setText(contact.getName()); // Let's just create another bitmap when we need one. This makes no attempts to re-use // bitmaps that were previously used in rendering past list view elements, causing a large // amount of memory to be consumed as you scroll farther down the list. Bitmap bm = BitmapFactory.decodeResource(convertView.getResources(), R.drawable.bbq); contactImage.setImageBitmap(bm); return convertView; }
View convertView, ViewGroup parent ) { Contact contact = getItem(position); LayoutInflater inflater = LayoutInflater.from(getContext()); // This line is wrong, we're inflating a new view always instead of only if it's null. // For demonstration purposes, we will leave this here to show the resulting jank. convertView = inflater.inflate(R.layout.item_contact, parent, false); TextView contactName = (TextView) convertView.findViewById(R.id.contact_name); ImageView contactImage = (ImageView) convertView.findViewById(R.id.contact_image); contactName.setText(contact.getName()); // Let's just create another bitmap when we need one. This makes no attempts to re-use // bitmaps that were previously used in rendering past list view elements, causing a large // amount of memory to be consumed as you scroll farther down the list. Bitmap bm = BitmapFactory.decodeResource(convertView.getResources(), R.drawable.bbq); contactImage.setImageBitmap(bm); return convertView; }
View convertView, ViewGroup parent ) { Contact contact = getItem(position); LayoutInflater inflater = LayoutInflater.from(getContext()); // This line is wrong, we're inflating a new view always instead of only if it's null. // For demonstration purposes, we will leave this here to show the resulting jank. convertView = inflater.inflate(R.layout.item_contact, parent, false); TextView contactName = (TextView) convertView.findViewById(R.id.contact_name); ImageView contactImage = (ImageView) convertView.findViewById(R.id.contact_image); contactName.setText(contact.getName()); // Let's just create another bitmap when we need one. This makes no attempts to re-use // bitmaps that were previously used in rendering past list view elements, causing a large // amount of memory to be consumed as you scroll farther down the list. Bitmap bm = BitmapFactory.decodeResource(convertView.getResources(), R.drawable.bbq); contactImage.setImageBitmap(bm); return convertView; }
throws InterruptedException { ListView listView = (ListView) mActivityRule.getActivity().findViewById(android.R.id.list); // Get last position and offset for zero-indexed position tracking. int lastPosition = listView.getAdapter().getCount() - 1; // Espresso method of scrolling to the last item. // onData(anything()).atPosition(lastPosition); // Standard Android method of scrolling to the last position. listView.smoothScrollToPositionFromTop(lastPosition, 0, SCROLL_TIME_IN_MILLIS); // Scrolling is performed asynchronously so we need to periodically loop and detect if // we're finished scrolling yet. This can be delayed by any work being done to display // data items in the ListView. while (listView.getLastVisiblePosition() != lastPosition) { Thread.sleep(300); } } @Rule public EnableTestTracing mEnableTestTracing = new EnableTestTracing(); @Rule public EnablePostTestDumpsys mEnablePostTestDumpsys = new EnablePostTestDumpsys(); @Rule public EnableLogcatDump mEnableLogcatDump = new EnableLogcatDump(); @Rule public EnableNetStatsDump mEnableNetStatsDump = new EnableNetStatsDump();
throws InterruptedException { ListView listView = (ListView) mActivityRule.getActivity().findViewById(android.R.id.list); // Get last position and offset for zero-indexed position tracking. int lastPosition = listView.getAdapter().getCount() - 1; // Espresso method of scrolling to the last item. // onData(anything()).atPosition(lastPosition); // Standard Android method of scrolling to the last position. listView.smoothScrollToPositionFromTop(lastPosition, 0, SCROLL_TIME_IN_MILLIS); // Scrolling is performed asynchronously so we need to periodically loop and detect if // we're finished scrolling yet. This can be delayed by any work being done to display // data items in the ListView. while (listView.getLastVisiblePosition() != lastPosition) { Thread.sleep(300); } } @Rule public EnableTestTracing mEnableTestTracing = new EnableTestTracing(); @Rule public EnablePostTestDumpsys mEnablePostTestDumpsys = new EnablePostTestDumpsys(); @Rule public EnableLogcatDump mEnableLogcatDump = new EnableLogcatDump(); @Rule public EnableNetStatsDump mEnableNetStatsDump = new EnableNetStatsDump();