Search in sources :

Example 31 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Timber by naman14.

the class MainFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
        viewPager.setOffscreenPageLimit(2);
    }
    TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    return rootView;
}
Also used : TabLayout(android.support.design.widget.TabLayout) AppCompatActivity(android.support.v7.app.AppCompatActivity) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 32 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Timber by naman14.

the class PlaylistFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_playlist, container, false);
    Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    pager = (MultiViewPager) rootView.findViewById(R.id.playlistpager);
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle(R.string.playlists);
    playlists = PlaylistLoader.getPlaylists(getActivity(), showAuto);
    playlistcount = playlists.size();
    if (isDefault) {
        initPager();
    } else {
        initRecyclerView();
    }
    return rootView;
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 33 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Timber by naman14.

the class SearchAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(ItemHolder itemHolder, final int position) {
    itemHolder.menu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    long[] song = new long[1];
                    song[0] = ((Song) searchResults.get(position)).id;
                    switch(item.getItemId()) {
                        case R.id.popup_song_play:
                            MusicPlayer.playAll(mContext, song, 0, -1, TimberUtils.IdType.NA, false);
                            break;
                        case R.id.popup_song_play_next:
                            MusicPlayer.playNext(mContext, song, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtils.navigateToAlbum(mContext, ((Song) searchResults.get(position)).albumId, null);
                            break;
                        case R.id.popup_song_goto_artist:
                            NavigationUtils.navigateToArtist(mContext, ((Song) searchResults.get(position)).artistId, null);
                            break;
                        case R.id.popup_song_addto_queue:
                            MusicPlayer.addToQueue(mContext, song, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            AddPlaylistDialog.newInstance(((Song) searchResults.get(position))).show(((AppCompatActivity) mContext).getSupportFragmentManager(), "ADD_PLAYLIST");
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.show();
        }
    });
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) PopupMenu(android.widget.PopupMenu)

Example 34 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Timber by naman14.

the class ArtistDetailFragment method setupToolbar.

private void setupToolbar() {
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setDisplayHomeAsUpEnabled(true);
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) ActionBar(android.support.v7.app.ActionBar)

Example 35 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Robot-Scouter by SUPERCILEX.

the class ActivityScoutListFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mRootView.findViewById(R.id.toolbar));
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    super.onActivityCreated(savedInstanceState);
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)99 View (android.view.View)43 ActionBar (android.support.v7.app.ActionBar)36 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 Toolbar (android.support.v7.widget.Toolbar)14 BindView (butterknife.BindView)11 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Transition (android.transition.Transition)7 MenuItem (android.view.MenuItem)7 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Bundle (android.os.Bundle)4 FragmentManager (android.support.v4.app.FragmentManager)4