version:5.1
fix: update:更改天气闹钟等为竖屏
This commit is contained in:
@@ -37,6 +37,16 @@ public class APPListActivity extends BaseActivity {
|
||||
return R.layout.activity_applist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
back = findViewById(R.id.iv_back);
|
||||
|
||||
@@ -40,6 +40,16 @@ public class AddIconActivity extends BaseActivity {
|
||||
return R.layout.activity_add_icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
@@ -62,6 +62,15 @@ public class AddItemActivity extends BaseActivity {
|
||||
return R.layout.add_item_confirmation_activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
|
||||
@@ -31,12 +31,26 @@ public class AddressActivity extends BaseDataBindingActivity {
|
||||
private AddressAdapter mAddressAdapter;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_address;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_address);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
mBinding.setListener(new Listener());
|
||||
|
||||
mAddressAdapter = new AddressAdapter();
|
||||
|
||||
@@ -50,6 +50,16 @@ public class ArticleActivity extends BaseActivity {
|
||||
return R.layout.activity_articl;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
@@ -113,6 +113,16 @@ public class ControlActivity extends BaseActivity {
|
||||
return R.layout.activity_control;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
@@ -37,6 +37,16 @@ public class DailyAppActivity extends BaseActivity {
|
||||
return R.layout.activity_dailyapp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
@@ -90,12 +90,27 @@ public class DetailsActivity extends BaseDataBindingActivity {
|
||||
private ActivityDetailsBinding mBinding;
|
||||
private GoodsInfo mGoodsInfo;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_details;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_details);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
ButterKnife.bind(this);
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) return;
|
||||
@@ -120,8 +135,8 @@ public class DetailsActivity extends BaseDataBindingActivity {
|
||||
}
|
||||
});
|
||||
tv_stock.setText("库存:" + mGoodsInfo.getStock());
|
||||
BigDecimal d =new BigDecimal(mGoodsInfo.getOriginal_price());
|
||||
BigDecimal d2 =new BigDecimal(mGoodsInfo.getBuying_price());
|
||||
BigDecimal d = new BigDecimal(mGoodsInfo.getOriginal_price());
|
||||
BigDecimal d2 = new BigDecimal(mGoodsInfo.getBuying_price());
|
||||
tv_subsidy.setText("官方补贴" + d.subtract(d2).toString());
|
||||
tv_buying_price.setText("¥" + mGoodsInfo.getBuying_price());
|
||||
tv_original_price.setText("原价:" + mGoodsInfo.getOriginal_price() + "元");
|
||||
|
||||
@@ -32,12 +32,27 @@ public class ExpressActivity extends BaseDataBindingActivity {
|
||||
|
||||
private ActivityExpressBinding mBinding;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_express;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_express);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +78,7 @@ public class ExpressActivity extends BaseDataBindingActivity {
|
||||
private void getOrderExpress(String orderSn, String orderId) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getOrderExpressObservable(orderSn, orderId)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<ExpressData>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -88,7 +103,7 @@ public class ExpressActivity extends BaseDataBindingActivity {
|
||||
}
|
||||
mBinding.timelineLayout.setVisibility(View.VISIBLE);
|
||||
mBinding.clNodata.setVisibility(View.GONE);
|
||||
}else {
|
||||
} else {
|
||||
mBinding.timelineLayout.setVisibility(View.GONE);
|
||||
mBinding.clNodata.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.uiuios.aios.activity;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@@ -15,11 +12,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.GoodsListAdapter;
|
||||
import com.uiuios.aios.base.BaseDataBindingActivity;
|
||||
import com.uiuios.aios.base.DataBindingActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
@@ -30,14 +25,13 @@ import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class GoodsActivity extends DataBindingActivity {
|
||||
public class GoodsActivity extends BaseDataBindingActivity {
|
||||
private static final String TAG = GoodsActivity.class.getSimpleName();
|
||||
|
||||
private ActivityGoodsBinding mBinding;
|
||||
@@ -47,16 +41,37 @@ public class GoodsActivity extends DataBindingActivity {
|
||||
|
||||
private HashMap<String, GoodsType> mGoodsTypeMap;
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_goods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 是否是黑色状态栏
|
||||
*/
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_goods);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
mBinding.setListener(new Listener());
|
||||
UltimateBarX.statusBarOnly(this)
|
||||
.transparent()
|
||||
.apply();
|
||||
// UltimateBarX.statusBarOnly(this)
|
||||
// .transparent()
|
||||
// .apply();
|
||||
UltimateBarX.addStatusBarTopPadding(mBinding.constraintLayout);
|
||||
mRecyclerView = mBinding.recyclerView;
|
||||
mGoodsAdapter = new GoodsListAdapter();
|
||||
@@ -105,7 +120,7 @@ public class GoodsActivity extends DataBindingActivity {
|
||||
private void getGoodsType() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsTypeListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsType>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -155,7 +170,7 @@ public class GoodsActivity extends DataBindingActivity {
|
||||
private void getAllGoods(int type) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable(type)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(getGoodsListObservable());
|
||||
}
|
||||
|
||||
@@ -163,7 +178,7 @@ public class GoodsActivity extends DataBindingActivity {
|
||||
private void getAllGoods() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(getGoodsListObservable());
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,16 @@ public class InfoListActivity extends BaseActivity {
|
||||
return R.layout.activity_info_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
@@ -69,7 +79,7 @@ public class InfoListActivity extends BaseActivity {
|
||||
@Override
|
||||
public void initData() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<ArticleList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.InformationAdapter;
|
||||
import com.uiuios.aios.base.BaseDataBindingActivity;
|
||||
import com.uiuios.aios.base.DataBindingActivity;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
@@ -26,7 +25,6 @@ import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import butterknife.BindView;
|
||||
@@ -35,10 +33,9 @@ import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class InformationActivity extends DataBindingActivity {
|
||||
public class InformationActivity extends BaseDataBindingActivity {
|
||||
private static final String TAG = InformationActivity.class.getSimpleName();
|
||||
|
||||
|
||||
@BindView(R.id.tabLayout)
|
||||
TabLayout tabLayout;
|
||||
@BindView(R.id.cl_bar)
|
||||
@@ -53,14 +50,35 @@ public class InformationActivity extends DataBindingActivity {
|
||||
|
||||
private HashMap<String, CategoryBean> mCategoryMap;
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_information;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 是否是黑色状态栏
|
||||
*/
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_information);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
ButterKnife.bind(this);
|
||||
UltimateBarX.statusBarOnly(this)
|
||||
.transparent()
|
||||
.apply();
|
||||
|
||||
// UltimateBarX.statusBarOnly(this)
|
||||
// .transparent()
|
||||
// .apply();
|
||||
UltimateBarX.addStatusBarTopPadding(cl_bar);
|
||||
|
||||
mInformationAdapter = new InformationAdapter();
|
||||
@@ -100,7 +118,7 @@ public class InformationActivity extends DataBindingActivity {
|
||||
|
||||
private void getCategorys() {
|
||||
NetInterfaceManager.getInstance().getCategorysObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<CategoryBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -150,14 +168,14 @@ public class InformationActivity extends DataBindingActivity {
|
||||
private void getArticleList() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(getArticleListObserver());
|
||||
}
|
||||
|
||||
private void getArticleList(int id) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getArticleListObservable(id)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(getArticleListObserver());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,27 @@ public class InformationDetailsActivity extends BaseDataBindingActivity {
|
||||
|
||||
private ActivityInfoDetailsBinding mBinding;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_info_details;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_info_details);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -62,12 +62,27 @@ public class OrderActivity extends BaseDataBindingActivity {
|
||||
|
||||
ActivityResultLauncher<Intent> launcher;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_order;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_order);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
launcher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
||||
@Override
|
||||
public void onActivityResult(ActivityResult result) {
|
||||
@@ -209,7 +224,7 @@ public class OrderActivity extends BaseDataBindingActivity {
|
||||
params.put("desktop_app_package", NetInterfaceManager.convertToRequestBody(BuildConfig.APPLICATION_ID));
|
||||
params.put("address_id", NetInterfaceManager.convertToRequestBody(mAddressId));
|
||||
NetInterfaceManager.getInstance().getGoodsBuyObservable(params)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<OrderBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -30,12 +30,27 @@ public class OrderListActivity extends BaseDataBindingActivity {
|
||||
private ActivityOrderListBinding mBinding;
|
||||
private OrderAdapter mOrderAdapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_order_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_order_list);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
|
||||
mOrderAdapter = new OrderAdapter();
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
@@ -100,13 +115,13 @@ public class OrderListActivity extends BaseDataBindingActivity {
|
||||
|
||||
private void getAllOrderList() {
|
||||
NetInterfaceManager.getInstance().getAllOrderObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(getOrderListObserver());
|
||||
}
|
||||
|
||||
private void getOrderIndexList(int status) {
|
||||
NetInterfaceManager.getInstance().getOrderIndexObservable(status)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(getOrderListObserver());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,27 @@ public class PayActivity extends BaseDataBindingActivity {
|
||||
|
||||
private OrderBean mOrderBean;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_pay;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_pay);
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
mBinding.tvRefresh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -74,7 +89,7 @@ public class PayActivity extends BaseDataBindingActivity {
|
||||
if (orderBean == null) return;
|
||||
NetInterfaceManager.getInstance()
|
||||
.getOrderPayObservable(orderBean.getOrder_sn(), orderBean.getOrder_id())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<WxpayBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -112,7 +127,7 @@ public class PayActivity extends BaseDataBindingActivity {
|
||||
mCountdownSubscribe.dispose();
|
||||
}
|
||||
mCountdownSubscribe = Observable.interval(1, TimeUnit.SECONDS)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Long>() {
|
||||
@@ -142,7 +157,7 @@ public class PayActivity extends BaseDataBindingActivity {
|
||||
mCheckOrderSubscribe.dispose();
|
||||
}
|
||||
mCheckOrderSubscribe = Observable.interval(5, TimeUnit.SECONDS)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Long>() {
|
||||
@@ -150,7 +165,7 @@ public class PayActivity extends BaseDataBindingActivity {
|
||||
public void accept(Long aLong) throws Exception {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getOrderPayCheckObservable(wxpayBean.getOrder_sn(), wxpayBean.getOrder_id())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -38,6 +38,16 @@ public class QuickAppActivity extends BaseActivity {
|
||||
return R.layout.activity_quick_app;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
@@ -90,6 +90,16 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
return R.layout.activity_screen_lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SpikeListActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
getLifecycleSubject().onNext(ActivityEvent.CREATE);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
@@ -54,6 +54,16 @@ public class SpikeListActivity extends BaseActivity {
|
||||
return R.layout.activity_spike_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
@@ -76,7 +86,7 @@ public class SpikeListActivity extends BaseActivity {
|
||||
private void getGoodsInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<GoodsList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -20,6 +20,16 @@ public class SplashActivity extends BaseActivity {
|
||||
return R.layout.activity_splash;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
|
||||
@@ -81,6 +81,15 @@ public class AlarmActivity extends BaseActivity implements AlarmContact.AlarmVie
|
||||
return R.layout.activity_alarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@@ -89,7 +98,7 @@ public class AlarmActivity extends BaseActivity implements AlarmContact.AlarmVie
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new AlarmPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
|
||||
mAlarmAdapter = new AlarmAdapter();
|
||||
mAlarmAdapter.setOnLongClickListener(new AlarmAdapter.OnLongClickListener() {
|
||||
@@ -236,7 +245,7 @@ public class AlarmActivity extends BaseActivity implements AlarmContact.AlarmVie
|
||||
mPresenter.getAlarmClock(mType);
|
||||
} else {
|
||||
NetInterfaceManager.getInstance().deleteAlarmClockObservable(alarmClockData.getId())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.uiuios.aios.activity.alarm;
|
||||
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.uiuios.aios.activity.alarm.port;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.alarmclock.port.PortAlarmClockAddActivity;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.alarm.PortAlarmAdapter;
|
||||
import com.uiuios.aios.base.mvvm.BaseMvvmActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.databinding.ActivityAlarmPortBinding;
|
||||
import com.uiuios.aios.dialog.DeleteDialog;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class PortAlarmActivity extends BaseMvvmActivity<PortAlarmViewModel, ActivityAlarmPortBinding> {
|
||||
private static final String TAG = PortAlarmActivity.class.getSimpleName();
|
||||
|
||||
private PortAlarmAdapter mAlarmAdapter;
|
||||
private int mType = 0;
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_alarm_port;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new Click());
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
|
||||
mAlarmAdapter = new PortAlarmAdapter();
|
||||
mAlarmAdapter.setOnLongClickListener(new PortAlarmAdapter.OnLongClickListener() {
|
||||
@Override
|
||||
public void onLongClick(AlarmClockData alarmClockData) {
|
||||
showDialog(alarmClockData);
|
||||
}
|
||||
});
|
||||
mViewDataBinding.rvData.setLayoutManager(new LinearLayoutManager(PortAlarmActivity.this));
|
||||
mViewDataBinding.rvData.setAdapter(mAlarmAdapter);
|
||||
mViewDataBinding.rvData.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
switch (newState){
|
||||
/*正在拖拽*/
|
||||
case RecyclerView.SCROLL_STATE_DRAGGING:
|
||||
break;
|
||||
/*滑动停止*/
|
||||
default:
|
||||
case RecyclerView.SCROLL_STATE_IDLE:
|
||||
break;
|
||||
/*惯性滑动中*/
|
||||
case RecyclerView.SCROLL_STATE_SETTLING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
@Override
|
||||
public void initData() {
|
||||
mViewModel.getAlarmClockData().observe(this, new androidx.lifecycle.Observer<List<AlarmClockData>>() {
|
||||
@Override
|
||||
public void onChanged(List<AlarmClockData> alarmClockData) {
|
||||
setAlarmClock(alarmClockData);
|
||||
}
|
||||
});
|
||||
|
||||
mViewModel.getAlarmClock(mType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
private void showDialog(AlarmClockData alarmClockData) {
|
||||
DeleteDialog dialog = new DeleteDialog(this);
|
||||
dialog.setTitle("提醒")
|
||||
.setMessage("是否要删除本次闹钟")
|
||||
.setPositive("确定")
|
||||
.setNegtive("取消")
|
||||
.setOnClickBottomListener(new DeleteDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
deleteAlarm(alarmClockData);
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegtiveClick() {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void deleteAlarm(AlarmClockData alarmClockData) {
|
||||
if (alarmClockData.isIs_local()) {
|
||||
alarmClockData.setDeleted(true);
|
||||
AlarmUtils.getInstance().deleteAlarmClock(alarmClockData);
|
||||
mViewModel.getAlarmClock(mType);
|
||||
} else {
|
||||
NetInterfaceManager.getInstance().deleteAlarmClockObservable(alarmClockData.getId())
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("deleteAlarm", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("deleteAlarm", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
AlarmUtils.getInstance().deleteAlarmClock(alarmClockData);
|
||||
ToastUtil.show("删除成功");
|
||||
} else {
|
||||
ToastUtil.show("删除失败:" + baseResponse.msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("deleteAlarm", "onError: " + e.getMessage());
|
||||
alarmClockData.setDeleted(true);
|
||||
AlarmUtils.getInstance().updateAlarmClock(alarmClockData);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("deleteAlarm", "onComplete: ");
|
||||
mViewModel.getAlarmClock(mType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setAlarmClock(List<AlarmClockData> alarmClockData) {
|
||||
List<AlarmClockData> localAddAlarm = AlarmUtils.getInstance().getLocalAddAlarm();
|
||||
Log.e(TAG, "setAlarmClock: localAddAlarm size = " + localAddAlarm);
|
||||
if (alarmClockData != null) {
|
||||
localAddAlarm.addAll(alarmClockData);
|
||||
}
|
||||
if (localAddAlarm.size() == 0) {
|
||||
mAlarmAdapter.setAlarmClockData(null);
|
||||
// swipeRefreshLayout.setRefreshing(false);
|
||||
mViewDataBinding.clNodata.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.rvData.setVisibility(View.GONE);
|
||||
ToastUtil.show("没有数据");
|
||||
} else {
|
||||
mAlarmAdapter.setAlarmClockData(localAddAlarm);
|
||||
// swipeRefreshLayout.setRefreshing(false);
|
||||
mViewDataBinding.clNodata.setVisibility(View.GONE);
|
||||
mViewDataBinding.rvData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class Click {
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void add(View view) {
|
||||
startActivity(new Intent(PortAlarmActivity.this, PortAlarmClockAddActivity.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.uiuios.aios.activity.alarm.port;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.base.mvvm.BaseViewModel;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.databinding.ActivityAlarmPortBinding;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class PortAlarmViewModel extends BaseViewModel<ActivityAlarmPortBinding> {
|
||||
|
||||
private static final String TAG = PortAlarmViewModel.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public ActivityAlarmPortBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
private MutableLiveData<List<AlarmClockData>> mAlarmClockData =new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<List<AlarmClockData>> getAlarmClockData() {
|
||||
return mAlarmClockData;
|
||||
}
|
||||
|
||||
public void getAlarmClock() {
|
||||
NetInterfaceManager.getInstance().getAlarmClock(true, getLifecycle(), new NetInterfaceManager.AlarmClockCallback() {
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
||||
if (alarmClockList.size() == 0) {
|
||||
setAlarmClockEmpty();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getAlarmClock(int type) {
|
||||
Log.e(TAG, "getAlarmClock: " + type);
|
||||
NetInterfaceManager.getInstance().getAlarmClockObservable(type)
|
||||
.subscribe(new Observer<BaseResponse<List<AlarmClockData>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAlarmClock", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AlarmClockData>> listBaseResponse) {
|
||||
Log.e("getAlarmClock", "onNext: " + listBaseResponse);
|
||||
mAlarmClockData.setValue(listBaseResponse.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAlarmClock", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAlarmClock", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,9 +19,9 @@ import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.alarm.AlarmAdapter;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.base.BaseLifecycleActivity;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.base.mvp.BaseMvpActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.dialog.DeleteDialog;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
@@ -37,7 +37,7 @@ import cn.jzvd.Jzvd;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class AlarmClockActivity extends BaseLifecycleActivity implements AlarmClockContact.ClockView {
|
||||
public class AlarmClockActivity extends BaseMvpActivity implements AlarmClockContact.ClockView {
|
||||
private static final String TAG = AlarmClockActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
@@ -59,6 +59,16 @@ public class AlarmClockActivity extends BaseLifecycleActivity implements AlarmCl
|
||||
return R.layout.activity_alarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
UltimateBarX.statusBarOnly(this)
|
||||
@@ -68,7 +78,7 @@ public class AlarmClockActivity extends BaseLifecycleActivity implements AlarmCl
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new AlarmClockPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
|
||||
mAlarmAdapter = new AlarmAdapter();
|
||||
mAlarmAdapter.setOnLongClickListener(new AlarmAdapter.OnLongClickListener() {
|
||||
@@ -126,7 +136,7 @@ public class AlarmClockActivity extends BaseLifecycleActivity implements AlarmCl
|
||||
AlarmUtils.getInstance().deleteAlarmClock(alarmClockData);
|
||||
} else {
|
||||
NetInterfaceManager.getInstance().deleteAlarmClockObservable(alarmClockData.getId())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -34,8 +34,8 @@ import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.base.BaseLifecycleActivity;
|
||||
import com.uiuios.aios.base.GlideEngine;
|
||||
import com.uiuios.aios.base.mvp.BaseMvpActivity;
|
||||
import com.uiuios.aios.service.main.MainService;
|
||||
import com.uiuios.aios.utils.FFmpegUtils;
|
||||
import com.uiuios.aios.utils.FileUtil;
|
||||
@@ -63,7 +63,7 @@ import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class AlarmClockAddActivity extends BaseLifecycleActivity {
|
||||
public class AlarmClockAddActivity extends BaseMvpActivity {
|
||||
private static final String TAG = AlarmClockAddActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.cl_content)
|
||||
@@ -114,9 +114,19 @@ public class AlarmClockAddActivity extends BaseLifecycleActivity {
|
||||
return R.layout.activity_add_alarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
getLifecycleSubject().onNext(ActivityEvent.CREATE);
|
||||
UltimateBarX.statusBarOnly(this)
|
||||
.colorRes(R.color.default_blue)
|
||||
.fitWindow(true)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.uiuios.aios.activity.alarmclock;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
package com.uiuios.aios.activity.alarmclock.port;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.CustomListener;
|
||||
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
||||
import com.bigkoo.pickerview.view.TimePickerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.luck.picture.lib.basic.PictureSelector;
|
||||
import com.luck.picture.lib.config.SelectMimeType;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.base.GlideEngine;
|
||||
import com.uiuios.aios.base.mvvm.BaseMvvmActivity;
|
||||
import com.uiuios.aios.databinding.ActivityAddAlarmPortBinding;
|
||||
import com.uiuios.aios.service.main.MainService;
|
||||
import com.uiuios.aios.utils.FFmpegUtils;
|
||||
import com.uiuios.aios.utils.FileUtil;
|
||||
import com.uiuios.aios.utils.ScreenUtil;
|
||||
import com.uiuios.aios.utils.TimeUtils;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class PortAlarmClockAddActivity extends BaseMvvmActivity<PortAlarmClockAddViewModel, ActivityAddAlarmPortBinding> {
|
||||
private static final String TAG = PortAlarmClockAddActivity.class.getSimpleName();
|
||||
|
||||
private TimePickerView pvTime;
|
||||
|
||||
private String mPictrueFilePath;
|
||||
private Date mDate;
|
||||
/*类型 1一次性 2每天 3周一到周五 4周六周日*/
|
||||
private int mDayType = 1;
|
||||
private int mClockType = 1;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_add_alarm_port;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new Click());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
UltimateBarX.statusBarOnly(this)
|
||||
.colorRes(R.color.default_blue)
|
||||
.fitWindow(true)
|
||||
.apply();
|
||||
|
||||
ButterKnife.bind(this);
|
||||
initTimePicker();
|
||||
|
||||
mViewDataBinding.rb1.setChecked(true);
|
||||
mViewDataBinding.rb1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
ColorStateList colorStateList = getResources().getColorStateList(R.color.white);
|
||||
mViewDataBinding.rb1.setTextColor(colorStateList);
|
||||
mDayType = 1;
|
||||
} else {
|
||||
ColorStateList colorStateList = getResources().getColorStateList(R.color.radio_botton_gray);
|
||||
mViewDataBinding.rb1.setTextColor(colorStateList);
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewDataBinding.rb2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
ColorStateList colorStateList = getResources().getColorStateList(R.color.white);
|
||||
mViewDataBinding.rb2.setTextColor(colorStateList);
|
||||
mDayType = 2;
|
||||
} else {
|
||||
ColorStateList colorStateList = getResources().getColorStateList(R.color.radio_botton_gray);
|
||||
mViewDataBinding.rb2.setTextColor(colorStateList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mViewDataBinding.rbAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
mClockType = 1;
|
||||
mViewDataBinding.etActivation.setText("用药闹钟");
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewDataBinding.rbLook.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
mClockType = 2;
|
||||
mViewDataBinding.etActivation.setText("接送闹钟");
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewDataBinding.rbReserve.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
mClockType = 3;
|
||||
mViewDataBinding.etActivation.setText("预约闹钟");
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void checkContent() {
|
||||
pvTime.returnData();
|
||||
if (TextUtils.isEmpty(mViewDataBinding.etActivation.getText())) {
|
||||
ToastUtil.show("请输入标题");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(mPictrueFilePath)) {
|
||||
ToastUtil.show("请选择图片");
|
||||
return;
|
||||
}
|
||||
String timeStamp = getTime(mDate);
|
||||
Log.e(TAG, "checkContent: " + timeStamp);
|
||||
Log.e(TAG, "checkContent: " + mPictrueFilePath);
|
||||
|
||||
AlarmClockData alarmClockData = new AlarmClockData();
|
||||
alarmClockData.setFile(mPictrueFilePath);
|
||||
alarmClockData.setType(mDayType);
|
||||
alarmClockData.setTime(timeStamp);
|
||||
alarmClockData.setTitle(mViewDataBinding.etActivation.getText().toString());
|
||||
alarmClockData.setRemind_type(0);
|
||||
alarmClockData.setIs_onoff(1);
|
||||
alarmClockData.setClazz(mClockType);
|
||||
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
int fakeId = random.nextInt(Integer.MAX_VALUE);
|
||||
Log.e(TAG, "checkContent: fakeId = " + fakeId);
|
||||
alarmClockData.setId(fakeId);
|
||||
alarmClockData.setIs_local(true);
|
||||
Log.e(TAG, "checkContent: addAlarmClock = " + AlarmUtils.getInstance().addAlarmClock(alarmClockData));
|
||||
ToastUtil.show("添加成功");
|
||||
Intent intent = new Intent(MainService.uploadAlarmClockReceiver.UPLOAD_ALARM_RECEIVER_ACTION);
|
||||
sendBroadcast(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void openSelector() {
|
||||
PictureSelector.create(PortAlarmClockAddActivity.this)
|
||||
.openGallery(SelectMimeType.ofAll())
|
||||
.setSelectionMode(1)
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.forResult(new OnResultCallbackListener<LocalMedia>() {
|
||||
@Override
|
||||
public void onResult(ArrayList<LocalMedia> result) {
|
||||
mPictrueFilePath = result.get(0).getRealPath();
|
||||
File file = new File(mPictrueFilePath);
|
||||
if (file.exists()) {
|
||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtil.dip2px(PortAlarmClockAddActivity.this, 8F)));
|
||||
Glide.with(mViewDataBinding.nvPic).load(file).apply(options).into(mViewDataBinding.nvPic);
|
||||
mViewDataBinding.nvPic.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.clPic.setVisibility(View.GONE);
|
||||
if (FileUtil.isVideoFile(mPictrueFilePath)) {
|
||||
FFmpegUtils.getDurationInMilliseconds(mPictrueFilePath, new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("openSelector", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull Integer integer) {
|
||||
Log.e("openSelector", "onNext: " + integer);
|
||||
mViewDataBinding.tvDuration.setText(TimeUtils.secToTime(integer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("openSelector", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("openSelector", "onComplete: ");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mViewDataBinding.tvDuration.setText("");
|
||||
}
|
||||
} else {
|
||||
mPictrueFilePath = "";
|
||||
mViewDataBinding.nvPic.setVisibility(View.GONE);
|
||||
mViewDataBinding.clPic.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Log.e(TAG, "onCancel: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initTimePicker() {
|
||||
//控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释)
|
||||
//因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11
|
||||
Calendar selectedDate = Calendar.getInstance();
|
||||
|
||||
Calendar startDate = Calendar.getInstance();
|
||||
startDate.set(2013, 0, 23);
|
||||
|
||||
Calendar endDate = Calendar.getInstance();
|
||||
endDate.set(2019, 11, 28);
|
||||
|
||||
//时间选择器
|
||||
pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
|
||||
@Override
|
||||
public void onTimeSelect(Date date, View v) {//选中事件回调
|
||||
// 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null
|
||||
/*btn_Time.setText(getTime(date));*/
|
||||
mDate = date;
|
||||
Log.e(TAG, "onTimeSelect: " + getTime(date));
|
||||
}
|
||||
})
|
||||
.setLayoutRes(R.layout.pickerview_custom_time, new CustomListener() {
|
||||
@Override
|
||||
public void customLayout(View v) {
|
||||
|
||||
}
|
||||
})
|
||||
.setType(new boolean[]{false, false, false, true, true, false})
|
||||
.setLabel("", "", "", "时", "分", "") //设置空字符串以隐藏单位提示 hide label
|
||||
.setDividerColor(Color.GRAY)
|
||||
.setContentTextSize(30)
|
||||
.setDate(selectedDate)
|
||||
.setRangDate(startDate, selectedDate)
|
||||
.setDecorView(mViewDataBinding.clContent)//非dialog模式下,设置ViewGroup, pickerView将会添加到这个ViewGroup中
|
||||
.setOutSideColor(0x00000000)
|
||||
.setOutSideCancelable(false)
|
||||
.build();
|
||||
pvTime.setKeyBackCancelable(false);//系统返回键监听屏蔽掉
|
||||
pvTime.show(mViewDataBinding.clContent, false);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view
|
||||
|
||||
}
|
||||
|
||||
private String getTime(Date date) {
|
||||
SimpleDateFormat format;
|
||||
if (mDayType == 1) {
|
||||
format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
} else {
|
||||
format = new SimpleDateFormat("HH:mm");
|
||||
}
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
|
||||
public class Click {
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void openGallery(View view) {
|
||||
openSelector();
|
||||
}
|
||||
|
||||
public void submit(View view) {
|
||||
checkContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.uiuios.aios.activity.alarmclock.port;
|
||||
|
||||
import com.uiuios.aios.base.mvvm.BaseViewModel;
|
||||
import com.uiuios.aios.databinding.ActivityAddAlarmPortBinding;
|
||||
|
||||
public class PortAlarmClockAddViewModel extends BaseViewModel<ActivityAddAlarmPortBinding> {
|
||||
|
||||
@Override
|
||||
public ActivityAddAlarmPortBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,12 +43,22 @@ public class FamilySpaceActivity extends BaseActivity implements FamilySpaceCont
|
||||
return R.layout.activity_family_space;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new FamilySpacePresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
iv_back.setOnClickListener(view -> finish());
|
||||
mHealthCodeAdapter = new HealthCodeAdapter();
|
||||
mViewPager.setAdapter(mHealthCodeAdapter);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiuios.aios.activity.code;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
import com.uiuios.aios.bean.HealthCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,16 +20,14 @@ import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.base.BaseLightActivity;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.base.GlideEngine;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.utils.GlideLoadUtils;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
import com.uiuios.aios.utils.Utils;
|
||||
import com.uiuios.aios.view.ToggleButton;
|
||||
|
||||
import java.io.File;
|
||||
@@ -47,7 +45,7 @@ import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class AddContactActivity extends BaseLightActivity {
|
||||
public class AddContactActivity extends BaseActivity {
|
||||
private static final String TAG = AddContactActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.iv_cancel)
|
||||
@@ -72,6 +70,16 @@ public class AddContactActivity extends BaseLightActivity {
|
||||
return R.layout.activity_add_contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
@@ -156,7 +164,7 @@ public class AddContactActivity extends BaseLightActivity {
|
||||
params.put("is_urgent", String.valueOf(toggleButton.isToggleOn()));
|
||||
NetInterfaceManager.getInstance()
|
||||
.getMailListAddObservable(params, body)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@@ -48,12 +48,22 @@ public class ContactActivity extends BaseActivity implements ContactContact.Cont
|
||||
return R.layout.activity_contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mContactPresenter = new ContactPresenter(this);
|
||||
mContactPresenter.attachView(this);
|
||||
mContactPresenter.setLifecycle(lifecycleSubject);
|
||||
mContactPresenter.setLifecycle(getLifecycleSubject());
|
||||
mContactAdapter = new ContactAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
rv_contact.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiuios.aios.activity.contact;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
import com.uiuios.aios.bean.Contact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -68,6 +68,16 @@ public class DialerActivity extends BaseActivity {
|
||||
return R.layout.activity_dialer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
|
||||
@@ -88,6 +88,16 @@ public class LocationAcivity extends BaseActivity implements LocationContact.Loc
|
||||
return R.layout.activity_location;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@@ -96,7 +106,7 @@ public class LocationAcivity extends BaseActivity implements LocationContact.Loc
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new LocationPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
bg.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiuios.aios.activity.location;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
import com.uiuios.aios.bean.AddressBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -87,13 +87,18 @@ public abstract class BaseMainActivity extends BaseActivity implements MainConta
|
||||
private int appListIndex = 3;
|
||||
private int defaultCurrent = 2;
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
toggleNotificationListenerService(this);
|
||||
mMainPresenter = new MainPresenter(this);
|
||||
mMainPresenter.attachView(this);
|
||||
mMainPresenter.setLifecycle(lifecycleSubject);
|
||||
mMainPresenter.setLifecycle(getLifecycleSubject());
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
// SystemClock.setCurrentTimeMillis(1662123600000L);//09-02
|
||||
|
||||
@@ -16,6 +16,11 @@ public class MainActivity extends BaseMainActivity {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiuios.aios.activity.main;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
|
||||
public class MainContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
|
||||
@@ -9,4 +9,9 @@ public class PhoneMainActivity extends BaseMainActivity {
|
||||
public int getLayoutId() {
|
||||
return R.layout.phone_activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,266 +1,251 @@
|
||||
package com.uiuios.aios.activity.weather;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.icu.util.Calendar;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.result.ActivityResult;
|
||||
import androidx.activity.result.ActivityResultCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
|
||||
import com.bigkoo.pickerview.view.OptionsPickerView;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.qweather.sdk.bean.base.Code;
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.location.LocationAcivity;
|
||||
import com.uiuios.aios.adapter.WeatherDayApdapter;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.adapter.WeatherDayApdapterPort;
|
||||
import com.uiuios.aios.base.mvvm.BaseMvvmActivity;
|
||||
import com.uiuios.aios.bean.JsonBean;
|
||||
import com.uiuios.aios.bean.MapGeoResult;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.gson.GetJsonDataUtil;
|
||||
import com.uiuios.aios.databinding.ActivityWeatherBinding;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.utils.DataUtil;
|
||||
import com.uiuios.aios.utils.TimeUtils;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
import com.uiuios.aios.view.HorizontalItemDecoration;
|
||||
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class WeatherActivity extends BaseActivity implements WeatherContact.WeatherView {
|
||||
public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, ActivityWeatherBinding>
|
||||
implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = WeatherActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.rv_weather)
|
||||
RecyclerView rv_weather;
|
||||
@BindView(R.id.tv_location)
|
||||
TextView tv_location;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
@BindView(R.id.tv_refresh)
|
||||
TextView tv_refresh;
|
||||
|
||||
private WeatherPresenter mPresenter;
|
||||
private WeatherDayApdapter mWeatherDayApdapter;
|
||||
private WeatherDayApdapterPort mWeatherDayApdapter;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private List<JsonBean> options1Items = new ArrayList<>();
|
||||
private ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
|
||||
private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();
|
||||
private Thread thread;
|
||||
private static final int MSG_LOAD_DATA = 0x0001;
|
||||
private static final int MSG_LOAD_SUCCESS = 0x0002;
|
||||
private static final int MSG_LOAD_FAILED = 0x0003;
|
||||
private static boolean isLoaded = false;
|
||||
private boolean mLoaded = false;
|
||||
|
||||
|
||||
private String mProvince;
|
||||
private String mCity;
|
||||
private String mDistrict;
|
||||
private ActivityResultLauncher<Intent> register = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
||||
@Override
|
||||
public void onActivityResult(ActivityResult result) {
|
||||
Log.e(TAG, "onActivityResult: " + result);
|
||||
if (result != null) {
|
||||
Intent intent = result.getData();
|
||||
if (intent != null && result.getResultCode() == Activity.RESULT_OK) {
|
||||
Bundle bundle = intent.getExtras();
|
||||
Log.e(TAG, "onActivityResult: " + bundle);
|
||||
String address = bundle.getString("address");
|
||||
String district = bundle.getString("district");
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_ADDRESS, address);
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, district);
|
||||
mViewModel.decodeGeo(address);
|
||||
mViewDataBinding.tvLocation.setText(district);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private ActivityResultLauncher<Intent> register;
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_weather;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
|
||||
mViewDataBinding.setClick(new ClickListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new WeatherPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
|
||||
RemoteManager.getInstance().getLocation();
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
Resources resources = getResources();
|
||||
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
rv_weather.addItemDecoration(new HorizontalItemDecoration(30, this));//10表示10dp
|
||||
mViewDataBinding.rvWeather.addItemDecoration(new HorizontalItemDecoration(30, this));//10表示10dp
|
||||
} else {
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
}
|
||||
rv_weather.setLayoutManager(linearLayoutManager);
|
||||
// rv_weather.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
// rv_weather.addItemDecoration(new RecyclerItemDecoration(ScreenUtils.dp2px(resources, 10), ScreenUtils.dp2px(resources, 10), 3));
|
||||
mWeatherDayApdapter = new WeatherDayApdapter();
|
||||
rv_weather.setAdapter(mWeatherDayApdapter);
|
||||
iv_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
tv_refresh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, "");
|
||||
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, "");
|
||||
if (TextUtils.isEmpty(tude)) {
|
||||
mPresenter.getLocation();
|
||||
} else {
|
||||
tv_location.setText(district);
|
||||
mPresenter.getWeather(tude);
|
||||
}
|
||||
ToastUtil.show("刷新成功");
|
||||
}
|
||||
});
|
||||
tv_location.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hideSoftKeyBoard(v);
|
||||
if (!isLoaded) {
|
||||
ToastUtil.show("位置数据没有加载完成");
|
||||
} else {
|
||||
// showPickerView();
|
||||
register.launch(new Intent(WeatherActivity.this, LocationAcivity.class));
|
||||
}
|
||||
}
|
||||
});
|
||||
register = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
||||
@Override
|
||||
public void onActivityResult(ActivityResult result) {
|
||||
Log.e(TAG, "onActivityResult: " + result);
|
||||
if (result != null) {
|
||||
Intent intent = result.getData();
|
||||
if (intent != null && result.getResultCode() == Activity.RESULT_OK) {
|
||||
Bundle bundle = intent.getExtras();
|
||||
Log.e(TAG, "onActivityResult: " + bundle);
|
||||
String address = bundle.getString("address");
|
||||
mDistrict = bundle.getString("district");
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_ADDRESS, address);
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, mDistrict);
|
||||
mPresenter.decodeGeo(address);
|
||||
tv_location.setText(mDistrict);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mViewDataBinding.rvWeather.setLayoutManager(linearLayoutManager);
|
||||
// mViewDataBinding.rvWeather.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
// mViewDataBinding.rvWeather.addItemDecoration(new RecyclerItemDecoration(ScreenUtils.dp2px(resources, 10), ScreenUtils.dp2px(resources, 10), 3));
|
||||
mWeatherDayApdapter = new WeatherDayApdapterPort();
|
||||
mViewDataBinding.rvWeather.setAdapter(mWeatherDayApdapter);
|
||||
|
||||
private void showPickerView() {// 弹出选择器
|
||||
OptionsPickerView pvOptions = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
|
||||
@Override
|
||||
public void onOptionsSelect(int options1, int options2, int options3, View v) {
|
||||
//返回的分别是三个级别的选中位置
|
||||
mProvince = options1Items.size() > 0 ?
|
||||
options1Items.get(options1).getPickerViewText() : "";
|
||||
mViewDataBinding.tvDate.setText(DataUtil.formatDateDay() + "\t" + TimeUtils.getWeek());
|
||||
|
||||
mCity = options2Items.size() > 0
|
||||
&& options2Items.get(options1).size() > 0 ?
|
||||
options2Items.get(options1).get(options2) : "";
|
||||
|
||||
mDistrict = options2Items.size() > 0
|
||||
&& options3Items.get(options1).size() > 0
|
||||
&& options3Items.get(options1).get(options2).size() > 0 ?
|
||||
options3Items.get(options1).get(options2).get(options3) : "";
|
||||
|
||||
String address = mProvince + mCity + mDistrict;
|
||||
Log.e(TAG, "onOptionsSelect: " + address);
|
||||
tv_location.setText(mDistrict);
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_ADDRESS, address);
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, mDistrict);
|
||||
mPresenter.decodeGeo(address);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
.setTitleText("城市选择")
|
||||
.setDividerColor(Color.BLACK)
|
||||
.setTextColorCenter(Color.BLACK) //设置选中项文字颜色
|
||||
.setContentTextSize(20)
|
||||
.setLineSpacingMultiplier(2.5f)
|
||||
.build();
|
||||
|
||||
// pvOptions.setPicker(options1Items);//一级选择器
|
||||
// pvOptions.setPicker(options1Items, options2Items);//二级选择器
|
||||
pvOptions.setPicker(options1Items, options2Items, options3Items);//三级选择器
|
||||
pvOptions.show();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
if (6 < hour && hour < 18) {
|
||||
mViewDataBinding.root.setBackground(getDrawable(R.drawable.weather_background_day));
|
||||
} else {
|
||||
mViewDataBinding.root.setBackground(getDrawable(R.drawable.weather_background_night));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mHandler.sendEmptyMessage(MSG_LOAD_DATA);
|
||||
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, "");
|
||||
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, "");
|
||||
|
||||
mViewModel.getOptions1ItemsData().observe(this, new Observer<List<JsonBean>>() {
|
||||
@Override
|
||||
public void onChanged(List<JsonBean> jsonBeans) {
|
||||
options1Items = jsonBeans;
|
||||
}
|
||||
});
|
||||
mViewModel.getOptions2ItemsData().observe(this, new Observer<ArrayList<ArrayList<String>>>() {
|
||||
@Override
|
||||
public void onChanged(ArrayList<ArrayList<String>> arrayLists) {
|
||||
options2Items = arrayLists;
|
||||
}
|
||||
});
|
||||
mViewModel.getOptions3ItemsData().observe(this, new Observer<ArrayList<ArrayList<ArrayList<String>>>>() {
|
||||
@Override
|
||||
public void onChanged(ArrayList<ArrayList<ArrayList<String>>> arrayLists) {
|
||||
options3Items = arrayLists;
|
||||
}
|
||||
});
|
||||
mViewModel.getBooleanData().observe(this, new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(Boolean aBoolean) {
|
||||
mLoaded = aBoolean;
|
||||
}
|
||||
});
|
||||
|
||||
mViewModel.getGeoResultData().observe(this, new Observer<MapGeoResult>() {
|
||||
@Override
|
||||
public void onChanged(MapGeoResult mapGeoResult) {
|
||||
if (mapGeoResult != null) {
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, mapGeoResult.getLocation().toString());
|
||||
mViewModel.getWeatherNow(mapGeoResult.getLocation().toString());
|
||||
mViewModel.getWeather7D(mapGeoResult.getLocation().toString());
|
||||
} else {
|
||||
ToastUtil.show("获取位置信息失败");
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewModel.getLocationData().observe(this, new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String s) {
|
||||
mViewDataBinding.tvLocation.setText(s);
|
||||
ToastUtil.show("刷新成功");
|
||||
mViewModel.decodeGeo(s);
|
||||
}
|
||||
});
|
||||
mViewModel.getWeatherNowData().observe(this, new Observer<WeatherNowBean>() {
|
||||
@Override
|
||||
public void onChanged(WeatherNowBean weatherNowBean) {
|
||||
//先判断返回的status是否正确,当status正确时获取数据,若status不正确,可查看status对应的Code值找到原因
|
||||
if (weatherNowBean != null) {
|
||||
if (Code.OK == weatherNowBean.getCode()) {
|
||||
WeatherNowBean.NowBaseBean now = weatherNowBean.getNow();
|
||||
Log.d("getWeatherNow: ", "onSuccess: now " + new Gson().toJson(now));
|
||||
mViewDataBinding.setNowBaseBean(now);
|
||||
ToastUtil.show("刷新成功");
|
||||
} else {
|
||||
//在此查看返回数据失败的原因
|
||||
Code code = weatherNowBean.getCode();
|
||||
Log.d("getWeatherNow: ", "failed code: " + code);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "getWeatherNow: weatherNowBean is null");
|
||||
ToastUtil.show("获取天气失败");
|
||||
mViewModel.getWeatherCache();
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewModel.getWeatherDailyData().observe(this, new Observer<WeatherDailyBean>() {
|
||||
@Override
|
||||
public void onChanged(WeatherDailyBean weatherDailyBean) {
|
||||
if (weatherDailyBean != null) {
|
||||
mWeatherDayApdapter.setDailyBeans(weatherDailyBean.getDaily());
|
||||
WeatherDailyBean.DailyBean dailyBean = weatherDailyBean.getDaily().get(0);
|
||||
mViewDataBinding.tvMinMax.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// mViewModel.loadProvince();
|
||||
getWeather();
|
||||
}
|
||||
|
||||
private void getWeather() {
|
||||
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, CommonConfig.DEFAULT_LOCATION_DISTRICT);
|
||||
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, CommonConfig.DEFAULT_LOCATION_TUDE);
|
||||
if (TextUtils.isEmpty(tude)) {
|
||||
mPresenter.getLocation();
|
||||
mViewModel.getLocation();
|
||||
} else {
|
||||
tv_location.setText(district);
|
||||
mPresenter.getWeather(tude);
|
||||
mViewDataBinding.tvLocation.setText(district);
|
||||
mViewModel.getWeatherNow(tude);
|
||||
mViewModel.getWeather7D(tude);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGeo(MapGeoResult mapGeoresult) {
|
||||
if (mapGeoresult != null) {
|
||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, mapGeoresult.getLocation().toString());
|
||||
mPresenter.getWeather(mapGeoresult.getLocation().toString());
|
||||
} else {
|
||||
ToastUtil.show("获取位置信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(String location) {
|
||||
tv_location.setText(location);
|
||||
ToastUtil.show("刷新成功");
|
||||
mPresenter.getWeatherCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeatherCache(WeatherDailyBean weatherCache) {
|
||||
if (weatherCache != null) {
|
||||
mWeatherDayApdapter.setDailyBeans(weatherCache.getDaily());
|
||||
}
|
||||
mPresenter.getWeather(RemoteManager.getInstance().getLocationTude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(WeatherDailyBean weather) {
|
||||
if (weather != null) {
|
||||
mWeatherDayApdapter.setDailyBeans(weather.getDaily());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mPresenter.detachView();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
}
|
||||
|
||||
private void hideSoftKeyBoard(View view) {
|
||||
@@ -270,105 +255,31 @@ public class WeatherActivity extends BaseActivity implements WeatherContact.Weat
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
private Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_LOAD_DATA:
|
||||
if (thread == null) {//如果已创建就不再重新创建子线程了
|
||||
Log.e(TAG, "handleMessage: Begin Parse Data");
|
||||
thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 子线程中解析省市区数据
|
||||
initJsonData();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_LOAD_SUCCESS:
|
||||
Log.e(TAG, "handleMessage: Parse Succeed");
|
||||
isLoaded = true;
|
||||
break;
|
||||
|
||||
case MSG_LOAD_FAILED:
|
||||
Log.e(TAG, "handleMessage: Parse Failed");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private void initJsonData() {//解析数据
|
||||
|
||||
/**
|
||||
* 注意:assets 目录下的Json文件仅供参考,实际使用可自行替换文件
|
||||
* 关键逻辑在于循环体
|
||||
*
|
||||
* */
|
||||
String JsonData = new GetJsonDataUtil().getJson(this, "province.json");//获取assets目录下的json文件数据
|
||||
|
||||
ArrayList<JsonBean> jsonBean = parseData(JsonData);//用Gson 转成实体
|
||||
|
||||
/**
|
||||
* 添加省份数据
|
||||
*
|
||||
* 注意:如果是添加的JavaBean实体,则实体类需要实现 IPickerViewData 接口,
|
||||
* PickerView会通过getPickerViewText方法获取字符串显示出来。
|
||||
*/
|
||||
options1Items = jsonBean;
|
||||
|
||||
for (int i = 0; i < jsonBean.size(); i++) {//遍历省份
|
||||
ArrayList<String> cityList = new ArrayList<>();//该省的城市列表(第二级)
|
||||
ArrayList<ArrayList<String>> province_AreaList = new ArrayList<>();//该省的所有地区列表(第三极)
|
||||
|
||||
for (int c = 0; c < jsonBean.get(i).getCityList().size(); c++) {//遍历该省份的所有城市
|
||||
String cityName = jsonBean.get(i).getCityList().get(c).getName();
|
||||
cityList.add(cityName);//添加城市
|
||||
ArrayList<String> city_AreaList = new ArrayList<>();//该城市的所有地区列表
|
||||
|
||||
//如果无地区数据,建议添加空字符串,防止数据为null 导致三个选项长度不匹配造成崩溃
|
||||
/*if (jsonBean.get(i).getCityList().get(c).getArea() == null
|
||||
|| jsonBean.get(i).getCityList().get(c).getArea().size() == 0) {
|
||||
city_AreaList.add("");
|
||||
} else {
|
||||
city_AreaList.addAll(jsonBean.get(i).getCityList().get(c).getArea());
|
||||
}*/
|
||||
city_AreaList.addAll(jsonBean.get(i).getCityList().get(c).getArea());
|
||||
province_AreaList.add(city_AreaList);//添加该省所有地区数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加城市数据
|
||||
*/
|
||||
options2Items.add(cityList);
|
||||
|
||||
/**
|
||||
* 添加地区数据
|
||||
*/
|
||||
options3Items.add(province_AreaList);
|
||||
public class ClickListener {
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
mHandler.sendEmptyMessage(MSG_LOAD_SUCCESS);
|
||||
}
|
||||
|
||||
public ArrayList<JsonBean> parseData(String result) {//Gson 解析
|
||||
ArrayList<JsonBean> detail = new ArrayList<>();
|
||||
try {
|
||||
JSONArray data = new JSONArray(result);
|
||||
Gson gson = new Gson();
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
JsonBean entity = gson.fromJson(data.optJSONObject(i).toString(), JsonBean.class);
|
||||
detail.add(entity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mHandler.sendEmptyMessage(MSG_LOAD_FAILED);
|
||||
public void selectAddress(View view) {
|
||||
hideSoftKeyBoard(view);
|
||||
// if (!mLoaded) {
|
||||
// ToastUtil.show("位置数据没有加载完成");
|
||||
// } else {
|
||||
register.launch(new Intent(WeatherActivity.this, LocationAcivity.class));
|
||||
// }
|
||||
}
|
||||
|
||||
public void refresh(View view) {
|
||||
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, CommonConfig.DEFAULT_LOCATION_DISTRICT);
|
||||
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, CommonConfig.DEFAULT_LOCATION_TUDE);
|
||||
if (TextUtils.isEmpty(tude)) {
|
||||
mViewModel.getLocation();
|
||||
} else {
|
||||
mViewDataBinding.tvLocation.setText(district);
|
||||
mViewModel.getWeatherNow(tude);
|
||||
mViewModel.getWeather7D(tude);
|
||||
}
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.uiuios.aios.activity.weather;
|
||||
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.bean.MapGeoResult;
|
||||
|
||||
public class WeatherContact {
|
||||
public interface Presenter extends BasePresenter<WeatherView> {
|
||||
void decodeGeo(String address);
|
||||
//获取定位缓存
|
||||
void getLocation();
|
||||
//获取天气缓存
|
||||
void getWeatherCache();
|
||||
//获取天气
|
||||
void getWeather(String locationTude);
|
||||
}
|
||||
|
||||
public interface WeatherView extends BaseView {
|
||||
void setGeo(MapGeoResult mapGeoresult);
|
||||
//设置定位缓存
|
||||
void setLocation(String location);
|
||||
//设置天气缓存
|
||||
void setWeatherCache(WeatherDailyBean weatherCache);
|
||||
//设置天气
|
||||
void setWeather(WeatherDailyBean weather);
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
package com.uiuios.aios.activity.weather;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.qweather.sdk.view.QWeather;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.bean.MapGeoBean;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* MainActivity和MainService 的 Presenter
|
||||
*
|
||||
* @author jgy02
|
||||
*/
|
||||
public class WeatherPresenter implements WeatherContact.Presenter {
|
||||
private static final String TAG = WeatherPresenter.class.getSimpleName();
|
||||
public static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING";
|
||||
private WeatherContact.WeatherView mView;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
WeatherPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "WeatherPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull WeatherContact.WeatherView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void decodeGeo(String address) {
|
||||
Log.e(TAG, "decodeGeo: " + address);
|
||||
NetInterfaceManager.getInstance().getGeoObservable(address)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<MapGeoBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("decodeGeo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull MapGeoBean mapGeoBean) {
|
||||
Log.e("decodeGeo", "onNext: " + mapGeoBean);
|
||||
if (mapGeoBean.getStatus() == 0) {
|
||||
mView.setGeo(mapGeoBean.getResult());
|
||||
} else {
|
||||
mView.setGeo(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("decodeGeo", "onError: " + e.getMessage());
|
||||
mView.setGeo(null);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("decodeGeo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLocation() {
|
||||
String location = RemoteManager.getInstance().getDistrict();
|
||||
mView.setLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWeatherCache() {
|
||||
// TODO: 2022/1/21 读取json,反序列化,排序
|
||||
String jsonString = mMMKV.decodeString(WEATHER_DAILY_KEY, "");
|
||||
Type type = new TypeToken<WeatherDailyBean>() {
|
||||
}.getType();
|
||||
WeatherDailyBean weatherDailyBean = new Gson().fromJson(jsonString, type);
|
||||
mView.setWeatherCache(weatherDailyBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWeather(String locationTude) {
|
||||
QWeather.getWeather7D(mContext, locationTude, new QWeather.OnResultWeatherDailyListener() {
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
Log.e("getWeather", "onError: " + throwable.getMessage());
|
||||
if (mView != null) {
|
||||
mView.setWeather(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WeatherDailyBean weatherDailyBean) {
|
||||
String jsonString = new Gson().toJson(weatherDailyBean);
|
||||
Log.d("getWeather", "onSuccess: " + jsonString);
|
||||
mMMKV.encode(WEATHER_DAILY_KEY, jsonString);
|
||||
if (mView != null) {
|
||||
mView.setWeather(weatherDailyBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package com.uiuios.aios.activity.weather;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.qweather.sdk.bean.base.Lang;
|
||||
import com.qweather.sdk.bean.base.Unit;
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||
import com.qweather.sdk.view.QWeather;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.base.mvvm.BaseViewModel;
|
||||
import com.uiuios.aios.bean.JsonBean;
|
||||
import com.uiuios.aios.bean.MapGeoBean;
|
||||
import com.uiuios.aios.bean.MapGeoResult;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.databinding.ActivityWeatherBinding;
|
||||
import com.uiuios.aios.gson.GetJsonDataUtil;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class WeatherViewModel extends BaseViewModel<ActivityWeatherBinding> {
|
||||
private static final String TAG = WeatherViewModel.class.getSimpleName();
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
@Override
|
||||
public ActivityWeatherBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
private MutableLiveData<List<JsonBean>> mOptions1ItemsData = new MutableLiveData<>();
|
||||
private MutableLiveData<ArrayList<ArrayList<String>>> mOptions2ItemsData = new MutableLiveData<>();
|
||||
private MutableLiveData<ArrayList<ArrayList<ArrayList<String>>>> mOptions3ItemsData = new MutableLiveData<>();
|
||||
private MutableLiveData<Boolean> mBooleanData = new MutableLiveData<>();
|
||||
|
||||
|
||||
public MutableLiveData<List<JsonBean>> getOptions1ItemsData() {
|
||||
return mOptions1ItemsData;
|
||||
}
|
||||
|
||||
public MutableLiveData<ArrayList<ArrayList<String>>> getOptions2ItemsData() {
|
||||
return mOptions2ItemsData;
|
||||
}
|
||||
|
||||
public MutableLiveData<ArrayList<ArrayList<ArrayList<String>>>> getOptions3ItemsData() {
|
||||
return mOptions3ItemsData;
|
||||
}
|
||||
|
||||
public MutableLiveData<Boolean> getBooleanData() {
|
||||
return mBooleanData;
|
||||
}
|
||||
|
||||
private MutableLiveData<MapGeoResult> mGeoResultData = new MutableLiveData<>();
|
||||
private MutableLiveData<String> mLocationData = new MutableLiveData<>();
|
||||
private MutableLiveData<WeatherNowBean> mWeatherNowData = new MutableLiveData<>();
|
||||
private MutableLiveData<WeatherDailyBean> mWeatherDailyData = new MutableLiveData<>();
|
||||
|
||||
|
||||
public MutableLiveData<MapGeoResult> getGeoResultData() {
|
||||
return mGeoResultData;
|
||||
}
|
||||
|
||||
public MutableLiveData<String> getLocationData() {
|
||||
return mLocationData;
|
||||
}
|
||||
|
||||
public MutableLiveData<WeatherNowBean> getWeatherNowData() {
|
||||
return mWeatherNowData;
|
||||
}
|
||||
|
||||
public MutableLiveData<WeatherDailyBean> getWeatherDailyData() {
|
||||
return mWeatherDailyData;
|
||||
}
|
||||
|
||||
|
||||
public void loadProvince() {
|
||||
Observable.create(new ObservableOnSubscribe<ArrayList<JsonBean>>() {
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<ArrayList<JsonBean>> emitter) throws Throwable {
|
||||
Log.e("loadProvince", "subscribe: ");
|
||||
String JsonData = new GetJsonDataUtil().getJson(getCtx(), "province.json");//获取assets目录下的json文件数据
|
||||
ArrayList<JsonBean> detail = new ArrayList<>();
|
||||
JSONArray data = new JSONArray(JsonData);
|
||||
Gson gson = new Gson();
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
JsonBean entity = gson.fromJson(data.optJSONObject(i).toString(), JsonBean.class);
|
||||
detail.add(entity);
|
||||
}
|
||||
emitter.onNext(detail);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ArrayList<JsonBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("loadProvince", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull ArrayList<JsonBean> jsonBeans) {
|
||||
Log.e("loadProvince", "onNext: ");
|
||||
mOptions1ItemsData.setValue(jsonBeans);
|
||||
|
||||
ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
|
||||
ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < jsonBeans.size(); i++) {//遍历省份
|
||||
ArrayList<String> cityList = new ArrayList<>();//该省的城市列表(第二级)
|
||||
ArrayList<ArrayList<String>> province_AreaList = new ArrayList<>();//该省的所有地区列表(第三极)
|
||||
|
||||
for (int c = 0; c < jsonBeans.get(i).getCityList().size(); c++) {//遍历该省份的所有城市
|
||||
String cityName = jsonBeans.get(i).getCityList().get(c).getName();
|
||||
cityList.add(cityName);//添加城市
|
||||
ArrayList<String> city_AreaList = new ArrayList<>();//该城市的所有地区列表
|
||||
|
||||
//如果无地区数据,建议添加空字符串,防止数据为null 导致三个选项长度不匹配造成崩溃
|
||||
/*if (jsonBean.get(i).getCityList().get(c).getArea() == null
|
||||
|| jsonBean.get(i).getCityList().get(c).getArea().size() == 0) {
|
||||
city_AreaList.add("");
|
||||
} else {
|
||||
city_AreaList.addAll(jsonBean.get(i).getCityList().get(c).getArea());
|
||||
}*/
|
||||
city_AreaList.addAll(jsonBeans.get(i).getCityList().get(c).getArea());
|
||||
province_AreaList.add(city_AreaList);//添加该省所有地区数据
|
||||
}
|
||||
options2Items.add(cityList);
|
||||
/**
|
||||
* 添加地区数据
|
||||
*/
|
||||
options3Items.add(province_AreaList);
|
||||
}
|
||||
mOptions2ItemsData.setValue(options2Items);
|
||||
mOptions3ItemsData.setValue(options3Items);
|
||||
mBooleanData.setValue(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("loadProvince", "onError: " + e.getMessage());
|
||||
mBooleanData.setValue(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("loadProvince", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void decodeGeo(String address) {
|
||||
Log.e(TAG, "decodeGeo: " + address);
|
||||
NetInterfaceManager.getInstance().getGeoObservable(address)
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<MapGeoBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("decodeGeo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull MapGeoBean mapGeoBean) {
|
||||
Log.e("decodeGeo", "onNext: " + mapGeoBean);
|
||||
if (mapGeoBean.getStatus() == 0) {
|
||||
mGeoResultData.setValue(mapGeoBean.getResult());
|
||||
} else {
|
||||
mGeoResultData.setValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("decodeGeo", "onError: " + e.getMessage());
|
||||
mGeoResultData.setValue(null);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("decodeGeo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void getWeatherCache() {
|
||||
Log.e(TAG, "getWeatherCache: ");
|
||||
String nowJsonString = mMMKV.decodeString(CommonConfig.WEATHER_NOW_KEY, "");
|
||||
Type nowType = new TypeToken<WeatherNowBean>() {
|
||||
}.getType();
|
||||
try {
|
||||
WeatherNowBean weatherNowBean = new Gson().fromJson(nowJsonString, nowType);
|
||||
mWeatherNowData.setValue(weatherNowBean);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getWeatherCache: now = " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
String jsonString = mMMKV.decodeString(CommonConfig.WEATHER_DAILY_KEY, "");
|
||||
Type type = new TypeToken<WeatherDailyBean>() {
|
||||
}.getType();
|
||||
try {
|
||||
WeatherDailyBean weatherDailyBean = new Gson().fromJson(jsonString, type);
|
||||
mWeatherDailyData.setValue(weatherDailyBean);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getWeatherCache: Daily = " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void getLocation() {
|
||||
String location = RemoteManager.getInstance().getDistrict();
|
||||
mLocationData.setValue(location);
|
||||
}
|
||||
|
||||
public void getWeatherNow(String locationTude) {
|
||||
Log.e(TAG, "getweather: " + locationTude);
|
||||
/**
|
||||
* 实况天气数据
|
||||
* @param location 所查询的地区,可通过该地区名称、ID、IP和经纬度进行查询经纬度格式:经度,纬度
|
||||
* (英文,分隔,十进制格式,北纬东经为正,南纬西经为负)
|
||||
* @param lang (选填)多语言,可以不使用该参数,默认为简体中文
|
||||
* @param unit (选填)单位选择,公制(m)或英制(i),默认为公制单位
|
||||
* @param listener 网络访问结果回调
|
||||
*/
|
||||
QWeather.getWeatherNow(getCtx(), locationTude, Lang.ZH_HANS, Unit.METRIC, new QWeather.OnResultWeatherNowListener() {
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getWeatherNow", "onError: " + e);
|
||||
mWeatherNowData.setValue(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WeatherNowBean weatherBean) {
|
||||
Log.d("getWeatherNow", "onSuccess: " + new Gson().toJson(weatherBean));
|
||||
String jsonString = new Gson().toJson(weatherBean);
|
||||
mMMKV.encode(CommonConfig.WEATHER_NOW_KEY, jsonString);
|
||||
mWeatherNowData.setValue(weatherBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getWeather7D(String locationTude) {
|
||||
QWeather.getWeather7D(getCtx(), locationTude, new QWeather.OnResultWeatherDailyListener() {
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
Log.e("getWeather", "onError: " + throwable.getMessage());
|
||||
// mWeatherDailyData.setValue(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WeatherDailyBean weatherDailyBean) {
|
||||
String jsonString = new Gson().toJson(weatherDailyBean);
|
||||
Log.d("getWeather", "onSuccess: " + jsonString);
|
||||
mMMKV.encode(CommonConfig.WEATHER_DAILY_KEY, jsonString);
|
||||
mWeatherDailyData.setValue(weatherDailyBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiuios.aios.activity.wifi;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.base.mvp.BasePresenter;
|
||||
import com.uiuios.aios.base.mvp.BaseView;
|
||||
import com.uiuios.aios.bean.WiFiInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,7 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.AvailableWiFiAdapter;
|
||||
import com.uiuios.aios.adapter.SavedWiFiAdapter;
|
||||
import com.uiuios.aios.base.BaseLightActivity;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.bean.WiFiInfo;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
import com.uiuios.aios.view.HorizontalItemDecoration;
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class WiFiManagerActivity extends BaseLightActivity implements WiFiContact.WiFiView {
|
||||
public class WiFiManagerActivity extends BaseActivity implements WiFiContact.WiFiView {
|
||||
|
||||
|
||||
@BindView(R.id.iv_close)
|
||||
@@ -49,12 +49,22 @@ public class WiFiManagerActivity extends BaseLightActivity implements WiFiContac
|
||||
return R.layout.activity_wifi_manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new WiFiPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
|
||||
iv_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user