use of android.widget.PopupMenu in project double-espresso by JakeWharton.
the class SendActivity method showPopupMenu.
public boolean showPopupMenu(View view) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
return false;
}
PopupMenu popup = new PopupMenu(this, view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.popup_menu, popup.getMenu());
popup.show();
return true;
}
use of android.widget.PopupMenu in project double-espresso by JakeWharton.
the class MenuActivity method showPopup.
public void showPopup(View view) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
TextView text = (TextView) findViewById(R.id.text_menu_result);
text.setText("Not supported in API " + Build.VERSION.SDK_INT);
} else {
PopupMenu popup = new PopupMenu(this, view);
popup.setOnMenuItemClickListener(new PopupMenuListener());
popup.getMenuInflater().inflate(R.menu.popupmenu, popup.getMenu());
popup.show();
}
}
use of android.widget.PopupMenu in project NPSmiles by bmcglynn1.
the class NewsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View viewer = inflater.inflate(R.layout.activity_news_feed, container, false);
View popupLayout = inflater.inflate(R.layout.popup_layout_logged_in, null);
final ListView list = (ListView) viewer.findViewById(R.id.list);
final ArrayList<NewsMessage> newsList = new ArrayList<>();
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("Reference");
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() != null) {
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
PopupMenu popup = new PopupMenu(parent.getContext(), view);
popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
final TextView title = (TextView) view.findViewById(R.id.title);
final TextView message = (TextView) view.findViewById(R.id.information);
if (mAuth.getCurrentUser() != null) {
popup.show();
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.EditMenu:
// refresh view if needed
break;
case R.id.DeleteMenu:
// delete from firebase
// refresh view
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("Reference");
Query titleQuery = myRef.child(title.getText().toString());
titleQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot titleSnapshot : dataSnapshot.getChildren()) {
dataSnapshot.getRef().removeValue();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
break;
}
return true;
}
});
}
}
});
}
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
newsList.clear();
for (DataSnapshot newsItem : dataSnapshot.getChildren()) {
NewsMessage newsMessage = new NewsMessage();
for (DataSnapshot item : newsItem.getChildren()) {
if (item.getKey().equals("title")) {
newsMessage.setTitle((String) item.getValue());
} else if (item.getKey().equals("message")) {
newsMessage.setMessage((String) item.getValue());
} else {
newsMessage.setDate((String) item.getValue());
}
}
newsList.add(newsMessage);
}
Collections.sort(newsList);
CustomAdapter adapter = new CustomAdapter(context, newsList);
list.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return viewer;
}
Aggregations