Commit c134b8de authored by Donald's avatar Donald

created MediaFragment

parent 5896805b
......@@ -39,12 +39,12 @@ public class MediaPagerAdapter extends FragmentStatePagerAdapter {
public Fragment getItem(int pos) {
Media p = media.get(pos);
if (p.isVideo()) {
VideoFragment fragment = VideoFragment.newInstance(p.getPath());
VideoFragment fragment = VideoFragment.newInstance();
fragment.setOnClickListener(videoOnClickListener);
return fragment;
}
if (p.isGif()) return GifFragment.newInstance(p.getPath());
else return ImageFragment.newInstance(p);
if (p.isGif()) return GifFragment.newInstance();
else return ImageFragment.newInstance();
}
@Override
......
package org.horaapps.leafpic.Fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -16,17 +15,12 @@ import uk.co.senab.photoview.PhotoViewAttacher;
/**
* Created by dnld on 18/02/16.
*/
public class GifFragment extends Fragment {
public class GifFragment extends MediaFragment {
private String path;
// newInstance constructor for creating fragment with arguments
public static GifFragment newInstance(String path) {
GifFragment fragmentFirst = new GifFragment();
Bundle args = new Bundle();
args.putString("path", path);
fragmentFirst.setArguments(args);
return fragmentFirst;
public static GifFragment newInstance() {
return new GifFragment();
}
......@@ -34,7 +28,6 @@ public class GifFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
path = getArguments().getString("path");
}
// Inflate the view for the fragment based on layout XML
......@@ -43,7 +36,7 @@ public class GifFragment extends Fragment {
PhotoView photoView = new PhotoView(container.getContext());
Ion.with(getContext())
.load(path)
.load(getMedia().getPath())
.intoImageView(photoView);
photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
......
package org.horaapps.leafpic.Fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
......@@ -12,7 +11,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.signature.StringSignature;
import org.horaapps.leafpic.Activities.SingleMediaActivity;
import org.horaapps.leafpic.MyApplication;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.Views.OrientationTransformation;
import org.horaapps.leafpic.data.Media;
......@@ -28,34 +26,15 @@ import uk.co.senab.photoview.PhotoViewAttacher;
*/
@SuppressWarnings("ResourceType")
public class ImageFragment extends Fragment {
public class ImageFragment extends MediaFragment {
//private Media img;
public static ImageFragment newInstance(Media asd) {
ImageFragment fragmentFirst = new ImageFragment();
Bundle args = new Bundle();
args.putParcelable("image", asd);
fragmentFirst.setArguments(args);
return fragmentFirst;
public static ImageFragment newInstance() {
return new ImageFragment();
}
//public void setOnTouchListener(View.OnTouchListener l){onTouchListener = l;}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//img = getArguments().getParcelable("image");
((MyApplication) getContext().getApplicationContext()).getAlbum().getCurrentMedia();
}
@Override
public void onDestroy() {
super.onDestroy();
// Need to call clean-up
}
@Override
......@@ -93,7 +72,7 @@ public class ImageFragment extends Fragment {
private void displayMedia(PhotoView photoView, boolean useCache) {
//PreferenceUtil SP = PreferenceUtil.getInstance(getContext());
Media img = ((MyApplication) getContext().getApplicationContext()).getAlbum().getCurrentMedia();
Media img = getMedia();
Glide.with(getContext())
.load(img.getUri())
......@@ -129,11 +108,11 @@ public class ImageFragment extends Fragment {
// TODO: 28/08/16 not working yet
PhotoView photoView = (PhotoView) getView();
Media img = ((MyApplication) getContext().getApplicationContext()).getAlbum().getCurrentMedia();
Media img = getMedia();
int orientation = Measure.rotateBy(img.getOrientation(), rotation);
Log.wtf("asd", img.getOrientation()+" + "+ rotation+" = " +orientation);
if(photoView != null && img.setOrientation(orientation)) {
if(photoView != null && getMedia().setOrientation(orientation)) {
Glide.clear(photoView);
Glide.with(getContext())
.load(img.getUri())
......
package org.horaapps.leafpic.Fragments;
import android.support.v4.app.Fragment;
import org.horaapps.leafpic.MyApplication;
import org.horaapps.leafpic.data.Media;
/**
* Created by dnld on 10/09/16.
*/
public class MediaFragment extends Fragment {
public Media getMedia() {
return ((MyApplication) getActivity().getApplicationContext()).getAlbum().getCurrentMedia();
}
}
package org.horaapps.leafpic.Fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -16,19 +15,12 @@ import org.horaapps.leafpic.Activities.SingleMediaActivity;
* Created by dnld on 18/02/16.
*/
public class VideoFragment extends Fragment {
public class VideoFragment extends MediaFragment {
private String path;
private View.OnClickListener onClickListener;
public static VideoFragment newInstance(String path) {
VideoFragment fragmentFirst = new VideoFragment();
Bundle args = new Bundle();
args.putString("path", path);
fragmentFirst.setArguments(args);
return fragmentFirst;
public static VideoFragment newInstance() {
return new VideoFragment();
}
public void setOnClickListener(View.OnClickListener onClickListener) {
......@@ -38,7 +30,6 @@ public class VideoFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
path = getArguments().getString("path");
}
......@@ -54,7 +45,7 @@ public class VideoFragment extends Fragment {
videoInd.setOnClickListener(onClickListener);
Ion.with(getContext())
.load(path)
.load(getMedia().getPath())
.withBitmap()
.intoImageView(picture);
picture.setOnClickListener(new View.OnClickListener() {
......
......@@ -6,7 +6,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
classpath 'com.android.tools.build:gradle:2.2.0-rc2'
classpath "gradle.plugin.com.gladed.gradle.androidgitversion:gradle-android-git-version:0.2.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment