Search in sources :

Example 11 with OnRefreshListener

use of com.scwang.smartrefresh.layout.listener.OnRefreshListener in project SmartRefreshLayout by scwang90.

the class WebViewPracticeActivity method onCreate.

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_practice_webview);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    final WebView webView = (WebView) findViewById(R.id.webView);
    final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
    refreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(@NonNull RefreshLayout refreshLayout) {
            webView.loadUrl("https://github.com/scwang90/SmartRefreshLayout");
        }
    });
    refreshLayout.autoRefresh();
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            refreshLayout.finishRefresh();
            view.loadUrl(String.format(Locale.CHINA, "javascript:document.body.style.paddingTop='%fpx'; void 0", DensityUtil.px2dp(webView.getPaddingTop())));
        }
    });
    // 状态栏透明和间距处理
    StatusBarUtil.immersive(this);
    StatusBarUtil.setPaddingSmart(this, webView);
    StatusBarUtil.setPaddingSmart(this, toolbar);
    StatusBarUtil.setMargin(this, findViewById(R.id.header));
    StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurView));
}
Also used : RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) Toolbar(android.support.v7.widget.Toolbar) WebViewClient(android.webkit.WebViewClient) SuppressLint(android.annotation.SuppressLint)

Example 12 with OnRefreshListener

use of com.scwang.smartrefresh.layout.listener.OnRefreshListener in project SmartRefreshLayout by scwang90.

the class ThreeLevelExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    if (recyclerView != null) {
        recyclerView.setAdapter(new BaseRecyclerAdapter<Void>(initData(), simple_list_item_2) {

            @Override
            protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) {
                holder.text(android.R.id.text1, getString(R.string.item_example_number_title, position));
                holder.text(android.R.id.text2, getString(R.string.item_example_number_abstract, position));
                holder.textColorId(android.R.id.text1, android.R.color.white);
                holder.textColorId(android.R.id.text2, android.R.color.white);
            }
        });
    }
    RefreshLayout refreshLayout1 = (RefreshLayout) view.findViewById(R.id.refreshLayout1);
    if (refreshLayout1 != null) {
        refreshLayout1.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                refreshLayout.finishRefresh(1000);
            }
        });
    }
    RefreshLayout refreshLayout2 = (RefreshLayout) view.findViewById(R.id.refreshLayout2);
    if (refreshLayout2 != null) {
        refreshLayout2.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                refreshLayout.finishRefresh(2000);
            }
        });
    }
}
Also used : SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) Toolbar(android.support.v7.widget.Toolbar)

Example 13 with OnRefreshListener

use of com.scwang.smartrefresh.layout.listener.OnRefreshListener in project AgentWeb by Justson.

the class SmartRefreshWebFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final SmartRefreshLayout mSmartRefreshLayout = (SmartRefreshLayout) this.mSmartRefreshWebLayout.getLayout();
    final WebView mWebView = this.mSmartRefreshWebLayout.getWebView();
    mSmartRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            mAgentWeb.getUrlLoader().reload();
            mSmartRefreshLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mSmartRefreshLayout.finishRefresh();
                }
            }, 2000);
        }
    });
    mSmartRefreshLayout.autoRefresh();
}
Also used : SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) WebView(android.webkit.WebView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Example 14 with OnRefreshListener

use of com.scwang.smartrefresh.layout.listener.OnRefreshListener in project weibo by dingdangmao123.

the class TitleFG method CreateView.

@Override
public void CreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, View v) {
    adapter = new TitleAdapter(data, getActivity());
    tl.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh();
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            rf.finishLoadmore();
        }
    });
    search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            Intent i = new Intent(getActivity(), Title.class);
            i.putExtra("title", s);
            getActivity().startActivity(i);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
}
Also used : SearchView(android.widget.SearchView) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) Title(com.gapcoder.weico.Title.Title) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) TitleAdapter(com.gapcoder.weico.Index.Adapter.TitleAdapter) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Example 15 with OnRefreshListener

use of com.scwang.smartrefresh.layout.listener.OnRefreshListener in project weibo by dingdangmao123.

the class AtFG method CreateView.

@Override
public void CreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, View v) {
    adapter = new AtAdapter(data, getActivity());
    tl.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh(1);
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            Refresh(0);
        }
    });
}
Also used : AtAdapter(com.gapcoder.weico.Message.Adapter.AtAdapter) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Aggregations

RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)20 OnRefreshListener (com.scwang.smartrefresh.layout.listener.OnRefreshListener)20 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)13 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)11 View (android.view.View)10 OnLoadmoreListener (com.scwang.smartrefresh.layout.listener.OnLoadmoreListener)10 Toolbar (android.support.v7.widget.Toolbar)8 RecyclerView (android.support.v7.widget.RecyclerView)6 SmartViewHolder (com.scwang.refreshlayout.adapter.SmartViewHolder)4 WebView (android.webkit.WebView)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 WeicoAdapter (com.gapcoder.weico.Index.Adapter.WeicoAdapter)3 Intent (android.content.Intent)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)2 ViewGroup (android.view.ViewGroup)2 WebViewClient (android.webkit.WebViewClient)2 AdapterView (android.widget.AdapterView)2 BaseRecyclerAdapter (com.scwang.refreshlayout.adapter.BaseRecyclerAdapter)2 RefreshHeader (com.scwang.smartrefresh.layout.api.RefreshHeader)2