Marijn appje #28

Merged
11166932 merged 27 commits from marijn-appje into master 2017-06-29 13:34:35 +02:00
6 changed files with 56 additions and 23 deletions
Showing only changes of commit c8f65c0dca - Show all commits

View File

@@ -127,7 +127,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
public void onPictureTaken(byte[] data, Camera camera) {
mPhoto = BitmapFactory.decodeByteArray(data, 0, data.length, null);
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto);
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto, facing);
mPicPreview.setId(R.id.pic_preview);
mCameraLayout.addView(mPicPreview);
@@ -213,7 +213,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
PicturePreview.filterPrev();
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto);
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto, facing);
mPicPreview.setId(R.id.pic_preview);
mCameraLayout.addView(mPicPreview);
@@ -231,7 +231,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
PicturePreview.filterNext();
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto);
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto, facing);
mPicPreview.setId(R.id.pic_preview);
mCameraLayout.addView(mPicPreview);

View File

@@ -9,6 +9,7 @@ import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.hardware.Camera;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -26,14 +27,24 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
private static int currentFilter = FILTER_NONE;
int facing;
int rotate;
Bitmap picture;
Bitmap filterPicture;
public PicturePreview(Context context, Bitmap bmp) {
public PicturePreview(Context context, Bitmap bmp, int facing) {
super(context);
setWillNotDraw(false);
picture = Bitmap.createScaledBitmap(bmp, bmp.getWidth() / 2, bmp.getHeight() / 2, false);
this.facing = facing;
if (((Integer)facing).equals(Camera.CameraInfo.CAMERA_FACING_FRONT)) {
picture = Bitmap.createBitmap(bmp);
rotate = 270;
} else {
picture = Bitmap.createScaledBitmap(bmp, bmp.getWidth() / 2, bmp.getHeight() / 2, false);
rotate = 90;
}
Log.d(TAG, "PicturePreview: " + bmp.getWidth() + " " + bmp.getHeight());
}
@@ -47,8 +58,8 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
switch (currentFilter) {
case FILTER_NONE:
canvas.drawBitmap(rotate(picture, 90), 0, 0, null);
filterPicture = rotate(picture, 90);
canvas.drawBitmap(rotate(picture, rotate), 0, 0, null);
filterPicture = rotate(picture, rotate);
break;
case FILTER_SEPIA:
filterPicture = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
@@ -62,8 +73,8 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
filter = new ColorMatrixColorFilter(cm);
paint.setColorFilter(filter);
saveCanvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
canvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
saveCanvas.drawBitmap(rotate(picture, rotate), 0, 0, paint);
canvas.drawBitmap(rotate(picture, rotate), 0, 0, paint);
break;
case FILTER_BW:
filterPicture = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
@@ -73,8 +84,8 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
filter = new ColorMatrixColorFilter(cm);
paint.setColorFilter(filter);
saveCanvas.setBitmap(filterPicture);
saveCanvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
canvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
saveCanvas.drawBitmap(rotate(picture, rotate), 0, 0, paint);
canvas.drawBitmap(rotate(picture, rotate), 0, 0, paint);
break;
case FILTER_NEG:
filterPicture = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
@@ -88,8 +99,8 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
filter = new ColorMatrixColorFilter(cm);
paint.setColorFilter(filter);
saveCanvas.setBitmap(filterPicture);
saveCanvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
canvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
saveCanvas.drawBitmap(rotate(picture, rotate), 0, 0, paint);
canvas.drawBitmap(rotate(picture, rotate), 0, 0, paint);
break;
}

View File

@@ -23,7 +23,7 @@ public class TimelineFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_timeline, container, false);
listView = (ListView) view.findViewById(R.id.listview);
listView = (ListView) view.findViewById(R.id.list);
downloadClass = new DownloadClass(getActivity());
downloadClass.getPostsFromServer();

View File

@@ -13,7 +13,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="16dp">
android:padding="0dp">
</FrameLayout>
<android.support.design.widget.BottomNavigationView

View File

@@ -5,11 +5,19 @@
android:orientation="vertical"
tools:context="nl.myhyvesbookplus.tagram.TimelineFragment">
<ListView
android:id="@+id/listview"
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>

View File

@@ -3,6 +3,10 @@
android:layout_height="match_parent"
android:orientation="vertical">
<Space
android:layout_width="match_parent"
android:layout_height="15dp" />
<ImageView
android:id="@+id/timeline_image_profile"
android:layout_width="wrap_content"
@@ -13,21 +17,31 @@
android:id="@+id/comment_timeline_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Hallo Ik ben een comment!" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp">
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/niet_slecht" />
android:layout_height="wrap_content"
android:clickable="false"
android:text="@string/niet_slecht"/>
<TextView
android:id="@+id/niet_slecht_count_profile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="20dp"
android:padding="10dp"
android:text="10" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>