Skip to content

Commit

Permalink
Initial framework
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirtyDegreesRay committed Jul 12, 2017
1 parent 5cea7ad commit fd63b8d
Show file tree
Hide file tree
Showing 59 changed files with 2,922 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/build
/captures
.externalNativeBuild
app/libs/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OpenHub
OpenHub is an android client for GitHub.
An android client for GitHub.

## License
Copyright 2017 ThirtyDegreesRay
Expand Down
58 changes: 49 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
applicationId "com.thirtydegreesray.openhub"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode VERSION_CODE as int
versionName VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -24,8 +25,47 @@ 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:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

compile "com.android.support:appcompat-v7:${ANDROID_SUPPORT_VERSION}"
compile "com.android.support:recyclerview-v7:${ANDROID_SUPPORT_VERSION}"
compile "com.android.support:design:${ANDROID_SUPPORT_VERSION}"
compile "com.android.support.constraint:constraint-layout:${CONSTRAINT_VERSION}"

testCompile 'junit:junit:4.12'

compile "com.thirtydegreesray:dataautoaccess:${DATAAUTOACCESS_VERSION}"
apt "com.thirtydegreesray:dataautoaccess-compiler:${DATAAUTOACCESS_VERSION}"

compile "com.jakewharton:butterknife:${BUTTERKNIFE_VERSION}"
apt "com.jakewharton:butterknife-compiler:${BUTTERKNIFE_VERSION}"

compile "com.yanzhenjie:andserver:${ANDSERVER_VERSION}"

//数据库工具
compile "org.greenrobot:greendao:${GREEN_DAO_VERSION}"
//事件总线
compile "org.greenrobot:eventbus:${EVENT_BUS_VERSION}"
//文件下载
compile "com.liulishuo.filedownloader:library:${FILE_DOWNLOADER_VERSION}"
//日志
compile "com.orhanobut:logger:${LOGGER_VERSION}"

//RxJava
compile "io.reactivex:rxjava:${RXJAVA_VERSION}"
compile "io.reactivex:rxandroid:${RXJAVA_VERSION}"

//Type-safe HTTP client for Android and Java by Square, Inc.
compile "com.squareup.retrofit2:retrofit:${RETROFIT_VERSION}"
compile "com.squareup.retrofit2:converter-gson:${RETROFIT_VERSION}"
compile "com.squareup.retrofit2:adapter-rxjava:${RETROFIT_VERSION}"

//dagger依赖注入
compile "com.google.dagger:dagger:${DAGGER_VERSION}"
apt "com.google.dagger:dagger-compiler:${DAGGER_VERSION}"

//Android6.0以上权限获取工具
//PermissionsDispatcher provides a simple annotation-based API to handle runtime permissions in Android Marshmallow.
// androidApt: 'com.neenbedankt.gradle.plugins:android-apt:1.8',
compile "com.github.hotchemi:permissionsdispatcher:${PERMISSIONS_DISPATCHER_VERSION}"
apt "com.github.hotchemi:permissionsdispatcher-processor:${PERMISSIONS_DISPATCHER_VERSION}"
}
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

<application
android:allowBackup="true"
android:icon="@mipmap/logo"
android:icon="@mipmap/logo_white"
android:label="@string/app_name"
android:roundIcon="@mipmap/logo"
android:roundIcon="@mipmap/logo_white"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:name=".ui.activity.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2017 ThirtyDegressRay
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.thirtydegreesray.openhub;

import android.app.Activity;

import com.thirtydegreesray.openhub.ui.activity.base.BaseActivity;

import java.util.ArrayList;

/**
* activity管理
* Created on 2016/10/9.
*
* @author YuYunhao
*/

public class ActivitiesManager {

private static class SingletonHolder{
private static ActivitiesManager instance = new ActivitiesManager();
}

private ActivitiesManager(){
activities = new ArrayList<>();
}

public static ActivitiesManager getInstance(){
return SingletonHolder.instance;
}

private ArrayList<BaseActivity> activities;

public void addActivity(BaseActivity activity){
activities.add(activity);
}

public void removeActivity(BaseActivity activity){
activities.remove(activity);
}

public void clearActivity(){
for(Activity activity : activities){
if(activity != null && !activity.isFinishing()){
activity.finish();
}
}
activities.clear();
}


public void finishActivity(Activity activity, int layerNum, boolean refreshPage){
for (int i = activities.size() - 1, j = 0; i >= 0; i--) {
if(activity.equals(activities.get(i)) || ( j > 0 && j < layerNum )){
activities.get(i).finish();
j++;
}else if( j >= layerNum ){
if(refreshPage){
activities.get(i).onRefreshWebPage();
}
return ;
}
}
}

public void exitApp(){
clearActivity();
System.exit(0);
}

}
69 changes: 69 additions & 0 deletions app/src/main/java/com/thirtydegreesray/openhub/AppApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2017 ThirtyDegressRay
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.thirtydegreesray.openhub;

import android.app.Application;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.thirtydegreesray.openhub.inject.component.AppComponent;
import com.thirtydegreesray.openhub.inject.component.DaggerAppComponent;
import com.thirtydegreesray.openhub.inject.module.AppModule;
import com.thirtydegreesray.openhub.util.NetHelper;

/**
* AppApplication
* Created by YuYunHao on 2016/7/13 14:01
*/
public class AppApplication extends Application {

private final String TAG = "AppApplication";

private AppComponent mAppComponent;

private static AppApplication application;

@Override
public void onCreate() {
super.onCreate();
application = this;
//init application
mAppComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
initLogger();
NetHelper.getInstance().init(this);

}

public static AppApplication get(){
return application;
}

public AppComponent getAppComponent(){
return mAppComponent;
}

private void initLogger() {
Logger.init("APP") // default PRETTYLOGGER or use just init()
.methodCount(2) // default 2
.hideThreadInfo() // default shown
.logLevel(LogLevel.FULL) // default LogLevel.FULL
.methodOffset(0); // default 0
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2017 ThirtyDegressRay
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.thirtydegreesray.openhub.common;

import org.greenrobot.eventbus.EventBus;

/**
* 事件总线
* Created by YuYunHao on 2016/8/22 14:55
*/

public class AppEventBus {

private AppEventBus(){
init();
}

public static class SingletonHolder{
private final static AppEventBus instance = new AppEventBus();
}

public static AppEventBus getInstance(){
return SingletonHolder.instance;
}

private EventBus eventBus ;

private void init(){
eventBus = EventBus.builder()
.installDefaultEventBus();
}

public EventBus getEventBus() {
return eventBus;
}
}
52 changes: 52 additions & 0 deletions app/src/main/java/com/thirtydegreesray/openhub/common/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2017 ThirtyDegressRay
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.thirtydegreesray.openhub.common;

/**
* 事件
* Created by YuYunHao on 2016/8/22 14:32
*/

public class Event {

/**
* 网络状态改变事件
*/
public static class NetChangedEvent{
public int preNetStatus;
public int curNetStatus;
public NetChangedEvent(int preNetStatus, int curNetStatus){
this.preNetStatus = preNetStatus;
this.curNetStatus = curNetStatus;
}
}

public static class ServerStatusChangedEvent{
public final static int SERVER_START = 0;

public final static int SERVER_STOP = 1;

public final static int SERVER_STARTED = 2;

public int serverStatus;

public ServerStatusChangedEvent(int serverStatus) {
this.serverStatus = serverStatus;
}
}

}
Loading

0 comments on commit fd63b8d

Please sign in to comment.