Kaynağa Gözat

Photo Viewer (almost) working

seavenois 10 yıl önce
ebeveyn
işleme
df5a6c38cc

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -43,7 +43,7 @@
         <activity
             android:name=".MainActivity"
             android:theme="@style/Theme.NoTitle"
-            android:windowSoftInputMode="adjustPan"
+            android:windowSoftInputMode="adjustResize"
             android:label="@string/app_name">
             
             <intent-filter>

+ 47 - 0
app/src/main/java/com/ivalentin/gm/AlbumLayout.java

@@ -8,6 +8,8 @@ import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -86,6 +88,10 @@ public class AlbumLayout extends Fragment {
             //Create a new row
             entry = (LinearLayout) factory.inflate(R.layout.row_album, null);
 
+			//Set left and right layouts
+			LinearLayout left = (LinearLayout) entry.findViewById(R.id.ll_row_album_left);
+			LinearLayout right = (LinearLayout) entry.findViewById(R.id.ll_row_album_right);
+
             //Set margins
             //LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
             //layoutParams.setMargins(10, 10, 10, 25);
@@ -117,6 +123,27 @@ public class AlbumLayout extends Fragment {
                 fpath.mkdirs();
                 new DownloadImage(GM.SERVER + "/img/galeria/preview/" + image, this.getContext().getFilesDir().toString() + "/img/galeria/preview/" + image, ivLeft).execute();
             }
+
+			//Set onClickListener
+			left.setOnClickListener(new View.OnClickListener(){
+				@Override
+				public void onClick(View v) {
+				//Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
+				Fragment fragment = new PhotoLayout();
+				Bundle bundle = new Bundle();
+				//Pass post id
+				int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_album_hidden_left)).getText().toString());
+				bundle.putInt("photo", id);
+				fragment.setArguments(bundle);
+
+				FragmentManager fm = AlbumLayout.this.getActivity().getSupportFragmentManager();
+				FragmentTransaction ft = fm.beginTransaction();
+
+				ft.replace(R.id.activity_main_content_fragment, fragment);
+				ft.addToBackStack("photo_" + id);
+				ft.commit();
+				}
+			});
             
             //If odd pass, to the right line
             if (imageCursor.moveToNext()){
@@ -149,6 +176,26 @@ public class AlbumLayout extends Fragment {
                     fpath.mkdirs();
                     new DownloadImage(GM.SERVER + "/img/galeria/preview/" + image, this.getContext().getFilesDir().toString() + "/img/galeria/preview/" + image, ivRight).execute();
                 }
+
+				//Set onClickListener
+				right.setOnClickListener(new View.OnClickListener(){
+					@Override
+					public void onClick(View v) {
+					Fragment fragment = new PhotoLayout();
+					Bundle bundle = new Bundle();
+					//Pass post id
+					int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_album_hidden_right)).getText().toString());
+					bundle.putInt("photo", id);
+					fragment.setArguments(bundle);
+
+					FragmentManager fm = AlbumLayout.this.getActivity().getSupportFragmentManager();
+					FragmentTransaction ft = fm.beginTransaction();
+
+					ft.replace(R.id.activity_main_content_fragment, fragment);
+					ft.addToBackStack("photo_" + id);
+					ft.commit();
+					}
+				});
             }
 
             llList.addView(entry);

+ 1 - 1
app/src/main/java/com/ivalentin/gm/GalleryLayout.java

@@ -78,7 +78,7 @@ public class GalleryLayout extends Fragment{
         }
 
         //Get data from the database
-        cursor = db.rawQuery("SELECT id, name_" + currLang+ " AS title FROM album ORDER BY random();", null);
+        cursor = db.rawQuery("SELECT DISTINCT album.id AS id, album.name_" + currLang + " AS name FROM photo, album, photo_album WHERE photo.id = photo AND album.id = album ORDER BY uploaded DESC;", null);
 
         //Loop
         while (cursor.moveToNext()){

+ 13 - 3
app/src/main/java/com/ivalentin/gm/HomeLayout.java

@@ -287,7 +287,7 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 
 		//Get data from the database of the future activities
 		SQLiteDatabase db = getActivity().openOrCreateDatabase(GM.DB_NAME, Context.MODE_PRIVATE, null);
-		Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + currLang + " AS title, text_" + currLang + " AS text, price, after_" + currLang + " AS after FROM activity WHERE date < date('now') ORDER BY date LIMIT 2;", null);
+		Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + currLang + " AS title, text_" + currLang + " AS text, price, after_" + currLang + " AS after FROM activity WHERE date < date('now') ORDER BY date DESC LIMIT 2;", null);
 
 		//Show section
 		LinearLayout llActivitiesPast = (LinearLayout) view.findViewById(R.id.ll_home_section_activities_past);
@@ -374,6 +374,7 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 					new DownloadImage(GM.SERVER + "/img/actividades/miniature/" + image, this.getContext().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv).execute();
 				}
 			}
+			cursorImage.close();
 
 			//Set onCLickListener
 			entry.setOnClickListener(new View.OnClickListener() {
@@ -427,7 +428,7 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 
 		//Get data from the database of the future activities
 		SQLiteDatabase db = getActivity().openOrCreateDatabase(GM.DB_NAME, Context.MODE_PRIVATE, null);
-		Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + currLang+ " AS title, text_" + currLang + " AS text, price FROM activity WHERE date >= date('now') ORDER BY date DESC LIMIT 2;", null);
+		Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + currLang+ " AS title, text_" + currLang + " AS text, price FROM activity WHERE date >= date('now') ORDER BY date LIMIT 2;", null);
 
 		//If there are future activities...
 		if (cursor.getCount() > 0) {
@@ -505,6 +506,8 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 					}
 				}
 
+				cursorImage.close();
+
 				//Set onCLickListener
 				entry.setOnClickListener(new View.OnClickListener() {
 					@Override
@@ -625,6 +628,8 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 				}
 			}
 
+			cursorImage.close();
+
 			//Set onCLickListener
 			entry.setOnClickListener(new View.OnClickListener(){
 				@Override
@@ -694,6 +699,7 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 			}
 			i ++;
 		}
+		cursor.close();
 		
 		//Get offers
 		cursor = db.rawQuery("SELECT price, days FROM offer ORDER BY id;", null);
@@ -721,11 +727,15 @@ public class HomeLayout extends Fragment implements LocationListener, OnMapReady
 					i ++;
 				}
 			}
+			closestOffer.close();
 		}
 		
 		//Set text
 		tvTotal.setText(v.getContext().getResources().getString(R.string.prices_total) + " " + total + v.getContext().getResources().getString(R.string.eur));
-		
+
+
+		cursor.close();
+		db.close();
 		//Return the total price
 		return total;
 	}

+ 230 - 0
app/src/main/java/com/ivalentin/gm/PhotoLayout.java

@@ -0,0 +1,230 @@
+package com.ivalentin.gm;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.util.Locale;
+
+/**
+ * Created by seavenois on 16/06/16.
+ */
+public class PhotoLayout extends Fragment {
+
+	//Main View
+	private View view;
+
+	String currLang;
+
+	Integer photos[];
+	int position;
+
+	Context context;
+
+	@SuppressLint("InflateParams") //Throws unknown error when done properly.
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		view = inflater.inflate(R.layout.fragment_layout_photo, null);
+		context = view.getContext();
+
+		//Get bundled id
+		Bundle bundle = this.getArguments();
+		int id = bundle.getInt("photo", -1);
+		if (id == -1) {
+			//TODO: Error, do something
+		}
+
+		photos = loadPhotos(id);
+		position = getPosition(photos, id);
+
+
+		populate(id, view);
+
+		return view;
+	}
+
+	/**
+	 * Given a photo id array and a photo id, tells the position of the photo in the array.
+	 *
+	 * @param list Array withe the ids of photos.
+	 * @param id Id of the reference photo.
+	 *
+	 * @return The position of the photo in the array.
+	 */
+	public int getPosition(Integer[] list, int id){
+		int i;
+		try{
+			i = 0;
+			while (list[i] != id){
+				i ++;
+			}
+
+		}
+		catch(Exception ex){
+			i = -1;
+		}
+
+		return i;
+	}
+
+	/**
+	 * Given a photo, builds an ordered array with the ids of all photos in the same album.
+	 *
+	 * @param id Id of the reference photo.
+	 *
+	 * @return A sorted Integer[] with the ids of the photos in the same album.
+	 */
+	private Integer[] loadPhotos(int id){
+
+		SQLiteDatabase db = getActivity().openOrCreateDatabase(GM.DB_NAME, Context.MODE_PRIVATE, null);
+
+		//Get album id for the photo
+		//Log.e("QUERY", "SELECT album FROM photo_album WHERE photo = " + id + ";");
+		Cursor cAlbum = db.rawQuery("SELECT album FROM photo_album WHERE photo = " + id + ";", null);
+		cAlbum.moveToFirst();
+		int album = cAlbum.getInt(0);
+		cAlbum.close();
+
+		//Get photos of the album
+		Cursor cursor = db.rawQuery("SELECT photo.id FROM photo,album, photo_album WHERE photo.id = photo AND album.id = album AND album = " + album + " ORDER BY uploaded DESC;", null);
+		Integer list[] = new Integer[cursor.getCount()];
+		int i = 0;
+		while(cursor.moveToNext()){
+			list[i] = cursor.getInt(0);
+			i ++;
+		}
+		cursor.close();
+		db.close();
+
+		return list;
+	}
+
+	private void populate(int id, View v){
+
+		final int photoId = id;
+
+		//Get data from database
+		SQLiteDatabase db = getActivity().openOrCreateDatabase(GM.DB_NAME, Context.MODE_PRIVATE, null);
+		final Cursor cursor;
+		currLang = Locale.getDefault().getDisplayLanguage();
+		if (!currLang.equals("es") && !currLang.equals("eu")){
+			currLang = "en";
+		}
+		cursor = db.rawQuery("SELECT id, file, title_" + currLang+ " AS title, description_" + currLang + " AS description, uploaded, width, height, size FROM photo WHERE id = " + id + ";", null);
+		cursor.moveToFirst();
+
+		//Get display elements
+		ImageView imageView = (ImageView) v.findViewById(R.id.iv_photo);
+
+		TextView tvTitle = (TextView) v.findViewById(R.id.tv_photo_title);
+		TextView tvDate = (TextView) v.findViewById(R.id.tv_photo_date);
+		final TextView tvComments = (TextView) v.findViewById(R.id.tv_comments);
+		TextView tvDescription = (TextView) v.findViewById(R.id.tv_photo_description);
+		LinearLayout llCommentList = (LinearLayout) v.findViewById(R.id.ll_comment_list);
+
+		//Set fields
+		tvTitle.setText(cursor.getString(2));
+		((MainActivity) getActivity()).setSectionTitle(cursor.getString(2));
+		tvDescription.setText(cursor.getString(3));
+		tvDate.setText(GM.formatDate(cursor.getString(4), currLang, true));
+
+		//Close the cursor
+		//cursor.close();
+
+		//Get image
+
+		String image = cursor.getString(1);
+
+		//Check if image exists
+		File f;
+		f = new File(this.getContext().getFilesDir().toString() + "/img/galeria/preview/" + image);
+		if (f.exists()){
+			//If the image exists, set it.
+			Bitmap myBitmap = BitmapFactory.decodeFile(this.getContext().getFilesDir().toString() + "/img/galeria/preview/" + image);
+			imageView.setImageBitmap(myBitmap);
+		}
+		else {
+			//If not, create directories and download asynchronously
+			File fpath;
+			fpath = new File(this.getContext().getFilesDir().toString() + "/img/galeria/preview/");
+			fpath.mkdirs();
+			new DownloadImage(GM.SERVER + "/img/galeria/preview/" + image, this.getContext().getFilesDir().toString() + "/img/galeria/preview/" + image, imageView).execute();
+		}
+
+
+		//Get comments
+		Cursor commentCursor = db.rawQuery("SELECT text, dtime, username FROM photo_comment WHERE photo = " + id + ";", null);
+		tvComments.setText(String.format(getResources().getQuantityString(R.plurals.comment_comments, commentCursor.getCount()), commentCursor.getCount()));
+		final int commentCount = commentCursor.getCount();
+		cursor.moveToFirst();
+		LinearLayout entry;
+		LinearLayout commentList = (LinearLayout) v.findViewById(R.id.ll_comment_list);
+		LayoutInflater factory = LayoutInflater.from(getActivity());
+		while (commentCursor.moveToNext()) {
+			entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);
+
+			//Set user
+			TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
+			tvUser.setText(commentCursor.getString(2));
+			TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
+			tvCDate.setText(GM.formatDate(commentCursor.getString(1), currLang, true));
+			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
+			tvText.setText(commentCursor.getString(0));
+
+			//Add to the list
+			llCommentList.addView(entry);
+		}
+		commentCursor.close();
+
+		//Set up comment form
+		final EditText etCommentText = (EditText) view.findViewById(R.id.et_comment_text);
+		final EditText etCommentName = (EditText) view.findViewById(R.id.et_comment_name);
+		Button btSendComment = (Button) view.findViewById(R.id.bt_comment_send);
+
+		btSendComment.setOnClickListener(new View.OnClickListener(){
+			@Override
+			public void onClick(View v) {
+			String user = etCommentName.getText().toString();
+			String text = etCommentText.getText().toString();
+			if (user.length() < 1){
+				Toast.makeText(getActivity(), getString(R.string.comment_toast_user), Toast.LENGTH_LONG).show();
+				etCommentName.requestFocus();
+				return;
+			}
+			if (text.length() < 1){
+				Toast.makeText(getActivity(), getString(R.string.comment_toast_text), Toast.LENGTH_LONG).show();
+				etCommentText.requestFocus();
+				return;
+			}
+
+			//Start async task
+			LinearLayout form = (LinearLayout) view.findViewById(R.id.ll_new_comment);
+			LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_comment_list);
+			new PostComment("galeria", user, text, currLang, photoId, form, list, commentCount, tvComments, context).execute();
+
+			}
+		});
+
+		cursor.close();
+		db.close();
+	}
+}

+ 18 - 14
app/src/main/java/com/ivalentin/gm/PostComment.java

@@ -55,13 +55,13 @@ class PostComment extends AsyncTask<String, String, Integer> {
      * */
     @Override
     protected void onPreExecute() {
-        Log.e("PRE", "START");
+        //Log.e("PRE", "START");
         super.onPreExecute();
-        btSend = (Button) form.findViewById(R.id.bt_post_comment_send);
+        btSend = (Button) form.findViewById(R.id.bt_comment_send);
         pb = (ProgressBar) form.findViewById(R.id.pb_comment);
         btSend.setVisibility(View.GONE);
         pb.setVisibility(View.VISIBLE);
-        Log.e("PRE", "END");
+        //Log.e("PRE", "END");
     }
 
     /**
@@ -69,7 +69,7 @@ class PostComment extends AsyncTask<String, String, Integer> {
      * */
     @Override
     protected Integer doInBackground(String... f_url) {
-        Log.e("DIB", "START");
+        //.e("DIB", "START");
         int count;
         URL url;
         String urlString, urlParams;
@@ -78,7 +78,6 @@ class PostComment extends AsyncTask<String, String, Integer> {
             //url = new URL(GM.SERVER + "/" + type + "/comment.php?user=" + user + "&text=" + text);
             urlString = GM.SERVER + "/" + type + "/comment.php?user=" + URLEncoder.encode(user) + "&text=" + URLEncoder.encode(text);
             urlParams = "user=" + URLEncoder.encode(user) + "&text=" + URLEncoder.encode(text);
-            Log.e("TYPE", type);
             switch (type){
                 case "blog":
                     urlParams = urlParams + "&post=" + id;
@@ -121,7 +120,7 @@ class PostComment extends AsyncTask<String, String, Integer> {
             conn.connect();
 
 
-            Log.e("URL", urlString);
+            //Log.e("URL", urlString);
             //url = new URL(urlString);
             //HttpURLConnection connection = (HttpURLConnection)url.openConnection();
             //connection.setRequestMethod("GET");
@@ -131,28 +130,33 @@ class PostComment extends AsyncTask<String, String, Integer> {
             Log.d("Comment status", "" + code);
 
             if (code == 200){
-                //TODO: Insert into local db
+                //Insert into local db
                 SQLiteDatabase db = context.openOrCreateDatabase(GM.DB_NAME, Context.MODE_PRIVATE, null);
                 String table = "";
+                String item = "";
                 switch (type){
                     case "blog":
                         table = "post_comment";
+                        item = "post";
                         break;
                     case "galeria":
                         table = "photo_comment";
+                        item = "photo";
                         break;
                     case "actividades":
                         table = "activity_comment";
+                        item = "activity";
                         break;
                 }
-                db.rawQuery("INSERT INTO " + table + " (post, text, username, lang) VALUES (" + id + ", '" + text + "', '" + user + "', '" + language + "');", null);
+                db.execSQL("INSERT INTO " + table + " (" + item + ", text, username, lang, dtime) VALUES (" + id + ", '" + text + "', '" + user + "', '" + language + "', datetime('NOW'));");
+                //Log.e("Query", "INSERT INTO " + table + " (" + item + ", text, username, lang, dtime) VALUES (" + id + ", '" + text + "', '" + user + "', '" + language + "', datetime('NOW'));");
                 db.close();
             }
 
         } catch (Exception e) {
             Log.e("Error posting: ", e.getMessage());
         }
-        Log.e("DIB", "END");
+        //Log.e("DIB", "END");
         return code;
     }
 
@@ -163,19 +167,19 @@ class PostComment extends AsyncTask<String, String, Integer> {
      * **/
     @Override
     protected void onPostExecute(Integer a) {
-        Log.e("POS", "START");
+        //Log.e("POS", "START");
         //Log.d("Comment posted", type);
 
         if (code == 200) {
             //Clear form
-            EditText formText = (EditText) form.findViewById(R.id.et_post_comment_text);
-            EditText formUser = (EditText) form.findViewById(R.id.et_post_comment_name);
+            EditText formText = (EditText) form.findViewById(R.id.et_comment_text);
+            EditText formUser = (EditText) form.findViewById(R.id.et_comment_name);
             formUser.setText("");
             formText.setText("");
 
             //TODO: Update counter
 
-            //TODO: Insert comment in list
+            //Insert comment in list
             LayoutInflater factory = LayoutInflater.from(context);
             LinearLayout entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);
 
@@ -198,6 +202,6 @@ class PostComment extends AsyncTask<String, String, Integer> {
         pb.setVisibility(View.GONE);
 
         //ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);
-        Log.e("POS", "END");
+        //Log.e("POS", "END");
     }
 }

+ 8 - 8
app/src/main/java/com/ivalentin/gm/PostLayout.java

@@ -70,9 +70,9 @@ public class PostLayout extends Fragment {
 
         TextView tvTitle = (TextView) view.findViewById(R.id.tv_post_title);
         TextView tvDate = (TextView) view.findViewById(R.id.tv_post_date);
-        final TextView tvComments = (TextView) view.findViewById(R.id.tv_post_comments);
+        final TextView tvComments = (TextView) view.findViewById(R.id.tv_comments);
         WebView wvText = (WebView) view.findViewById(R.id.wv_post_text);
-        LinearLayout llCommentList = (LinearLayout) view.findViewById(R.id.ll_post_comment_list);
+        LinearLayout llCommentList = (LinearLayout) view.findViewById(R.id.ll_comment_list);
 
         //Set fields
         tvTitle.setText(cursor.getString(1));
@@ -118,7 +118,7 @@ public class PostLayout extends Fragment {
         final int commentCount = commentCursor.getCount();
         cursor.moveToFirst();
         LinearLayout entry;
-        LinearLayout commentList = (LinearLayout) view.findViewById(R.id.ll_post_comment_list);
+        LinearLayout commentList = (LinearLayout) view.findViewById(R.id.ll_comment_list);
         LayoutInflater factory = LayoutInflater.from(getActivity());
         while (commentCursor.moveToNext()) {
             entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);
@@ -137,9 +137,9 @@ public class PostLayout extends Fragment {
         commentCursor.close();
 
         //Set up comment form
-        final EditText etCommentText = (EditText) view.findViewById(R.id.et_post_comment_text);
-        final EditText etCommentName = (EditText) view.findViewById(R.id.et_post_comment_name);
-        Button btSendComment = (Button) view.findViewById(R.id.bt_post_comment_send);
+        final EditText etCommentText = (EditText) view.findViewById(R.id.et_comment_text);
+        final EditText etCommentName = (EditText) view.findViewById(R.id.et_comment_name);
+        Button btSendComment = (Button) view.findViewById(R.id.bt_comment_send);
 
         btSendComment.setOnClickListener(new View.OnClickListener(){
             @Override
@@ -158,8 +158,8 @@ public class PostLayout extends Fragment {
                 }
 
                 //Start async task
-                LinearLayout form = (LinearLayout) view.findViewById(R.id.ll_post_new_comment);
-                LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_post_comment_list);
+                LinearLayout form = (LinearLayout) view.findViewById(R.id.ll_new_comment);
+                LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_comment_list);
                 new PostComment("blog", user, text, currLang, cursor.getInt(0), form, list, commentCount, tvComments, context).execute();
 
             }

+ 192 - 0
app/src/main/res/layout/fragment_layout_photo.xml

@@ -0,0 +1,192 @@
+<com.ivalentin.gm.CustomScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:background="@color/background_app"
+    android:padding="7dp">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@drawable/section"
+        android:paddingBottom="15dp"
+        android:paddingLeft="7dp"
+        android:paddingTop="7dp"
+        android:paddingRight="7dp">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:text="Large Text"
+            android:id="@+id/tv_photo_title"/>
+
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@drawable/entry"
+            android:padding="7dp">
+
+            <ImageView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/iv_photo"
+                android:padding="2dp"
+                android:background="@color/album_border"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="Medium Text"
+                android:id="@+id/tv_photo_description"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceSmall"
+                android:text="Small Text"
+                android:id="@+id/tv_photo_date"
+                android:layout_marginLeft="15dp"/>
+
+            <LinearLayout
+                android:orientation="horizontal"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_gravity="center_horizontal"
+                android:gravity="center_horizontal"
+                android:padding="7dp">
+
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blog_pager_previous"
+                    android:id="@+id/bt_photo_previous"
+                    android:background="@drawable/button_selector"
+                    android:textStyle="bold"
+                    android:textColor="@color/input_button_color"
+                    android:layout_gravity="center_horizontal"
+                    android:visibility="visible"
+                    android:layout_margin="5dp"/>
+
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blog_pager_next"
+                    android:id="@+id/bt_photo_next"
+                    android:background="@drawable/button_selector"
+                    android:textStyle="bold"
+                    android:textColor="@color/input_button_color"
+                    android:layout_gravity="center_horizontal"
+                    android:layout_margin="5dp"/>
+            </LinearLayout>
+        </LinearLayout>
+
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@drawable/entry"
+            android:layout_marginTop="15dp"
+            android:padding="7dp">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="New Text"
+                android:id="@+id/tv_comments"
+                android:textAppearance="@android:style/TextAppearance.Medium" />
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:id="@+id/ll_comment_list">
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="2dp"
+                android:background="@color/background_separator"
+                android:layout_margin="6dp" />
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:id="@+id/ll_new_comment"
+                android:layout_marginTop="15dp"
+                android:layout_marginLeft="7dp"
+                android:layout_marginRight="7dp"
+                android:layout_marginBottom="7dp">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/comment_your_comment"
+                    android:textAppearance="@android:style/TextAppearance.Medium" />
+
+                <EditText
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/et_comment_text"
+                    android:minLines="2"
+                    android:hint="@string/comment_text"
+                    android:capitalize="sentences"
+                    android:background="@drawable/input"
+                    android:textColor="@color/input_text_color"
+                    android:textColorHint="@color/input_hint_color"
+                    android:gravity="top"
+                    android:layout_margin="4dp" />
+
+                <EditText
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/et_comment_name"
+                    android:layout_marginLeft="20dp"
+                    android:layout_marginRight="20dp"
+                    android:hint="@string/comment_name"
+                    android:capitalize="words"
+                    android:background="@drawable/input"
+                    android:textColor="@color/input_text_color"
+                    android:textColorHint="@color/input_hint_color"
+                    android:layout_marginTop="5dp"
+                    android:layout_marginBottom="5dp" />
+
+                <LinearLayout
+                    android:orientation="horizontal"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:gravity="center_horizontal"
+                    android:layout_marginBottom="10dp">
+
+                    <Button
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/comment_send"
+                        android:id="@+id/bt_comment_send"
+                        android:layout_gravity="center_horizontal"
+                        android:background="@drawable/button_selector"
+                        android:textColor="@color/input_button_color"
+                        android:textStyle="bold"
+                        android:layout_marginTop="5dp"
+                        android:layout_marginBottom="5dp" />
+
+                    <ProgressBar
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:id="@+id/pb_comment"
+                        android:layout_gravity="center_horizontal"
+                        android:visibility="gone" />
+                </LinearLayout>
+
+            </LinearLayout>
+        </LinearLayout>
+
+    </LinearLayout>
+
+</com.ivalentin.gm.CustomScrollView>

+ 6 - 6
app/src/main/res/layout/fragment_layout_post.xml

@@ -106,14 +106,14 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="New Text"
-                android:id="@+id/tv_post_comments"
+                android:id="@+id/tv_comments"
                 android:textAppearance="@android:style/TextAppearance.Medium" />
 
             <LinearLayout
                 android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:id="@+id/ll_post_comment_list">
+                android:id="@+id/ll_comment_list">
 
             </LinearLayout>
 
@@ -128,7 +128,7 @@
                 android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:id="@+id/ll_post_new_comment"
+                android:id="@+id/ll_new_comment"
                 android:layout_marginTop="15dp"
                 android:layout_marginLeft="7dp"
                 android:layout_marginRight="7dp"
@@ -144,7 +144,7 @@
                 <EditText
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
-                    android:id="@+id/et_post_comment_text"
+                    android:id="@+id/et_comment_text"
                     android:minLines="2"
                     android:hint="@string/comment_text"
                     android:capitalize="sentences"
@@ -157,7 +157,7 @@
                 <EditText
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
-                    android:id="@+id/et_post_comment_name"
+                    android:id="@+id/et_comment_name"
                     android:layout_marginLeft="20dp"
                     android:layout_marginRight="20dp"
                     android:hint="@string/comment_name"
@@ -179,7 +179,7 @@
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:text="@string/comment_send"
-                        android:id="@+id/bt_post_comment_send"
+                        android:id="@+id/bt_comment_send"
                         android:layout_gravity="center_horizontal"
                         android:background="@drawable/button_selector"
                         android:textColor="@color/input_button_color"