Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_xunmi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_xunmi
Commits
21e3c4c4
Commit
21e3c4c4
authored
Aug 10, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
2ba70ad5
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
247 additions
and
316 deletions
+247
-316
BaseAppCompatActivity.java
...in/java/com/mints/library/base/BaseAppCompatActivity.java
+90
-90
BaseAppFragment.java
...src/main/java/com/mints/library/base/BaseAppFragment.java
+78
-78
BaseWebActivity.java
...src/main/java/com/mints/library/base/BaseWebActivity.java
+14
-14
MintsApplication.java
...n/app/src/main/java/com/mints/xunmi/MintsApplication.java
+1
-1
JpushLoginManager.java
.../main/java/com/mints/xunmi/manager/JpushLoginManager.java
+9
-9
PositionManager.java
...rc/main/java/com/mints/xunmi/manager/PositionManager.java
+0
-67
BaseActivity.java
.../java/com/mints/xunmi/ui/activitys/base/BaseActivity.java
+43
-43
MainFragment.kt
...src/main/java/com/mints/xunmi/ui/fragment/MainFragment.kt
+3
-3
MyFragment.kt
...p/src/main/java/com/mints/xunmi/ui/fragment/MyFragment.kt
+4
-4
BaseFragment.java
...n/java/com/mints/xunmi/ui/fragment/base/BaseFragment.java
+4
-4
activity_aboutus.xml
position/app/src/main/res/layout/activity_aboutus.xml
+1
-1
fragment_main_my.xml
position/app/src/main/res/layout/fragment_main_my.xml
+0
-2
No files found.
position/app/src/main/java/com/mints/library/base/BaseAppCompatActivity.java
View file @
21e3c4c4
This diff is collapsed.
Click to expand it.
position/app/src/main/java/com/mints/library/base/BaseAppFragment.java
View file @
21e3c4c4
...
...
@@ -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
;
}
...
...
position/app/src/main/java/com/mints/library/base/BaseWebActivity.java
View file @
21e3c4c4
...
...
@@ -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
()
{
...
...
position/app/src/main/java/com/mints/xunmi/MintsApplication.java
View file @
21e3c4c4
...
...
@@ -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
,
"5f2
78cd2d309322154744c91
"
,
CommonUtils
.
getAppMetaData
(
context
,
"CHANNEL_NAME"
),
UMConfigure
.
DEVICE_TYPE_PHONE
,
""
);
UMConfigure
.
init
(
context
,
"5f2
f75acb4b08b653e9261ee
"
,
CommonUtils
.
getAppMetaData
(
context
,
"CHANNEL_NAME"
),
UMConfigure
.
DEVICE_TYPE_PHONE
,
""
);
}
/**
...
...
position/app/src/main/java/com/mints/xunmi/manager/JpushLoginManager.java
View file @
21e3c4c4
...
...
@@ -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
()
{
...
...
position/app/src/main/java/com/mints/xunmi/manager/PositionManager.java
deleted
100755 → 0
View file @
2ba70ad5
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
)
{
}
}
position/app/src/main/java/com/mints/xunmi/ui/activitys/base/BaseActivity.java
View file @
21e3c4c4
...
...
@@ -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
()
{
...
...
position/app/src/main/java/com/mints/xunmi/ui/fragment/MainFragment.kt
View file @
21e3c4c4
...
...
@@ -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
()
{
...
...
position/app/src/main/java/com/mints/xunmi/ui/fragment/MyFragment.kt
View file @
21e3c4c4
...
...
@@ -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}"
}
...
...
position/app/src/main/java/com/mints/xunmi/ui/fragment/base/BaseFragment.java
View file @
21e3c4c4
...
...
@@ -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)
...
...
position/app/src/main/res/layout/activity_aboutus.xml
View file @
21e3c4c4
...
...
@@ -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>
...
...
position/app/src/main/res/layout/fragment_main_my.xml
View file @
21e3c4c4
...
...
@@ -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"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment