use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.
the class ItemCollectionFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
AppCompatActivity activity = (AppCompatActivity) getActivity();
//activity.setTitle(getTitle());
activity.setSupportActionBar(mToolbar);
// As in https://developer.android.com/guide/topics/ui/controls/radiobutton.html .
View.OnClickListener collectionStateButtonOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!((RadioButton) view).isChecked()) {
return;
}
ItemCollectionState oldCollectionState = mCollectionState;
switch(view.getId()) {
case R.id.todo:
mCollectionState = ItemCollectionState.TODO;
break;
case R.id.doing:
mCollectionState = ItemCollectionState.DOING;
break;
case R.id.done:
mCollectionState = ItemCollectionState.DONE;
break;
}
if (mCollectionState != oldCollectionState) {
onCollectionStateChanged();
}
}
};
mTodoButton.setOnClickListener(collectionStateButtonOnClickListener);
mDoingButton.setOnClickListener(collectionStateButtonOnClickListener);
mDoneButton.setOnClickListener(collectionStateButtonOnClickListener);
mRatingBar.setOnRatingChangeListener(new MaterialRatingBar.OnRatingChangeListener() {
@Override
public void onRatingChanged(MaterialRatingBar ratingBar, float rating) {
mRatingHintText.setText(DoubanUtils.getRatingHint((int) rating, mRatingHintText.getContext()));
}
});
}
use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.
the class BroadcastListActivityFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setTitle(getTitle());
activity.setSupportActionBar(mToolbar);
TransitionUtils.setupTransitionOnActivityCreated(this);
if (savedInstanceState == null) {
FragmentUtils.add(BroadcastListFragment.newInstance(mUserIdOrUid, mTopic), this, R.id.broadcast_list_fragment);
}
}
use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.
the class HomeFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(mToolbar);
mTabAdapter = new TabFragmentPagerAdapter(this);
mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {
@Override
public Fragment createFragment() {
return HomeBroadcastListFragment.newInstance();
}
}, getString(R.string.home_broadcast));
mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {
@Override
public Fragment createFragment() {
return NotYetImplementedFragment.newInstance();
}
}, getString(R.string.home_discover));
mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {
@Override
public Fragment createFragment() {
return NotYetImplementedFragment.newInstance();
}
}, getString(R.string.home_online));
mViewPager.setOffscreenPageLimit(mTabAdapter.getCount() - 1);
mViewPager.setAdapter(mTabAdapter);
mTabLayout.setupWithViewPager(mViewPager);
}
use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class DetailFragment method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.fab:
if (albumArtist != null) {
MusicUtils.shuffleAll(getActivity(), albumArtist.getSongsObservable());
} else if (album != null) {
MusicUtils.shuffleAll(getActivity(), album.getSongsObservable());
} else if (genre != null) {
MusicUtils.shuffleAll(getActivity(), genre.getSongsObservable(getContext()));
} else if (playlist != null) {
MusicUtils.shuffleAll(getActivity(), playlist.getSongsObservable(getContext()));
}
break;
case R.id.btn_overflow:
final PopupMenu menu = new PopupMenu(getActivity(), v);
if (album != null) {
MenuUtils.addAlbumMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, album);
menu.getMenu().add(ALBUM_FRAGMENT_GROUP_ID, VIEW_INFO, Menu.NONE, R.string.info);
} else if (albumArtist != null) {
MenuUtils.addAlbumArtistMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, albumArtist);
menu.getMenu().add(ALBUM_FRAGMENT_GROUP_ID, VIEW_INFO, Menu.NONE, R.string.info);
} else if (genre != null) {
} else if (playlist != null) {
MenuUtils.addPlaylistMenuOptions(menu, playlist);
//Remove the delete menu option, since we're looking at the playlist we would delete.
if (menu.getMenu().findItem(MusicUtils.PlaylistMenuOrder.DELETE_PLAYLIST) != null) {
menu.getMenu().removeItem(MusicUtils.PlaylistMenuOrder.DELETE_PLAYLIST);
}
MenuUtils.addClickHandler(getActivity(), menu, playlist, (materialDialog, dialogAction) -> {
//The user might have changed the playlist name
lineOne.setText(playlist.name);
}, (materialDialog, dialogAction) -> {
//If the user clicked 'edit', they've probably set a new 'week' range. Restart the loader.
refreshAdapterItems();
});
}
menu.show();
break;
}
}
use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class SongFragment method onOverflowClick.
@Override
public void onOverflowClick(View v, int position, final Song song) {
PopupMenu menu = new PopupMenu(SongFragment.this.getActivity(), v);
MenuUtils.addSongMenuOptions(getActivity(), menu);
MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, song, item -> {
switch(item.getItemId()) {
case BLACKLIST:
{
BlacklistHelper.addToBlacklist(song);
return true;
}
}
return false;
});
menu.show();
}
Aggregations