市一级设置地区选择
This commit is contained in:
parent
aaac1c8e18
commit
fbcd9c7b9f
@ -52,8 +52,9 @@ public class BaseMyApplication extends Application {
|
||||
}
|
||||
|
||||
private void getConfigCityCode() {
|
||||
UserLgUtils.setCityCode(this.getResources().getString(R.string.CITY_CODE));
|
||||
UserLgUtils.setCityId(this.getResources().getString(R.string.CITY_ID));
|
||||
UserLgUtils.setCurrentCityCode(this.getResources().getString(R.string.CITY_CODE));
|
||||
UserLgUtils.setCurrentCity(this.getResources().getString(R.string.CITY_NAME));
|
||||
UserLgUtils.setCurrentCityId(this.getResources().getString(R.string.CITY_ID));
|
||||
}
|
||||
|
||||
private void initShare() {
|
||||
|
@ -53,7 +53,7 @@ public class BaseUrlApi {
|
||||
public static final String BASE_ACTIVIY_IP = BASE_SYSTEM_IP;/* 活动URL */
|
||||
public static final String BASE_PLACE_IP = BASE_SYSTEM_IP;/* 场馆 */
|
||||
public static final String BASE_VOLUNTEER_IP = BASE_SYSTEM_IP;/* 志愿者 */
|
||||
public static final String BASE_LIVE_IP = BASE_SYSTEM_IP + "live/";
|
||||
public static final String BASE_LIVE_IP = IP_URL + "live/";
|
||||
public static final String BASE_LIVE_URL = BASE_SYSTEM_IP;//直播回放视频url
|
||||
public static final String BASE_CULTURAL_SHARE = BASE_SYSTEM_IP;/* 文化分享 */
|
||||
public static final String BASE_LEGACY_IP = BASE_SYSTEM_IP;//非遗数据库
|
||||
|
@ -24,7 +24,7 @@ public class AreaInterceptor implements Interceptor {
|
||||
public okhttp3.Response intercept(Chain chain) throws IOException {
|
||||
Request originalRequest = chain.request();
|
||||
Request request;
|
||||
String areaCode = UserLgUtils.getCityCode();
|
||||
String areaCode = UserLgUtils.getCurrentCityCode();
|
||||
//判断是否需要添加
|
||||
List<String> baseUrlName = originalRequest.headers("need_area");
|
||||
if (baseUrlName.size() > 0) {
|
||||
|
@ -64,6 +64,33 @@ public class UserLgUtils {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("email");
|
||||
}
|
||||
|
||||
//===============地理信息=====================
|
||||
|
||||
public static void setCurrentCity(String city) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("currentCity", city);
|
||||
}
|
||||
|
||||
public static String getCurrentCity() {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("currentCity");
|
||||
}
|
||||
|
||||
public static String getCurrentCityCode() {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("currentCityCode");
|
||||
}
|
||||
|
||||
public static void setCurrentCityCode(String code) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("currentCityCode", code);
|
||||
}
|
||||
|
||||
public static void setCurrentCityId(String city) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("currentCityId", city);
|
||||
}
|
||||
|
||||
public static String getCurrentCityId() {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("currentCityId");
|
||||
}
|
||||
|
||||
|
||||
//==============================
|
||||
public static void setLoginInfo(String userInfo) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("userInfos", userInfo);
|
||||
@ -146,21 +173,6 @@ public class UserLgUtils {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("city");
|
||||
}
|
||||
|
||||
public static void setCurrentCity(String city) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("currentCity", city);
|
||||
}
|
||||
|
||||
public static String getCurrentCity() {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("currentCity");
|
||||
}
|
||||
|
||||
public static String getCurrentCityCode() {
|
||||
return SPUtils.getInstance(SP_USER_INFO).getString("currentCityCode");
|
||||
}
|
||||
|
||||
public static void setCurrentCityCode(String code) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("currentCityCode", code);
|
||||
}
|
||||
|
||||
public static void setLocationAddress(String address) {
|
||||
SPUtils.getInstance(SP_USER_INFO).put("address", address);
|
||||
|
@ -10,6 +10,7 @@ project.ext {
|
||||
dimension 'market'
|
||||
resValue("string", "CITY_CODE", "540200000000")
|
||||
resValue("string", "CITY_ID", "640675")
|
||||
resValue("string", "CITY_NAME", "日喀则市")
|
||||
manifestPlaceholders = [CHANNEL_VALUE: "cultural",
|
||||
APP_LOGO : "@drawable/app_logo",
|
||||
CITY_ID : "640675",
|
||||
|
@ -232,17 +232,16 @@ public class ChooseCityActivity extends BaseActivity {
|
||||
}
|
||||
mArea4Adapter.notifyDataSetChanged();
|
||||
}
|
||||
mCurrentCityCode =UserLgUtils.getCurrentCityCode();
|
||||
mCurrentCityCode = UserLgUtils.getCurrentCityId();
|
||||
mCurrentCityId = UserLgUtils.getCurrentCityCode();
|
||||
mCurrentCityName = PathConfig.CITY_DEFAULT_NAME;
|
||||
UserLgUtils.setCityLevel(2);
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(UserLgUtils.getCurrentCity())) {
|
||||
mCurrentCityName = UserLgUtils.getCurrentCity();
|
||||
} else {
|
||||
mCurrentCityName = PathConfig.CITY_DEFAULT_NAME;
|
||||
}
|
||||
mCurrentCityCode = UserLgUtils.getCurrentCityCode();
|
||||
mCurrentCityCode = UserLgUtils.getCurrentCityId();
|
||||
mCurrentCityId = UserLgUtils.getCurrentCityCode();
|
||||
}
|
||||
mTvCurrentArea.setText(mCurrentCityName);
|
||||
|
@ -83,7 +83,7 @@ public class MainActivity extends BaseActivity {
|
||||
mRlTitleBar1.setVisibility(View.VISIBLE);
|
||||
mFragments = new ArrayList<>();
|
||||
Fragment homefragment = FragmentUtils.getHomeFragment();
|
||||
Fragment shopFragment = FragmentUtils.getActivityFragment();
|
||||
Fragment shopFragment = FragmentUtils.getShopFragment();
|
||||
Fragment placeFragment = FragmentUtils.getPlaceFragment();
|
||||
Fragment culturalFragment = FragmentUtils.getCulturalFragment();
|
||||
Fragment mineMainFragment = FragmentUtils.getMineFragment();
|
||||
@ -92,12 +92,6 @@ public class MainActivity extends BaseActivity {
|
||||
mFragments.add(culturalFragment);
|
||||
mFragments.add(shopFragment);
|
||||
mFragments.add(mineMainFragment);
|
||||
// String locationCity = UserLgUtils.getCurrentCity();
|
||||
// if (TextUtils.isEmpty(locationCity)) {
|
||||
// UserLgUtils.setCurrentCity(PathConfig.CITY_DEFAULT_NAME);
|
||||
// UserLgUtils.setCurrentCityCode(PathConfig.CITY_DEFAULT_CODE);
|
||||
// UserLgUtils.setCityLevel(PathConfig.CITY_DEFAULT_LEVEL);
|
||||
// }
|
||||
mVpContent.setAdapter(new MyFragmentPageAdapter(this));
|
||||
mVpContent.setUserInputEnabled(false);
|
||||
|
||||
@ -192,7 +186,7 @@ public class MainActivity extends BaseActivity {
|
||||
});
|
||||
mRlTitleBar.setVisibility(View.VISIBLE);
|
||||
mRlTitleBar1.setVisibility(View.VISIBLE);
|
||||
mTvAppBack.setVisibility(View.GONE);
|
||||
mTvAppBack.setVisibility(View.VISIBLE);
|
||||
String city = TextUtils.isEmpty(UserLgUtils.getCurrentCity()) ? "地区选择" : UserLgUtils.getCurrentCity();
|
||||
mTvAppBack.setText(city);
|
||||
mTvAppBack.setOnClickListener(v -> ARouter.getInstance()
|
||||
@ -241,11 +235,15 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
if (requestCode == 1234) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (resultCode == 333) {
|
||||
String chooseCity = data.getStringExtra("chooseCity");
|
||||
String chooseCityCode = data.getStringExtra("chooseCityCode");
|
||||
String cityId = data.getStringExtra("chooseCityId");
|
||||
|
||||
UserLgUtils.setCurrentCityCode(cityId);
|
||||
UserLgUtils.setCurrentCityId(chooseCityCode);
|
||||
UserLgUtils.setCurrentCity(chooseCity);
|
||||
|
||||
mTvAppBack.setText(chooseCity);
|
||||
refreshData();
|
||||
}
|
||||
|
@ -256,12 +256,14 @@ public class HomeFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
//TODO 错误处理
|
||||
if (mNewsSkeleton != null) {
|
||||
mNewsSkeleton.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
mSrlView.finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -295,7 +297,7 @@ public class HomeFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
mSrlView.finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -430,7 +432,7 @@ public class HomeFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
mSrlView.finishRefresh();
|
||||
}
|
||||
});
|
||||
|
||||
@ -713,7 +715,7 @@ public class HomeFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
mSrlView.finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1021,7 +1023,6 @@ public class HomeFragment extends BaseFragment {
|
||||
if (mNewsSkeleton != null) {
|
||||
mNewsSkeleton.show();
|
||||
}
|
||||
// getNewsList(null);
|
||||
mLlNewsContent.removeAllViews();
|
||||
getMainFuncMenu();
|
||||
getMainNewsTab();
|
||||
@ -1042,11 +1043,13 @@ public class HomeFragment extends BaseFragment {
|
||||
public void notifyData() {
|
||||
//重新加载数据
|
||||
mMainCommendBeans.clear();
|
||||
if (mNewsSkeleton != null) {
|
||||
mNewsSkeleton.show();
|
||||
}
|
||||
mLlNewsContent.removeAllViews();
|
||||
buildBannerData();
|
||||
getMainFuncMenu();
|
||||
getMainNewsTab();
|
||||
// getNewsList(null);
|
||||
getLiveList();
|
||||
getMainCommendList();
|
||||
getBannerData();
|
||||
|
@ -175,7 +175,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/ll_content"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/sel_btn_login"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/app_title" />
|
||||
<solid android:color="@color/app_title_9f_no" />
|
||||
<corners android:radius="5dp" />
|
||||
</shape>
|
Loading…
Reference in New Issue
Block a user