Search in sources :

Example 6 with FunnyContent

use of forpdateam.ru.forpda.ui.views.FunnyContent in project ForPDA by RadiationX.

the class SearchFragment method onLoadData.

private void onLoadData(SearchResult searchResult) {
    setRefreshing(false);
    recyclerView.scrollToPosition(0);
    hidePopupWindows();
    data = searchResult;
    Log.d("SUKA", "SEARCH SIZE " + searchResult.getItems().size());
    if (data.getItems().isEmpty()) {
        if (!contentController.contains(ContentController.TAG_NO_DATA)) {
            FunnyContent funnyContent = new FunnyContent(getContext()).setImage(R.drawable.ic_search).setTitle(R.string.funny_search_nodata_title).setDesc(R.string.funny_search_nodata_desc);
            contentController.addContent(funnyContent, ContentController.TAG_NO_DATA);
        }
        contentController.showContent(ContentController.TAG_NO_DATA);
    } else {
        contentController.hideContent(ContentController.TAG_NO_DATA);
    }
    Log.d("SUKA", "" + data.getSettings().getResult() + " : " + data.getSettings().getResourceType());
    if (data.getSettings().getResult().equals(SearchSettings.RESULT_POSTS.first) && data.getSettings().getResourceType().equals(SearchSettings.RESOURCE_FORUM.first)) {
        for (int i = 0; i < refreshLayout.getChildCount(); i++) {
            if (refreshLayout.getChildAt(i) instanceof RecyclerView) {
                refreshLayout.removeViewAt(i);
                fixTargetView();
                break;
            }
        }
        if (refreshLayout.getChildCount() <= 1) {
            if (scrollButtonEnable) {
                fab.setVisibility(View.VISIBLE);
            }
            refreshLayout.addView(webView);
            Log.d(LOG_TAG, "add webview");
        }
        if (webViewClient == null) {
            webViewClient = new CustomWebViewClient();
            webView.setWebViewClient(webViewClient);
            webView.setWebChromeClient(new CustomWebChromeClient());
        }
        Log.d("SUKA", "SEARCH SHOW WEBVIEW");
        webView.loadDataWithBaseURL("https://4pda.ru/forum/", data.getHtml(), "text/html", "utf-8", null);
    } else {
        for (int i = 0; i < refreshLayout.getChildCount(); i++) {
            if (refreshLayout.getChildAt(i) instanceof ExtendedWebView) {
                refreshLayout.removeViewAt(i);
                fixTargetView();
            }
        }
        if (refreshLayout.getChildCount() <= 1) {
            fab.setVisibility(View.GONE);
            refreshLayout.addView(recyclerView);
            Log.d(LOG_TAG, "add recyclerview");
        }
        Log.d("SUKA", "SEARCH SHOW RECYCLERVIEW");
        adapter.clear();
        adapter.addAll(data.getItems());
    }
    paginationHelper.updatePagination(data.getPagination());
    setSubtitle(paginationHelper.getTitle());
}
Also used : FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent) RecyclerView(android.support.v7.widget.RecyclerView) CustomWebViewClient(forpdateam.ru.forpda.common.webview.CustomWebViewClient) CustomWebChromeClient(forpdateam.ru.forpda.common.webview.CustomWebChromeClient) SuppressLint(android.annotation.SuppressLint) ExtendedWebView(forpdateam.ru.forpda.ui.views.ExtendedWebView)

Example 7 with FunnyContent

use of forpdateam.ru.forpda.ui.views.FunnyContent in project ForPDA by RadiationX.

the class NotesFragment method loadCacheData.

@Override
public void loadCacheData() {
    super.loadCacheData();
    if (!realm.isClosed()) {
        setRefreshing(true);
        RealmResults<NoteItemBd> results = realm.where(NoteItemBd.class).findAllSorted("id", Sort.DESCENDING);
        if (results.isEmpty()) {
            if (!contentController.contains(ContentController.TAG_NO_DATA)) {
                FunnyContent funnyContent = new FunnyContent(getContext()).setImage(R.drawable.ic_bookmark).setTitle(R.string.funny_notes_nodata_title);
                contentController.addContent(funnyContent, ContentController.TAG_NO_DATA);
            }
            contentController.showContent(ContentController.TAG_NO_DATA);
        } else {
            contentController.hideContent(ContentController.TAG_NO_DATA);
        }
        ArrayList<NoteItem> nonBdResult = new ArrayList<>();
        for (NoteItemBd item : results) {
            nonBdResult.add(new NoteItem(item));
        }
        adapter.addAll(nonBdResult);
    }
    setRefreshing(false);
}
Also used : FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent) NoteItem(forpdateam.ru.forpda.data.models.notes.NoteItem) ArrayList(java.util.ArrayList) NoteItemBd(forpdateam.ru.forpda.data.realm.notes.NoteItemBd)

Example 8 with FunnyContent

use of forpdateam.ru.forpda.ui.views.FunnyContent in project ForPDA by RadiationX.

the class QmsBlackListFragment method onLoadContacts.

private void onLoadContacts(ArrayList<QmsContact> data) {
    setRefreshing(false);
    if (data.isEmpty()) {
        if (!contentController.contains(ContentController.TAG_NO_DATA)) {
            FunnyContent funnyContent = new FunnyContent(getContext()).setImage(R.drawable.ic_contacts).setTitle(R.string.funny_blacklist_nodata_title).setDesc(R.string.funny_blacklist_nodata_desc);
            contentController.addContent(funnyContent, ContentController.TAG_NO_DATA);
        }
        contentController.showContent(ContentController.TAG_NO_DATA);
    } else {
        contentController.hideContent(ContentController.TAG_NO_DATA);
    }
    recyclerView.scrollToPosition(0);
    currentData = data;
    adapter.addAll(currentData);
}
Also used : FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent)

Example 9 with FunnyContent

use of forpdateam.ru.forpda.ui.views.FunnyContent in project ForPDA by RadiationX.

the class QmsContactsFragment method bindView.

private void bindView() {
    if (realm.isClosed())
        return;
    results = realm.where(QmsContactBd.class).findAll();
    if (results.isEmpty()) {
        if (!contentController.contains(ContentController.TAG_NO_DATA)) {
            FunnyContent funnyContent = new FunnyContent(getContext()).setImage(R.drawable.ic_contacts).setTitle(R.string.funny_contacts_nodata_title);
            contentController.addContent(funnyContent, ContentController.TAG_NO_DATA);
        }
        contentController.showContent(ContentController.TAG_NO_DATA);
    } else {
        contentController.hideContent(ContentController.TAG_NO_DATA);
    }
    ArrayList<QmsContact> currentItems = new ArrayList<>();
    for (QmsContactBd qmsContactBd : results) {
        QmsContact contact = new QmsContact(qmsContactBd);
        currentItems.add(contact);
    }
    int count = 0;
    for (QmsContact contact : currentItems) {
        if (contact.getCount() > 0) {
            count += contact.getCount();
        }
    }
    ClientHelper.setQmsCount(count);
    ClientHelper.get().notifyCountsChanged();
    adapter.addAll(currentItems);
}
Also used : FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent) ArrayList(java.util.ArrayList) IQmsContact(forpdateam.ru.forpda.api.qms.interfaces.IQmsContact) QmsContact(forpdateam.ru.forpda.api.qms.models.QmsContact) QmsContactBd(forpdateam.ru.forpda.data.realm.qms.QmsContactBd)

Aggregations

FunnyContent (forpdateam.ru.forpda.ui.views.FunnyContent)9 ArrayList (java.util.ArrayList)3 SuppressLint (android.annotation.SuppressLint)1 RecyclerView (android.support.v7.widget.RecyclerView)1 IFavItem (forpdateam.ru.forpda.api.favorites.interfaces.IFavItem)1 FavItem (forpdateam.ru.forpda.api.favorites.models.FavItem)1 IQmsContact (forpdateam.ru.forpda.api.qms.interfaces.IQmsContact)1 QmsContact (forpdateam.ru.forpda.api.qms.models.QmsContact)1 CustomWebChromeClient (forpdateam.ru.forpda.common.webview.CustomWebChromeClient)1 CustomWebViewClient (forpdateam.ru.forpda.common.webview.CustomWebViewClient)1 NoteItem (forpdateam.ru.forpda.data.models.notes.NoteItem)1 NoteItemBd (forpdateam.ru.forpda.data.realm.notes.NoteItemBd)1 QmsContactBd (forpdateam.ru.forpda.data.realm.qms.QmsContactBd)1 ExtendedWebView (forpdateam.ru.forpda.ui.views.ExtendedWebView)1