This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); | |
toneGen1.startTone(ToneGenerator.TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP,5000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); | |
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); | |
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build(); | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl("https://backend.example.com") | |
.client(client) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#okhttp3 | |
# JSR 305 annotations are for embedding nullability information. | |
-dontwarn javax.annotation.** | |
# A resource is loaded with a relative path so the package of this class must be preserved. | |
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase | |
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. | |
-dontwarn org.codehaus.mojo.animal_sniffer.* | |
# OkHttp platform used only on JVM and when Conscrypt dependency is available. | |
-dontwarn okhttp3.internal.platform.ConscryptPlatform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String modifyDate(String incomeDate) { | |
try { | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
Date d = sdf.parse(incomeDate); | |
SimpleDateFormat sdfOut = new SimpleDateFormat("LLL dd, yyyy"); | |
String dateAsString = sdfOut.format(d); | |
return dateAsString; | |
} catch (Exception exc) { | |
exc.printStackTrace(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private byte[] compress(String data) throws IOException { | |
ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length()); | |
GZIPOutputStream gzip = new GZIPOutputStream(bos); | |
gzip.write(data.getBytes()); | |
gzip.close(); | |
byte[] compressed = bos.toByteArray(); | |
bos.close(); | |
return compressed; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Saving List. | |
//If you want persist List you need implement TypeConverter | |
//List<User> to json as string; json as string to List<User>. | |
public class YourTypeConverterForPersistList { | |
@TypeConverter | |
public String listUsersToJson(List<User> users) { | |
Gson gson = new Gson(); | |
Type type = new TypeToken<List<User>>() {}.getType(); | |
String json = gson.toJson(users, type); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
//views | |
private Toolbar mToolbar; | |
private BottomNavigationView mBottomNavigationView; | |
//general vars | |
private HomeFragment mHomeFragment; | |
private VideosFragment mVideosFragment; | |
private HistoryFragment mHistoryFragment; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
03-31 21:07:56.453 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onAttach: fragment | |
03-31 21:07:56.453 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onCreate: fragment | |
03-31 21:07:56.517 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onCreateView: fragment | |
03-31 21:07:56.518 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onCreate: | |
03-31 21:07:56.519 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onActivityCreated: fragment | |
03-31 21:07:56.519 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onStart: fragment | |
03-31 21:07:56.519 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onStart: | |
03-31 21:07:56.520 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onResume: | |
03-31 21:07:56.520 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onResume: fragment | |
03-31 21:08:37.075 20548-20548/com.oliverstudio.androidlifecycler D/devptag: onPause: fragment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. add maven in allprojects | |
//maven { | |
// url "https://maven.google.com" | |
//} | |
//2. add implementation 'com.google.android.ads.consent:consent-library:1.0.6' | |
//then rest | |
public class MainActivity extends AppCompatActivity { | |
ConsentForm form; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String filePath = "/data/data/com.example.vadym.test1/filename.txt"; | |
String all = ""; | |
try { | |
BufferedReader br = new BufferedReader(new FileReader(filePath)); | |
String strLine; | |
while ((strLine = br.readLine()) != null){ | |
all = all + strLine; | |
} | |
Log.d(Utils.TAG, all); | |
} catch (IOException e) { |