Просмотр исходного кода

1.Android RA Image增加Manufacture功能。
2.修改Android RA Image图片列表布局。

Pen Li 9 лет назад
Родитель
Сommit
75140b618e
19 измененных файлов с 1109 добавлено и 54 удалено
  1. 0 7
      RA Image/app/app.iml
  2. 5 2
      RA Image/app/src/main/AndroidManifest.xml
  3. 37 0
      RA Image/app/src/main/java/com/usai/redant/raimage/MainActivity.java
  4. 2 2
      RA Image/app/src/main/java/com/usai/redant/raimage/ModeActivity.java
  5. 128 0
      RA Image/app/src/main/java/com/usai/redant/raimage/Model/ManufactureListActivity.java
  6. 602 0
      RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/CustomLayoutManager.java
  7. 37 0
      RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/GridLayoutRecycler/RAGridLayoutManager.java
  8. 175 0
      RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/GridLayoutRecycler/RAPreviewRecyclerView.java
  9. 30 5
      RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/NewPhotoPreviewActivity.java
  10. 14 22
      RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/PhotoListActivity.java
  11. 20 1
      RA Image/app/src/main/res/layout-land/activity_model.xml
  12. 15 0
      RA Image/app/src/main/res/layout/activity_manufacture_list.xml
  13. 12 4
      RA Image/app/src/main/res/layout/activity_model.xml
  14. 5 6
      RA Image/app/src/main/res/layout/activity_new_photo_preview.xml
  15. 21 0
      RA Image/app/src/main/res/layout/manufacture_cell.xml
  16. 3 4
      RA Image/app/src/main/res/layout/photo_list_item.xml
  17. 3 1
      RA Image/app/src/main/res/layout/photo_preview_item.xml
  18. BIN
      RA Image/captures/com.usai.redant.raimage_2017.06.19_11.30.li
  19. BIN
      RA Image/captures/com.usai.redant.raimage_2017.06.20_09.49.li

+ 0 - 7
RA Image/app/app.iml

@@ -80,21 +80,14 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />

+ 5 - 2
RA Image/app/src/main/AndroidManifest.xml

@@ -159,15 +159,18 @@
             android:theme="@style/Theme.AppCompat.Light" />
         <activity
             android:name=".PhotoList.PhotoListActivity"
-            android:configChanges="orientation|keyboard"
-            android:screenOrientation="portrait"
             android:stateNotNeeded="true"
             android:theme="@style/Theme.AppCompat.Light" />
         <activity
             android:name=".PhotoList.NewPhotoPreviewActivity"
             android:label="@string/app_name"
             android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light" />
+        <activity
+            android:name=".Model.ManufactureListActivity"
             android:theme="@style/Theme.AppCompat.Light"/>
+
+
     </application>
 
 </manifest>

+ 37 - 0
RA Image/app/src/main/java/com/usai/redant/raimage/MainActivity.java

@@ -11,6 +11,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 
+import com.usai.redant.raimage.Model.ManufactureListActivity;
 import com.usai.redant.raimage.Model.ModelActivity;
 import com.usai.redant.raimage.POP.PopActivity;
 import com.usai.redant.raimage.PhotoList.PhotoListActivity;
@@ -62,6 +63,7 @@ public class MainActivity extends AppCompatActivity
 	static final int	REQUEST_PREVIEW			= 4;
 	static final int	REQUEST_SCAN_BARCODE	= 2;
 	static final int	REQUEST_LOCKER			= 3;
+	static final int 	REQUEST_MANUFACTURE 	= 5;
 	// HashMap<String, String> hashMap = new HashMap<String, String>();
 
 	// ArrayList<String> pic_file = new ArrayList<String>();
@@ -97,6 +99,17 @@ public class MainActivity extends AppCompatActivity
 	protected ImageButton ibtnscan;
 	protected ImageButton captureButton;
 	protected ImageButton uploadButton;
+	protected Button manufactureBtn;
+	private String manufacture;
+
+	void setManufacture(String value) {
+		manufacture = value;
+		if (TextUtils.isEmpty(value)) {
+			manufactureBtn.setText("Select Manufacturer");
+		} else  {
+			manufactureBtn.setText(value);
+		}
+	}
 
 	public void showWarning(String msg) {
 		if (TextUtils.isEmpty(msg)) {
@@ -122,6 +135,7 @@ public class MainActivity extends AppCompatActivity
 		ibtnscan = (ImageButton)findViewById(R.id.scan_btn);
 		captureButton = (ImageButton)findViewById(R.id.camera_btn);
 		uploadButton = (ImageButton)findViewById(R.id.upload_btn);
+		manufactureBtn = (Button)findViewById(R.id.manufacture_btn);
 
         /***/
 		thumbsImageView.setOnClickListener(new View.OnClickListener()
@@ -198,6 +212,21 @@ public class MainActivity extends AppCompatActivity
             }
         });
 
+		/**Model*/
+		if (this.getClass().equals(ModelActivity.class)) {
+			if (manufactureBtn != null) {
+				manufactureBtn.setOnClickListener(new View.OnClickListener() {
+					@Override
+					public void onClick(View v) {
+						Intent intent = new Intent(MainActivity.this, ManufactureListActivity.class);
+						startActivityForResult(intent,REQUEST_MANUFACTURE);
+					}
+				});
+			}
+		}
+
+
+
 //        m_tvalert = (TextView) findViewById(R.id.tvalert);
 //        m_tvalert.setSelected(true);
 
@@ -215,6 +244,7 @@ public class MainActivity extends AppCompatActivity
             String savedPiid = savedInstanceState.getString("PIID");
 			String savedNote = savedInstanceState.getString("Note");
 			File savedPhotoFile = (File) savedInstanceState.getSerializable("photoFile");
+			String manufacture = savedInstanceState.getString("manufacture");
 
 			if (savedBitmap != null) {
 				thumbBitmap = savedBitmap;
@@ -242,6 +272,7 @@ public class MainActivity extends AppCompatActivity
 					noteTextView.setText(savedNote);
 					noteTextView.setSelection(savedNote.length());
 				}
+				setManufacture(manufacture);
 			}
 
         }
@@ -669,6 +700,11 @@ public class MainActivity extends AppCompatActivity
 					updateUploadButton();
 				}
 			}
+		} else if (requestCode == REQUEST_MANUFACTURE) {
+			if (resultCode == RESULT_OK) {
+				String manufacture = data.getStringExtra("manufacture");
+				setManufacture(manufacture);
+			}
 		}
 		super.onActivityResult(requestCode, resultCode, data);
 	}
@@ -813,6 +849,7 @@ public class MainActivity extends AppCompatActivity
 			outState.putString("PIID", pidval.getText().toString());
 			if (this.getClass().equals(ModelActivity.class)) {
 				outState.putString("Note",noteTextView.getText().toString());
+				outState.putString("manufacture",manufacture);
 			}
 		} else  {
 			TextView pidval = (TextView) findViewById(R.id.pidval);

+ 2 - 2
RA Image/app/src/main/java/com/usai/redant/raimage/ModeActivity.java

@@ -118,9 +118,9 @@ public class ModeActivity extends AppCompatActivity {
                 JSONObject mode = dataSource.get(position);
                try {
                    int enable = mode.getInt("enable");
-                   if (enable != 0) {
+//                   if (enable != 0) {
                        showActivityMode(mode);
-                   }
+//                   }
 
                } catch (Exception e) {
                    e.printStackTrace();

+ 128 - 0
RA Image/app/src/main/java/com/usai/redant/raimage/Model/ManufactureListActivity.java

@@ -0,0 +1,128 @@
+package com.usai.redant.raimage.Model;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.support.v7.widget.ListViewCompat;
+import android.text.Layout;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.usai.redant.raimage.R;
+import com.usai.redant.raimage.RedAntApplication;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ManufactureListActivity extends AppCompatActivity {
+
+    private ListView manufacureList;
+    private ArrayList<String> dataSource;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_manufacture_list);
+
+        ActionBar mActionBar = getSupportActionBar();
+        mActionBar.setHomeButtonEnabled(true);
+        mActionBar.setDisplayHomeAsUpEnabled(true);
+        mActionBar.setTitle("RA Image");
+
+        /**Data*/
+        try {
+            JSONArray modeArr = RedAntApplication.server_info.getJSONArray("modellist");
+            for (int i = 0;i < modeArr.length(); i++) {
+                JSONObject obj = modeArr.getJSONObject(i);
+                String name = obj.getString("name");
+                if (name.equals("Model")) {
+                    JSONArray manufactureArr = obj.getJSONArray("manifacturer");
+                    dataSource = new ArrayList<String>();
+                    for (int j = 0; j < manufactureArr.length(); j++) {
+                        String manufacture = manufactureArr.getString(j);
+                        dataSource.add(manufacture);
+                    }
+                }
+                break;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        /***/
+        manufacureList = (ListView)findViewById(R.id.manufacture_list);
+        ManufactureAdapter adapter = new ManufactureAdapter(this,R.layout.manufacture_cell,dataSource);
+        manufacureList.setAdapter(adapter);
+
+        manufacureList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                String manufacture = dataSource.get(position);
+                Intent intent = new Intent();
+                intent.putExtra("manufacture",manufacture);
+                setResult(RESULT_OK,intent);
+                finish();
+            }
+        });
+
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        switch (item.getItemId()) {
+            case android.R.id.home: {
+                finish();
+            }
+            break;
+        }
+        return true;
+    }
+
+    class ManufactureAdapter extends ArrayAdapter<String> {
+        private int resourceID;
+        public ManufactureAdapter(Context ctx,int resourceId,List<String> list) {
+            super(ctx,resourceId,list);
+            resourceID = resourceId;
+        }
+
+        @NonNull
+        @Override
+        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+
+            String manufacture = dataSource.get(position);
+
+            View cell = null;
+            ViewHolder holder = null;
+            if (convertView != null) {
+                cell = convertView;
+                holder = (ViewHolder)cell.getTag();
+            } else  {
+                cell = LayoutInflater.from(getContext()).inflate(resourceID,null);
+                holder = new ViewHolder();
+                cell.setTag(holder);
+                holder.manufacutre_tv = (TextView) cell.findViewById(R.id.manufacture_cell_tv);
+            }
+
+            holder.manufacutre_tv.setText(manufacture);
+
+            return cell;
+        }
+
+        class ViewHolder {
+            public TextView manufacutre_tv;
+        }
+    }
+}

+ 602 - 0
RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/CustomLayoutManager.java

@@ -0,0 +1,602 @@
+package com.usai.redant.raimage.PhotoList;
+
+import android.content.Context;
+import android.graphics.PointF;
+import android.graphics.Rect;
+import android.support.annotation.IntDef;
+import android.support.v7.widget.LinearSmoothScroller;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.util.SparseArray;
+import android.util.SparseBooleanArray;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * CustomLayoutManager
+ * HowToCustomLayoutManager <com.vilyever.howtocustomlayoutmanager>
+ * Created by vilyever on 2016/1/7.
+ * Feature:
+ * 展示一个斜线布局的示例
+ * 支持横向纵向滑动
+ */
+public class CustomLayoutManager extends RecyclerView.LayoutManager {
+    /** Convenience Var to call this */
+    final CustomLayoutManager self = this;
+
+    int screen_w,screen_h;
+
+    /**
+     * init with orientation and itemLineCount
+     * @param orientation {@link com.usai.redant.raimage.PhotoList.CustomLayoutManager.State#orientation}
+//     * @param itemLineCount {@link com.usai.redant.raimage.PhotoList.CustomLayoutManager.State#itemLineCount}
+     */
+    public CustomLayoutManager(@Orientation int orientation, int screen_w, int screen_h) {
+        setOrientation(orientation);
+        this.screen_w = screen_w;
+        this.screen_h = screen_h;
+    }
+
+    /** @see RecyclerView.LayoutManager#onLayoutChildren(RecyclerView.Recycler, RecyclerView.State) */
+    @Override
+    public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
+        if (state.isPreLayout()) { // 跳过preLayout,preLayout主要用于支持动画,暂时先使用自带的简单的fading
+            return;
+        }
+        self.detachAndScrapAttachedViews(recycler); // 分离所有的itemView
+
+        self.getState().contentWidth = 0;
+        self.getState().contentHeight = 0;
+
+        if (getItemCount() == 0) {
+            self.getState().scrolledX = 0;
+            self.getState().scrolledY = 0;
+            self.getState().totalSpreadCount = 0;
+            return;
+        }
+
+        self.getState().totalSpreadCount = 1;
+
+        int offsetX = 15; // 当前X偏移,下一个item的left为此值
+        int offsetY = 0; // 当前Y偏移,下一个item的top为此值
+        int occupiedLineBlock = 0; // 当前line已被占用的块数
+
+        /**
+         * {@link #orientation} 为 {@link #HORIZONTAL} 时,当前line的最大宽度
+         * {@link #orientation} 为 {@link #VERTICAL} 时,当前line的最大高度
+         */
+        int currentLineSpreadLength = 0;
+
+        /**
+         * {@link #orientation} 为 {@link #HORIZONTAL} 时,当前line的总高度
+         * {@link #orientation} 为 {@link #VERTICAL} 时,当前line的总宽度
+         */
+        int currentLineLength = 0;
+
+        /**
+         * {@link #orientation} 为 {@link #HORIZONTAL} 时,所有line的最大高度
+         * {@link #orientation} 为 {@link #VERTICAL} 时,所有line的最大宽度
+         */
+        int maxLineLength = 0;
+
+        /**
+         * 计算所有item的frame,以及总宽高
+         */
+        for (int i = 0; i < getItemCount(); i++) {
+            View scrap = recycler.getViewForPosition(i); // 根据position获取一个碎片view,可以从回收的view中获取,也可能新构造一个
+
+
+            self.addView(scrap);
+            self.measureChildWithMargins(scrap, 0, 0);  // 计算此碎片view包含边距的尺寸
+
+            int width = self.getDecoratedMeasuredWidth(scrap);  // 获取此碎片view包含边距和装饰的宽度width
+            int height = self.getDecoratedMeasuredHeight(scrap); // 获取此碎片view包含边距和装饰的高度height
+
+            LayoutParams layoutParams = (LayoutParams) scrap.getLayoutParams();
+            occupiedLineBlock += Math.max(layoutParams.occupationLineBlocks, 1); // 记录当前line已占用的块数,每个item至少占1块
+
+            /**宽度超过屏幕宽度就移动到下一行*/
+            int col = screen_w / width;
+            int margin = (screen_w - col * width) / (col + 1);
+            if (getOrientation() == VERTICAL) {
+                if (i == 0) {
+                    offsetX = margin;
+                }
+            }
+
+            /** 占用的块数若超过了{@link com.vilyever.howtocustomlayoutmanager.CustomLayoutManager.State#itemLineCount},切换到下一line */
+            if (occupiedLineBlock > col/*self.getState().itemLineCount*/) {
+                if (self.getState().orientation == HORIZONTAL) {
+                    offsetX += currentLineSpreadLength; // 横向偏移当前line的最大宽度
+                    offsetY = 0; // 纵向重置到0
+                    self.getState().contentWidth += currentLineSpreadLength; // contentWidth增加当前line的最大宽度
+                }
+                else {
+                    offsetX = margin; // 横向重置到0
+                    offsetY += currentLineSpreadLength + margin; // 纵向偏移当前line的最大高度
+                    self.getState().contentHeight += currentLineSpreadLength; // contentHeight增加当前line的最大高度
+                }
+
+                occupiedLineBlock = layoutParams.occupationLineBlocks; // 切换到新line布置item
+                currentLineSpreadLength = 0; // 新line还没有item,不占空间
+                maxLineLength = Math.max(maxLineLength, currentLineLength); // 记录之前所有line的最大长度
+                currentLineLength = 0; // 重置
+                self.getState().totalSpreadCount++;
+            }
+
+
+
+
+
+            Rect frame = self.getState().itemsFrames.get(i); // 若先前生成过Rect,重复使用
+            if (frame == null) {
+                frame = new Rect();
+            }
+
+            frame.set(offsetX, offsetY, offsetX + width, offsetY + height);
+            self.getState().itemsFrames.put(i, frame); // 记录每个item的frame
+            self.getState().itemsAttached.put(i, false); // 因为先前已经回收了所有item,此处将item显示标识置否
+
+            if (self.getState().orientation == HORIZONTAL) {
+                offsetY += height; // 纵向偏移,横向不变
+                currentLineSpreadLength = Math.max(currentLineSpreadLength, width); // 记录当前line最大宽度
+                currentLineLength += height; // 记录当前line总高度
+            }
+            else {
+                offsetX += width + margin; // 横向偏移,纵向不变
+                currentLineSpreadLength = Math.max(currentLineSpreadLength, height); // 记录当前line最大高度
+                currentLineLength += width; // 记录当前line总宽度
+            }
+
+            self.detachAndScrapView(scrap, recycler); // 回收本次计算的碎片view
+        }
+
+        if (self.getState().orientation == HORIZONTAL) {
+            self.getState().contentWidth += currentLineSpreadLength; // contentWidth增加最后line的最大宽度
+            self.getState().contentHeight = maxLineLength; // contentHeight设为所有line的最大高度
+        }
+        else {
+            self.getState().contentWidth = maxLineLength; // contentWidth设为所有line的最大宽度
+            self.getState().contentHeight += currentLineSpreadLength; // contentWidth增加最后line的最大高度
+        }
+
+        self.getState().contentWidth = Math.max(self.getState().contentWidth, self.getHorizontalSpace()); // 内容宽度最小为RecyclerView容器宽度
+        self.getState().contentHeight = Math.max(self.getState().contentHeight, self.getVerticalSpace()); // 内容高度最小为RecyclerView容器高度
+
+        // 依照新内容宽高调整记录的滑动距离,防止滑动偏移过大
+        self.fixScrollOffset();
+
+        self.layoutItems(recycler, state); // 放置当前scroll offset处要展示的item
+    }
+
+    /** @see RecyclerView.LayoutManager#canScrollHorizontally() */
+    @Override
+    public boolean canScrollHorizontally() {
+        return self.getState().canScrollHorizontal;
+    }
+
+    /** @see RecyclerView.LayoutManager#scrollHorizontallyBy(int, RecyclerView.Recycler, RecyclerView.State) */
+    @Override
+    public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
+        int willScroll = dx;
+        /**
+         * 限制滑动距离的最小值和最大值
+         */
+        if (self.getState().scrolledX + dx < 0) {
+            willScroll = -self.getState().scrolledX;
+        }
+        else if (self.getState().scrolledX + dx > self.getState().contentWidth - self.getHorizontalSpace()) {
+            willScroll = self.getState().contentWidth - self.getHorizontalSpace() - self.getState().scrolledX;
+        }
+
+        // 如果将要滑动的距离为0,返回-dx以显示边缘光晕
+        if (willScroll == 0) {
+            return -dx;
+        }
+
+        self.getState().scrolledX += willScroll;
+
+        // 平移容器内的item
+        self.offsetChildrenHorizontal(-willScroll);
+        // 移除屏幕外的item,添加当前可显示的新item
+        self.layoutItems(recycler, state);
+
+        return willScroll;
+    }
+
+    /** @see RecyclerView.LayoutManager#canScrollVertically() */
+    @Override
+    public boolean canScrollVertically() {
+        return self.getState().canScrollVertical;
+    }
+
+    /** @see RecyclerView.LayoutManager#scrollVerticallyBy(int, RecyclerView.Recycler, RecyclerView.State) */
+    @Override
+    public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
+        int willScroll = dy;
+
+        /**
+         * 限制滑动距离的最小值和最大值
+         */
+        if (self.getState().scrolledY + dy < 0) {
+            willScroll = -self.getState().scrolledY;
+        }
+        else if (self.getState().scrolledY + dy > self.getState().contentHeight - self.getVerticalSpace()) {
+            willScroll = self.getState().contentHeight - self.getVerticalSpace() - self.getState().scrolledY;
+        }
+
+        // 如果将要滑动的距离为0,返回-dy以显示边缘光晕
+        if (willScroll == 0) {
+            return -dy;
+        }
+
+        self.getState().scrolledY += willScroll;
+
+        // 平移容器内的item
+        self.offsetChildrenVertical(-willScroll);
+        // 移除屏幕外的item,添加当前可显示的新item
+        self.layoutItems(recycler, state);
+
+        return willScroll;
+    }
+
+    @Override
+    public void scrollToPosition(int position) {
+        position = Math.max(position, 0);
+        position = Math.min(position, self.getItemCount());
+
+        self.getState().scrolledX = self.getState().itemsFrames.get(position).left;
+        self.getState().scrolledY = self.getState().itemsFrames.get(position).top;
+        self.fixScrollOffset();
+
+        self.requestLayout();
+    }
+
+    @Override
+    public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
+        position = Math.max(position, 0);
+        position = Math.min(position, self.getItemCount());
+
+        /*
+         * LinearSmoothScroller's default behavior is to scroll the contents until
+         * the child is fully visible. It will snap to the top-left or bottom-right
+         * of the parent depending on whether the direction of travel was positive
+         * or negative.
+         */
+        LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()) {
+            /*
+             * LinearSmoothScroller, at a minimum, just need to know the vector
+             * (x/y distance) to travel in order to get from the current positioning
+             * to the target.
+             */
+            @Override
+            public PointF computeScrollVectorForPosition(int targetPosition) {
+                int oldScrollX = self.getState().scrolledX;
+                int oldScrollY = self.getState().scrolledY;
+
+                self.getState().scrolledX = self.getState().itemsFrames.get(targetPosition).left;
+                self.getState().scrolledY = self.getState().itemsFrames.get(targetPosition).top;
+                self.fixScrollOffset();
+
+                int newScrollX = self.getState().scrolledX;
+                int newScrollY = self.getState().scrolledY;
+
+                self.getState().scrolledX = oldScrollX;
+                self.getState().scrolledY = oldScrollY;
+
+                return new PointF(newScrollX - oldScrollX, newScrollY - oldScrollY);
+            }
+        };
+        scroller.setTargetPosition(position);
+        self.startSmoothScroll(scroller);
+    }
+
+    /** @see RecyclerView.LayoutManager#generateDefaultLayoutParams() */
+    @Override
+    public LayoutParams generateDefaultLayoutParams() {
+        return new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+    }
+    /** @see RecyclerView.LayoutManager#generateLayoutParams(ViewGroup.LayoutParams) */
+    @Override
+    public RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
+        if (lp instanceof ViewGroup.MarginLayoutParams) {
+            return new LayoutParams((ViewGroup.MarginLayoutParams) lp);
+        } else {
+            return new LayoutParams(lp);
+        }
+    }
+    /** @see RecyclerView.LayoutManager#generateLayoutParams(Context, AttributeSet) */
+    @Override
+    public RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs) {
+        return new LayoutParams(c, attrs);
+    }
+    /** @see RecyclerView.LayoutManager#checkLayoutParams(RecyclerView.LayoutParams) */
+    @Override
+    public boolean checkLayoutParams(RecyclerView.LayoutParams lp) {
+        return lp instanceof LayoutParams;
+    }
+
+    public static class LayoutParams extends RecyclerView.LayoutParams {
+
+        /**
+         * 占用块数
+         * 不同方向布局时,占用行数或列数的值
+         * {@link State#itemLineCount}
+         * default is 1, must > 0
+         */
+        public int occupationLineBlocks = 1;
+
+        public LayoutParams(Context c, AttributeSet attrs) {
+            super(c, attrs);
+        }
+        public LayoutParams(int width, int height) {
+            super(width, height);
+        }
+        public LayoutParams(ViewGroup.MarginLayoutParams source) {
+            super(source);
+        }
+        public LayoutParams(ViewGroup.LayoutParams source) {
+            super(source);
+        }
+        public LayoutParams(RecyclerView.LayoutParams source) {
+            super(source);
+        }
+    }
+
+    /**
+     * 摆放当前状态下要展示的item
+     * @param recycler         Recycler to use for fetching potentially cached views for a
+     *                         position
+     * @param state            Transient state of RecyclerView
+     */
+    private void layoutItems(RecyclerView.Recycler recycler, RecyclerView.State state) {
+        if (state.isPreLayout()) { // 跳过preLayout,preLayout主要用于支持动画
+            return;
+        }
+
+        // 当前scroll offset状态下的显示区域
+        Rect displayFrame = new Rect(self.getState().scrolledX, self.getState().scrolledY, self.getState().scrolledX + self.getHorizontalSpace(), self.getState().scrolledY + self.getVerticalSpace());
+
+        /**
+         * 移除已显示的但在当前scroll offset状态下处于屏幕外的item
+         */
+        Rect childFrame = new Rect();
+        for (int i = 0; i < self.getChildCount(); i++) {
+            View child = self.getChildAt(i);
+            childFrame.left = self.getDecoratedLeft(child);
+            childFrame.top = self.getDecoratedTop(child);
+            childFrame.right = self.getDecoratedRight(child);
+            childFrame.bottom = self.getDecoratedBottom(child);
+
+            if (!Rect.intersects(displayFrame, childFrame)) {
+                self.getState().itemsAttached.put(self.getPosition(child), false);
+                self.removeAndRecycleView(child, recycler);
+            }
+        }
+
+        /**
+         * 摆放需要显示的item
+         * 由于RecyclerView实际上并没有scroll,也就是说RecyclerView容器的滑动效果是依赖于LayoutManager对item进行平移来实现的
+         * 故在放置item时要将item的计算位置平移到实际位置
+         */
+        for (int i = 0; i < self.getItemCount(); i++) {
+            if (Rect.intersects(displayFrame, self.getState().itemsFrames.get(i))) {
+                /**
+                 * 在onLayoutChildren时由于移除了所有的item view,可以遍历全部item进行添加
+                 * 在scroll时就不同了,由于scroll时会先将已显示的item view进行平移,然后移除屏幕外的item view,此时仍然在屏幕内显示的item view就无需再次添加了
+                 */
+                if (!self.getState().itemsAttached.get(i)) {
+                    View scrap = recycler.getViewForPosition(i);
+                    self.measureChildWithMargins(scrap, 0, 0);
+                    self.addView(scrap);
+
+                    Rect frame = self.getState().itemsFrames.get(i);
+                    self.layoutDecorated(scrap,
+                            frame.left - self.getState().scrolledX,
+                            frame.top - self.getState().scrolledY,
+                            frame.right - self.getState().scrolledX,
+                            frame.bottom - self.getState().scrolledY); // Important!布局到RecyclerView容器中,所有的计算都是为了得出任意position的item的边界来布局
+
+                    self.getState().itemsAttached.put(i, true);
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 记录当前LayoutManager的一些信息
+     */
+    private State state;
+    public State getState() {
+        if (state == null) {
+            state = new State();
+        }
+        return state;
+    }
+    class State {
+        /**
+         * 存放所有item的位置和尺寸
+         */
+        SparseArray<Rect> itemsFrames;
+
+        /**
+         * 记录item是否已经展示
+         */
+        SparseBooleanArray itemsAttached;
+
+        /**
+         * 横向滑动距离
+         * @see #scrollHorizontallyBy(int, RecyclerView.Recycler, RecyclerView.State)
+         */
+        int scrolledX;
+
+        /**
+         * 纵向滑动距离
+         * @see #scrollVerticallyBy(int, RecyclerView.Recycler, RecyclerView.State)
+         */
+        int scrolledY;
+
+        /**
+         * 内容宽度
+         * note:最小宽度为容器宽度
+         */
+        int contentWidth;
+
+        /**
+         * 内容高度
+         * note:最小高度为容器高度
+         */
+        int contentHeight;
+
+        /**
+         * 是否允许横向滑动
+         * 默认允许
+         */
+        boolean canScrollHorizontal;
+
+        /**
+         * 是否允许纵向滑动
+         * 默认允许
+         */
+        boolean canScrollVertical;
+
+        /**
+         * Current orientation. Either {@link #HORIZONTAL} or {@link #VERTICAL}
+         */
+        int orientation;
+
+        /**
+         * {@link #orientation} 为 {@link #HORIZONTAL} 时,每列显示的item数
+         * {@link #orientation} 为 {@link #VERTICAL} 时,每行显示的item数
+         * 每个item有可能占用多格 {@link com.usai.redant.raimage.PhotoList.CustomLayoutManager.LayoutParams#occupationLineBlocks}
+         */
+        int itemLineCount;
+
+        /**
+         * {@link #orientation} 为 {@link #HORIZONTAL} 时,表示列数
+         * {@link #orientation} 为 {@link #VERTICAL} 时,表示行数
+         */
+        int totalSpreadCount;
+
+        public State() {
+            itemsFrames = new SparseArray<>();
+            itemsAttached = new SparseBooleanArray();
+            scrolledX = 0;
+            scrolledY = 0;
+            contentWidth = 0;
+            contentHeight = 0;
+            canScrollHorizontal = true;
+            canScrollVertical = true;
+            itemLineCount = 1;
+            totalSpreadCount = 0;
+        }
+    }
+
+    /**
+     * 启用/禁用横向滑动
+     * @param canScrollHorizontal 启用/禁用
+     * @return {@link State#canScrollHorizontal}
+     */
+    public CustomLayoutManager setCanScrollHorizontal(boolean canScrollHorizontal) {
+        self.getState().canScrollHorizontal = canScrollHorizontal;
+        return this;
+    }
+    public boolean getCanScrollHorizontal() {
+        return self.getState().canScrollHorizontal;
+    }
+
+    /**
+     * 启用/禁用纵向滑动
+     * @param canScrollVertical 启用/禁用
+     * @return {@link State#canScrollVertical}
+     */
+    public CustomLayoutManager setCanScrollVertical(boolean canScrollVertical) {
+        self.getState().canScrollVertical = canScrollVertical;
+        return this;
+    }
+    public boolean getCanScrollVertical() {
+        return self.getState().canScrollVertical;
+    }
+
+    /**
+     * 纵然此LayoutManager在水平方向和垂直方向都可以滑动
+     * 此LayoutManager仍然带有orientation属性
+     * orientation将影响item摆放的次序
+     *
+     * 若Direction为Vertical,item的摆放顺序为从左到右,一行铺满后填充下一行
+     * 若Direction为Horizontal,item的摆放顺序为从上到下,一列铺满后填充下一列
+     */
+    @IntDef({HORIZONTAL, VERTICAL})
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface Orientation {}
+    public static final int HORIZONTAL = LinearLayout.HORIZONTAL;
+    public static final int VERTICAL = LinearLayout.VERTICAL;
+    public CustomLayoutManager setOrientation(@Orientation int orientation) {
+        if (orientation != HORIZONTAL && orientation != VERTICAL) {
+            throw new IllegalArgumentException("invalid orientation:" + orientation);
+        }
+        assertNotInLayoutOrScroll(null);
+        if (orientation == self.getState().orientation) {
+            return this;
+        }
+        self.getState().orientation = orientation;
+        self.requestLayout();
+        return this;
+    }
+    @Orientation
+    public int getOrientation() {
+        return self.getState().orientation;
+    }
+
+    public CustomLayoutManager setItemLineCount(int itemLineCount) {
+        assertNotInLayoutOrScroll(null);
+        if (itemLineCount == self.getState().itemLineCount) {
+            return this;
+        }
+        self.getState().itemLineCount = itemLineCount;
+        self.requestLayout();
+        return this;
+    }
+    public int getItemLineCount() {
+        return self.getState().itemLineCount;
+    }
+
+    /**
+     * 依照内容宽高调整记录的滑动距离,防止滑动偏移过大
+     */
+    private void fixScrollOffset() {
+        if (self.getState().contentWidth == self.getHorizontalSpace()) {
+            self.getState().scrolledX = 0;
+        }
+        if (self.getState().scrolledX > (self.getState().contentWidth - self.getHorizontalSpace())) {
+            self.getState().scrolledX = self.getState().contentWidth - self.getHorizontalSpace();
+        }
+        if (self.getState().contentHeight == self.getVerticalSpace()) {
+            self.getState().scrolledY = 0;
+        }
+        if (self.getState().scrolledY > (self.getState().contentHeight - self.getVerticalSpace())) {
+            self.getState().scrolledY = self.getState().contentHeight - self.getVerticalSpace();
+        }
+    }
+
+    /**
+     * 容器去除padding后的宽度
+     * @return 实际可摆放item的空间
+     */
+    private int getHorizontalSpace() {
+        return self.getWidth() - self.getPaddingRight() - self.getPaddingLeft();
+    }
+
+    /**
+     * 容器去除padding后的高度
+     * @return 实际可摆放item的空间
+     */
+    private int getVerticalSpace() {
+        return self.getHeight() - self.getPaddingBottom() - self.getPaddingTop();
+    }
+}

+ 37 - 0
RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/GridLayoutRecycler/RAGridLayoutManager.java

@@ -0,0 +1,37 @@
+package com.usai.redant.raimage.PhotoList.GridLayoutRecycler;
+
+import android.content.Context;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.view.View;
+
+/**
+ * Created by macmini1 on 2017/6/19.
+ */
+
+
+public class RAGridLayoutManager extends GridLayoutManager {
+
+    private int measuredWidth = 0;
+    private int measuredHeight = 0;
+
+    public RAGridLayoutManager(Context ctx,int spanCount) {
+        super(ctx,spanCount);
+    }
+
+    public RAGridLayoutManager(Context ctx,int spanCount,int orientaion,boolean reverseLayout) {
+        super(ctx,spanCount,orientaion,reverseLayout);
+    }
+
+    public RAGridLayoutManager(Context ctx, AttributeSet attrs,int defStyleAttr,int defStyleRes) {
+        super(ctx,attrs,defStyleAttr,defStyleRes);
+    }
+
+    @Override
+    public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
+
+        super.onMeasure(recycler,state,widthSpec,heightSpec);
+
+    }
+}

+ 175 - 0
RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/GridLayoutRecycler/RAPreviewRecyclerView.java

@@ -0,0 +1,175 @@
+package com.usai.redant.raimage.PhotoList.GridLayoutRecycler;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
+
+import static android.view.MotionEvent.ACTION_DOWN;
+import static android.view.MotionEvent.ACTION_MOVE;
+import static android.view.MotionEvent.ACTION_UP;
+
+/**
+ * Created by macmini1 on 2017/6/19.
+ */
+
+public class RAPreviewRecyclerView extends RecyclerView {
+
+
+    private int totalPage = 0;
+    private int curPage = 0;
+
+    /**
+     * 0: 停止滚动
+     * 1: 开始滚动
+     * 2: 手指移开
+     *
+     * */
+    private int scrollState = 0;
+    private int shortestDistance;
+    private float slideDistance;
+    private float scrollX = 0; // X轴当前的位置
+
+    public PageIndicator indicator;
+
+    public RAPreviewRecyclerView(Context context) {
+        this(context, null);
+    }
+
+    public RAPreviewRecyclerView(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public RAPreviewRecyclerView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+
+    }
+
+    @Override
+    protected void onMeasure(int widthSpec, int heightSpec) {
+        super.onMeasure(widthSpec, heightSpec);
+        shortestDistance = getMeasuredWidth() / 3;
+        totalPage = getAdapter().getItemCount();
+    }
+
+    /**
+     * 取消惯性滑动
+     * 阻尼:1000为将惯性滚动速度缩小1000倍,近似drag操作。
+     * */
+    @Override
+    public boolean fling(int velocityX, int velocityY) {
+        return super.fling(velocityX / 1000, velocityY / 1000);
+    }
+
+    /**滚动*/
+    @Override
+    public void onScrolled(int dx, int dy) {
+//        Log.d("Scroll","scroll X: " + dx);
+        scrollX += dx;
+        if (scrollState == 1) {
+            slideDistance += dx;
+        }
+        super.onScrolled(dx, dy);
+    }
+
+    @Override
+    public void onScrollStateChanged(int state) {
+
+        switch (state) {
+            case 2: {
+                scrollState = 2;
+            }
+                break;
+            case 1:
+                scrollState = 1;
+                break;
+            case 0:
+                if (slideDistance == 0) {
+                    break;
+                }
+                scrollState = 0;
+
+//                if (slideDistance < 0) { // 上页
+//                    curPage = (int) Math.ceil(scrollX / getWidth());
+////                    Log.d("Scroll","<0 scroll X: " + scrollX + " Cur :" + curPage);
+//                    if (curPage * getWidth() - scrollX < shortestDistance) {
+//                        curPage += 1;
+//                    }
+//                } else { // 下页
+//                    curPage = (int) Math.ceil(scrollX / getWidth()) + 1;
+////                    Log.d("Scroll",">0 scroll X: " + scrollX + " Cur :" + curPage);
+//                    if (curPage <= totalPage) {
+//                        if (scrollX - (curPage - 2) * getWidth() < shortestDistance) {
+//                            // 如果这一页滑出距离不足,则定位到前一页
+//                            curPage -= 1;
+//                        }
+//                    } else {
+//                        curPage = totalPage;
+//                    }
+//                }
+
+                int offsetX = computeHorizontalScrollOffset();
+                int width = getWidth();
+                curPage = (int)Math.ceil(offsetX / width);
+
+                if (slideDistance < 0) {
+                    if ((curPage * width) - offsetX > shortestDistance) {
+                        curPage--;
+                    }
+                } else  {
+                    if ((curPage * width) - offsetX < shortestDistance) {
+                        curPage++;
+                        if (curPage >= totalPage) {
+                            curPage = totalPage - 1;
+                        }
+                    }
+                }
+
+
+                // 执行自动滚动
+                scrollToPosition(curPage);
+                // 修改指示器选中项
+                if (indicator != null) {
+                    indicator.changePageIndex(curPage,totalPage);
+                }
+                slideDistance = 0;
+                break;
+        }
+        super.onScrollStateChanged(state);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent e) {
+
+        int action = e.getAction();
+        if (action == ACTION_DOWN) {
+
+        }
+
+        if (action == ACTION_UP) {
+
+        }
+
+        if (action == ACTION_MOVE) {
+
+        }
+
+        return super.onTouchEvent(e);
+    }
+
+    @Override
+    public void computeScroll() {
+
+        super.computeScroll();
+    }
+
+    public void scrollToPage(int page) {
+        curPage = page;
+        scrollToPosition(curPage);
+    }
+
+    public interface PageIndicator {
+        void changePageIndex(int index,int total);
+    }
+}

+ 30 - 5
RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/NewPhotoPreviewActivity.java

@@ -1,6 +1,8 @@
 package com.usai.redant.raimage.PhotoList;
 
 import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.net.Uri;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
@@ -15,6 +17,7 @@ import android.view.ViewGroup;
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.usai.redant.raimage.PhotoList.GridLayoutRecycler.RAPreviewRecyclerView;
 import com.usai.redant.raimage.R;
 
 import java.io.File;
@@ -23,7 +26,7 @@ import java.util.ArrayList;
 public class NewPhotoPreviewActivity extends AppCompatActivity {
 
     private TextView indexTV;
-    private RecyclerView recyclerView;
+    private RAPreviewRecyclerView recyclerView;
     private ArrayList<String> photos;
     private int currentIdx;
     private PreviewAdapter adapter;
@@ -40,6 +43,7 @@ public class NewPhotoPreviewActivity extends AppCompatActivity {
 
         /**View*/
         indexTV = (TextView)findViewById(R.id.index_tv);
+        recyclerView = (RAPreviewRecyclerView) findViewById(R.id.preview_recycler);
 
 
         /** Setting */
@@ -58,8 +62,17 @@ public class NewPhotoPreviewActivity extends AppCompatActivity {
         // 设置Adapter
         recyclerView.setAdapter(adapter = new PreviewAdapter());
 
+        recyclerView.indicator = new RAPreviewRecyclerView.PageIndicator() {
+            @Override
+            public void changePageIndex(int index, int total) {
+                indexTV.setText(index + 1 + " / " + total);
+            }
+        };
+
+        recyclerView.scrollToPage(currentIdx);
+
+
 
-        recyclerView.scrollToPosition(currentIdx);
     }
 
     @Override
@@ -94,9 +107,13 @@ public class NewPhotoPreviewActivity extends AppCompatActivity {
         @Override
         public void onBindViewHolder(PreviewHolder holder, int position) {
             String path = photos.get(position);
-            File file = new File(path);
-            Uri uri = Uri.fromFile(file);
-            holder.imageView.setImageURI(uri);
+//            File file = new File(path);
+//            Uri uri = Uri.fromFile(file);
+//            holder.imageView.setImageURI(uri);
+
+            Bitmap bitmap = scaleImage(path,150,150);
+
+            holder.imageView.setImageBitmap(bitmap);
         }
 
         @Override
@@ -104,4 +121,12 @@ public class NewPhotoPreviewActivity extends AppCompatActivity {
             return photos.size();
         }
     }
+
+    public Bitmap scaleImage(String path, int width, int height) {
+        Bitmap source = BitmapFactory.decodeFile(path);
+
+        Bitmap scaled = Bitmap.createScaledBitmap(source, width, height, true);
+        return scaled;
+    }
+
 }

+ 14 - 22
RA Image/app/src/main/java/com/usai/redant/raimage/PhotoList/PhotoListActivity.java

@@ -68,17 +68,22 @@ public class PhotoListActivity extends AppCompatActivity {
             }
         });
 
+
+        int h = getWindowManager().getDefaultDisplay().getHeight();
+        int w = getWindowManager().getDefaultDisplay().getWidth();
+
         // 设置布局管理器
-        layoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
-        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
-            @Override
-            public int getSpanSize(int position) {
-                return 1;
-            }
-        });
-        recycler.setLayoutManager(layoutManager);
+//        layoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
+//        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
+//            @Override
+//            public int getSpanSize(int position) {
+//                return 1;
+//            }
+//        });
+//        recycler.setLayoutManager(layoutManager);
+        recycler.setLayoutManager(new CustomLayoutManager(CustomLayoutManager.VERTICAL,w,h));
         // 添加分割线
-        recycler.addItemDecoration(new GridItemDecoration(3, getResources().getDimensionPixelSize(R.dimen.padding_middle), true));
+//        recycler.addItemDecoration(new GridItemDecoration(3, getResources().getDimensionPixelSize(R.dimen.padding_middle), true));
         // 设置Item增加、移除动画
         recycler.setItemAnimator(new DefaultItemAnimator());
         // 设置Adapter
@@ -103,19 +108,6 @@ public class PhotoListActivity extends AppCompatActivity {
          return true;
     }
 
-    @Override
-    public void onConfigurationChanged(Configuration newConfig) {
-        super.onConfigurationChanged(newConfig);
-        if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT){
-
-            layoutManager.setSpanCount(3);
-        }
-        if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
-
-            layoutManager.setSpanCount(4);
-        }
-    }
-
     private void showPhotoPreview(int index) {
         Toast.makeText(PhotoListActivity.this,"Click" + index,Toast.LENGTH_LONG).show();
         Intent intent = new Intent(this,NewPhotoPreviewActivity.class);

+ 20 - 1
RA Image/app/src/main/res/layout-land/activity_model.xml

@@ -7,13 +7,32 @@
     android:background="@color/black_overlay"
     tools:context="com.usai.redant.raimage.Model.ModelActivity">
 
+    <RelativeLayout
+        android:id="@+id/manufacture_layout"
+        android:layout_width="220dp"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="31dp"
+        android:layout_marginStart="31dp"
+        >
+
+        <Button
+            android:id="@+id/manufacture_btn"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerHorizontal="true"
+            android:text="Select Manufacturer"
+            android:textAllCaps="false"
+            />
+
+    </RelativeLayout>>
+
     <RelativeLayout
         android:id="@+id/photo_layout"
         android:layout_width="220dp"
         android:layout_height="220dp"
         android:layout_marginLeft="31dp"
         android:layout_marginStart="31dp"
-        android:layout_centerVertical="true"
+        android:layout_below="@id/manufacture_layout"
         >
 
         <ImageView

+ 15 - 0
RA Image/app/src/main/res/layout/activity_manufacture_list.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="com.usai.redant.raimage.Model.ManufactureListActivity">
+
+    <ListView
+        android:id="@+id/manufacture_list"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        />
+
+</android.support.constraint.ConstraintLayout>

+ 12 - 4
RA Image/app/src/main/res/layout/activity_model.xml

@@ -7,15 +7,23 @@
     android:background="@color/black_overlay"
     tools:context="com.usai.redant.raimage.Model.ModelActivity">
 
+    <Button
+        android:id="@+id/manufacture_btn"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:text="Select Manufacturer"
+        android:textAllCaps="false"
+        />
+
     <ImageView
         android:id="@+id/photo_iv"
         android:layout_width="260dp"
         android:layout_height="260dp"
-        android:layout_alignParentTop="true"
-        android:layout_centerHorizontal="true"
-        android:layout_marginTop="30dp"
+        android:layout_below="@id/manufacture_btn"
         android:scaleType="centerCrop"
-        app:srcCompat="@drawable/no_pic" />
+        app:srcCompat="@drawable/no_pic"
+        android:layout_centerHorizontal="true" />
 
     <TextView
         android:id="@+id/photo_count_lb"

+ 5 - 6
RA Image/app/src/main/res/layout/activity_new_photo_preview.xml

@@ -1,21 +1,20 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="#000000"
-    tools:context="com.usai.redant.raimage.PhotoList.NewPhotoPreviewActivity">
+    android:background="#ff0000"
+    >
 
 
 
-    <android.support.v7.widget.RecyclerView
+    <com.usai.redant.raimage.PhotoList.GridLayoutRecycler.RAPreviewRecyclerView
         android:id="@+id/preview_recycler"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_alignParentTop="true"
         android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true" />
+        android:layout_alignParentStart="true"
+        android:background="#aaff00"/>
 
     <TextView
         android:id="@+id/index_tv"

+ 21 - 0
RA Image/app/src/main/res/layout/manufacture_cell.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView
+        android:id="@+id/manufacture_cell_tv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_vertical"
+        android:layout_marginStart="10dp"
+        android:layout_marginLeft="10dp"
+        android:layout_marginTop="10dp"
+        android:layout_marginBottom="10dp"
+        android:textSize="20sp"
+        android:textColor="#000000"
+        android:textAlignment="gravity"
+        />
+
+</LinearLayout>

+ 3 - 4
RA Image/app/src/main/res/layout/photo_list_item.xml

@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="100dp"
-    android:layout_height="100dp"
+    android:layout_width="120dp"
+    android:layout_height="120dp"
     >
 
     <ImageView
@@ -11,6 +9,7 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="centerCrop"
+        android:layout_margin="5dp"
         />
 
     <ImageButton

+ 3 - 1
RA Image/app/src/main/res/layout/photo_preview_item.xml

@@ -1,12 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:background="#0aa">
 
     <ImageView
         android:id="@+id/preview_item"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:layout_margin="10dp"
         />
 
 </LinearLayout>

BIN
RA Image/captures/com.usai.redant.raimage_2017.06.19_11.30.li


BIN
RA Image/captures/com.usai.redant.raimage_2017.06.20_09.49.li