Java Code Examples for android.support.v4.widget.SwipeRefreshLayout#setRefreshing()

The following examples show how to use android.support.v4.widget.SwipeRefreshLayout#setRefreshing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrashTickets.java    From faveo-helpdesk-android-app with Open Software License 3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        textViewTotalCount= (TextView) rootView.findViewById(R.id.totalcount);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        if (InternetReceiver.isConnected()){
            swipeRefresh.setRefreshing(true);
            new FetchFirst(getActivity()).execute();
        }


        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new FetchFirst(getActivity()).execute();
            }
        });
        tv = (TextView) rootView.findViewById(R.id.empty_view);
    }
   // ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.trash_tickets));
    return rootView;
}
 
Example 2
Source File: TriggerListFragment.java    From AndroidSDK with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View contentView = inflater.inflate(R.layout.fragment_trigger_list, container, false);
    mRecyclerView = (RecyclerView) contentView.findViewById(R.id.recyler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) contentView.findViewById(R.id.swipe_refresh_layout);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mAdapter = new TriggerListAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnLoadMoreListener(mLoadMoreListener, mRecyclerView);
    mSwipeRefreshLayout.setColorSchemeColors(0xFFDA4336);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    getTriggers(false);
    mSwipeRefreshLayout.setRefreshing(true);

    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateApiKeyReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_APIKEY));
    return contentView;
}
 
Example 3
Source File: MyTickets.java    From faveo-helpdesk-android-app with Open Software License 3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        textViewTotalCount= (TextView) rootView.findViewById(R.id.totalcount);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        if (InternetReceiver.isConnected()){
            swipeRefresh.setRefreshing(true);
            new FetchFirst(getActivity()).execute();
        }


        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new FetchFirst(getActivity()).execute();
            }
        });
        tv = (TextView) rootView.findViewById(R.id.empty_view);
    }
    //  ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.my_tickets));
    return rootView;
}
 
Example 4
Source File: ClosedTickets.java    From faveo-helpdesk-android-app with Open Software License 3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        textViewTotalCount= (TextView) rootView.findViewById(R.id.totalcount);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        if (InternetReceiver.isConnected()){
            swipeRefresh.setRefreshing(true);
            new FetchFirst(getActivity()).execute();
        }


        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new FetchFirst(getActivity()).execute();
            }
        });
        tv = (TextView) rootView.findViewById(R.id.empty_view);
    }
    //  ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.closed_tickets));
    return rootView;
}
 
Example 5
Source File: HomePageFragment.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	View fragmentView = inflater.inflate(R.layout.fragment_homepage,
			container, false);
	mActivity = (MainActivity) getActivity();
	mNetState = new NetworkState();
	mListView = (LoadMoreList) fragmentView
			.findViewById(R.id.lvHomeListView);
	mAdapter = new HomePageAdapter(mActivity, R.layout.list_item_homepage,
			itemDataList);
	mListView.setAdapter(mAdapter);
	mListView.setOnLoadMoreListener(this);
	mSwipeLayout = (SwipeRefreshLayout) fragmentView
			.findViewById(R.id.swipe_container);
	mSwipeLayout.setOnRefreshListener(this);
	// ����ˢ����ɫ��ʽ
	mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
			android.R.color.holo_green_light,
			android.R.color.holo_orange_light,
			android.R.color.holo_red_light);
	mSwipeLayout.setRefreshing(true);
	getData(mPage);
	return fragmentView;
}
 
Example 6
Source File: CustomRequestFragment.java    From VolleyX with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));//这里用线性显示 类似于listview
    mAdapter = new CustomRequestFragment.ItemRecyclerViewAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshItems();
        }
    });

    refreshItems();
    mSwipeRefreshLayout.setRefreshing(true);
}
 
Example 7
Source File: StringRequestFragment.java    From VolleyX with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));//这里用线性显示 类似于listview
    mAdapter = new ItemRecyclerViewAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshItems();
        }
    });

    refreshItems();
    mSwipeRefreshLayout.setRefreshing(true);
}
 
Example 8
Source File: DeviceActivity.java    From AndroidSDK with MIT License 6 votes vote down vote up
private void initViews() {
    mDeviceItem = (DeviceItem) getIntent().getSerializableExtra(EXTRA_DEVICE_ITEM);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle(mDeviceItem.getTitle());
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_material);

    mRecyclerView = (RecyclerView) findViewById(R.id.recyler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    mFabAddDataStream = (FloatingActionButton) findViewById(R.id.fab_add_ds);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new DSListAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout.setColorSchemeColors(0xFFDA4336);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    getDataStreams();
    mSwipeRefreshLayout.setRefreshing(true);

    mFabAddDataStream.setOnClickListener(this);
}
 
Example 9
Source File: InboxTickets.java    From faveo-helpdesk-android-app with Open Software License 3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        recyclerView = (RecyclerView) rootView.findViewById(R.id.cardList);
        recyclerView.setHasFixedSize(false);
        textViewTotalCount= (TextView) rootView.findViewById(R.id.totalcount);
        final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);

        if (InternetReceiver.isConnected()){
            swipeRefresh.setRefreshing(true);
            new FetchFirst(getActivity()).execute();
        }

        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new FetchFirst(getActivity()).execute();
            }
        });
        tv = (TextView) rootView.findViewById(R.id.empty_view);
    }
   // ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.inbox_tickets));
    return rootView;
}
 
Example 10
Source File: DeviceListFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View contentView = inflater.inflate(R.layout.fragment_device_list, container, false);
    mRecyclerView = (RecyclerView) contentView.findViewById(R.id.recyler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) contentView.findViewById(R.id.swipe_refresh_layout);
    mFabAddDevice = (FloatingActionButton) contentView.findViewById(R.id.fab_add_device);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mAdapter = new DeviceListAdapter();
    mAdapter.setOnLoadMoreListener(mLoadMoreListener, mRecyclerView);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            DeviceActivity.actionDevice(getContext(), mDeviceItems.get(position));
        }
    });
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout.setColorSchemeColors(0xFFDA4336);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    getDevices(false);
    mSwipeRefreshLayout.setRefreshing(true);

    mFabAddDevice.setOnClickListener(this);
    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateApiKeyReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_APIKEY));
    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateDeviceListReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_DEVICE_LIST));
    return contentView;
}
 
Example 11
Source File: ViewUtils.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
/**
 * 下拉刷新成功
 */
public static void setRefreshSuccess(SwipeRefreshLayout swipeRefreshLayout) {
    if (swipeRefreshLayout != null) {
        swipeRefreshLayout.setRefreshing(false);
        swipeRefreshLayout.setEnabled(false);
    }
}
 
Example 12
Source File: RefreshableFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@UiThread(propagation = UiThread.Propagation.REUSE)
public void hideProgressBar() {
    SwipeRefreshLayout swipeRefreshLayout = getSwipeRefreshLayout();
    if (swipeRefreshLayout != null) {
        swipeRefreshLayout.setRefreshing(false);
    }
}
 
Example 13
Source File: CatalogNetworkFragment.java    From Ouroboros with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    catalogAdapter.changeCursor(infiniteDbHelper.getCatalogCursor(SettingsHelper.getSortByMethod(getContext())));
    swipeRefreshLayout = (SwipeRefreshLayout) activity.findViewById(R.id.catalog_swipe_container);
    ProgressBar progressBar = (ProgressBar) activity.findViewById(R.id.progress_bar);
    if(swipeRefreshLayout != null) {
        swipeRefreshLayout.setRefreshing(false);
    }
    if (progressBar != null){
        progressBar.setVisibility(View.INVISIBLE);
    }
}
 
Example 14
Source File: RefreshableFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@UiThread(propagation = UiThread.Propagation.REUSE)
public void showProgressBar() {
    SwipeRefreshLayout swipeRefreshLayout = getSwipeRefreshLayout();
    if (swipeRefreshLayout != null) {
        swipeRefreshLayout.setRefreshing(true);
    }
}
 
Example 15
Source File: BaseListDelegate.java    From CoreModule with Apache License 2.0 4 votes vote down vote up
public void setSwipeRefreshLoadingState() {
    SwipeRefreshLayout refreshLayout = get(R.id.swiperefreshlayout);
    refreshLayout.setRefreshing(true);
    refreshLayout.setEnabled(false);
}
 
Example 16
Source File: BaseListDelegate.java    From CoreModule with Apache License 2.0 4 votes vote down vote up
public void setSwipeRefreshLoadedState() {
    SwipeRefreshLayout refreshLayout = get(R.id.swiperefreshlayout);
    refreshLayout.setRefreshing(false);
    refreshLayout.setEnabled(true);
}
 
Example 17
Source File: HomeFragment.java    From QuickNews with MIT License 4 votes vote down vote up
public JsonObjectRequest getJokeData(String baseUrl, String parameter, final ListView listView
        , final SwipeRefreshLayout refreshLayout) {
    System.out.println("访问的Url为" + (baseUrl + parameter));
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest((baseUrl + parameter).trim(), null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    try {
                        System.out.println("Volley得到的response是+" + response.toString());
                        Gson gson = new Gson();
                        JokeData jokeData = gson.fromJson(response.toString(), new TypeToken<JokeData>() {
                        }.getType());
                        List<Joke> jokeList = jokeData.getData();
                        refreshLayout.setRefreshing(false);
                        JokeAdapter adapter = new JokeAdapter(getActivity(), jokeList);
                        listView.setAdapter(adapter);
                        adapter.notifyDataSetChanged();
                        final List<Joke> finalJokeList = jokeList;
                        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                Intent intent = new Intent(getActivity(), NewsActivity.class);
                                System.out.println("i的位置" + position);
                                System.out.println("newsList的size" + finalJokeList.size());
                                System.out.println("newsList.get(i).getDisplay_url()" + finalJokeList.get(position).getGroup().getShare_url());
                                intent.putExtra("news_url", finalJokeList.get(position).getGroup().getShare_url());
                                startActivity(intent);
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            System.out.println("获取信息失败……");
            System.out.println("error是" + error.toString());

        }
    });

    System.out.println("jsonObjectRequest" + jsonObjectRequest.toString());
    return jsonObjectRequest;
}
 
Example 18
Source File: ClientList.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
/**
 *
 * @param inflater for loading the fragment.
 * @param container where the fragment is going to be load.
 * @param savedInstanceState
 * @return after initializing returning the rootview
 * which is having the fragment.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        ButterKnife.bind(this, rootView);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        if (InternetReceiver.isConnected()) {
            noInternet_view.setVisibility(View.GONE);
            swipeRefresh.setRefreshing(true);
            new FetchClients(getActivity()).execute();
        } else {
            noInternet_view.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.INVISIBLE);
            empty_view.setVisibility(View.GONE);
        }

        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (InternetReceiver.isConnected()) {
                    loading = true;
                    recyclerView.setVisibility(View.VISIBLE);
                    noInternet_view.setVisibility(View.GONE);
                    new FetchClients(getActivity()).execute();
                } else {
                    recyclerView.setVisibility(View.INVISIBLE);
                    swipeRefresh.setRefreshing(false);
                    empty_view.setVisibility(View.GONE);
                    noInternet_view.setVisibility(View.VISIBLE);
                }
            }
        });

        empty_view.setText(R.string.no_clients);
    }
    ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.client_list));
    return rootView;
}
 
Example 19
Source File: BindingConfig.java    From Android-MVVMFramework with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("refreshing")
public static void setRefreshing(SwipeRefreshLayout view, boolean refreshing) {
    if (refreshing != view.isRefreshing()) {
        view.setRefreshing(refreshing);
    }
}
 
Example 20
Source File: RefreshBinding.java    From SimpleFTP with MIT License 2 votes vote down vote up
/**
 * Sets the new refresh state.
 * @param view The current swipe refresh layout.
 * @param value The value indicating whether the refresh animation should be activated.
 */
@BindingAdapter("isRefreshing")
public static void setIsRefreshing(SwipeRefreshLayout view, boolean value) {
    view.setRefreshing(value);
}