use of android.support.v4.content.ContextCompat.getDrawable in project Rashr by DsLNeXuS.
the class BackupRestoreFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_backup_restore, container, false);
mActivity = (RashrActivity) getActivity();
mContext = root.getContext();
mPager = (ViewPager) root.findViewById(R.id.vpBackupRestore);
mAdapter = new BackupRestorePagerAdapter(getChildFragmentManager());
mPager.setAdapter(mAdapter);
SlidingTabLayout slidingTabLayout = (SlidingTabLayout) root.findViewById(R.id.stlBackupRestore);
slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = mContext.getTheme();
theme.resolveAttribute(R.attr.colorAccent, typedValue, true);
return typedValue.data;
}
@Override
public int getDividerColor(int position) {
return 0;
}
});
slidingTabLayout.setViewPager(mPager);
final FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fabCreateBackup);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isRecovery = mPager.getCurrentItem() == 0;
createBackup(isRecovery);
}
});
fab.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_add_white));
slidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (position == 0) {
if (RashrApp.DEVICE.isRecoveryDD() || RashrApp.DEVICE.isRecoveryMTD()) {
fab.setVisibility(View.VISIBLE);
} else {
fab.setVisibility(View.INVISIBLE);
}
} else {
if (RashrApp.DEVICE.isKernelDD() || RashrApp.DEVICE.isKernelMTD()) {
fab.setVisibility(View.VISIBLE);
} else {
fab.setVisibility(View.INVISIBLE);
}
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mAdapter.getRecoveryBackupFragment().getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!(RashrApp.DEVICE.isRecoveryDD() || RashrApp.DEVICE.isRecoveryMTD())) {
Toast.makeText(mContext, R.string.op_not_supported, Toast.LENGTH_SHORT).show();
} else {
showPopup(view);
}
}
});
mAdapter.getKernelBackupFragment().getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!(RashrApp.DEVICE.isKernelDD() || RashrApp.DEVICE.isKernelMTD())) {
Toast.makeText(mContext, R.string.op_not_supported, Toast.LENGTH_SHORT).show();
} else {
showPopup(view);
}
}
});
return root;
}
use of android.support.v4.content.ContextCompat.getDrawable in project android-topeka by googlesamples.
the class AvatarView method onDraw.
@Override
protected void onDraw(@NonNull Canvas canvas) {
super.onDraw(canvas);
if (mChecked) {
Drawable border = ContextCompat.getDrawable(getContext(), R.drawable.selector_avatar);
border.setBounds(0, 0, getWidth(), getHeight());
border.draw(canvas);
}
}
use of android.support.v4.content.ContextCompat.getDrawable in project android-UniversalMusicPlayer by googlesamples.
the class FullScreenPlayerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_player);
initializeToolbar();
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
}
mBackgroundImage = (ImageView) findViewById(R.id.background_image);
mPauseDrawable = ContextCompat.getDrawable(this, R.drawable.uamp_ic_pause_white_48dp);
mPlayDrawable = ContextCompat.getDrawable(this, R.drawable.uamp_ic_play_arrow_white_48dp);
mPlayPause = (ImageView) findViewById(R.id.play_pause);
mSkipNext = (ImageView) findViewById(R.id.next);
mSkipPrev = (ImageView) findViewById(R.id.prev);
mStart = (TextView) findViewById(R.id.startText);
mEnd = (TextView) findViewById(R.id.endText);
mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
mLine1 = (TextView) findViewById(R.id.line1);
mLine2 = (TextView) findViewById(R.id.line2);
mLine3 = (TextView) findViewById(R.id.line3);
mLoading = (ProgressBar) findViewById(R.id.progressBar1);
mControllers = findViewById(R.id.controllers);
mSkipNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaControllerCompat.TransportControls controls = MediaControllerCompat.getMediaController(FullScreenPlayerActivity.this).getTransportControls();
controls.skipToNext();
}
});
mSkipPrev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaControllerCompat.TransportControls controls = MediaControllerCompat.getMediaController(FullScreenPlayerActivity.this).getTransportControls();
controls.skipToPrevious();
}
});
mPlayPause.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PlaybackStateCompat state = MediaControllerCompat.getMediaController(FullScreenPlayerActivity.this).getPlaybackState();
if (state != null) {
MediaControllerCompat.TransportControls controls = MediaControllerCompat.getMediaController(FullScreenPlayerActivity.this).getTransportControls();
switch(state.getState()) {
// fall through
case PlaybackStateCompat.STATE_PLAYING:
case PlaybackStateCompat.STATE_BUFFERING:
controls.pause();
stopSeekbarUpdate();
break;
case PlaybackStateCompat.STATE_PAUSED:
case PlaybackStateCompat.STATE_STOPPED:
controls.play();
scheduleSeekbarUpdate();
break;
default:
LogHelper.d(TAG, "onClick with state ", state.getState());
}
}
}
});
mSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mStart.setText(DateUtils.formatElapsedTime(progress / 1000));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
stopSeekbarUpdate();
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
MediaControllerCompat.getMediaController(FullScreenPlayerActivity.this).getTransportControls().seekTo(seekBar.getProgress());
scheduleSeekbarUpdate();
}
});
// Only update from the intent if we are not recreating from a config change:
if (savedInstanceState == null) {
updateFromParams(getIntent());
}
mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null);
}
use of android.support.v4.content.ContextCompat.getDrawable in project android-UniversalMusicPlayer by googlesamples.
the class PlaybackControlsFragment method onPlaybackStateChanged.
private void onPlaybackStateChanged(PlaybackStateCompat state) {
LogHelper.d(TAG, "onPlaybackStateChanged ", state);
if (getActivity() == null) {
LogHelper.w(TAG, "onPlaybackStateChanged called when getActivity null," + "this should not happen if the callback was properly unregistered. Ignoring.");
return;
}
if (state == null) {
return;
}
boolean enablePlay = false;
switch(state.getState()) {
case PlaybackStateCompat.STATE_PAUSED:
case PlaybackStateCompat.STATE_STOPPED:
enablePlay = true;
break;
case PlaybackStateCompat.STATE_ERROR:
LogHelper.e(TAG, "error playbackstate: ", state.getErrorMessage());
Toast.makeText(getActivity(), state.getErrorMessage(), Toast.LENGTH_LONG).show();
break;
}
if (enablePlay) {
mPlayPause.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_play_arrow_black_36dp));
} else {
mPlayPause.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_pause_black_36dp));
}
MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity());
String extraInfo = null;
if (controller != null && controller.getExtras() != null) {
String castName = controller.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST);
if (castName != null) {
extraInfo = getResources().getString(R.string.casting_to_device, castName);
}
}
setExtraInfo(extraInfo);
}
use of android.support.v4.content.ContextCompat.getDrawable in project MTweaks-KernelAdiutorMOD by morogoku.
the class NavigationActivity method appendFragments.
private void appendFragments(boolean setShortcuts) {
sActualFragments.clear();
Menu menu = mNavigationView.getMenu();
menu.clear();
SubMenu lastSubMenu = null;
for (NavigationFragment navigationFragment : sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
Drawable drawable = ContextCompat.getDrawable(this, Utils.DONATED && Prefs.getBoolean("section_icons", true, this) && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable : R.drawable.ic_blank);
if (fragment == null) {
lastSubMenu = menu.addSubMenu(id);
sActualFragments.put(id, null);
} else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled", true, this)) {
MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) : lastSubMenu.add(0, id, 0, id);
menuItem.setIcon(drawable);
menuItem.setCheckable(true);
if (mSelection != 0) {
mNavigationView.setCheckedItem(mSelection);
}
sActualFragments.put(id, fragment);
}
}
if (setShortcuts) {
setShortcuts();
}
}
Aggregations