Search in sources :

Example 96 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project BetterBatteryStats by asksven.

the class RawStatsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.raw_stats);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getString(R.string.label_raw_stats));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayUseLogoEnabled(false);
    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            doRefresh();
        }
    });
    // Spinner for selecting the stat
    Spinner spinnerStat = (Spinner) findViewById(R.id.spinnerStat);
    ArrayAdapter spinnerStatAdapter = ArrayAdapter.createFromResource(this, R.array.stats, R.layout.bbs_spinner_layout);
    spinnerStatAdapter.setDropDownViewResource(R.layout.bbs_spinner_dropdown_item);
    spinnerStat.setAdapter(spinnerStatAdapter);
    // setSelection MUST be called after setAdapter
    spinnerStat.setSelection(m_iStat);
    spinnerStat.setOnItemSelectedListener(this);
    TextView tvSince = (TextView) findViewById(R.id.TextViewSince);
    long sinceMs = SystemClock.elapsedRealtime();
    if (sinceMs != -1) {
        String sinceText = DateUtils.formatDuration(sinceMs);
        tvSince.setText(sinceText);
        Log.i(TAG, "Since " + sinceText);
    } else {
        tvSince.setText("n/a ");
        Log.i(TAG, "Since: n/a ");
    }
}
Also used : Spinner(android.widget.Spinner) TextView(android.widget.TextView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(android.support.v7.widget.Toolbar)

Example 97 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project Ruisi by freedom10086.

the class FrageHistory method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    initToolbar(true, "浏览历史");
    addToolbarMenu(R.drawable.ic_delete_24dp).setOnClickListener(view -> {
        Dialog alertDialog = new AlertDialog.Builder(getActivity()).setTitle("清空历史记录").setMessage("你确定要清空浏览历史吗??").setPositiveButton("是的(=・ω・=)", (dialogInterface, i) -> {
            MyDB db = new MyDB(getActivity());
            db.clearHistory();
            datas.clear();
            adapter.notifyDataSetChanged();
            Toast.makeText(getActivity(), "浏览历史已清空~~", Toast.LENGTH_SHORT).show();
        }).setNegativeButton("取消", null).setCancelable(true).create();
        alertDialog.show();
    });
    RecyclerView recyclerView = mRootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    SwipeRefreshLayout refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setEnabled(false);
    adapter = new HistoryAdapter(getActivity(), datas);
    adapter.setPlaceHolderText("暂无浏览历史");
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    refresh();
    return mRootView;
}
Also used : Bundle(android.os.Bundle) AsyncTask(android.os.AsyncTask) LayoutInflater(android.view.LayoutInflater) MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) Dialog(android.app.Dialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BaseAdapter(me.yluo.ruisiapp.adapter.BaseAdapter) ViewGroup(android.view.ViewGroup) R(me.yluo.ruisiapp.R) ArrayList(java.util.ArrayList) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) ReadHistoryData(me.yluo.ruisiapp.model.ReadHistoryData) MyDB(me.yluo.ruisiapp.database.MyDB) Toast(android.widget.Toast) View(android.view.View) HistoryAdapter(me.yluo.ruisiapp.adapter.HistoryAdapter) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) RecyclerView(android.support.v7.widget.RecyclerView) HistoryAdapter(me.yluo.ruisiapp.adapter.HistoryAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) MyDB(me.yluo.ruisiapp.database.MyDB)

Example 98 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project Ruisi by freedom10086.

the class FrageTopicStar method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // 从activity传过来的Bundle
    Bundle bundle = getArguments();
    if (bundle != null) {
        int type = bundle.getInt("type", -1);
        switch(type) {
            case FrageType.TOPIC:
                currentIndex = 0;
                title = "我的帖子";
                break;
            case FrageType.START:
                currentIndex = 1;
                title = "我的收藏";
                break;
        }
    }
    initToolbar(true, title);
    RecyclerView recyclerView = mRootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    SwipeRefreshLayout refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setEnabled(false);
    String uid = App.getUid(getActivity());
    switch(currentIndex) {
        case 0:
            // 主题
            url = "home.php?mod=space&uid=" + uid + "&do=thread&view=me&mobile=2";
            break;
        case 1:
            // 我的收藏
            url = "home.php?mod=space&uid=" + uid + "&do=favorite&view=me&type=thread&mobile=2";
            break;
    }
    datas = new ArrayList<>();
    adapter = new SimpleListAdapter(ListType.ARTICLE, getActivity(), datas);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    recyclerView.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) layoutManager, this, 10));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    refresh();
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) Bundle(android.os.Bundle) SimpleListAdapter(me.yluo.ruisiapp.adapter.SimpleListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 99 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project RoMote by wseemann.

the class AltMainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // ManualConnectionDialog fragment = ManualConnectionDialog.getInstance(this);
            // fragment.show(MainFragment.this.getFragmentManager(), ManualConnectionDialog.class.getName());
            Intent intent = new Intent(AltMainActivity.this, ManualConnectionActivity.class);
            startActivityForResult(intent, 0);
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            }
        }
    });
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("first_use", true)) {
        startActivity(new Intent(this, ConfigureDeviceActivity.class));
        finish();
    }
    Intent intent = getIntent();
    if (intent != null && intent.getData() != null) {
        String channelCode = intent.getData().getPath().replace("/install/", "");
        InstallChannelDialog fragment = InstallChannelDialog.getInstance(this, channelCode);
        fragment.show(getFragmentManager(), InstallChannelDialog.class.getName());
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(3);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    // Bind to NotificationService
    Intent intent1 = new Intent(this, NotificationService.class);
    bindService(intent1, mConnection, Context.BIND_AUTO_CREATE);
    mSelectDeviceText = (TextView) findViewById(R.id.select_device_text);
    mProgressLayout = (RelativeLayout) findViewById(R.id.progress_layout);
    mList = (ListView) findViewById(android.R.id.list);
    View emptyView = findViewById(android.R.id.empty);
    mList.setEmptyView(emptyView);
    mSwiperefresh = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    /*mSwiperefresh.setOnRefreshListener(
                new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
                        // This method performs the actual data-refresh operation.
                        // The method calls setRefreshing(false) when it's finished.
                        setLoadingText(true);
                        getLoaderManager().restartLoader(0, new Bundle(), mAvailableDevicesLoader);
                    }
                }
        );*/
    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Device device = (Device) parent.getItemAtPosition(position);
            DBUtils.insertDevice(AltMainActivity.this, device);
            PreferenceUtils.setConnectedDevice(AltMainActivity.this, device.getSerialNumber());
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AltMainActivity.this);
            SharedPreferences.Editor editor = prefs.edit();
            editor.putBoolean("first_use", false);
            editor.commit();
            Toast.makeText(AltMainActivity.this, "Device " + device.getSerialNumber() + " " + getString(R.string.connected), Toast.LENGTH_SHORT).show();
            sendBroadcast(new Intent(Constants.UPDATE_DEVICE_BROADCAST));
            AppWidgetManager widgetManager = AppWidgetManager.getInstance(AltMainActivity.this);
            ComponentName widgetComponent = new ComponentName(AltMainActivity.this, RokuAppWidgetProvider.class);
            int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
            Intent update = new Intent();
            update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
            update.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
            sendBroadcast(update);
            if (mListener != null) {
                mListener.onDeviceSelected();
            }
            mAvailableDeviceAdapter.clear();
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(1, new Bundle(), mPairedDevicesLoader);
        }
    });
    mAdapter = new SeparatedListAdapter(this);
    mPairedDeviceAdapter = new DeviceAdapter(this, new ArrayList<Device>(), mHandler);
    mAvailableDeviceAdapter = new DeviceAdapter(this, new ArrayList<Device>(), mHandler);
    mAdapter.addSection("Paired devices", mPairedDeviceAdapter);
    mAdapter.addSection("Available devices", mAvailableDeviceAdapter);
    mList.setAdapter(mAdapter);
    refreshList(false);
    ImageButton refreshButton = (ImageButton) findViewById(R.id.refresh_button);
    refreshButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getLoaderManager().restartLoader(0, new Bundle(), mAvailableDevicesLoader);
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) ImageButton(android.widget.ImageButton) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) DeviceAdapter(wseemann.media.romote.adapter.DeviceAdapter) ComponentName(android.content.ComponentName) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar) SharedPreferences(android.content.SharedPreferences) Device(com.jaku.model.Device) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) SeparatedListAdapter(wseemann.media.romote.adapter.SeparatedListAdapter) RokuAppWidgetProvider(wseemann.media.romote.widget.RokuAppWidgetProvider) AdapterView(android.widget.AdapterView) InstallChannelDialog(wseemann.media.romote.fragment.InstallChannelDialog)

Example 100 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project wigle-wifi-wardriving by wiglenet.

the class RankStatsFragment method setupSwipeRefresh.

private void setupSwipeRefresh(final LinearLayout rootView) {
    // Lookup the swipe container view
    final SwipeRefreshLayout swipeContainer = (SwipeRefreshLayout) rootView.findViewById(R.id.rank_swipe_container);
    // Setup refresh listener which triggers new data loading
    swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            // Your code to refresh the list here.
            // Make sure you call swipeContainer.setRefreshing(false)
            // once the network request has completed successfully.
            downloadRanks(false);
        }
    });
}
Also used : SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)115 View (android.view.View)65 RecyclerView (android.support.v7.widget.RecyclerView)58 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)43 TextView (android.widget.TextView)30 Bundle (android.os.Bundle)21 Intent (android.content.Intent)20 Handler (android.os.Handler)17 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)16 Toolbar (android.support.v7.widget.Toolbar)16 ArrayList (java.util.ArrayList)16 AdapterView (android.widget.AdapterView)14 ListView (android.widget.ListView)12 ImageView (android.widget.ImageView)11 GridLayoutManager (android.support.v7.widget.GridLayoutManager)10 Context (android.content.Context)9 LayoutInflater (android.view.LayoutInflater)9 ViewGroup (android.view.ViewGroup)9 DialogInterface (android.content.DialogInterface)8 FrameLayout (android.widget.FrameLayout)7