Search in sources :

Example 16 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 17 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 18 with AppCompatActivity

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

the class NavigationUtils method navigateToArtist.

@TargetApi(21)
public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) {
    FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
    Fragment fragment;
    if (TimberUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) {
        Transition changeImage = TransitionInflater.from(context).inflateTransition(R.transition.image_transform);
        transaction.addSharedElement(transitionViews.first, transitionViews.second);
        fragment = ArtistDetailFragment.newInstance(artistID, true, transitionViews.second);
        fragment.setSharedElementEnterTransition(changeImage);
    } else {
        transaction.setCustomAnimations(R.anim.activity_fade_in, R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out);
        fragment = ArtistDetailFragment.newInstance(artistID, false, null);
    }
    transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
    transaction.add(R.id.fragment_container, fragment);
    transaction.addToBackStack(null).commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Transition(android.transition.Transition) AppCompatActivity(android.support.v7.app.AppCompatActivity) ArtistDetailFragment(com.naman14.timber.fragments.ArtistDetailFragment) Fragment(android.support.v4.app.Fragment) AlbumDetailFragment(com.naman14.timber.fragments.AlbumDetailFragment) TargetApi(android.annotation.TargetApi)

Example 19 with AppCompatActivity

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

the class Timber5 method setupSlidingQueue.

private void setupSlidingQueue() {
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
    adapter = new SlidingQueueAdapter((AppCompatActivity) getActivity(), QueueLoader.getQueueSongs(getActivity()));
    recyclerView.setAdapter(adapter);
    recyclerView.scrollToPosition(MusicPlayer.getQueuePosition() - 3);
}
Also used : SlidingQueueAdapter(com.naman14.timber.adapters.SlidingQueueAdapter) AppCompatActivity(android.support.v7.app.AppCompatActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 20 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project T-MVP by north2016.

the class SysPermissionAspect method aroundJoinPoint.

@Around("execution(@com.app.annotation.aspect.Permission * *(..)) && @annotation(permission)")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint, Permission permission) throws Throwable {
    AppCompatActivity ac = (AppCompatActivity) App.getAppContext().getCurActivity();
    new AlertDialog.Builder(ac).setTitle("提示").setMessage("为了应用可以正常使用,请您点击确认申请权限。").setNegativeButton("取消", null).setPositiveButton("允许", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            MPermissionUtils.requestPermissionsResult(ac, 1, permission.value(), new MPermissionUtils.OnPermissionListener() {

                @Override
                public void onPermissionGranted() {
                    try {
                        //获得权限,执行原方法
                        joinPoint.proceed();
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onPermissionDenied() {
                    MPermissionUtils.showTipsDialog(ac);
                }
            });
        }
    }).create().show();
}
Also used : DialogInterface(android.content.DialogInterface) AppCompatActivity(android.support.v7.app.AppCompatActivity) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)85 View (android.view.View)36 ActionBar (android.support.v7.app.ActionBar)32 TextView (android.widget.TextView)22 RecyclerView (android.support.v7.widget.RecyclerView)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 ImageView (android.widget.ImageView)16 Toolbar (android.support.v7.widget.Toolbar)12 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 Transition (android.transition.Transition)6 MenuItem (android.view.MenuItem)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 FragmentManager (android.support.v4.app.FragmentManager)4 PopupMenu (android.widget.PopupMenu)4 BindView (butterknife.BindView)4