Commit 21e3c4c4 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 2ba70ad5
......@@ -32,24 +32,24 @@ import butterknife.ButterKnife;
*/
public abstract class BaseAppFragment extends TransitionFragment {
/**
* Log tag
*/
protected static String TAG_LOG = null;
/**
* Screen information
*/
protected int mScreenWidth = 0;
protected int mScreenHeight = 0;
protected float mScreenDensity = 0.0f;
// /**
// * Log tag
// */
// protected static String TAG_LOG = null;
//
// /**
// * Screen information
// */
// protected int mScreenWidth = 0;
// protected int mScreenHeight = 0;
// protected float mScreenDensity = 0.0f;
/**
* context
*/
protected Context mContext = null;
private VaryViewHelperController mVaryViewHelperController = null;
// private VaryViewHelperController mVaryViewHelperController = null;
@Override
public void onAttach(Activity activity) {
......@@ -62,7 +62,7 @@ public abstract class BaseAppFragment extends TransitionFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TAG_LOG = this.getClass().getSimpleName();
// TAG_LOG = this.getClass().getSimpleName();
}
@Override
......@@ -84,18 +84,18 @@ public abstract class BaseAppFragment extends TransitionFragment {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
if (null != getLoadingTargetView()) {
mVaryViewHelperController = new VaryViewHelperController(getLoadingTargetView());
}
// if (null != getLoadingTargetView()) {
// mVaryViewHelperController = new VaryViewHelperController(getLoadingTargetView());
// }
DisplayMetrics displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// DisplayMetrics displayMetrics = new DisplayMetrics();
// getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
RudenessScreenHelper.resetDensity(getActivity(), AppConfig.design_width);
mScreenDensity = displayMetrics.density;
mScreenHeight = displayMetrics.heightPixels;
mScreenWidth = displayMetrics.widthPixels;
// mScreenDensity = displayMetrics.density;
// mScreenHeight = displayMetrics.heightPixels;
// mScreenWidth = displayMetrics.widthPixels;
initViewsAndEvents();
}
......@@ -130,7 +130,7 @@ public abstract class BaseAppFragment extends TransitionFragment {
/**
* get loading target view
*/
protected abstract View getLoadingTargetView();
// protected abstract View getLoadingTargetView();
/**
* init all views and add events
......@@ -219,34 +219,34 @@ public abstract class BaseAppFragment extends TransitionFragment {
*
* @param toggle
*/
protected void toggleShowLoading(boolean toggle, String msg) {
if (null == mVaryViewHelperController) {
throw new IllegalArgumentException("You must return a right target view for loading");
}
if (toggle) {
mVaryViewHelperController.showLoading(msg);
} else {
mVaryViewHelperController.restore();
}
}
// protected void toggleShowLoading(boolean toggle, String msg) {
// if (null == mVaryViewHelperController) {
// throw new IllegalArgumentException("You must return a right target view for loading");
// }
//
// if (toggle) {
// mVaryViewHelperController.showLoading(msg);
// } else {
// mVaryViewHelperController.restore();
// }
// }
/**
* toggle show empty
*
* @param toggle
*/
protected void toggleShowEmpty(boolean toggle, String msg, View.OnClickListener onClickListener) {
if (null == mVaryViewHelperController) {
throw new IllegalArgumentException("You must return a right target view for loading");
}
if (toggle) {
mVaryViewHelperController.showEmpty(msg, R.mipmap.icon_empty, onClickListener);
} else {
mVaryViewHelperController.restore();
}
}
// protected void toggleShowEmpty(boolean toggle, String msg, View.OnClickListener onClickListener) {
// if (null == mVaryViewHelperController) {
// throw new IllegalArgumentException("You must return a right target view for loading");
// }
//
// if (toggle) {
// mVaryViewHelperController.showEmpty(msg, R.mipmap.icon_empty, onClickListener);
// } else {
// mVaryViewHelperController.restore();
// }
// }
/**
* toggle show empty
......@@ -256,52 +256,52 @@ public abstract class BaseAppFragment extends TransitionFragment {
* @param msg
* @param onClickListener
*/
protected void toggleShowEmpty(boolean toggle, int resId, String msg, View.OnClickListener onClickListener) {
if (null == mVaryViewHelperController) {
throw new IllegalArgumentException("You must return a right target view for loading");
}
if (resId == 0)
resId = R.mipmap.icon_empty;
if (toggle) {
mVaryViewHelperController.showEmpty(msg, resId, onClickListener);
} else {
mVaryViewHelperController.restore();
}
}
// protected void toggleShowEmpty(boolean toggle, int resId, String msg, View.OnClickListener onClickListener) {
// if (null == mVaryViewHelperController) {
// throw new IllegalArgumentException("You must return a right target view for loading");
// }
// if (resId == 0)
// resId = R.mipmap.icon_empty;
// if (toggle) {
// mVaryViewHelperController.showEmpty(msg, resId, onClickListener);
// } else {
// mVaryViewHelperController.restore();
// }
// }
/**
* toggle show error
*
* @param toggle
*/
protected void toggleShowError(boolean toggle, String msg, View.OnClickListener onClickListener) {
if (null == mVaryViewHelperController) {
throw new IllegalArgumentException("You must return a right target view for loading");
}
if (toggle) {
mVaryViewHelperController.showError(msg, onClickListener);
} else {
mVaryViewHelperController.restore();
}
}
// protected void toggleShowError(boolean toggle, String msg, View.OnClickListener onClickListener) {
// if (null == mVaryViewHelperController) {
// throw new IllegalArgumentException("You must return a right target view for loading");
// }
//
// if (toggle) {
// mVaryViewHelperController.showError(msg, onClickListener);
// } else {
// mVaryViewHelperController.restore();
// }
// }
/**
* toggle show network error
*
* @param toggle
*/
protected void toggleNetworkError(boolean toggle, View.OnClickListener onClickListener) {
if (null == mVaryViewHelperController) {
throw new IllegalArgumentException("You must return a right target view for loading");
}
if (toggle) {
mVaryViewHelperController.showNetworkError(onClickListener);
} else {
mVaryViewHelperController.restore();
}
}
// protected void toggleNetworkError(boolean toggle, View.OnClickListener onClickListener) {
// if (null == mVaryViewHelperController) {
// throw new IllegalArgumentException("You must return a right target view for loading");
// }
//
// if (toggle) {
// mVaryViewHelperController.showNetworkError(onClickListener);
// } else {
// mVaryViewHelperController.restore();
// }
// }
@Override
protected boolean toggleIsBack2Left() { return false; }
......
......@@ -62,10 +62,10 @@ public class BaseWebActivity extends BaseSwipeBackCompatActivity {
return R.layout.activity_common_web;
}
@Override
protected View getLoadingTargetView() {
return null;
}
// @Override
// protected View getLoadingTargetView() {
// return null;
// }
@Override
protected void initViewsAndEvents() {
......@@ -120,16 +120,16 @@ public class BaseWebActivity extends BaseSwipeBackCompatActivity {
}
}
@Override
protected void onNetworkConnected(NetUtils.NetType type) {
}
@Override
protected void onNetworkDisConnected() {
}
// @Override
// protected void onNetworkConnected(NetUtils.NetType type) {
//
// }
//
//
// @Override
// protected void onNetworkDisConnected() {
//
// }
@Override
protected boolean isApplyStatusBarTranslucency() {
......
......@@ -177,7 +177,7 @@ public class MintsApplication extends MultiDexApplication {
* 参数4:设备类型,必须参数,传参数为UMConfigure.DEVICE_TYPE_PHONE则表示手机;传参数为UMConfigure.DEVICE_TYPE_BOX则表示盒子;默认为手机。
* 参数5:Push推送业务的secret,需要集成Push功能时必须传入Push的secret,否则传空。
*/
UMConfigure.init(context, "5f278cd2d309322154744c91", CommonUtils.getAppMetaData(context, "CHANNEL_NAME"), UMConfigure.DEVICE_TYPE_PHONE, "");
UMConfigure.init(context, "5f2f75acb4b08b653e9261ee", CommonUtils.getAppMetaData(context, "CHANNEL_NAME"), UMConfigure.DEVICE_TYPE_PHONE, "");
}
/**
......
......@@ -69,15 +69,15 @@ public class JpushLoginManager implements LoginView {
}
public void userLogin() {
// if (MintsApplication.JpushLoginFlag) {
// // 支持
// jPushLogin();
// } else {
// // 不支持
// readyGo(LoginActivity.class);
// }
readyGo(LoginActivity.class);
if (MintsApplication.JpushLoginFlag) {
// 支持
jPushLogin();
} else {
// 不支持
readyGo(LoginActivity.class);
}
// readyGo(LoginActivity.class);
}
private void jPushLogin() {
......
package com.mints.xunmi.manager;
import android.content.Context;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.services.core.AMapException;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.RegeocodeQuery;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.mints.xunmi.MintsApplication;
public class PositionManager implements GeocodeSearch.OnGeocodeSearchListener {
private static PositionManager _inst;
private Context context;
private String addressName;
private GeocodeSearch geocoderSearch;
public static PositionManager getInstance() {
if (_inst != null) {
return _inst;
} else {
_inst = new PositionManager();
return _inst;
}
}
private PositionManager() {
init();
}
private void init() {
context = MintsApplication.getContext();
geocoderSearch = new GeocodeSearch(context);
geocoderSearch.setOnGeocodeSearchListener(this);
}
public void setPositionParam(double longitude,double latitude) {
LatLonPoint latLonPoint = new LatLonPoint(latitude, longitude);
RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200,
GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
geocoderSearch.getFromLocationAsyn(query);// 设置异步逆地理编码请求
}
public String getAddressName() {
return addressName;
}
@Override
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
if (rCode == AMapException.CODE_AMAP_SUCCESS) {
if (result != null && result.getRegeocodeAddress() != null
&& result.getRegeocodeAddress().getFormatAddress() != null) {
addressName = result.getRegeocodeAddress().getFormatAddress();
}
}
}
@Override
public void onGeocodeSearched(GeocodeResult geocodeResult, int i) {
}
}
......@@ -70,37 +70,37 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
return this;
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
View v = getCurrentFocus();
//如果不是落在EditText区域,则需要关闭输入法
if (HideKeyboard(v, ev)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
// FixUtils.fixInputMethodManagerLeak(this);
}
}
return super.dispatchTouchEvent(ev);
}
// 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
private boolean HideKeyboard(View view, MotionEvent event) {
if (view != null && (view instanceof EditText)) {
int[] location = {0, 0};
view.getLocationInWindow(location);
//获取现在拥有焦点的控件view的位置,即EditText
int left = location[0], top = location[1], bottom = top + view.getHeight(), right = left + view.getWidth();
//判断我们手指点击的区域是否落在EditText上面,如果不是,则返回true,否则返回false
boolean isInEt = (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom);
return !isInEt;
}
return false;
}
// @Override
// public boolean dispatchTouchEvent(MotionEvent ev) {
// if (ev.getAction() == MotionEvent.ACTION_UP) {
// View v = getCurrentFocus();
//
// //如果不是落在EditText区域,则需要关闭输入法
// if (HideKeyboard(v, ev)) {
// InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
//// FixUtils.fixInputMethodManagerLeak(this);
// }
// }
// return super.dispatchTouchEvent(ev);
//
// }
//
// // 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
// private boolean HideKeyboard(View view, MotionEvent event) {
// if (view != null && (view instanceof EditText)) {
//
// int[] location = {0, 0};
// view.getLocationInWindow(location);
//
// //获取现在拥有焦点的控件view的位置,即EditText
// int left = location[0], top = location[1], bottom = top + view.getHeight(), right = left + view.getWidth();
// //判断我们手指点击的区域是否落在EditText上面,如果不是,则返回true,否则返回false
// boolean isInEt = (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom);
// return !isInEt;
// }
// return false;
// }
@Override
protected void onDestroy() {
......@@ -111,10 +111,10 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
/**
* 如果需要在前台做断网判断则需要重写
*/
@Override
protected void onNetworkDisConnected() {
showToast(getString(R.string.netfail));
}
// @Override
// protected void onNetworkDisConnected() {
// showToast(getString(R.string.netfail));
// }
@Override
protected boolean isApplyStatusBarTranslucency() {
......@@ -125,15 +125,15 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
protected void getBundleExtras(Bundle extras) {
}
@Override
protected View getLoadingTargetView() {
return null;
}
@Override
protected void onNetworkConnected(NetUtils.NetType type) {
// @Override
// protected View getLoadingTargetView() {
// return null;
// }
}
// @Override
// protected void onNetworkConnected(NetUtils.NetType type) {
//
// }
@Override
protected boolean toggleOverridePendingTransition() {
......
......@@ -105,8 +105,8 @@ class MainFragment : BaseFragment()
} else {
getCares(null)
}
// ivMainCourse.visibility = View.VISIBLE
ivMainCourse.visibility = View.GONE
ivMainCourse.visibility = View.VISIBLE
// ivMainCourse.visibility = View.GONE
} else {
// 无会员
getCares(null)
......@@ -397,7 +397,7 @@ class MainFragment : BaseFragment()
}
/**
* 消息弹窗
* 五折弹窗
*/
private fun discountDialog() {
discountDialog = DiscountDialog(context, object : DialogListener() {
......
......@@ -99,8 +99,8 @@ class MyFragment : BaseFragment()
tvMyLogin.text = mobile
if (BuildConfig.DEBUG) {
// tvMyLoginText.text = "测试环境 唯一码:${idcode}"
tvMyLoginText.text = "唯一码:${idcode}"
tvMyLoginText.text = "测试环境 唯一码:${idcode}"
// tvMyLoginText.text = "唯一码:${idcode}"
} else {
tvMyLoginText.text = "唯一码:${idcode}"
}
......@@ -112,8 +112,8 @@ class MyFragment : BaseFragment()
tvMyLockText.text = "解锁使用更多功能"
if (BuildConfig.DEBUG) {
// tvMyLoginText.text = "测试环境 唯一码:${idcode}"
tvMyLoginText.text = "唯一码:${idcode}"
tvMyLoginText.text = "测试环境 唯一码:${idcode}"
// tvMyLoginText.text = "唯一码:${idcode}"
} else {
tvMyLoginText.text = "唯一码:${idcode}"
}
......
......@@ -43,10 +43,10 @@ public abstract class BaseFragment extends BaseAppFragment {
return getActivity();
}
@Override
protected View getLoadingTargetView() {
return null;
}
// @Override
// protected View getLoadingTargetView() {
// return null;
// }
/**
* 显示加载进度条(自定义message)
......
......@@ -102,7 +102,7 @@
android:layout_marginLeft="60pt"
android:layout_marginRight="60pt"
android:gravity="center"
android:text="Copyright © 2019 北京明策智数科技有限公司 Inc.."
android:text="Copyright © 2019 Inc.."
android:textColor="@color/text_font"
android:textSize="12sp" />
</LinearLayout>
......
......@@ -253,7 +253,6 @@
android:layout_width="match_parent"
android:layout_height="96pt"
android:layout_marginTop="6pt"
android:visibility="gone"
android:paddingLeft="30pt"
android:paddingRight="30pt">
......@@ -279,7 +278,6 @@
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:visibility="gone"
android:layout_marginLeft="100pt"
android:background="#E1E1E1" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment