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 ");
}
}
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;
}
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;
}
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);
}
});
}
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);
}
});
}
Aggregations