use of com.android.settings.widget.LoadingViewController in project platform_packages_apps_Settings by BlissRoms.
the class DataUsageList method onViewCreated.
@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
super.onViewCreated(v, savedInstanceState);
mHeader = setPinnedHeaderView(R.layout.apps_filter_spinner);
mHeader.findViewById(R.id.filter_settings).setOnClickListener(btn -> {
final Bundle args = new Bundle();
args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, mTemplate);
startFragment(DataUsageList.this, BillingCycleSettings.class.getName(), R.string.billing_cycle, 0, args);
});
mCycleSpinner = mHeader.findViewById(R.id.filter_spinner);
mCycleAdapter = new CycleAdapter(mCycleSpinner.getContext(), new SpinnerInterface() {
@Override
public void setAdapter(CycleAdapter cycleAdapter) {
mCycleSpinner.setAdapter(cycleAdapter);
}
@Override
public void setOnItemSelectedListener(OnItemSelectedListener listener) {
mCycleSpinner.setOnItemSelectedListener(listener);
}
@Override
public Object getSelectedItem() {
return mCycleSpinner.getSelectedItem();
}
@Override
public void setSelection(int position) {
mCycleSpinner.setSelection(position);
}
}, mCycleListener, true);
mLoadingViewController = new LoadingViewController(getView().findViewById(R.id.loading_container), getListView());
mLoadingViewController.showLoadingViewDelayed();
}
use of com.android.settings.widget.LoadingViewController in project platform_packages_apps_Settings by BlissRoms.
the class ManageApplicationsTest method updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer.
@Test
public void updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer() {
final ManageApplications fragment = mock(ManageApplications.class);
ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
when(fragment.getActivity()).thenReturn(mock(Activity.class));
final Handler handler = mock(Handler.class);
final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
final LoadingViewController loadingViewController = mock(LoadingViewController.class);
ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
ReflectionHelpers.setField(adapter, "mFgHandler", handler);
// app loading not yet completed
ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", false);
adapter.updateLoading();
verify(loadingViewController).showLoadingViewDelayed();
}
use of com.android.settings.widget.LoadingViewController in project platform_packages_apps_Settings by BlissRoms.
the class ManageApplicationsTest method onRebuildComplete_shouldHideLoadingView.
@Test
public void onRebuildComplete_shouldHideLoadingView() {
final Context context = RuntimeEnvironment.application;
final ManageApplications fragment = mock(ManageApplications.class);
final View loadingContainer = mock(View.class);
when(loadingContainer.getContext()).thenReturn(context);
final View listContainer = mock(View.class);
when(listContainer.getVisibility()).thenReturn(View.INVISIBLE);
when(listContainer.getContext()).thenReturn(context);
ReflectionHelpers.setField(fragment, "mLoadingContainer", loadingContainer);
ReflectionHelpers.setField(fragment, "mListContainer", listContainer);
when(fragment.getActivity()).thenReturn(mock(Activity.class));
final Handler handler = mock(Handler.class);
final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
final LoadingViewController loadingViewController = mock(LoadingViewController.class);
ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
ReflectionHelpers.setField(adapter, "mFgHandler", handler);
ReflectionHelpers.setField(adapter, "mFilterMode", -1);
// app loading not yet completed
ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", false);
adapter.updateLoading();
// app loading completed
ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", true);
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
appList.add(mock(ApplicationsState.AppEntry.class));
when(mSession.getAllApps()).thenReturn(appList);
adapter.onRebuildComplete(null);
verify(loadingViewController).showContent(true);
}
use of com.android.settings.widget.LoadingViewController in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageApplicationsTest method updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer.
@Test
public void updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer() {
ReflectionHelpers.setField(mFragment, "mLoadingContainer", mock(View.class));
ReflectionHelpers.setField(mFragment, "mListContainer", mock(View.class));
final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, mFragment, AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
final LoadingViewController loadingViewController = mock(LoadingViewController.class);
ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
// app loading not yet completed
ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", false);
adapter.updateLoading();
verify(loadingViewController).showLoadingViewDelayed();
}
use of com.android.settings.widget.LoadingViewController in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageApplicationsTest method updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer.
@Test
public void updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer() {
ReflectionHelpers.setField(mFragment, "mLoadingContainer", mock(View.class));
ReflectionHelpers.setField(mFragment, "mListContainer", mock(View.class));
final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, mFragment, AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
final LoadingViewController loadingViewController = mock(LoadingViewController.class);
ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
// app loading completed
ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", true);
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
appList.add(mock(ApplicationsState.AppEntry.class));
when(mSession.getAllApps()).thenReturn(appList);
adapter.updateLoading();
verify(loadingViewController, never()).showLoadingViewDelayed();
}
Aggregations