Skip to content

Instantly share code, notes, and snippets.

View nazmulidris's full-sized avatar
🤙
❯ Write Rust 🦀 for r3bl-open-core ❯ rec 📹 live code vids developerlife YT chan

Nazmul Idris nazmulidris

🤙
❯ Write Rust 🦀 for r3bl-open-core ❯ rec 📹 live code vids developerlife YT chan
View GitHub Profile
public class MyService extends Service{
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
boolean containsCommand = MyIntentBuilder
.containsCommand(intent);
d(TAG,
String.format(
"Service in [%s] state. cmdId: [%d]. startId: [%d]",
mServiceIsStarted ? "STARTED" : "NOT STARTED",
containsCommand ?
@TargetApi(26)
public static class O {
public static final String CHANNEL_ID =
String.valueOf(getRandomNumber());
public static void createNotification(Service context) {
String channelId = createChannel(context);
Notification notification =
buildNotification(context, channelId);
@TargetApi(25)
public static class PreO {
public static void createNotification(Service context) {
// Create Pending Intents.
PendingIntent piLaunchMainActivity =
getLaunchActivityPI(context);
PendingIntent piStopService = getStopServicePI(context);
// Action to stop the service.
public class MyIntentBuilder{
public static MyIntentBuilder getInstance(Context context) {
return new MyIntentBuilder(context);
}
public MyIntentBuilder(Context context) {
this.mContext = context;
}
public MyIntentBuilder setMessage(String message) {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Support lib
implementation 'com.android.support:appcompat-v7:27.0.2'
// Lifecycles
implementation "android.arch.lifecycle:runtime:1.0.3"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
implementation "android.arch.lifecycle:common-java8:1.0.0"
class CounterLiveData extends MutableLiveData<Long> {
public String toString() {
return String.format("count=%d", getValue());
}
public Long get() {
return getValue() == null ? 0L : getValue();
}
public void set(Long value) {
class StateViewModel extends AndroidViewModel {
private final ScheduledExecutorService myExecutor;
private String mData; // This value doesn't change after it is initialized
private CounterLiveData mCounter = new CounterLiveData(); // This value changes over time
public StateViewModel(Application context) {
super(context);
myExecutor = Executors.newSingleThreadScheduledExecutor();
myExecutor.scheduleWithFixedDelay(this::recurringTask, 0, 1, TimeUnit.SECONDS);
Log.d(Tags.viewmodel.name(), "ViewModel constructor: created executor");
public class MainActivity extends AppCompatActivity {
private TextView dataTextView;
private TextView counterTextView;
private StateViewModel stateViewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dataTextView = findViewById(R.id.data_textview);
private void initializeSeekBar() {
mSeekBarAudio.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
int userSelectedPosition = 0;
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
mUserIsSeeking = true;
}
public interface PlayerAdapter {
void loadMedia(int resourceId);
void release();
boolean isPlaying();
void play();