From cbc9db73cd53e30bd854a508ec74555e3035f170 Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Wed, 17 Feb 2021 11:40:47 -0800 Subject: [PATCH] Changed (unused) gallery and slideshow code to Kotlin --- .../listify/ui/gallery/GalleryFragment.java | 35 ------------------- .../listify/ui/gallery/GalleryFragment.kt | 23 ++++++++++++ .../listify/ui/gallery/GalleryViewModel.java | 19 ---------- .../listify/ui/gallery/GalleryViewModel.kt | 16 +++++++++ .../ui/slideshow/SlideshowFragment.java | 35 ------------------- .../listify/ui/slideshow/SlideshowFragment.kt | 23 ++++++++++++ .../ui/slideshow/SlideshowViewModel.java | 19 ---------- .../ui/slideshow/SlideshowViewModel.kt | 16 +++++++++ 8 files changed, 78 insertions(+), 108 deletions(-) delete mode 100644 Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.java create mode 100644 Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.kt delete mode 100644 Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.java create mode 100644 Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.kt delete mode 100644 Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.java create mode 100644 Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.kt delete mode 100644 Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.java create mode 100644 Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.kt diff --git a/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.java b/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.java deleted file mode 100644 index 2cbcb13..0000000 --- a/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.listify.ui.gallery; - -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.ViewModelProviders; - -import com.example.listify.R; - -public class GalleryFragment extends Fragment { - - private GalleryViewModel galleryViewModel; - - public View onCreateView(@NonNull LayoutInflater inflater, - ViewGroup container, Bundle savedInstanceState) { - galleryViewModel = - ViewModelProviders.of(this).get(GalleryViewModel.class); - View root = inflater.inflate(R.layout.fragment_gallery, container, false); - final TextView textView = root.findViewById(R.id.text_gallery); - galleryViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { - @Override - public void onChanged(@Nullable String s) { - textView.setText(s); - } - }); - return root; - } -} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.kt b/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.kt new file mode 100644 index 0000000..856a686 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryFragment.kt @@ -0,0 +1,23 @@ +package com.example.listify.ui.gallery + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import com.example.listify.R + +class GalleryFragment : Fragment() { + private var galleryViewModel: GalleryViewModel? = null + override fun onCreateView(inflater: LayoutInflater, + container: ViewGroup?, savedInstanceState: Bundle?): View? { + galleryViewModel = ViewModelProviders.of(this).get(GalleryViewModel::class.java) + val root = inflater.inflate(R.layout.fragment_gallery, container, false) + val textView = root.findViewById(R.id.text_gallery) + galleryViewModel!!.text.observe(viewLifecycleOwner, Observer { s -> textView.text = s }) + return root + } +} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.java b/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.java deleted file mode 100644 index 336cba6..0000000 --- a/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.listify.ui.gallery; - -import androidx.lifecycle.LiveData; -import androidx.lifecycle.MutableLiveData; -import androidx.lifecycle.ViewModel; - -public class GalleryViewModel extends ViewModel { - - private MutableLiveData mText; - - public GalleryViewModel() { - mText = new MutableLiveData<>(); - mText.setValue("This is gallery fragment"); - } - - public LiveData getText() { - return mText; - } -} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.kt b/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.kt new file mode 100644 index 0000000..80ebcff --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/ui/gallery/GalleryViewModel.kt @@ -0,0 +1,16 @@ +package com.example.listify.ui.gallery + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class GalleryViewModel : ViewModel() { + private val mText: MutableLiveData + val text: LiveData + get() = mText + + init { + mText = MutableLiveData() + mText.value = "This is gallery fragment" + } +} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.java b/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.java deleted file mode 100644 index d8cf351..0000000 --- a/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.listify.ui.slideshow; - -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.ViewModelProviders; - -import com.example.listify.R; - -public class SlideshowFragment extends Fragment { - - private SlideshowViewModel slideshowViewModel; - - public View onCreateView(@NonNull LayoutInflater inflater, - ViewGroup container, Bundle savedInstanceState) { - slideshowViewModel = - ViewModelProviders.of(this).get(SlideshowViewModel.class); - View root = inflater.inflate(R.layout.fragment_slideshow, container, false); - final TextView textView = root.findViewById(R.id.text_slideshow); - slideshowViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { - @Override - public void onChanged(@Nullable String s) { - textView.setText(s); - } - }); - return root; - } -} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.kt b/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.kt new file mode 100644 index 0000000..635bbf0 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowFragment.kt @@ -0,0 +1,23 @@ +package com.example.listify.ui.slideshow + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import com.example.listify.R + +class SlideshowFragment : Fragment() { + private var slideshowViewModel: SlideshowViewModel? = null + override fun onCreateView(inflater: LayoutInflater, + container: ViewGroup?, savedInstanceState: Bundle?): View? { + slideshowViewModel = ViewModelProviders.of(this).get(SlideshowViewModel::class.java) + val root = inflater.inflate(R.layout.fragment_slideshow, container, false) + val textView = root.findViewById(R.id.text_slideshow) + slideshowViewModel!!.text.observe(viewLifecycleOwner, Observer { s -> textView.text = s }) + return root + } +} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.java b/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.java deleted file mode 100644 index f9911d7..0000000 --- a/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.listify.ui.slideshow; - -import androidx.lifecycle.LiveData; -import androidx.lifecycle.MutableLiveData; -import androidx.lifecycle.ViewModel; - -public class SlideshowViewModel extends ViewModel { - - private MutableLiveData mText; - - public SlideshowViewModel() { - mText = new MutableLiveData<>(); - mText.setValue("This is slideshow fragment"); - } - - public LiveData getText() { - return mText; - } -} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.kt b/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.kt new file mode 100644 index 0000000..985e604 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/ui/slideshow/SlideshowViewModel.kt @@ -0,0 +1,16 @@ +package com.example.listify.ui.slideshow + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class SlideshowViewModel : ViewModel() { + private val mText: MutableLiveData + val text: LiveData + get() = mText + + init { + mText = MutableLiveData() + mText.value = "This is slideshow fragment" + } +} \ No newline at end of file