Skip to content

Commit

Permalink
添加VonPhotoUtils使用实例
Browse files Browse the repository at this point in the history
添加VonPhotoUtils使用实例,调用UZrop裁剪库
  • Loading branch information
秋逸 committed Nov 14, 2016
1 parent fb1dae5 commit 29aa5cb
Show file tree
Hide file tree
Showing 20 changed files with 820 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions VonTools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:25.0.0'
}

def siteUrl = 'https://github.com/vondear/VonTools'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.vondear.vontools;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Created by vonde on 2016/11/13.
*/

public class VonRecyclerViewUtils {

public static class SpaceItemDecoration extends RecyclerView.ItemDecoration {

private int space;
private boolean isTop = false;

public SpaceItemDecoration(int space, boolean isTop) {
this.space = space;
this.isTop = isTop;
}

public SpaceItemDecoration(int space) {
this.space = space;
}

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
//不是第一个的格子都设一个左边和底部的间距
outRect.left = space;
outRect.right = space;
outRect.bottom = space;
outRect.top = space;
if (isTop) {
if (parent.getChildLayoutPosition(view) == 0) {
outRect.top = 0;
}
outRect.left = 0;
outRect.right = 0;
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.vondear.vontools.view;


import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager.LayoutParams;

import com.vondear.vontools.R;


public class TransparentDialog extends Dialog {
private LayoutParams attr;

public LayoutParams getAttr() {
return attr;
}

public TransparentDialog(Context context, int themeResId) {
super(context, themeResId);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setBackgroundDrawableResource(R.drawable.transparent_bg);
Window window = this.getWindow();
LayoutParams lp = window.getAttributes();
lp.alpha = 1f;
window.setAttributes(lp);
attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = Gravity.CENTER;
}
}

public TransparentDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setBackgroundDrawableResource(R.drawable.transparent_bg);
Window window = this.getWindow();
LayoutParams lp = window.getAttributes();
lp.alpha = 1f;
window.setAttributes(lp);
attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = Gravity.CENTER;
}
}

public TransparentDialog(Context context) {
super(context);
// TODO Auto-generated constructor stub
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setBackgroundDrawableResource(
R.drawable.transparent_bg);
Window window = this.getWindow();
LayoutParams lp = window.getAttributes();
lp.alpha = 1f;
window.setAttributes(lp);
attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = Gravity.CENTER;
}
}

public TransparentDialog(Activity context) {
super(context);
// TODO Auto-generated constructor stub
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setBackgroundDrawableResource(
R.drawable.transparent_bg);
Window window = this.getWindow();
LayoutParams lp = window.getAttributes();
lp.alpha = 1f;
window.setAttributes(lp);
attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = Gravity.CENTER;
}
}

/**
*
* @param context
* @param alpha 透明度 0.0f--1f(不透明)
* @param gravity 方向(Gravity.BOTTOM,Gravity.TOP,Gravity.LEFT,Gravity.RIGHT)
*/
public TransparentDialog(Context context, float alpha, int gravity) {
super(context);
// TODO Auto-generated constructor stub
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setBackgroundDrawableResource(
R.drawable.transparent_bg);
Window window = this.getWindow();
LayoutParams lp = window.getAttributes();
lp.alpha = alpha;
window.setAttributes(lp);
attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = gravity;
}
}

/**
*
* @param context
* @param alpha 透明度 0.0f--1f(不透明)
* @param gravity 方向(Gravity.BOTTOM,Gravity.TOP,Gravity.LEFT,Gravity.RIGHT)
*/
public TransparentDialog(Context context, float alpha, int gravity, boolean isOnScreen) {
super(context, android.R.style.Theme);
setOwnerActivity((Activity)context);
// TODO Auto-generated constructor stub
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setBackgroundDrawableResource(R.drawable.transparent_bg);
Window window = this.getWindow();
LayoutParams lp = window.getAttributes();
lp.alpha = alpha;
window.setAttributes(lp);
attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = gravity;
}
}

/**
* 隐藏头部导航栏状态栏
*/
public void skipTools() {
if (Build.VERSION.SDK_INT < 19) {
return;
}
getWindow().setFlags(
LayoutParams.FLAG_FULLSCREEN,
LayoutParams.FLAG_FULLSCREEN);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions VonTools/src/main/res/drawable/shape_round_black.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<!--<gradient android:angle="270" android:endColor="#A8C3B0"
android:startColor="#C6CFCE"/>-->
<!--<size android:height="60dp" android:width="320dp" />-->
<solid android:color="#aa000000"/>
<corners android:radius="15dp" />
<!-- <stroke android:width="1dp" android:color="#000000" />-->

</shape>
11 changes: 11 additions & 0 deletions VonTools/src/main/res/drawable/shape_round_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<!--<gradient android:angle="270" android:endColor="#A8C3B0"
android:startColor="#C6CFCE"/>-->
<!--<size android:height="60dp" android:width="320dp" />-->
<solid android:color="#FFFFFF"/>
<corners android:radius="5dp" />
<!-- <stroke android:width="1dp" android:color="#000000" />-->

</shape>
74 changes: 74 additions & 0 deletions VonTools/src/main/res/layout/dialog_picker_pictrue.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/transparent_bg"
android:orientation="vertical">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_round_white"
android:orientation="vertical">

<TextView
android:layout_width="fill_parent"
android:layout_height="45dp"
android:gravity="center"
android:text="请选择图片来源"
android:textColor="#b9b9b9" />

<View
android:layout_width="fill_parent"
android:layout_height="0.1dp"
android:background="#b9b9b9" />

<TextView
android:id="@+id/tv_camera"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="照相机"
android:textColor="#FF4081"
android:textSize="20sp" />

<View
android:layout_width="fill_parent"
android:layout_height="0.1dp"
android:background="#cccccc" />

<TextView
android:id="@+id/tv_file"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="相册"
android:textColor="#009EE7"
android:textSize="20sp" />


</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/shape_round_white"
android:orientation="vertical">

<TextView
android:id="@+id/tv_cancelid"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="取消"
android:textColor="#cccccc"
android:textSize="20sp"
android:textStyle="bold" />

</LinearLayout>
</LinearLayout>
21 changes: 17 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.vondear.tools"
minSdkVersion 9
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
Expand All @@ -24,6 +25,18 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:appcompat-v7:25.0.0'
testCompile 'junit:junit:4.12'

compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'

compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile project(path: ':VonTools')

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'jp.wasabeef:glide-transformations:2.0.1'

compile 'com.yalantis:ucrop:2.2.0'
}
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vondear.tools">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -15,6 +18,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ActivityVonPhoto"></activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
</application>

</manifest>
Loading

0 comments on commit 29aa5cb

Please sign in to comment.