forked from getActivity/AndroidProject
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
108 changed files
with
4,362 additions
and
4,137 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
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
Binary file not shown.
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
260 changes: 128 additions & 132 deletions
260
...a/com/hjq/demo/common/CommonActivity.java → ...in/java/com/hjq/demo/base/MyActivity.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 |
---|---|---|
@@ -1,133 +1,129 @@ | ||
package com.hjq.demo.common; | ||
|
||
import android.content.pm.ActivityInfo; | ||
import android.view.View; | ||
|
||
import com.hjq.bar.OnTitleBarListener; | ||
import com.hjq.bar.TitleBar; | ||
import com.hjq.toast.ToastUtils; | ||
import com.umeng.analytics.MobclickAgent; | ||
|
||
import butterknife.ButterKnife; | ||
import butterknife.Unbinder; | ||
|
||
/** | ||
* author : HJQ | ||
* github : https://github.com/getActivity/AndroidProject | ||
* time : 2018/10/18 | ||
* desc : 项目中的Activity基类 | ||
*/ | ||
public abstract class CommonActivity extends UIActivity | ||
implements OnTitleBarListener { | ||
|
||
private Unbinder mButterKnife;//View注解 | ||
|
||
@Override | ||
public void init() { | ||
|
||
//初始化标题栏的监听 | ||
if (getTitleBarId() > 0) { | ||
if (findViewById(getTitleBarId()) instanceof TitleBar) { | ||
((TitleBar) findViewById(getTitleBarId())).setOnTitleBarListener(this); | ||
} | ||
} | ||
|
||
mButterKnife = ButterKnife.bind(this); | ||
|
||
initOrientation(); | ||
|
||
super.init(); | ||
} | ||
|
||
/** | ||
* 初始化横竖屏方向,会和 LauncherTheme 主题样式有冲突,注意不要同时使用 | ||
*/ | ||
protected void initOrientation() { | ||
//如果没有指定屏幕方向,则默认为竖屏 | ||
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { | ||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
} | ||
} | ||
|
||
/** | ||
* 设置标题栏的标题 | ||
*/ | ||
@Override | ||
public void setTitle(int titleId) { | ||
setTitle(getText(titleId)); | ||
} | ||
|
||
/** | ||
* 设置标题栏的标题 | ||
*/ | ||
@Override | ||
public void setTitle(CharSequence title) { | ||
super.setTitle(title); | ||
TitleBar titleBar = getTitleBar(); | ||
if (titleBar != null) { | ||
titleBar.setTitle(title); | ||
} | ||
} | ||
|
||
protected TitleBar getTitleBar() { | ||
if (getTitleBarId() > 0 && findViewById(getTitleBarId()) instanceof TitleBar) { | ||
return findViewById(getTitleBarId()); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean statusBarDarkFont() { | ||
//返回true表示黑色字体 | ||
return true; | ||
} | ||
|
||
/** | ||
* {@link OnTitleBarListener} | ||
*/ | ||
|
||
// 标题栏左边的View被点击了 | ||
@Override | ||
public void onLeftClick(View v) { | ||
onBackPressed(); | ||
} | ||
|
||
// 标题栏中间的View被点击了 | ||
@Override | ||
public void onTitleClick(View v) {} | ||
|
||
// 标题栏右边的View被点击了 | ||
@Override | ||
public void onRightClick(View v) {} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
// 手动统计页面 | ||
MobclickAgent.onPageStart(getClass().getSimpleName()); | ||
// 友盟统计 | ||
MobclickAgent.onResume(this); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
// 手动统计页面,必须保证 onPageEnd 在 onPause 之前调用,因为SDK会在 onPause 中保存onPageEnd统计到的页面数据 | ||
MobclickAgent.onPageEnd(getClass().getSimpleName()); | ||
// 友盟统计 | ||
MobclickAgent.onPause(this); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
if (mButterKnife != null) mButterKnife.unbind(); | ||
} | ||
|
||
/** | ||
* 显示一个吐司 | ||
*/ | ||
public void toast(CharSequence s) { | ||
ToastUtils.show(s); | ||
} | ||
package com.hjq.demo.base; | ||
|
||
import android.content.pm.ActivityInfo; | ||
import android.view.View; | ||
|
||
import com.hjq.bar.OnTitleBarListener; | ||
import com.hjq.bar.TitleBar; | ||
import com.hjq.toast.ToastUtils; | ||
import com.hjq.umeng.UmengHelper; | ||
|
||
import butterknife.ButterKnife; | ||
import butterknife.Unbinder; | ||
|
||
/** | ||
* author : HJQ | ||
* github : https://github.com/getActivity/AndroidProject | ||
* time : 2018/10/18 | ||
* desc : 项目中的Activity基类 | ||
*/ | ||
public abstract class MyActivity extends UIActivity | ||
implements OnTitleBarListener { | ||
|
||
private Unbinder mButterKnife;//View注解 | ||
|
||
@Override | ||
public void init() { | ||
|
||
//初始化标题栏的监听 | ||
if (getTitleBarId() > 0) { | ||
if (findViewById(getTitleBarId()) instanceof TitleBar) { | ||
((TitleBar) findViewById(getTitleBarId())).setOnTitleBarListener(this); | ||
} | ||
} | ||
|
||
mButterKnife = ButterKnife.bind(this); | ||
|
||
initOrientation(); | ||
|
||
super.init(); | ||
} | ||
|
||
/** | ||
* 初始化横竖屏方向,会和 LauncherTheme 主题样式有冲突,注意不要同时使用 | ||
*/ | ||
protected void initOrientation() { | ||
//如果没有指定屏幕方向,则默认为竖屏 | ||
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { | ||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
} | ||
} | ||
|
||
/** | ||
* 设置标题栏的标题 | ||
*/ | ||
@Override | ||
public void setTitle(int titleId) { | ||
setTitle(getText(titleId)); | ||
} | ||
|
||
/** | ||
* 设置标题栏的标题 | ||
*/ | ||
@Override | ||
public void setTitle(CharSequence title) { | ||
super.setTitle(title); | ||
TitleBar titleBar = getTitleBar(); | ||
if (titleBar != null) { | ||
titleBar.setTitle(title); | ||
} | ||
} | ||
|
||
protected TitleBar getTitleBar() { | ||
if (getTitleBarId() > 0 && findViewById(getTitleBarId()) instanceof TitleBar) { | ||
return findViewById(getTitleBarId()); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean statusBarDarkFont() { | ||
//返回true表示黑色字体 | ||
return true; | ||
} | ||
|
||
/** | ||
* {@link OnTitleBarListener} | ||
*/ | ||
|
||
// 标题栏左边的View被点击了 | ||
@Override | ||
public void onLeftClick(View v) { | ||
onBackPressed(); | ||
} | ||
|
||
// 标题栏中间的View被点击了 | ||
@Override | ||
public void onTitleClick(View v) {} | ||
|
||
// 标题栏右边的View被点击了 | ||
@Override | ||
public void onRightClick(View v) {} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
// 友盟统计 | ||
UmengHelper.onResume(this); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
// 友盟统计 | ||
UmengHelper.onPause(this); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
if (mButterKnife != null) mButterKnife.unbind(); | ||
} | ||
|
||
/** | ||
* 显示一个吐司 | ||
*/ | ||
public void toast(CharSequence s) { | ||
ToastUtils.show(s); | ||
} | ||
} |
Oops, something went wrong.