mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-25 19:49:43 +08:00
Convert Java Code to Kotlin Code
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@
|
||||
[](https://github.com/rmbadmin/SteamTools/network/members)
|
||||

|
||||
[](https://github.com/SteamTools-Team/SteamTools/search?l=c%23)
|
||||
[](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-6)
|
||||
[](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-7)
|
||||
[](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10)
|
||||
|
||||
[](https://github.com/AvaloniaUI/Avalonia)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
[](https://github.com/rmbadmin/SteamTools/network/members)
|
||||

|
||||
[](https://github.com/SteamTools-Team/SteamTools/search?l=c%23)
|
||||
[](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-6)
|
||||
[](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-7)
|
||||
[](https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-new/csharp-10)
|
||||
|
||||
[](https://github.com/AvaloniaUI/Avalonia)
|
||||
|
||||
@@ -7,7 +7,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "net.steampp.app.design"
|
||||
minSdkVersion 21
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package net.steampp.app.ui;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
static Context _context;
|
||||
|
||||
public static Context getContext() {
|
||||
return _context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
_context = this;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package net.steampp.app.ui
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
|
||||
class MainApplication : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
context = this
|
||||
}
|
||||
|
||||
companion object {
|
||||
var context: Context? = null
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package net.steampp.app.ui.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import net.steampp.app.design.R;
|
||||
import net.steampp.app.ui.databinding.ActivityMainBinding;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
// 底部导航(https://material.io/components/bottom-navigation)
|
||||
// - 需要从应用程序中的任何地方访问的顶级目的地
|
||||
// - 三到五个目的地
|
||||
// - 仅限移动或平板电脑
|
||||
// 导航抽屉(https://material.io/components/navigation-drawer)
|
||||
// - 具有五个或更多顶级目的地的应用
|
||||
// - 具有两个或两个以上级别的导航等级的应用程序
|
||||
// - 不相关的目的地之间的快速导航
|
||||
|
||||
BottomNavigationView navView = findViewById(R.id.nav_view);
|
||||
// Passing each menu ID as a set of Ids because each
|
||||
// menu should be considered as top level destinations.
|
||||
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
||||
R.id.navigation_local_auth, R.id.navigation_community_fix, R.id.navigation_game_list, R.id.navigation_my)
|
||||
.build();
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
NavigationUI.setupWithNavController(binding.navView, navController);
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package net.steampp.app.ui.activities
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import net.steampp.app.design.R
|
||||
import androidx.navigation.Navigation
|
||||
import androidx.navigation.ui.NavigationUI
|
||||
import net.steampp.app.ui.databinding.ActivityMainBinding
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private var binding: ActivityMainBinding? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding!!.root)
|
||||
|
||||
// 底部导航(https://material.io/components/bottom-navigation)
|
||||
// - 需要从应用程序中的任何地方访问的顶级目的地
|
||||
// - 三到五个目的地
|
||||
// - 仅限移动或平板电脑
|
||||
// 导航抽屉(https://material.io/components/navigation-drawer)
|
||||
// - 具有五个或更多顶级目的地的应用
|
||||
// - 具有两个或两个以上级别的导航等级的应用程序
|
||||
// - 不相关的目的地之间的快速导航
|
||||
|
||||
// Passing each menu ID as a set of Ids because each
|
||||
// menu should be considered as top level destinations.
|
||||
val appBarConfiguration = AppBarConfiguration.Builder(
|
||||
R.id.navigation_local_auth,
|
||||
R.id.navigation_community_fix,
|
||||
R.id.navigation_game_list,
|
||||
R.id.navigation_my
|
||||
)
|
||||
.build()
|
||||
val navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main)
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration)
|
||||
NavigationUI.setupWithNavController(binding!!.navView, navController)
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package net.steampp.app.ui.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package net.steampp.app.ui.activities
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.content.Intent
|
||||
|
||||
class SplashActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package net.steampp.app.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import net.steampp.app.ui.databinding.FragmentGameListBinding;
|
||||
import net.steampp.app.ui.viewmodels.GameListViewModel;
|
||||
|
||||
public class ASFPlusFragment extends Fragment {
|
||||
|
||||
private GameListViewModel viewModel;
|
||||
private FragmentGameListBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
viewModel =
|
||||
new ViewModelProvider(this).get(GameListViewModel.class);
|
||||
|
||||
binding = FragmentGameListBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
final TextView textView = binding.textView;
|
||||
viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package net.steampp.app.ui.fragments
|
||||
|
||||
import net.steampp.app.ui.viewmodels.GameListViewModel
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import net.steampp.app.ui.databinding.FragmentGameListBinding
|
||||
|
||||
class ASFPlusFragment : Fragment() {
|
||||
private var viewModel: GameListViewModel? = null
|
||||
private var binding: FragmentGameListBinding? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
viewModel = ViewModelProvider(this).get(GameListViewModel::class.java)
|
||||
binding = FragmentGameListBinding.inflate(inflater, container, false)
|
||||
val root: View = binding!!.root
|
||||
val textView: TextView = binding!!.textView
|
||||
viewModel!!.text.observe(viewLifecycleOwner, { s -> textView.text = s })
|
||||
return root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
binding = null
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package net.steampp.app.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import net.steampp.app.ui.databinding.FragmentCommunityFixBinding;
|
||||
import net.steampp.app.ui.viewmodels.CommunityFixViewModel;
|
||||
|
||||
public class CommunityFixFragment extends Fragment {
|
||||
|
||||
private CommunityFixViewModel viewModel;
|
||||
private FragmentCommunityFixBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
viewModel =
|
||||
new ViewModelProvider(this).get(CommunityFixViewModel.class);
|
||||
|
||||
binding = FragmentCommunityFixBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
final TextView textView = binding.textView;
|
||||
viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package net.steampp.app.ui.fragments
|
||||
|
||||
import net.steampp.app.ui.viewmodels.CommunityFixViewModel
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import net.steampp.app.ui.databinding.FragmentCommunityFixBinding
|
||||
|
||||
class CommunityFixFragment : Fragment() {
|
||||
private var viewModel: CommunityFixViewModel? = null
|
||||
private var binding: FragmentCommunityFixBinding? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
viewModel = ViewModelProvider(this).get(CommunityFixViewModel::class.java)
|
||||
binding = FragmentCommunityFixBinding.inflate(inflater, container, false)
|
||||
val root: View = binding!!.root
|
||||
val textView: TextView = binding!!.textView
|
||||
viewModel!!.text.observe(viewLifecycleOwner, { s -> textView.text = s })
|
||||
return root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
binding = null
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package net.steampp.app.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import net.steampp.app.ui.databinding.FragmentGameListBinding;
|
||||
import net.steampp.app.ui.viewmodels.GameListViewModel;
|
||||
|
||||
public class GameListFragment extends Fragment {
|
||||
|
||||
private GameListViewModel viewModel;
|
||||
private FragmentGameListBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
viewModel =
|
||||
new ViewModelProvider(this).get(GameListViewModel.class);
|
||||
|
||||
binding = FragmentGameListBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
final TextView textView = binding.textView;
|
||||
viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package net.steampp.app.ui.fragments
|
||||
|
||||
import net.steampp.app.ui.viewmodels.GameListViewModel
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import net.steampp.app.ui.databinding.FragmentGameListBinding
|
||||
|
||||
class GameListFragment : Fragment() {
|
||||
private var viewModel: GameListViewModel? = null
|
||||
private var binding: FragmentGameListBinding? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
viewModel = ViewModelProvider(this).get(GameListViewModel::class.java)
|
||||
binding = FragmentGameListBinding.inflate(inflater, container, false)
|
||||
val root: View = binding!!.root
|
||||
val textView: TextView = binding!!.textView
|
||||
viewModel!!.text.observe(viewLifecycleOwner, { s -> textView.text = s })
|
||||
return root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
binding = null
|
||||
}
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
package net.steampp.app.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import net.steampp.app.design.R;
|
||||
import net.steampp.app.ui.viewmodels.LocalAuthViewModel;
|
||||
|
||||
public class LocalAuthFragment extends Fragment {
|
||||
|
||||
private LocalAuthViewModel viewModel;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
viewModel =
|
||||
new ViewModelProvider(this).get(LocalAuthViewModel.class);
|
||||
|
||||
View root = inflater.inflate(R.layout.fragment_local_auth_test, container, false);
|
||||
|
||||
final TextView textView = root.findViewById(R.id.textView);
|
||||
viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package net.steampp.app.ui.fragments
|
||||
|
||||
import net.steampp.app.ui.viewmodels.LocalAuthViewModel
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import net.steampp.app.design.R
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
class LocalAuthFragment : Fragment() {
|
||||
private var viewModel: LocalAuthViewModel? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
viewModel = ViewModelProvider(this).get(LocalAuthViewModel::class.java)
|
||||
val root = inflater.inflate(R.layout.fragment_local_auth_test, container, false)
|
||||
val textView = root.findViewById<TextView>(R.id.textView)
|
||||
viewModel!!.text.observe(viewLifecycleOwner, { s -> textView.text = s })
|
||||
return root
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package net.steampp.app.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import net.steampp.app.ui.databinding.FragmentMyBinding;
|
||||
import net.steampp.app.ui.viewmodels.MyViewModel;
|
||||
|
||||
public class MyFragment extends Fragment {
|
||||
|
||||
private MyViewModel viewModel;
|
||||
private FragmentMyBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
viewModel =
|
||||
new ViewModelProvider(this).get(MyViewModel.class);
|
||||
|
||||
binding = FragmentMyBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
// final TextView textView = binding.textView;
|
||||
// viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
// @Override
|
||||
// public void onChanged(@Nullable String s) {
|
||||
// textView.setText(s);
|
||||
// }
|
||||
// });
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package net.steampp.app.ui.fragments
|
||||
|
||||
import net.steampp.app.ui.viewmodels.MyViewModel
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import net.steampp.app.ui.databinding.FragmentMyBinding
|
||||
|
||||
class MyFragment : Fragment() {
|
||||
private var viewModel: MyViewModel? = null
|
||||
private var binding: FragmentMyBinding? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
viewModel = ViewModelProvider(this).get(MyViewModel::class.java)
|
||||
binding =
|
||||
FragmentMyBinding.inflate(inflater, container, false)
|
||||
|
||||
// final TextView textView = binding.textView;
|
||||
// viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
// @Override
|
||||
// public void onChanged(@Nullable String s) {
|
||||
// textView.setText(s);
|
||||
// }
|
||||
// });
|
||||
return binding!!.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
binding = null
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package net.steampp.app.ui.viewmodels;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.steampp.app.design.R;
|
||||
import net.steampp.app.ui.MainApplication;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CommunityFixViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
|
||||
public CommunityFixViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue(Arrays.stream(this.getClass().getName().split("\\.")).reduce((first, second) -> second).orElse("").replace("ViewModel","") + "\n" + MainApplication.getContext().getString(R.string.under_construction));
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package net.steampp.app.ui.viewmodels
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.LiveData
|
||||
import net.steampp.app.ui.MainApplication
|
||||
import net.steampp.app.design.R
|
||||
import java.util.*
|
||||
|
||||
class CommunityFixViewModel : ViewModel() {
|
||||
private val mText: MutableLiveData<String>
|
||||
val text: LiveData<String>
|
||||
get() = mText
|
||||
|
||||
init {
|
||||
mText = MutableLiveData()
|
||||
mText.setValue(
|
||||
"""
|
||||
${
|
||||
Arrays.stream(this.javaClass.name.split("\\.").toTypedArray())
|
||||
.reduce { first: String?, second: String -> second }.orElse("")
|
||||
.replace("ViewModel", "")
|
||||
}
|
||||
${MainApplication.context?.getString(R.string.under_construction)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package net.steampp.app.ui.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.steampp.app.design.R;
|
||||
import net.steampp.app.ui.MainApplication;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GameListViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
|
||||
public GameListViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue(Arrays.stream(this.getClass().getName().split("\\.")).reduce((first, second) -> second).orElse("").replace("ViewModel","") + "\n" + MainApplication.getContext().getString(R.string.under_construction));
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package net.steampp.app.ui.viewmodels
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.LiveData
|
||||
import net.steampp.app.ui.MainApplication
|
||||
import net.steampp.app.design.R
|
||||
import java.util.*
|
||||
|
||||
class GameListViewModel : ViewModel() {
|
||||
private val mText: MutableLiveData<String>
|
||||
val text: LiveData<String>
|
||||
get() = mText
|
||||
|
||||
init {
|
||||
mText = MutableLiveData()
|
||||
mText.setValue(
|
||||
"""
|
||||
${
|
||||
Arrays.stream(this.javaClass.name.split("\\.").toTypedArray())
|
||||
.reduce { first: String?, second: String -> second }.orElse("")
|
||||
.replace("ViewModel", "")
|
||||
}
|
||||
${MainApplication.context?.getString(R.string.under_construction)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package net.steampp.app.ui.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.steampp.app.design.R;
|
||||
import net.steampp.app.ui.MainApplication;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LocalAuthViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
|
||||
public LocalAuthViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue(Arrays.stream(this.getClass().getName().split("\\.")).reduce((first, second) -> second).orElse("").replace("ViewModel","") + "\n" + MainApplication.getContext().getString(R.string.under_construction));
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package net.steampp.app.ui.viewmodels
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.LiveData
|
||||
import net.steampp.app.ui.MainApplication
|
||||
import net.steampp.app.design.R
|
||||
import java.util.*
|
||||
|
||||
class LocalAuthViewModel : ViewModel() {
|
||||
private val mText: MutableLiveData<String>
|
||||
val text: LiveData<String>
|
||||
get() = mText
|
||||
|
||||
init {
|
||||
mText = MutableLiveData()
|
||||
mText.setValue(
|
||||
"""
|
||||
${
|
||||
Arrays.stream(this.javaClass.name.split("\\.").toTypedArray())
|
||||
.reduce { first: String?, second: String -> second }.orElse("")
|
||||
.replace("ViewModel", "")
|
||||
}
|
||||
${MainApplication.context?.getString(R.string.under_construction)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package net.steampp.app.ui.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.steampp.app.design.R;
|
||||
import net.steampp.app.ui.MainApplication;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MyViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
|
||||
public MyViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue(Arrays.stream(this.getClass().getName().split("\\.")).reduce((first, second) -> second).orElse("").replace("ViewModel","") + "\n" + MainApplication.getContext().getString(R.string.under_construction));
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package net.steampp.app.ui.viewmodels
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.LiveData
|
||||
import net.steampp.app.ui.MainApplication
|
||||
import net.steampp.app.design.R
|
||||
import java.util.*
|
||||
|
||||
class MyViewModel : ViewModel() {
|
||||
private val mText: MutableLiveData<String>
|
||||
val text: LiveData<String>
|
||||
get() = mText
|
||||
|
||||
init {
|
||||
mText = MutableLiveData()
|
||||
mText.setValue(
|
||||
"""
|
||||
${
|
||||
Arrays.stream(this.javaClass.name.split("\\.").toTypedArray())
|
||||
.reduce { first: String?, second: String -> second }.orElse("")
|
||||
.replace("ViewModel", "")
|
||||
}
|
||||
${MainApplication.context?.getString(R.string.under_construction)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
package com.github.wwluo14.nospacetextview;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.text.Layout;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
/**
|
||||
* @author luowang8
|
||||
* @date 2020-01-17 16:36
|
||||
* @url https://github.com/wwluo14/NoSpaceTextView/blob/master/app/src/main/java/com/demo/nospacetextview/NoSpaceTextView.java
|
||||
*/
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public class NoSpaceTextView extends AppCompatTextView {
|
||||
|
||||
/**
|
||||
* 控制measure()方法 刷新测量
|
||||
*/
|
||||
private boolean refreshMeasure = false;
|
||||
|
||||
public NoSpaceTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public NoSpaceTextView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public NoSpaceTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
removeSpace(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
super.setText(text, type);
|
||||
// 每次文本内容改变时,需要测量两次,确保计算的高度没有问题
|
||||
refreshMeasure = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 这里处理文本的上下留白问题
|
||||
*/
|
||||
private void removeSpace(int widthspc, int heightspc) {
|
||||
String[] linesText = getLinesText();
|
||||
TextPaint paint = getPaint();
|
||||
Rect rect = new Rect();
|
||||
String text = linesText[0];
|
||||
paint.getTextBounds(text, 0, text.length(), rect);
|
||||
|
||||
Paint.FontMetricsInt fontMetricsInt = new Paint.FontMetricsInt();
|
||||
paint.getFontMetricsInt(fontMetricsInt);
|
||||
|
||||
int paddingTop = (fontMetricsInt.top - rect.top);
|
||||
|
||||
// 设置TextView向上的padding (小于0, 即把TextView文本内容向上移动)
|
||||
setPadding(getLeftPaddingOffset()
|
||||
, paddingTop + getTopPaddingOffset()
|
||||
, getRightPaddingOffset()
|
||||
, getBottomPaddingOffset());
|
||||
|
||||
String endText = linesText[linesText.length - 1];
|
||||
paint.getTextBounds(endText, 0, endText.length(), rect);
|
||||
|
||||
// 再减去最后一行文本的底部空白,得到的就是TextView内容上线贴边的的高度,到达消除文本上下留白的问题
|
||||
setMeasuredDimension(getMeasuredWidth()
|
||||
, getMeasuredHeight() - (fontMetricsInt.bottom - rect.bottom));
|
||||
|
||||
if (refreshMeasure) {
|
||||
refreshMeasure = false;
|
||||
measure(widthspc, heightspc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取每一行的文本内容
|
||||
*/
|
||||
private String[] getLinesText() {
|
||||
int start = 0;
|
||||
|
||||
String[] texts = new String[getLineCount()];
|
||||
|
||||
String text = getText().toString();
|
||||
|
||||
Layout layout = getLayout();
|
||||
|
||||
for (int i = 0; i < getLineCount(); i++) {
|
||||
int end = layout.getLineEnd(i);
|
||||
|
||||
String line = text.substring(start, end); //指定行的内容
|
||||
start = end;
|
||||
|
||||
texts[i] = line;
|
||||
}
|
||||
|
||||
return texts;
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.github.wwluo14.nospacetextview
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import android.graphics.Paint.FontMetricsInt
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
|
||||
/**
|
||||
* @author luowang8
|
||||
* @date 2020-01-17 16:36
|
||||
* @url https://github.com/wwluo14/NoSpaceTextView/blob/master/app/src/main/java/com/demo/nospacetextview/NoSpaceTextView.java
|
||||
*/
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
class NoSpaceTextView : AppCompatTextView {
|
||||
/**
|
||||
* 控制measure()方法 刷新测量
|
||||
*/
|
||||
private var refreshMeasure = false
|
||||
|
||||
constructor(context: Context?) : super(context!!) {}
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(
|
||||
context!!, attrs
|
||||
) {
|
||||
}
|
||||
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context!!, attrs, defStyleAttr
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
removeSpace(widthMeasureSpec, heightMeasureSpec)
|
||||
}
|
||||
|
||||
override fun setText(text: CharSequence, type: BufferType) {
|
||||
super.setText(text, type)
|
||||
// 每次文本内容改变时,需要测量两次,确保计算的高度没有问题
|
||||
refreshMeasure = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 这里处理文本的上下留白问题
|
||||
*/
|
||||
private fun removeSpace(widthspc: Int, heightspc: Int) {
|
||||
val rect = Rect()
|
||||
val text = linesText[0]
|
||||
paint.getTextBounds(text, 0, text!!.length, rect)
|
||||
val fontMetricsInt = FontMetricsInt()
|
||||
paint.getFontMetricsInt(fontMetricsInt)
|
||||
val paddingTop = fontMetricsInt.top - rect.top
|
||||
|
||||
// 设置TextView向上的padding (小于0, 即把TextView文本内容向上移动)
|
||||
setPadding(
|
||||
leftPaddingOffset,
|
||||
paddingTop + topPaddingOffset,
|
||||
rightPaddingOffset,
|
||||
bottomPaddingOffset
|
||||
)
|
||||
val endText = linesText[linesText.size - 1]
|
||||
paint.getTextBounds(endText, 0, endText!!.length, rect)
|
||||
|
||||
// 再减去最后一行文本的底部空白,得到的就是TextView内容上线贴边的的高度,到达消除文本上下留白的问题
|
||||
setMeasuredDimension(
|
||||
measuredWidth, measuredHeight - (fontMetricsInt.bottom - rect.bottom)
|
||||
)
|
||||
if (refreshMeasure) {
|
||||
refreshMeasure = false
|
||||
measure(widthspc, heightspc)
|
||||
}
|
||||
}//指定行的内容
|
||||
|
||||
/**
|
||||
* 获取每一行的文本内容
|
||||
*/
|
||||
private val linesText: Array<String?>
|
||||
private get() {
|
||||
var start = 0
|
||||
val texts = arrayOfNulls<String>(lineCount)
|
||||
val text = text.toString()
|
||||
val layout = layout
|
||||
for (i in 0 until lineCount) {
|
||||
val end = layout.getLineEnd(i)
|
||||
val line = text.substring(start, end) //指定行的内容
|
||||
start = end
|
||||
texts[i] = line
|
||||
}
|
||||
return texts
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace System.Application.UI
|
||||
string? requestUri,
|
||||
int targetSize = 0,
|
||||
int targetResId = 0,
|
||||
ScaleType? scaleType = default)
|
||||
ScaleType scaleType = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(requestUri))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user