Skip to content

Instantly share code, notes, and snippets.

View dynoChris's full-sized avatar
🎯
Focusing

dyno_chris dynoChris

🎯
Focusing
View GitHub Profile
@dynoChris
dynoChris / gist:282bae9239507b9b96d1e43e714bee05
Created January 9, 2022 08:58
How to add shadow to the text Android
android:shadowColor="#000"
android:shadowDx="-2"
android:shadowDy="-2"
android:shadowRadius="5"
<TextView
android:id="@+id/title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
@dynoChris
dynoChris / gist:6dde2296113c5e69572784c49d226770
Created January 5, 2022 00:20
How to use buildconfig arraylist
buildConfigField "String[]", "STRING_LIST",
"{" +
"\"String 1\"" +
"}"
@dynoChris
dynoChris / MainActivity.java
Last active August 4, 2021 14:49
How to work with MediaPlayer in Android
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
public class Toggler {
private static final int DEFAULT_MODE = 1; //count = 2: *,-,*,-,*,-,*,-...
//count = 1: *,*,*,*,*,*,*,*...
//count = 3: *,-,-,*,-,-,*,-...
public static final int WAIT_MODE = 2; //count = 2: -,*,*,*,*,*,*,*,*...
//count = 1: *,*,*,*,*,*,*,*,*...
//count = 3: -,-,*,*,*,*,*,*,*...
private int mMode = DEFAULT_MODE;
@dynoChris
dynoChris / gist:1427f6cbf9b6a3ecfd6e210ba800537d
Created May 19, 2021 10:14
How to change ProgressBar color in Android?
intermidiateTint="#fff"
@dynoChris
dynoChris / Repeater.java
Created October 11, 2020 17:36
How to repeat task in Java
public class Repeater {
private final int mEach;
private int mLap;
public Repeater(int each) {
this.mEach = each;
this.mLap = each;
}
@dynoChris
dynoChris / MainActivity.java
Created October 1, 2020 01:56
How to add multiple data to Firestore | Batched Writes (Android)
package com.oliverstudio.firestoreadmintest1;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.firestore.CollectionReference;
int switcher = 0;
int countLaps = 3;
switch (switcher) {
case 0:
switcher = (switcher+1)%countLaps;
break;
case 1:
switcher = (switcher+1)%countLaps;
@dynoChris
dynoChris / MainActivity.java
Last active November 24, 2020 08:07
putStringSet() Issue in Shared Preferences SOLVED
//What the problem?
//If you will put the String Set to Shared Preferences with a putStringSet() method it will be put,
//but for second iteration and more it is work uncorrectly. Let's see
public class MainActivity extends AppCompatActivity {
private Button mFirstButton, mSecondButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@dynoChris
dynoChris / MainActivity.java
Last active February 6, 2020 18:14
Work with SharedPreferences in Android
//put
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt("tag_number", 10);
editor.apply();
//get
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
int x = sharedPreferences.getInt("tag_number", 0);