Java Code Examples for android.widget.ListView.setEmptyView()

The following are Jave code examples for showing how to use setEmptyView() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: searchablespinner   File: SearchableSpinner.java   View Source Code Vote up 7 votes
public SearchableSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mContext = context;
    getAttributeSet(attrs, defStyleAttr, defStyleRes);

    final LayoutInflater factory = LayoutInflater.from(context);
    factory.inflate(R.layout.view_searchable_spinner, this, true);

    mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
    mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
    if (mListItemDivider != null) {
        mSpinnerListView.setDivider(mListItemDivider);
        mSpinnerListView.setDividerHeight(mListDividerSize);
    }
    mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
    mSpinnerListView.setEmptyView(mEmptyTextView);
}
 
Example 2
Project: GravityBox   File: OngoingNotifPreference.java   View Source Code Vote up 6 votes
@Override
protected void onBindDialogView(View view) {
    mListView = (ListView) view.findViewById(R.id.icon_list);
    mListView.setOnItemClickListener(this);
    mListView.setEmptyView(view.findViewById(R.id.info_list_empty));

    mBtnResetList = (Button) view.findViewById(R.id.btnReset);
    mBtnResetList.setOnClickListener(this);

    mDescription = (TextView) view.findViewById(R.id.description);
    mDivider = (View) view.findViewById(R.id.divider);

    super.onBindView(view);

    setData();
}
 
Example 3
Project: wirtualnaApteczka   File: MedicinesFamilyListTabFragment.java   View Source Code Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.family_tab_medicines_list, container, false);
    medicineFamilyListView = (ListView) view.findViewById(R.id.medicine_family_list_view);
    medicineFamilyListView.setEmptyView(view.findViewById(R.id.medicine_family_list_empty));

    searchMedicineBtn = (FloatingActionButton) view.findViewById(R.id.search_medicines_family_btn);
    searchMedicineBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SearchMedicineDialogHelper searchMedicineDialogHelper = new SearchMedicineDialogHelper();
            searchMedicineDialogHelper.initializeSearchFamilyMedicineDialog(MedicinesFamilyListTabFragment.this);
        }
    });

    Map<String, User> userIdToUserObjMap = SessionManager.getFamilyUserMembers();
    List<User> familyUsers = new ArrayList<>(userIdToUserObjMap.values());

    List<Medicine> sharedMedicinesFromFamilyMembers = prepareSharedMedicinesFromFamilyMembers(familyUsers);
    FamilyMedicineItemArrayAdapter familyMedicineItemArrayAdapter = new FamilyMedicineItemArrayAdapter(getContext(), R.id.medicine_family_list_view, sharedMedicinesFromFamilyMembers);
    medicineFamilyListView.setAdapter(familyMedicineItemArrayAdapter);

    initializeFirebaseListeners();

    return view;
}
 
Example 4
Project: GravityBox   File: QsDetailItemsList.java   View Source Code Vote up 6 votes
private QsDetailItemsList(LinearLayout view) {
    mView = view;

    mListView = (ListView) mView.findViewById(android.R.id.list);
    mListView.setOnTouchListener(new OnTouchListener() {
        // Setting on Touch Listener for handling the touch inside ScrollView
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });
    mEmpty = mView.findViewById(android.R.id.empty);
    mEmpty.setVisibility(View.GONE);
    mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
    mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
    mListView.setEmptyView(mEmpty);
}
 
Example 5
Project: QuranAndroid   File: PartsFragment.java   View Source Code Vote up 6 votes
/**
 * Init views in the fragment
 *
 * @param rootView Fragment view
 */
private void init(View rootView) {

    Soras = new ArrayList<Sora>();
    adapter = new PartShowAdapter(getActivity(), Soras);
    partsList = (ListView) rootView.findViewById(R.id.listView);
    partsList.setEmptyView(rootView.findViewById(R.id.progressBar3));
    partsList.setAdapter(adapter);
    partsList.setActivated(true);
    partsList.setOnItemClickListener(this);

    adapter.addAll(MainActivity.soraListModified);
    adapter.notifyDataSetChanged();


}
 
Example 6
Project: zabbkit-android   File: HostActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_hosts);

    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.view_logo);

    mHostsListView = (ListView) findViewById(R.id.hosts_listview);
    mHostsListView.setEmptyView(findViewById(R.id.empty_hosts_textview));
    registerForContextMenu(mHostsListView);
    mHostsListView.setOnItemClickListener(this);

    hostsAdapter = new HostsCursorAdapter(HostActivity.this, null, true);
    mHostsListView.setAdapter(hostsAdapter);
    getSupportLoaderManager().initLoader(0, null, this);
}
 
Example 7
Project: zabbkit-android   File: BookmarksFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fr_bookmarks_list, container,
            false);

    mBookmarksListView = (ListView) rootView
            .findViewById(R.id.bookmarks_list);
    mBookmarksListView.setEmptyView(rootView
            .findViewById(R.id.empty_bookmarks_textview));
    mBookmarksListView.setOnItemClickListener(this);

    return rootView;
}
 
Example 8
Project: android_ui   File: BaseSamplesListFragment.java   View Source Code Vote up 5 votes
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
	super.onViewCreated(view, savedInstanceState);
	final ListView listView = findAdapterView();
	listView.setEmptyView(getEmptyView());
	listView.setOnItemClickListener(this);
}
 
Example 9
Project: QuranAndroid   File: SearchActivity.java   View Source Code Vote up 5 votes
/**
 * Function to init views
 */
private void init() {
       Intent intent = getIntent();
       searchText = intent.getStringExtra(AppConstants.General.SEARCH_TEXT);
       Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
       toolbar.setTitle(getString(R.string.search));
       setSupportActionBar(toolbar);
       getSupportActionBar().setDisplayHomeAsUpEnabled(true);
       getSupportActionBar().setDisplayShowHomeEnabled(true);

       resultsInfo = (TextView) findViewById(R.id.textView13);
       ayas = new ArrayList<Aya>();

       searchResults = (ListView) findViewById(R.id.listView3);
       searchResults.setOnItemClickListener(this);
       searchResults.setEmptyView(findViewById(R.id.progressBar3));
    if(searchText.contains("%")||searchText.contains("%")||searchText.contains("%")||searchText.contains("_")||searchText.contains("@")||searchText.contains("$")||searchText.contains(" % ")||searchText.contains("^")||searchText.contains("&")||searchText.contains("*")||searchText.contains("(")||searchText.contains(")")||searchText.contains("-")||searchText.contains("?")||searchText.contains(">")||searchText.contains("<")||searchText.contains("'")||searchText.contains(":")||searchText.contains(";")||searchText.contains("+")||searchText.contains("=")||searchText.contains("/")||searchText.contains("_")||searchText.contains(".")||searchText.contains(",")||searchText.contains("`")){
        resultsInfo.setText("  0 results for : "+searchText);
            findViewById(R.id.progressBar3).setVisibility(View.GONE);
            searchResults.setEmptyView(findViewById(R.id.empty));
    }else{
        adapter = new SearchShowAdapter(this, searchText, ayas);
       searchResults.setAdapter(adapter);

        new SearchResults().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

}
}
 
Example 10
Project: QuranAndroid   File: TranslationsActivity.java   View Source Code Vote up 5 votes
/**
 * Function to init activity view
 */
private void init() {

    //init views
    adapter = new TranslationAdapter(this);
    translationManagmentList = (ListView) findViewById(R.id.download);
    translationManagmentList.setOnItemClickListener(this);
    translationManagmentList.setTextFilterEnabled(true);
    translationManagmentList.setEmptyView(findViewById(R.id.progressBar3));
    translationManagmentList.setAdapter(adapter);

    //async thread to load translations
    new TafaseerLists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 11
Project: aos-Video   File: AutoScraperActivity.java   View Source Code Vote up 4 votes
@Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
        getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

        // Notify the application that the activity has started
        CustomApplication app = (CustomApplication)getApplication();
        app.setAutoScraperActive(true);
        mScraper = new Scraper(this);

        // Check if the intent which created this activity contains a folder path
        Uri folderUri = getIntent().getData();
        if (folderUri != null) {
            mFolderMode = true;
            // FIXME: this is broken for smb:// files
            mFolderPath = folderUri.getPath();
            if (DBG) Log.d(TAG, "onCreate : search in folder " + mFolderPath);
        }
        else {
            mFolderMode = false;
            mFolderPath = null;
            if (DBG) Log.d(TAG, "onCreate : search in the full database");
        }

        setContentView(R.layout.auto_scraper_main);

        mMainView = findViewById(R.id.main_view);
        mAbortButton = (Button)findViewById(R.id.abort_button);
        mAbortButton.setOnClickListener(this);
        mExitButton = (Button)findViewById(R.id.exit_button);
        mExitButton.setOnClickListener(this);

        mListView = (ListView) findViewById(R.id.list_items);
        mListView.setTextFilterEnabled(true);
        mListView.setCacheColorHint(0);
        mListView.setSelector(R.drawable.list_selector_no_background);
        mListView.setOnCreateContextMenuListener(this);
        mListView.setOnScrollListener(this);
        mListView.setOnKeyListener(this);

        mActivityFileCursor = getFileListCursor();
        getColumnIndices(mActivityFileCursor);
        buildFileProperties(mActivityFileCursor);
        mAdapterFileCursor = buildAdapterCursor(mActivityFileCursor);

        mAdapter = new AutoScraperAdapter(getApplication(), this,
                                          R.layout.auto_scraper_item,
                                          mAdapterFileCursor);
        mListView.setAdapter(mAdapter);
/*
        if (!mListView.isInTouchMode()) {
            // The application is remotely controlled => set the focus by default
            // on the Cancel button so that the user can abort the task with a 
            // single click instead of navigating the full ListView
            mAbortButton.requestFocus();
        }
*/
        mEmptyView = buildEmptyView();
        mListView.setEmptyView(mEmptyView);
        updateControlButtons(false);
        if (mFileCount > 0) {
            mMainView.setVisibility(View.VISIBLE);
        }
        else {
            mMainView.setVisibility(View.GONE);
        }

        mIsLargeScreen = getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)|| TVUtils.isTV(this);

        PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "AutoScraperActivity");
    }
 
Example 12
Project: BlackList   File: SMSConversationsListFragment.java   View Source Code Vote up 4 votes
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // notify user if permission isn't granted
    Permissions.notifyIfNotGranted(getContext(), Permissions.READ_SMS);
    Permissions.notifyIfNotGranted(getContext(), Permissions.READ_CONTACTS);

    // cursor adapter
    cursorAdapter = new SMSConversationsListCursorAdapter(getContext());
    // on row click listener (receives clicked row)
    cursorAdapter.setOnClickListener(new OnRowClickListener());
    // on row long click listener (receives clicked row)
    cursorAdapter.setOnLongClickListener(new OnRowLongClickListener());

    // add cursor listener to the list
    listView = (ListView) view.findViewById(R.id.rows_list);
    listView.setAdapter(cursorAdapter);

    // on list empty comment
    TextView textEmptyView = (TextView) view.findViewById(R.id.text_empty);
    listView.setEmptyView(textEmptyView);

    // init internal broadcast event receiver
    internalEventBroadcast = new InternalEventBroadcast() {
        // SMS was written
        @Override
        public void onSMSWasWritten(String phoneNumber) {
            ContactsAccessHelper db = ContactsAccessHelper.getInstance(getContext());
            int threadId = db.getSMSThreadIdByNumber(getContext(), phoneNumber);
            if (threadId >= 0 &&
                    // refresh cached list view items
                    cursorAdapter.invalidateCache(threadId)) {
                cursorAdapter.notifyDataSetChanged();
            } else {
                // reload all list view items
                loadListViewItems(false, false);
            }
        }

        // SMS was deleted
        @Override
        public void onSMSWasDeleted(String phoneNumber) {
            // reload all list view items
            loadListViewItems(false, false);
        }

        // SMS thread was read
        @Override
        public void onSMSThreadWasRead(int threadId) {
            // refresh cached list view items
            cursorAdapter.invalidateCache(threadId);
            cursorAdapter.notifyDataSetChanged();
        }
    };
    internalEventBroadcast.register(getContext());

    // load SMS conversations to the list
    loadListViewItems(listPosition, true, true);
}
 
Example 13
Project: Quake-report   File: EarthquakeActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.earthquake_activity);

    // Find a reference to the {@link ListView} in the layout
    ListView earthquakeListView = (ListView) findViewById(R.id.list);

    mEmptyStateTextView = (TextView) findViewById(R.id.empty_view);
    earthquakeListView.setEmptyView(mEmptyStateTextView);

    // Create a new adapter that takes an empty list of earthquakes as input
    mAdapter = new EarthquakeAdapter(this, new ArrayList<Earthquake>());

    // Set the adapter on the {@link ListView}
    // so the list can be populated in the user interface
    earthquakeListView.setAdapter(mAdapter);

    // Set an item click listener on the ListView, which sends an intent to a web browser
    // to open a website with more information about the selected earthquake.
    earthquakeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // Find the current earthquake that was clicked on
            Earthquake currentEarthquake = (Earthquake) mAdapter.getItem(position);

            // Convert the String URL into a URI object (to pass into the Intent constructor)
            Uri earthquakeUri = Uri.parse(currentEarthquake.getUrl());

            // Create a new intent to view the earthquake URI
            Intent websiteIntent = new Intent(Intent.ACTION_VIEW, earthquakeUri);

            // Send the intent to launch a new activity
            startActivity(websiteIntent);
        }
    });

    // Get a reference to the ConnectivityManager to check state of network connectivity
    ConnectivityManager connMgr = (ConnectivityManager)
            getSystemService(Context.CONNECTIVITY_SERVICE);

    // Get details on the currently active default data network
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    // If there is a network connection, fetch data
    if (networkInfo != null && networkInfo.isConnected()) {
        // Get a reference to the LoaderManager, in order to interact with loaders.
        LoaderManager loaderManager = getLoaderManager();

        // Initialize the loader. Pass in the int ID constant defined above and pass in null for
        // the bundle. Pass in this activity for the LoaderCallbacks parameter (which is valid
        // because this activity implements the LoaderCallbacks interface).
        loaderManager.initLoader(EARTHQUAKE_LOADER_ID, null, this);
    } else {
        // Otherwise, display error
        // First, hide loading indicator so error message will be visible
        View loadingIndicator = findViewById(R.id.loading_indicator);
        loadingIndicator.setVisibility(View.GONE);

        // Update empty state with no connection error message
        mEmptyStateTextView.setText(R.string.no_internet_connection);
    }
}
 
Example 14
Project: Samachar-App   File: GeneralFragment.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    // Inflate the layout for this fragment
    rootView = inflater.inflate(R.layout.layout, container, false);

    loadingIndicator = (ProgressBar)rootView.findViewById(R.id.loading_indicator);


    // Find a reference to the {@link ListView} in the layout
    ListView newsListView = (ListView) rootView.findViewById(R.id.list);

    mEmptyStateTextView = (TextView) rootView.findViewById(R.id.empty_view);
    newsListView.setEmptyView(mEmptyStateTextView);

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    mAdapter = new NewsAdapter(getActivity(), new ArrayList<News>());


    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    newsListView.setAdapter(mAdapter);

    // Set an item click listener on the ListView, which sends an intent to a web browser
    // to open a website with more information about the selected earthquake.
    newsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // Find the current earthquake that was clicked on
            News currentEarthquake = mAdapter.getItem(position);

            // Convert the String URL into a URI object (to pass into the Intent constructor)
            Uri newsUri = Uri.parse(currentEarthquake.getUrl());

            // Create a new intent to view the earthquake URI
            Intent websiteIntent = new Intent(Intent.ACTION_VIEW, newsUri);

            // Send the intent to launch a new activity
            startActivity(websiteIntent);
        }
    });

    // Get a reference to the ConnectivityManager to check state of network connectivity
    ConnectivityManager connMgr = (ConnectivityManager)
            getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

    // Get details on the currently active default data network
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    // If there is a network connection, fetch data
    if (networkInfo != null && networkInfo.isConnected()) {

        loadingIndicator.setVisibility(View.VISIBLE);
        // Get a reference to the LoaderManager, in order to interact with loaders.
        LoaderManager loaderManager = getLoaderManager();
        // Initialize the loader. Pass in the int ID constant defined above and pass in null for
        // the bundle. Pass in this activity for the LoaderCallbacks parameter (which is valid
        // because this activity implements the LoaderCallbacks interface).
        loaderManager.initLoader(GENERAL_LOADER_ID, null, this);
    } else {
        // Otherwise, display error
        // First, hide loading indicator so error message will be visible
     //   View loadingIndicator = rootView.findViewById(R.id.loading_indicator);
        loadingIndicator.setVisibility(View.GONE);

        // Update empty state with no connection error message
        mEmptyStateTextView.setText(R.string.no_internet_connection);
    }
    return rootView;
}
 
Example 15
Project: quake-alert-android-app   File: QuakeActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    String themes = sharedPrefs.getString(
            getString(R.string.settings_themes_key),
            getString(R.string.settings_themes_default));
    switch (themes) {
        case "dark":
            setTheme(R.style.AppTheme);

            break;
        case "light":
            setTheme(R.style.AppTheme_Light);
            break;
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quake);
    dialog = new Dialog(this);
    Boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE)
            .getBoolean("isFirstRun", true);

    if (isFirstRun) {

        dialog.setContentView(R.layout.instruction_dialog);

        dialog.show();

        getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit()
                .putBoolean("isFirstRun", false).apply();
    }

    listView = (ListView) findViewById(R.id.listView);
    progressBar = (ProgressBar) findViewById(R.id.pbar);
    emptyView = (TextView) findViewById(R.id.empty_view);
    emptyDesc = (TextView) findViewById(R.id.empty_view_desc);
    emptyImageView = (ImageView) findViewById(R.id.empty_imageview);
    mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    listView.setEmptyView(emptyView);
    listView.setEmptyView(emptyImageView);
    listView.setEmptyView(emptyDesc);
    loaderManager = getLoaderManager();
    mySwipeRefreshLayout.setOnRefreshListener(
            new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                    loaderManager.restartLoader(0, null, QuakeActivity.this);
                }
            }
    );


    if (googleServicesAvailable()) {
        checkConnection();
        if (networkInfo != null && networkInfo.isConnected()) {
            loaderManager.initLoader(0, null, QuakeActivity.this);
        } else {
            progressBar.setVisibility(View.GONE);
            emptyView.setText(R.string.noInternet);
            emptyDesc.setText(R.string.emptyDesc);
            emptyImageView.setImageResource(R.drawable.no_connection);
        }

    }

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            checkConnection();
            if (networkInfo != null && networkInfo.isConnected()) {
                Intent intent = new Intent(QuakeActivity.this, MapsActivity.class);
                startActivity(intent);
            } else {
                Toast.makeText(QuakeActivity.this, "No Internet Connection. Please Check your connectivity and try again.",Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
Example 16
Project: Botanist   File: SimilarPlantsController.java   View Source Code Vote up 4 votes
@Override
public void load() {
    ListView list = getActivity().findViewById(R.id.similar_plants);
    list.setEmptyView(getActivity().findViewById(R.id.empty_list_view));
    populateSimilarPlantsList(list);
}
 
Example 17
Project: Samachar-App   File: SportsFragment.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    // Inflate the layout for this fragment
    rootView = inflater.inflate(R.layout.layout, container, false);

    // Find a reference to the {@link ListView} in the layout
    ListView newsListView = (ListView) rootView.findViewById(R.id.list);

    mEmptyStateTextView = (TextView) rootView.findViewById(R.id.empty_view);
    newsListView.setEmptyView(mEmptyStateTextView);

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    mAdapter = new NewsAdapter(getActivity(), new ArrayList<News>());


    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    newsListView.setAdapter(mAdapter);

    // Set an item click listener on the ListView, which sends an intent to a web browser
    // to open a website with more information about the selected earthquake.
    newsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // Find the current earthquake that was clicked on
            News currentEarthquake = mAdapter.getItem(position);

            // Convert the String URL into a URI object (to pass into the Intent constructor)
            Uri newsUri = Uri.parse(currentEarthquake.getUrl());

            // Create a new intent to view the earthquake URI
            Intent websiteIntent = new Intent(Intent.ACTION_VIEW, newsUri);

            // Send the intent to launch a new activity
            startActivity(websiteIntent);
        }
    });

    // Get a reference to the ConnectivityManager to check state of network connectivity
    ConnectivityManager connMgr = (ConnectivityManager)
            getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

    // Get details on the currently active default data network
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    // If there is a network connection, fetch data
    if (networkInfo != null && networkInfo.isConnected()) {
        // Get a reference to the LoaderManager, in order to interact with loaders.
        LoaderManager loaderManager = getLoaderManager();
        // Initialize the loader. Pass in the int ID constant defined above and pass in null for
        // the bundle. Pass in this activity for the LoaderCallbacks parameter (which is valid
        // because this activity implements the LoaderCallbacks interface).
        loaderManager.initLoader(SPORTS_LOADER_ID, null, this);
    } else {
        // Otherwise, display error
        // First, hide loading indicator so error message will be visible
        View loadingIndicator = rootView.findViewById(R.id.loading_indicator);
        loadingIndicator.setVisibility(View.GONE);

        // Update empty state with no connection error message
        mEmptyStateTextView.setText(R.string.no_internet_connection);
    }
    return rootView;
}
 
Example 18
Project: chromium-for-android-56-debug-video   File: ListUrlsActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.physical_web_list_urls_activity);

    initSharedPreferences();

    mAdapter = new NearbyUrlsAdapter(this);

    View emptyView = findViewById(R.id.physical_web_empty);
    mListView = (ListView) findViewById(R.id.physical_web_urls_list);
    mListView.setEmptyView(emptyView);
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(this);

    mEmptyListText = (TextView) findViewById(R.id.physical_web_empty_list_text);

    mScanningImageView = (ImageView) findViewById(R.id.physical_web_logo);

    mSwipeRefreshWidget =
            (SwipeRefreshWidget) findViewById(R.id.physical_web_swipe_refresh_widget);
    mSwipeRefreshWidget.setOnRefreshListener(this);

    mBottomBar = findViewById(R.id.physical_web_bottom_bar);

    int shadowColor = ApiCompatibilityUtils.getColor(getResources(),
            R.color.bottom_bar_shadow_color);
    FadingShadowView shadow =
            (FadingShadowView) findViewById(R.id.physical_web_bottom_bar_shadow);
    shadow.init(shadowColor, FadingShadow.POSITION_BOTTOM);

    View bottomBarClose = (View) findViewById(R.id.physical_web_bottom_bar_close);
    bottomBarClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideBottomBar();
        }
    });

    mPwsClient = new PwsClientImpl(this);
    int referer = getIntent().getIntExtra(REFERER_KEY, 0);
    if (savedInstanceState == null) {  // Ensure this is a newly-created activity.
        PhysicalWebUma.onActivityReferral(this, referer);
    }
    mIsInitialDisplayRecorded = false;
    mIsRefreshing = false;
    mIsRefreshUserInitiated = false;
    mNearbyForegroundSubscription = new NearbyForegroundSubscription(this);
}
 
Example 19
Project: orgzly-android   File: FilterSelectDialogActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.activity_filter_select_dialog);

    /* Create adapter using Cursor. */
    mListAdapter = FiltersFragment.Companion.createFilterCursorAdapter(this);

    ListView list = (ListView) findViewById(R.id.filter_select_list);

    list.setAdapter(mListAdapter);

    list.setEmptyView(findViewById(R.id.filter_select_no_filters));

    list.setOnItemClickListener(this);

    getSupportLoaderManager().initLoader(0, null, this);
}
 
Example 20
Project: IM_Here   File: FriendsListFragment.java   View Source Code Vote up 3 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {


    View rootView = inflater.inflate(R.layout.fragment_friends_list, container, false);

    ListView friendsListGridView = (ListView) rootView.findViewById(R.id.user_friend_list);
    View emptyView = rootView.findViewById(R.id.friend_list_empty_frame);

    friendsListGridView.setEmptyView(emptyView);

    friendsListSwipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.friends_list_swipe_refresh);

    if(friendsListSwipeRefresh != null) {
        friendsListSwipeRefresh.setColorSchemeResources(R.color.active_tab);
        friendsListSwipeRefresh.setOnRefreshListener(swipeRefreshListener);
    }

    friendsAccountList = new ArrayList<>();
    userFriendsListAdapter = new UserPropertiesAdapter(getContext(),this);

    // setAdapter ..
    friendsListGridView.setAdapter(userFriendsListAdapter);

    return rootView;
}