Skip to content

Commit cf7feea

Browse files
authored
Overhaul Application (#17)
- YOLO
1 parent 0a10f72 commit cf7feea

33 files changed

+1779
-793
lines changed

TODO.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
- Implement Retrofit into Current Settings
44
- ❓ Implement Room into Retrofit (or keep separate)
55
- ❓ Replace SettingsActivity with a SettingsFragment
6-
- ❓ Update Navigation with addToBackStack (like Zipline)
76

87
## Layouts
98

109
- Server Setup (Login)
11-
- File(s) Preview
1210
- Text Preview
13-
- URL Preview
1411
- Add Server
1512
- Edit Server
1613

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ dependencies {
4646
implementation(libs.material)
4747
implementation(libs.androidx.activity)
4848
implementation(libs.androidx.preference.ktx)
49+
implementation(libs.androidx.lifecycle.livedata.ktx)
50+
implementation(libs.androidx.lifecycle.viewmodel.ktx)
51+
implementation(libs.androidx.navigation.fragment.ktx)
52+
implementation(libs.androidx.navigation.ui.ktx)
4953
implementation(libs.okhttp)
5054
implementation(libs.retrofit)
5155
implementation(libs.retrofit.gson)

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262

6363
</activity>
6464

65-
<!-- TODO: Remove SettingsActivity -->
66-
<activity android:name=".settings.SettingsActivity" />
67-
6865
</application>
6966

7067
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.djangofiles.djangofiles
2+
3+
import androidx.lifecycle.LiveData
4+
import androidx.lifecycle.MutableLiveData
5+
import androidx.lifecycle.ViewModel
6+
7+
class HomeViewModel : ViewModel() {
8+
9+
//private val _urlToLoad = MutableLiveData<String>()
10+
private val _urlToLoad = MutableLiveData<Event<String>>()
11+
12+
//val urlToLoad: LiveData<String> = _urlToLoad
13+
val urlToLoad: LiveData<Event<String>> = _urlToLoad
14+
15+
val webViewUrl = MutableLiveData<String>()
16+
17+
fun navigateTo(url: String) {
18+
//_urlToLoad.value = url
19+
_urlToLoad.value = Event(url)
20+
}
21+
}
22+
23+
class Event<out T>(private val content: T) {
24+
private var hasBeenHandled = false
25+
26+
fun getContentIfNotHandled(): T? {
27+
return if (hasBeenHandled) null else {
28+
hasBeenHandled = true
29+
content
30+
}
31+
}
32+
33+
fun peekContent(): T = content
34+
}

0 commit comments

Comments
 (0)