|
@@ -4,6 +4,9 @@ import android.app.Activity;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.pm.ActivityInfo;
|
|
import android.content.pm.ActivityInfo;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.util.TypedValue;
|
|
|
|
|
+import android.view.Window;
|
|
|
|
|
+import android.view.WindowManager;
|
|
|
|
|
|
|
|
import com.android.volley.Request;
|
|
import com.android.volley.Request;
|
|
|
import com.android.volley.RetryPolicy;
|
|
import com.android.volley.RetryPolicy;
|
|
@@ -16,6 +19,8 @@ import com.xzjmyk.pm.activity.util.PreferenceUtils;
|
|
|
import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
import com.xzjmyk.pm.activity.volley.FastVolley;
|
|
import com.xzjmyk.pm.activity.volley.FastVolley;
|
|
|
|
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 带网络请求的Activity继承
|
|
* 带网络请求的Activity继承
|
|
|
*
|
|
*
|
|
@@ -28,8 +33,11 @@ public abstract class BaseActivity extends ActionBackActivity {
|
|
|
public CustomProgressDialog progressDialog;
|
|
public CustomProgressDialog progressDialog;
|
|
|
public Context ct;
|
|
public Context ct;
|
|
|
public Activity activity;
|
|
public Activity activity;
|
|
|
-
|
|
|
|
|
- public void preOnCreacte(){};
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public void preOnCreacte() {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
|
|
|
|
|
public BaseActivity() {
|
|
public BaseActivity() {
|
|
|
super();
|
|
super();
|
|
@@ -51,13 +59,53 @@ public abstract class BaseActivity extends ActionBackActivity {
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
+ if (android.os.Build.VERSION.SDK_INT > 108) {
|
|
|
|
|
+ Window window = getWindow();
|
|
|
|
|
+ window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
|
|
|
|
|
+ WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
|
|
|
|
+ window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
|
|
|
|
|
+ WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
|
|
|
|
+ //设置根布局的内边距
|
|
|
|
|
+// RelativeLayout relativeLayout = (RelativeLayout)
|
|
|
|
|
+// findViewById(R.id.layout);
|
|
|
|
|
+// relativeLayout.setPadding(0, getActionBarHeight() + getStatusBarHeight(), 0,
|
|
|
|
|
+// 0);
|
|
|
|
|
+ }
|
|
|
preOnCreacte();
|
|
preOnCreacte();
|
|
|
- ct=this;
|
|
|
|
|
- activity=this;
|
|
|
|
|
|
|
+ ct = this;
|
|
|
|
|
+ activity = this;
|
|
|
setNotTouchEvent(true);
|
|
setNotTouchEvent(true);
|
|
|
mFastVolley = MyApplication.getInstance().getFastVolley();
|
|
mFastVolley = MyApplication.getInstance().getFastVolley();
|
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
|
|
|
- progressDialog= CustomProgressDialog.createDialog(this);
|
|
|
|
|
|
|
+ progressDialog = CustomProgressDialog.createDialog(this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int getStatusBarHeight() {
|
|
|
|
|
+ Class c = null;
|
|
|
|
|
+ Object obj = null;
|
|
|
|
|
+ Field field = null;
|
|
|
|
|
+ int x = 0, statusBarHeight = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ c = Class.forName("com.android.internal.R$dimen");
|
|
|
|
|
+ obj = c.newInstance();
|
|
|
|
|
+ field = c.getField("status_bar_height");
|
|
|
|
|
+ x = Integer.parseInt(field.get(obj).toString());
|
|
|
|
|
+ statusBarHeight = getResources().getDimensionPixelSize(x);
|
|
|
|
|
+ } catch (Exception e1) {
|
|
|
|
|
+ e1.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return statusBarHeight;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取ActionBar的高度
|
|
|
|
|
+ public int getActionBarHeight() {
|
|
|
|
|
+ TypedValue tv = new TypedValue();
|
|
|
|
|
+ int actionBarHeight = 0;
|
|
|
|
|
+ if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))// 如果资源是存在的、有效的
|
|
|
|
|
+ {
|
|
|
|
|
+ actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
|
|
|
|
|
+ }
|
|
|
|
|
+ return actionBarHeight;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void setTouch(boolean b) {
|
|
public void setTouch(boolean b) {
|