This file contains 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
@RunWith(PowerMockRunner.class) – Tell Junit that run this test using PowerMockRunner | |
@PrepareForTest(A.class) – This is needed when we need to test static methods of A class | |
AService mock = PowerMockito.mock(A.class) – Creating a mock for A class | |
PowerMockito.when(mock.mockedMethod()).thenReturn(value) – When mockedMethod is called in the code, then return the value specified here. |
This file contains 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
android { | |
defaultConfig { | |
multiDexEnabled true // Multiple dex enable only for Android Version >21 (prior v21 see more at: https://developer.android.com/studio/build/multidex.html) | |
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | |
// Keep file into main dex | |
multiDexKeepFile file('multidex-config.txt') | |
multiDexKeepProguard file('multidex-config.pro') | |
} | |
buildTypes { |
This file contains 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 lateinit var binding: ActivityMainBinding | |
binding = DataBindingUtil.setContentView(this, R.layout.activity_main) | |
// Set view model | |
binding.viewModel = viewModel | |
// Execute pending binding data | |
binding.executePendingBindings() | |
// View model | |
val viewModel = ViewModelProviders.of(this, viewModelFactory).get(MainViewModel::class.java) |
This file contains 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
Every app that requests the SYSTEM_ALERT_WINDOW permission and that is installed through the Play Store | |
(version 6.0.5 or higher is required), will have granted the permission automatically. | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ | |
// Show alert dialog to the user saying a separate permission is needed | |
// Launch the settings activity if the user prefers | |
Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); | |
startActivity(myIntent); | |
} |
This file contains 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
package com.tcsdev.tcsapp.features.usermenu.userprofile; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; |
This file contains 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
allprojects { | |
repositories { | |
jcenter() | |
} | |
} | |
ext { | |
//Android | |
androidBuildToolsVersion = "26.0.1" | |
androidMinSdkVersion = 15 |
This file contains 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
app_themes.xml https://codelabs.developers.google.com/codelabs/material-design-style/img/5ffbda8697aa2b0f.png |
This file contains 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
// 其次把文件插入到系统图库 | |
try { | |
MediaStore.Images.Media.insertImage(view.getMyContext().getContentResolver(), file.getAbsolutePath(), fileName, null); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} | |
// 最后通知图库更新 | |
view.getMyContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getPath()))); |
NewerOlder