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();
}
});
}
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);
}
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();
}
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);
}
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();
}
Aggregations