Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
coolstar1204 committed Mar 16, 2016
0 parents commit 4251b28
Show file tree
Hide file tree
Showing 113 changed files with 7,583 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
35 changes: 35 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.coolstar.makeposter"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {

}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'de.greenrobot:eventbus:3.0.0-beta1'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
compile 'joda-time:joda-time:2.9.2'
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\eclipse\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.coolstar.makeposter;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
35 changes: 35 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionName="1.0.0"
package="com.coolstar.makeposter" >

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".CustomApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".view.mainview.MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".view.posterview.PosterActivity"
android:launchMode="singleTask"
android:configChanges="keyboard|orientation|locale"
android:windowSoftInputMode="adjustPan|stateHidden"
android:screenOrientation="portrait">

</activity>
</application>

</manifest>
31 changes: 31 additions & 0 deletions app/src/main/java/com/coolstar/makeposter/CustomApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.coolstar.makeposter;

import android.app.Application;

import com.coolstar.makeposter.utils.DeviceInfo;

/**
* Created by jiguangxing on 2016/3/7.
*/
public class CustomApplication extends Application {

public static CustomApplication appContext;

@Override
public void onCreate() {
super.onCreate();
appContext = this;
DeviceInfo.init(this);
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
}

@Override
public void onTerminate() {
super.onTerminate();
}

@Override
public void onLowMemory() {
super.onLowMemory();
}
}
64 changes: 64 additions & 0 deletions app/src/main/java/com/coolstar/makeposter/ExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.coolstar.makeposter;

import android.text.TextUtils;

import com.coolstar.makeposter.utils.DirMgr;

import org.joda.time.LocalDateTime;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
* Created by jiguangxing on 2016/3/8.
*/
public class ExceptionHandler implements Thread.UncaughtExceptionHandler {

@Override
public void uncaughtException(Thread thread, Throwable ex) {
StringBuilder stringBuilder = new StringBuilder(1024);
stringBuilder.append("Thread.id=").append(thread.getId()).append("\n");
stringBuilder.append("exception=").append(throwable2String(ex));
saveCrachToFile(stringBuilder.toString());
}

private void saveCrachToFile(String log) {
if(TextUtils.isEmpty(log)){
return;
}
log = log.replaceAll("\n", "\r\n");
LocalDateTime dayTime = new LocalDateTime();
String crachFilePath = DirMgr.getDir(DirMgr.CRACH)+dayTime.toString("yyMMddHHmmss")+".log";
FileOutputStream fos =null;
try {
fos = new FileOutputStream(crachFilePath);
fos.write(log.getBytes());
fos.flush();
} catch (Exception e) {
e.printStackTrace();
}finally {
if(fos!=null){
try {
fos.close();
fos = null;
}catch (Exception ee){
ee.printStackTrace();
}
}
System.exit(0);
}
}

public static String throwable2String(final Throwable tr) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
tr.printStackTrace(pw);
return sw.toString();
} catch (Throwable e) {
}
return "No Memory, throwable2String failed";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.coolstar.makeposter.beans;

import java.util.Objects;

/**
* Created by jiguangxing on 2016/3/4.
*/
public class AsyncErrorInfo {
int error;
String msg;

public AsyncErrorInfo(int err, String errMsg) {
this.error = err;
this.msg = errMsg;
}
}
52 changes: 52 additions & 0 deletions app/src/main/java/com/coolstar/makeposter/beans/PictureInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.coolstar.makeposter.beans;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;


/**
* 手机图片项信息定义
* Created by jiguangxing on 2016/3/4.
*/
public class PictureInfo implements Parcelable {

public String picName; //图片名称
public String fileName; //文字路径及名称
public String dirName; //图片所在目录名称

public Bitmap decodeBmp; //只用于传递解码出来的bitmap

public PictureInfo() {
}

protected PictureInfo(Parcel in) {
picName = in.readString();
fileName = in.readString();
dirName = in.readString();
}

public static final Creator<PictureInfo> CREATOR = new Creator<PictureInfo>() {
@Override
public PictureInfo createFromParcel(Parcel in) {
return new PictureInfo(in);
}

@Override
public PictureInfo[] newArray(int size) {
return new PictureInfo[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(picName);
dest.writeString(fileName);
dest.writeString(dirName);
}
}
10 changes: 10 additions & 0 deletions app/src/main/java/com/coolstar/makeposter/mod/main/IMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.coolstar.makeposter.mod.main;

import android.content.Context;

/**
* Created by jiguangxing on 2016/3/4.
*/
public interface IMain {
void asyncLoadPictureList(Context context);
}
61 changes: 61 additions & 0 deletions app/src/main/java/com/coolstar/makeposter/mod/main/MainMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.coolstar.makeposter.mod.main;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

import com.coolstar.makeposter.beans.AsyncErrorInfo;
import com.coolstar.makeposter.beans.PictureInfo;
import com.coolstar.makeposter.utils.BitmapUtils;
import com.coolstar.makeposter.utils.ThreadBuilder;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import de.greenrobot.event.EventBus;

/**
* Created by jiguangxing on 2016/3/4.
*/
public class MainMod implements IMain {
@Override
public void asyncLoadPictureList(final Context context) {
ThreadBuilder.getInstance().runThread(new Runnable() {
@Override
public void run() {
String[] projection = new String[] { MediaStore.Images.Media._ID,
MediaStore.Images.Media.BUCKET_ID, // 直接包含该图片文件的文件夹ID,防止在不同下的文件夹重名
MediaStore.Images.Media.BUCKET_DISPLAY_NAME, // 直接包含该图片文件的文件夹名
MediaStore.Images.Media.DISPLAY_NAME, // 图片文件名
MediaStore.Images.Media.DATA // 图片绝对路径
// ,"count("+MediaStore.Images.Media._ID+")"//统计当前文件夹下共有多少张图片
};
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
try {

Cursor cursor = context.getContentResolver().query(uri,projection,null,null,null);
if(cursor!=null){
List<PictureInfo> list = new ArrayList<PictureInfo>();
while (cursor.moveToNext()){
PictureInfo item = new PictureInfo();
item.fileName = cursor.getString(4);
item.picName = cursor.getString(3);
item.dirName = cursor.getString(2);
if(BitmapUtils.isBigBitmap(item.fileName)){
list.add(item);
}
}
EventBus.getDefault().post(list);
}else{
EventBus.getDefault().post(new AsyncErrorInfo(2,"parse error"));
}
} catch (Exception e) {
e.printStackTrace();
EventBus.getDefault().post(new AsyncErrorInfo(1,"db query error"));
}
}
});
}
}
Loading

0 comments on commit 4251b28

Please sign in to comment.