diff --git a/android/res/drawable/button_background.xml b/android/res/drawable/button_background.xml new file mode 100644 index 0000000..33f3967 --- /dev/null +++ b/android/res/drawable/button_background.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android/res/layout/fragment_photo_page.xml b/android/res/layout/fragment_photo_page.xml new file mode 100644 index 0000000..3108acd --- /dev/null +++ b/android/res/layout/fragment_photo_page.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/android/res/layout/photo_page_element.xml b/android/res/layout/photo_page_element.xml new file mode 100644 index 0000000..8103c4b --- /dev/null +++ b/android/res/layout/photo_page_element.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/android/src/fishrungames/bashgid/PhotoFragment.java b/android/src/fishrungames/bashgid/PhotoFragment.java new file mode 100644 index 0000000..d1794a3 --- /dev/null +++ b/android/src/fishrungames/bashgid/PhotoFragment.java @@ -0,0 +1,72 @@ +package fishrungames.bashgid; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.view.ViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import fishrungames.bashgid.core.AlbumManager.AlbumFullData; + +public class PhotoFragment extends Fragment +{ + + AlbumFullData album; + String albumName; + int currentPhoto; + + PhotoFragmentAdapter listAdapter; + + public PhotoFragment() + { + album = null; + albumName = ""; + currentPhoto = -1; + } + + public PhotoFragment(String albumName, int currentPhoto) + { + this.albumName = albumName; + this.currentPhoto = currentPhoto; + RestoreAlbum(); + } + + @Override + public void onSaveInstanceState(final Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("albumName", albumName); + outState.putInt("currentPhoto", currentPhoto); + + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + if (savedInstanceState != null) { + albumName = savedInstanceState.getString("albumName"); + currentPhoto = savedInstanceState.getInt("currentPhoto"); + RestoreAlbum(); + } + + View rootView = inflater.inflate(R.layout.fragment_photo_page, container, false); + + listAdapter = new PhotoFragmentAdapter(getActivity(), album/*, currentPhoto*/); + + ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager); + + pager.setAdapter(listAdapter); + + pager.setCurrentItem(currentPhoto); + + return rootView; + } + + void RestoreAlbum() + { + album = MainActivity.getInstance().albumDataSource.GetAlbumFullData(albumName); + } + +} \ No newline at end of file diff --git a/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java b/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java new file mode 100644 index 0000000..a8e2ad2 --- /dev/null +++ b/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java @@ -0,0 +1,66 @@ +package fishrungames.bashgid; + +import fishrungames.bashgid.core.AlbumManager.AlbumFullData; + +import fishrungames.networkutils.ImageManager; + + +import android.content.Context; + +import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import android.widget.ImageView; +import android.widget.LinearLayout; + +public class PhotoFragmentAdapter extends PagerAdapter { + + private Context context; + + AlbumFullData album; + + //int currentPhoto; + + public PhotoFragmentAdapter(Context context, AlbumFullData album/*, int currentPhoto*/) { + this.context = context; + this.album = album; + //this.currentPhoto = currentPhoto; + } + + @Override + public int getCount() { + return album.photoRecordArr.size(); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == ((LinearLayout) object); + } + + @Override + public Object instantiateItem(ViewGroup container, int position) { + + + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + View viewLayout = inflater.inflate(R.layout.photo_page_element, container, + false); + + ImageView image = (ImageView) viewLayout.findViewById(R.id.image); + + ImageManager.getInstance().ApplyImageToImageView(image, album.photoRecordArr.get(position).imageUrl); + + ((ViewPager) container).addView(viewLayout); + + return viewLayout; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object object) { + ((ViewPager) container).removeView((LinearLayout) object); + + } +} \ No newline at end of file