mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Changed (unused) gallery and slideshow code to Kotlin
This commit is contained in:
parent
5da20048a5
commit
cbc9db73cd
@ -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<String>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable String s) {
|
|
||||||
textView.setText(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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<TextView>(R.id.text_gallery)
|
||||||
|
galleryViewModel!!.text.observe(viewLifecycleOwner, Observer { s -> textView.text = s })
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<String> mText;
|
|
||||||
|
|
||||||
public GalleryViewModel() {
|
|
||||||
mText = new MutableLiveData<>();
|
|
||||||
mText.setValue("This is gallery fragment");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<String> getText() {
|
|
||||||
return mText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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<String>
|
||||||
|
val text: LiveData<String>
|
||||||
|
get() = mText
|
||||||
|
|
||||||
|
init {
|
||||||
|
mText = MutableLiveData()
|
||||||
|
mText.value = "This is gallery fragment"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<String>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable String s) {
|
|
||||||
textView.setText(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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<TextView>(R.id.text_slideshow)
|
||||||
|
slideshowViewModel!!.text.observe(viewLifecycleOwner, Observer { s -> textView.text = s })
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<String> mText;
|
|
||||||
|
|
||||||
public SlideshowViewModel() {
|
|
||||||
mText = new MutableLiveData<>();
|
|
||||||
mText.setValue("This is slideshow fragment");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<String> getText() {
|
|
||||||
return mText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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<String>
|
||||||
|
val text: LiveData<String>
|
||||||
|
get() = mText
|
||||||
|
|
||||||
|
init {
|
||||||
|
mText = MutableLiveData()
|
||||||
|
mText.value = "This is slideshow fragment"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user