Skip to content

Commit

Permalink
位置信息容错;懒加载。发版3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
woxingxiao committed Jan 12, 2019
1 parent f900078 commit 126c27f
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 13 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

## 更新日志
### 最新:
### 3.0.0 (Build 57)
彻底重构,采用`arch` + `DataBinding`为核心的`MVVM`架构
功能精简,保留了最核心的功能
### 3.1.0 (Build 58)
移除右滑返回库,提高兼容和稳定性
数据优化,定位优化,大量代码优化

### 更新历史:
[**UpdateLog**](https://github.com/woxingxiao/GracefulMovies/blob/master/UpdateLog.md)  
Expand All @@ -35,7 +35,6 @@
1. [Glide](https://github.com/bumptech/glide)
1. [AndPermission](https://github.com/yanzhenjie/AndPermission)
1. [SimpleRatingBar](https://github.com/FlyingPumba/SimpleRatingBar)
1. [SlideBack](https://github.com/oubowu/SlideBack)
1. [LoggingInterceptor](https://github.com/ihsanbal/LoggingInterceptor)
1. [DiscreteScrollView](https://github.com/yarolegovich/DiscreteScrollView)
1. [PhotoView](https://github.com/chrisbanes/PhotoView)
Expand Down
4 changes: 4 additions & 0 deletions UpdateLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.1.0 (Build 58)
移除右滑返回库,提高兼容和稳定性;
数据优化,定位优化,大量代码优化。

### 3.0.0 (Build 57)
彻底重构,采用`arch` + `DataBinding`为核心的`MVVM`架构;
功能精简,保留了最核心的功能。
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ dependencies {
exclude group: 'org.androidannotations'
}
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.xw.repo:bubbleseekbar:3.8@aar'
implementation 'com.github.woxingxiao:VectorCompatTextView:2.5'
implementation 'com.github.woxingxiao:BounceScrollView:1.3'
implementation('com.yarolegovich:discrete-scrollview:1.3.0') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public static class ReGeo {
////////////////////////////////////////////////////////////////////////////////////////////////
public static class ReGeoInfo {
public String province;
public String city;
public Object city;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ public void onLocationChanged(Location location) {
public void onNext(ReGeoResult.ReGeoInfo info) {
String cityName;
CityRepository repository = GMApplication.getInstance().getCityRepository();
if (TextUtils.isEmpty(info.city) && TextUtils.isEmpty(info.province)) {
if (info.city == null && TextUtils.isEmpty(info.province)) {
cityName = repository.genDefaultCity().getName();
} else if (TextUtils.isEmpty(info.city)) {
} else if (info.city instanceof ArrayList) {
cityName = Util.trimCity(info.province);
} else {
cityName = Util.trimCity(info.city);
cityName = Util.trimCity(info.city.toString());
}

CityEntity preCity = repository.getCityEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment
protected FragmentActivity mActivity;
protected VDB mBinding;
private StatusView mStatusView;
private boolean isVisibleToUser;
private boolean isViewPrepared;
private boolean isDataHasLoaded;

@Override
public void onAttach(Context context) {
Expand All @@ -64,11 +67,51 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
return mBinding.getRoot();
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

isViewPrepared = true;
lazyLoad();
}

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);

this.isVisibleToUser = isVisibleToUser;
lazyLoad();
}

private void lazyLoad() {
if (!isDataHasLoaded && isViewPrepared && isVisibleToUser) {
isDataHasLoaded = true;
onLazyLoad();
}
}

protected void onLazyLoad() {
}

@LayoutRes
protected abstract int viewLayoutRes();

protected abstract void afterInflateView();

@Override
public void onDestroy() {
isDataHasLoaded = false;
isViewPrepared = false;
super.onDestroy();
}

@Override
public void onDestroyView() {
isDataHasLoaded = false;
isViewPrepared = false;
super.onDestroyView();
}

public static Fragment newInstance(@NonNull Class<? extends Fragment> cls) {
try {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ protected void afterInflateView() {
}
}
});
GMApplication.getInstance().getCityRepository().getCity().observe(this, mMovieViewModel::setCity);
GMApplication.getInstance().getCityRepository().getCity()
.observe(getViewLifecycleOwner(), mMovieViewModel::setCity);
}

@Override
protected void onLazyLoad() {
mMovieViewModel.load();
}

Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/item_box_office.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@
android:layout_marginStart="@dimen/dp_72"
android:padding="@dimen/dp_8">

<android.support.v7.widget.AppCompatTextView
<TextView
android:id="@+id/bo_name_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@{model.movieName}"
android:textColor="@android:color/white"
android:textSize="@dimen/sp_18"
app:autoSizeMaxTextSize="@dimen/sp_18"
app:autoSizeTextType="uniform"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/app_name"/>
Expand Down

0 comments on commit 126c27f

Please sign in to comment.