use of android.support.v4.widget.SwipeRefreshLayout in project wigle-wifi-wardriving by wiglenet.
the class UploadsFragment method setupSwipeRefresh.
private void setupSwipeRefresh(final LinearLayout rootView) {
// Lookup the swipe container view
final SwipeRefreshLayout swipeContainer = (SwipeRefreshLayout) rootView.findViewById(R.id.uploads_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.
downloadUploads();
}
});
}
use of android.support.v4.widget.SwipeRefreshLayout in project Lets-Chat by kshitiz1007.
the class ChatActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
mChatAddButton = (ImageButton) findViewById(R.id.chatAddButton);
mChatSendButton = (ImageButton) findViewById(R.id.chatSendButton);
mMessageView = (EditText) findViewById(R.id.chatMessageView);
// -----GETING FROM INTENT----
mChatUser = getIntent().getStringExtra("user_id");
String userName = getIntent().getStringExtra("user_name");
// ---SETTING ONLINE------
mDatabaseReference = FirebaseDatabase.getInstance().getReference().child("users");
// ----ADDING ACTION BAR-----
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayHomeAsUpEnabled(true);
// ---INFLATING APP BAR LAYOUT INTO ACTION BAR----
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
View actionBarView = inflater.inflate(R.layout.app_bar_layout, null);
actionBar.setCustomView(actionBarView);
// ---ADDING DATA ON ACTION BAR----
mUserName = (TextView) actionBarView.findViewById(R.id.textView3);
mUserLastSeen = (TextView) actionBarView.findViewById(R.id.textView5);
mUserImage = (CircleImageView) actionBarView.findViewById(R.id.circleImageView);
mUserName.setText(userName);
mRootReference = FirebaseDatabase.getInstance().getReference();
mImageStorage = FirebaseStorage.getInstance().getReference();
mAuth = FirebaseAuth.getInstance();
mCurrentUserId = mAuth.getCurrentUser().getUid();
mMessageAdapter = new MessageAdapter(messagesList);
mMessagesList = (RecyclerView) findViewById(R.id.recycleViewMessageList);
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.message_swipe_layout);
mLinearLayoutManager = new LinearLayoutManager(ChatActivity.this);
// mMessagesList.setHasFixedSize(true);
mMessagesList.setLayoutManager(mLinearLayoutManager);
mMessagesList.setAdapter(mMessageAdapter);
loadMessages();
// ----ADDING LAST SEEN-----
mRootReference.child("users").child(mChatUser).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String onlineValue = dataSnapshot.child("online").getValue().toString();
String imageValue = dataSnapshot.child("thumb_image").getValue().toString();
Picasso.with(ChatActivity.this).load(imageValue).placeholder(R.drawable.user_img).into(mUserImage);
if (onlineValue.equals("true")) {
mUserLastSeen.setText("online");
} else {
GetTimeAgo getTimeAgo = new GetTimeAgo();
long lastTime = Long.parseLong(onlineValue);
String lastSeen = getTimeAgo.getTimeAgo(lastTime, getApplicationContext());
mUserLastSeen.setText(lastSeen);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
// ----ADDING SEEN OF MESSAGES----
mRootReference.child("chats").child(mCurrentUserId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (!dataSnapshot.hasChild(mChatUser)) {
Map chatAddMap = new HashMap();
chatAddMap.put("seen", false);
chatAddMap.put("time_stamp", ServerValue.TIMESTAMP);
Map chatUserMap = new HashMap();
chatUserMap.put("chats/" + mChatUser + "/" + mCurrentUserId, chatAddMap);
chatUserMap.put("chats/" + mCurrentUserId + "/" + mChatUser, chatAddMap);
mRootReference.updateChildren(chatUserMap, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
if (databaseError == null) {
Toast.makeText(getApplicationContext(), "Successfully Added chats feature", Toast.LENGTH_SHORT).show();
} else
Toast.makeText(getApplicationContext(), "Cannot Add chats feature", Toast.LENGTH_SHORT).show();
}
});
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(getApplicationContext(), "Something went wrong.. Please go back..", Toast.LENGTH_SHORT).show();
}
});
// ----SEND MESSAGE--BUTTON----
mChatSendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String message = mMessageView.getText().toString();
if (!TextUtils.isEmpty(message)) {
String current_user_ref = "messages/" + mCurrentUserId + "/" + mChatUser;
String chat_user_ref = "messages/" + mChatUser + "/" + mCurrentUserId;
DatabaseReference user_message_push = mRootReference.child("messages").child(mCurrentUserId).child(mChatUser).push();
String push_id = user_message_push.getKey();
Map messageMap = new HashMap();
messageMap.put("message", message);
messageMap.put("seen", false);
messageMap.put("type", "text");
messageMap.put("time", ServerValue.TIMESTAMP);
messageMap.put("from", mCurrentUserId);
Map messageUserMap = new HashMap();
messageUserMap.put(current_user_ref + "/" + push_id, messageMap);
messageUserMap.put(chat_user_ref + "/" + push_id, messageMap);
mRootReference.updateChildren(messageUserMap, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
if (databaseError != null) {
Log.e("CHAT_ACTIVITY", "Cannot add message to database");
} else {
Toast.makeText(ChatActivity.this, "Message sent", Toast.LENGTH_SHORT).show();
mMessageView.setText("");
}
}
});
}
}
});
/*
//----THE WRAP CONTENT OF IMAGE VIEW IS GIVING ERROR--- SO REMOVING THIS FUNCTIONALITY-------
mChatAddButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent galleryIntent=new Intent();
galleryIntent.setType("image/*");
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(galleryIntent,"Select Image"),GALLERY_PICK);
}
});
*/
// ----LOADING 10 MESSAGES ON SWIPE REFRESH----
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
itemPos = 0;
mCurrentPage++;
loadMoreMessages();
;
}
});
}
use of android.support.v4.widget.SwipeRefreshLayout in project fuckView by w568w.
the class OnlineRulesFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
SwipeRefreshLayout layout = (SwipeRefreshLayout) inflater.inflate(R.layout.online_rules_fragment, null);
mInfo = (TextView) layout.findViewById(R.id.online_rules_info);
mDownload = (Button) layout.findViewById(R.id.online_rules_download);
mProgressBar = (ProgressBar) layout.findViewById(R.id.online_rules_progressBar);
mLayout = layout;
mDownload.setEnabled(false);
mDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mRules == null) {
return;
}
mProgressBar.setMax(mRules.size());
// noinspection unchecked
new FliterTask().execute(mRules);
}
});
mLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new RefreshTask().execute();
}
});
mLayout.findViewById(R.id.online_rules_rl).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return event.getAction() == MotionEvent.ACTION_DOWN;
}
});
return layout;
}
use of android.support.v4.widget.SwipeRefreshLayout in project RoMote by wseemann.
the class ChannelFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_channels, container, false);
final GridView mGridView = (GridView) v.findViewById(android.R.id.list);
mSwiperefresh = (SwipeRefreshLayout) v.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.
getLoaderManager().restartLoader(0, new Bundle(), ChannelFragment.this);
}
});
// View emptyView = v.findViewById(android.R.id.empty);
// mGridView.setEmptyView(emptyView);
mGridView.setAdapter(mAdapter);
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Channel channel = (Channel) parent.getItemAtPosition(position);
performLaunch(channel.getId());
}
});
mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
// Pause fetcher to ensure smoother scrolling when flinging
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
// Before Honeycomb pause image loading on scroll to help with performance
if (!Utils.hasHoneycomb()) {
mImageFetcher.setPauseWork(true);
}
} else {
mImageFetcher.setPauseWork(false);
}
}
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
// This listener is used to get the final width of the GridView and then calculate the
// number of columns and the width of each column. The width of each column is variable
// as the GridView has stretchMode=columnWidth. The column width is used to set the height
// of each view so we get nice square thumbnails.
mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
if (mAdapter.getNumColumns() == 0) {
final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
if (numColumns > 0) {
final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
mAdapter.setNumColumns(numColumns);
mAdapter.setItemHeight(columnWidth);
if (BuildConfig.DEBUG) {
Log.d(TAG, "onCreateView - numColumns set to " + numColumns);
}
if (Utils.hasJellyBean()) {
mGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
mGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
}
}
});
return v;
}
use of android.support.v4.widget.SwipeRefreshLayout in project RoMote by wseemann.
the class MainFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
mSelectDeviceText = (TextView) view.findViewById(R.id.select_device_text);
mProgressLayout = (RelativeLayout) view.findViewById(R.id.progress_layout);
mList = (ListView) view.findViewById(android.R.id.list);
View emptyView = view.findViewById(android.R.id.empty);
mList.setEmptyView(emptyView);
mSwiperefresh = (SwipeRefreshLayout) view.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);
}
});
mFab = (FloatingActionButton) view.findViewById(R.id.fab);
return view;
}
Aggregations