-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cea7ad
commit fd63b8d
Showing
59 changed files
with
2,922 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/build | ||
/captures | ||
.externalNativeBuild | ||
app/libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
app/src/main/java/com/thirtydegreesray/openhub/ActivitiesManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
69
app/src/main/java/com/thirtydegreesray/openhub/AppApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
app/src/main/java/com/thirtydegreesray/openhub/common/AppEventBus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
52
app/src/main/java/com/thirtydegreesray/openhub/common/Event.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.