Skip to content

Commit

Permalink
加入置顶功能
Browse files Browse the repository at this point in the history
  • Loading branch information
1993hzw committed Jul 17, 2017
1 parent e245658 commit daaa925
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 6 deletions.
4 changes: 4 additions & 0 deletions graffiti/src/main/java/cn/hzw/graffiti/GraffitiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ private void initView() {
findViewById(R.id.btn_undo).setOnClickListener(mOnClickListener);
findViewById(R.id.graffiti_selectable_edit).setOnClickListener(mOnClickListener);
findViewById(R.id.graffiti_selectable_remove).setOnClickListener(mOnClickListener);
findViewById(R.id.graffiti_selectable_top).setOnClickListener(mOnClickListener);
mShapeModeContainer = findViewById(R.id.bar_shape_mode);
mSelectedTextEditContainer = findViewById(R.id.graffiti_selectable_edit_container);
mEditContainer = findViewById(R.id.graffiti_edit_container);
Expand Down Expand Up @@ -800,6 +801,9 @@ public void onClick(View v) {
} else if (v.getId() == R.id.graffiti_selectable_remove) {
mGraffitiView.removeSelectedItem();
mDone = true;
} else if (v.getId() == R.id.graffiti_selectable_top) {
mGraffitiView.topSelectedItem();
mDone = true;
}
if (mDone) {
return;
Expand Down
14 changes: 14 additions & 0 deletions graffiti/src/main/java/cn/hzw/graffiti/GraffitiView.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,12 @@ public final void removeSelectableItem(GraffitiSelectableItem item) {
mUndoStack.remove(item);
}

public final void topSelectableItem(GraffitiSelectableItem item) {
removeSelectableItem(item);
mSelectableStack.add(item);
mUndoStack.add(item);
}

private void initCanvas() {
if (mGraffitiBitmap != null) {
mGraffitiBitmap.recycle();
Expand Down Expand Up @@ -1205,6 +1211,14 @@ public void removeSelectedItem() {
invalidate();
}

public void topSelectedItem() {
if (mSelectedItem == null) {
throw new NullPointerException("Selected item is null!");
}
topSelectableItem(mSelectedItem);
invalidate();
}

public float getOriginalPivotX() {
return mOriginalPivotX;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private ImageLoader(Context context) {
mImageLoaderGroup = new ImageLoaderGroup(context, memoryCacheSize, 25 * 1024 * 1024);
mImageLoaderGroup.addImageLoader(new LocalImagerLoader(context));
ImageLoaderConfig config = mImageLoaderGroup.getImageLoaderConfig();
config.setLoadingDrawable(context.getResources().getDrawable(R.drawable.imageselector_loading));
config.setLoadingDrawable(context.getResources().getDrawable(R.drawable.graffit_imageselector_loading));
config.setLoadFailedDrawable(new ColorDrawable(Color.RED));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public long getItemId(int position) {
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = View.inflate(mContext, R.layout.imageselector_item, null);
convertView = View.inflate(mContext, R.layout.graffiti_imageselector_item, null);
holder = new ViewHolder();
holder.mImage = (ImageView) convertView.findViewById(R.id.image);
holder.mImageSelected = (ImageView) convertView.findViewById(R.id.image_selected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ImageSelectorView extends FrameLayout implements View.OnClickListen

public ImageSelectorView(Context context, boolean isMultipleChoice, int maxCount, final List<String> pathList, ImageSelectorListener listener) {
super(context);
View view = LayoutInflater.from(getContext()).inflate(R.layout.activity_image_selector, null);
View view = LayoutInflater.from(getContext()).inflate(R.layout.graffit_layout_image_selector, null);
addView(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

mIsMultipleChoice = isMultipleChoice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:scaleType="fitXY"
android:src="@drawable/imageselector_image_selected"
android:src="@drawable/graffiti_imageselector_image_selected"
/>
</RelativeLayout>
15 changes: 13 additions & 2 deletions graffiti/src/main/res/layout/layout_graffiti.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,18 @@
android:layout_weight="1"
android:background="@drawable/graffiti_btn_effect_rect_pressed_black"
android:gravity="center"
android:text="编辑"
android:text="@string/graffiti_edit"
android:textColor="#ffffff"
android:textSize="16dp"/>

<TextView
android:id="@+id/graffiti_selectable_top"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/graffiti_btn_effect_rect_pressed_black"
android:gravity="center"
android:text="@string/graffiti_top"
android:textColor="#ffffff"
android:textSize="16dp"/>

Expand All @@ -392,7 +403,7 @@
android:layout_weight="1"
android:background="@drawable/graffiti_btn_effect_rect_pressed_black"
android:gravity="center"
android:text="移除"
android:text="@string/graffiti_remove"
android:textColor="#ffffff"
android:textSize="16dp"/>
</LinearLayout>
Expand Down
4 changes: 4 additions & 0 deletions graffiti/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<string name="graffiti_cancel">取消</string>
<string name="graffiti_success">成功</string>
<string name="graffiti_failed">失败</string>

<string name="graffiti_edit">编辑</string>
<string name="graffiti_remove">移除</string>
<string name="graffiti_top">置顶</string>
</resources>

0 comments on commit daaa925

Please sign in to comment.