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
| @Module | |
| @InstallIn(ApplicationComponent::class) | |
| class TestAPIModule { | |
| @Provides | |
| fun giveRetrofitAPIService(): API = | |
| Retrofit.Builder() | |
| .baseUrl("http://localhost:8080/") | |
| // .baseUrl("http://127.0.0.1:8080") // this too works | |
| .addConverterFactory(MoshiConverterFactory.create()) |
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
| android { | |
| ... | |
| defaultConfig { | |
| ... | |
| testInstrumentationRunner "com.example.newsapp.runner.NewsRunner" | |
| ... | |
| } | |
| } |
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
| class NewsRunner : AndroidJUnitRunner() { | |
| override fun newApplication( | |
| cl: ClassLoader?, | |
| className: String?, | |
| context: Context? | |
| ): Application { | |
| return super.newApplication(cl, HiltTestApplication::class.java.name, context) | |
| } | |
| } |
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
| dependencies { | |
| ... | |
| // For instrumented tests. | |
| androidTestImplementation 'com.google.dagger:hilt-android-testing:2.28-alpha' | |
| kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.28-alpha' | |
| androidTestImplementation "io.mockk:mockk-android:1.9.3" | |
| androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.6.0" | |
| ... | |
| } |
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 void main(String[] args) { | |
| HashMap<Character, Character> map = new HashMap<>(); | |
| map.put('(', ')'); | |
| map.put('{', '}'); | |
| map.put('[', ']'); | |
| String ipString = "{[}]"; | |
| System.out.println(isBalancedParenthesis(map, ipString)); | |
| } |
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 void main(String[] args) { | |
| int i = 10; | |
| Integer ii = new Integer(i); // boxing - putting primitive type in wrapper classes | |
| Integer iii = i; // auto-boxing - putting primitive type in wrapper classes | |
| int j = ii.intValue(); // unboxing - getting primitive type from wrapper classes | |
| int jj = iii; // auto-unboxing - gettingg primitive types from wrapper classes | |
| System.out.println(i); | |
| System.out.println(ii); |
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
| fun main() { | |
| val bluePen = Pen(inkColor = "Blue") | |
| bluePen.showInkColor() | |
| val blackPen = Pen(inkColor = "Black") | |
| blackPen.showInkColor() | |
| val blueBlackPen = bluePen + blackPen | |
| blueBlackPen.showInkColor() | |
| } |
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
| fun main() { | |
| val emp1 = Employee(name = "audhil", id = 33) | |
| val emp2 = Employee(name = "audhil", id = 33) | |
| if (emp1 == emp2) { | |
| println("equal") | |
| } else | |
| println("not equal") | |
| println(emp1.hashCode()) |
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
| // based on http://www.theappguruz.com/blog/android-time-zone-demo | |
| class DummyActivity : Activity() { | |
| private var spinnerAvailableID: Spinner? = null | |
| private var current: Calendar? = null | |
| private var textTimeZone: TextView? = null | |
| private var txtCurrentTime: TextView? = null | |
| private var txtTimeZoneTime: TextView? = null | |
| private var miliSeconds: Long = 0 | |
| private var idAdapter: ArrayAdapter<String>? = null |
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
| // based on http://www.theappguruz.com/blog/android-time-zone-demo | |
| class DummyActivity : Activity() { | |
| private var spinnerAvailableID: Spinner? = null | |
| private var current: Calendar? = null | |
| private var textTimeZone: TextView? = null | |
| private var txtCurrentTime: TextView? = null | |
| private var txtTimeZoneTime: TextView? = null | |
| private var miliSeconds: Long = 0 | |
| private var idAdapter: ArrayAdapter<String>? = null |