Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
@@ -41,9 +41,14 @@
|
|||||||
android:theme="@style/Theme.RiderPro">
|
android:theme="@style/Theme.RiderPro">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="image/*" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<service
|
<service
|
||||||
android:name=".MyFirebaseMessagingService"
|
android:name=".MyFirebaseMessagingService"
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import android.Manifest
|
|||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -25,6 +27,7 @@ import com.aiosman.riderpro.data.AccountService
|
|||||||
import com.aiosman.riderpro.data.AccountServiceImpl
|
import com.aiosman.riderpro.data.AccountServiceImpl
|
||||||
import com.aiosman.riderpro.ui.Navigation
|
import com.aiosman.riderpro.ui.Navigation
|
||||||
import com.aiosman.riderpro.ui.NavigationRoute
|
import com.aiosman.riderpro.ui.NavigationRoute
|
||||||
|
import com.aiosman.riderpro.ui.post.NewPostViewModel
|
||||||
import com.aiosman.riderpro.ui.post.PostViewModel
|
import com.aiosman.riderpro.ui.post.PostViewModel
|
||||||
import com.google.android.libraries.places.api.Places
|
import com.google.android.libraries.places.api.Places
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
@@ -108,6 +111,17 @@ class MainActivity : ComponentActivity() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// 处理分享过来的图片
|
||||||
|
if (intent?.action == Intent.ACTION_SEND || intent?.action == Intent.ACTION_SEND_MULTIPLE) {
|
||||||
|
val imageUris: List<Uri>? = if (intent.action == Intent.ACTION_SEND) {
|
||||||
|
listOf(intent.getParcelableExtra(Intent.EXTRA_STREAM)!!)
|
||||||
|
} else {
|
||||||
|
intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM)
|
||||||
|
}
|
||||||
|
NewPostViewModel.asNewPostWithImageUris(imageUris!!.map { it.toString() })
|
||||||
|
navController.navigate(NavigationRoute.NewPost.route)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import androidx.paging.Pager
|
|||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
|
import com.aiosman.riderpro.AppState
|
||||||
import com.aiosman.riderpro.data.MomentService
|
import com.aiosman.riderpro.data.MomentService
|
||||||
import com.aiosman.riderpro.entity.MomentEntity
|
import com.aiosman.riderpro.entity.MomentEntity
|
||||||
import com.aiosman.riderpro.entity.MomentPagingSource
|
import com.aiosman.riderpro.entity.MomentPagingSource
|
||||||
@@ -34,14 +35,13 @@ object FavouriteListViewModel:ViewModel() {
|
|||||||
if (force) {
|
if (force) {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
}
|
}
|
||||||
val profile = accountService.getMyAccountProfile()
|
|
||||||
isLoading = false
|
isLoading = false
|
||||||
Pager(
|
Pager(
|
||||||
config = PagingConfig(pageSize = 5, enablePlaceholders = false),
|
config = PagingConfig(pageSize = 5, enablePlaceholders = false),
|
||||||
pagingSourceFactory = {
|
pagingSourceFactory = {
|
||||||
MomentPagingSource(
|
MomentPagingSource(
|
||||||
MomentRemoteDataSource(momentService),
|
MomentRemoteDataSource(momentService),
|
||||||
favoriteUserId = profile.id
|
favoriteUserId = AppState.UserId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
).flow.cachedIn(viewModelScope).collectLatest {
|
).flow.cachedIn(viewModelScope).collectLatest {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import androidx.paging.PagingData
|
|||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
import androidx.paging.filter
|
import androidx.paging.filter
|
||||||
import androidx.paging.map
|
import androidx.paging.map
|
||||||
|
import com.aiosman.riderpro.AppState
|
||||||
import com.aiosman.riderpro.data.AccountService
|
import com.aiosman.riderpro.data.AccountService
|
||||||
import com.aiosman.riderpro.entity.MomentPagingSource
|
import com.aiosman.riderpro.entity.MomentPagingSource
|
||||||
import com.aiosman.riderpro.entity.MomentRemoteDataSource
|
import com.aiosman.riderpro.entity.MomentRemoteDataSource
|
||||||
@@ -40,9 +41,8 @@ object MomentViewModel : ViewModel() {
|
|||||||
if (pullRefresh) {
|
if (pullRefresh) {
|
||||||
refreshing = true
|
refreshing = true
|
||||||
}
|
}
|
||||||
val profile = accountService.getMyAccountProfile()
|
|
||||||
// 检查是否有动态
|
// 检查是否有动态
|
||||||
val existMoments = momentService.getMoments(timelineId = profile.id, pageNumber = 1)
|
val existMoments = momentService.getMoments(timelineId = AppState.UserId, pageNumber = 1)
|
||||||
if (existMoments.list.isEmpty()) {
|
if (existMoments.list.isEmpty()) {
|
||||||
existsMoment.value = true
|
existsMoment.value = true
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ object MomentViewModel : ViewModel() {
|
|||||||
MomentPagingSource(
|
MomentPagingSource(
|
||||||
MomentRemoteDataSource(momentService),
|
MomentRemoteDataSource(momentService),
|
||||||
// 如果没有动态,则显示热门动态
|
// 如果没有动态,则显示热门动态
|
||||||
timelineId = if (existMoments.list.isEmpty()) null else profile.id,
|
timelineId = if (existMoments.list.isEmpty()) null else AppState.UserId,
|
||||||
trend = if (existMoments.list.isEmpty()) true else null
|
trend = if (existMoments.list.isEmpty()) true else null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ object MyProfileViewModel : ViewModel() {
|
|||||||
refreshing = true
|
refreshing = true
|
||||||
}
|
}
|
||||||
firstLoad = false
|
firstLoad = false
|
||||||
profile = accountService.getMyAccountProfile()
|
|
||||||
val profile = accountService.getMyAccountProfile()
|
val profile = accountService.getMyAccountProfile()
|
||||||
|
this@MyProfileViewModel.profile = profile
|
||||||
refreshing = false
|
refreshing = false
|
||||||
try {
|
try {
|
||||||
Pager(
|
Pager(
|
||||||
@@ -71,13 +71,11 @@ object MyProfileViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun logout() {
|
suspend fun logout() {
|
||||||
accountService.getMyAccountProfile()
|
|
||||||
AppStore.apply {
|
AppStore.apply {
|
||||||
token = null
|
token = null
|
||||||
rememberMe = false
|
rememberMe = false
|
||||||
saveData()
|
saveData()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateUserProfileBanner(bannerImageUrl: Uri?, context: Context) {
|
fun updateUserProfileBanner(bannerImageUrl: Uri?, context: Context) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ object DiscoverViewModel:ViewModel() {
|
|||||||
}
|
}
|
||||||
fun refreshPager() {
|
fun refreshPager() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val profile = accountService.getMyAccountProfile()
|
|
||||||
Pager(
|
Pager(
|
||||||
config = PagingConfig(pageSize = 5, enablePlaceholders = false),
|
config = PagingConfig(pageSize = 5, enablePlaceholders = false),
|
||||||
pagingSourceFactory = {
|
pagingSourceFactory = {
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ object NewPostViewModel : ViewModel() {
|
|||||||
imageUriList = listOf()
|
imageUriList = listOf()
|
||||||
relPostId = null
|
relPostId = null
|
||||||
}
|
}
|
||||||
|
fun asNewPostWithImageUris(imageUris: List<String>) {
|
||||||
|
textContent = ""
|
||||||
|
searchPlaceAddressResult = null
|
||||||
|
modificationList = listOf()
|
||||||
|
imageUriList = imageUris
|
||||||
|
relPostId = null
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun uriToFile(context: Context, uri: Uri): File {
|
suspend fun uriToFile(context: Context, uri: Uri): File {
|
||||||
val inputStream: InputStream? = context.contentResolver.openInputStream(uri)
|
val inputStream: InputStream? = context.contentResolver.openInputStream(uri)
|
||||||
|
|||||||
Reference in New Issue
Block a user