version:1.7
fix: update:增加抢购,修复bug
This commit is contained in:
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -127,7 +128,7 @@ public class AppListFragment extends BaseFragment {
|
||||
ConstraintLayout constraintLayout = view.findViewById(R.id.btn_booktag);
|
||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||
if (desktopIcon != null) {
|
||||
String pkg =desktopIcon.getPackageName();
|
||||
String pkg = desktopIcon.getPackageName();
|
||||
Log.e(TAG, "getView: " + pkg);
|
||||
int i = IconUtils.appClassNameList.indexOf(pkg);
|
||||
if (i != -1) {
|
||||
@@ -172,6 +173,29 @@ public class AppListFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onItemClick(View v, int index) {
|
||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||
if (desktopIcon != null) {
|
||||
Log.e(TAG, "onItemClick: " + desktopIcon.getPackageName());
|
||||
switch (desktopIcon.getPackageName()) {
|
||||
case "aios.exit":
|
||||
case "com.android.dialer":
|
||||
int qch_call_forbid = Settings.System.getInt(mContext.getContentResolver(), "aole_call_forbid", 0);
|
||||
if (qch_call_forbid == 1) {
|
||||
ToastUtil.show("电话功能被禁用");
|
||||
return;
|
||||
} else {
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
SendRunningApp(getActivity());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
SendRunningApp(getActivity());
|
||||
}
|
||||
}
|
||||
if (desktopIcon != null) {
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
@@ -183,6 +207,7 @@ public class AppListFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onLongClick(View v, int index) {
|
||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||
if (desktopIcon == null) return;
|
||||
String pkg = desktopIcon.getPackageName();
|
||||
Log.e(TAG, "onLongClick: " + pkg);
|
||||
switch (pkg) {
|
||||
|
||||
@@ -197,7 +197,7 @@ public class ViewPager2Adapter extends FragmentStateAdapter {
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Fragment getItem(int position) {
|
||||
// public SecondFragment getItem(int position) {
|
||||
// return mFragmentList.get(position);
|
||||
// }
|
||||
//
|
||||
|
||||
@@ -7,7 +7,10 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
@@ -49,6 +52,7 @@ import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.ControlActivity;
|
||||
import com.uiuios.aios.activity.EmergencyActivity;
|
||||
import com.uiuios.aios.activity.QuickAppActivity;
|
||||
import com.uiuios.aios.activity.alarm.AlarmClockActivity;
|
||||
import com.uiuios.aios.activity.code.HealthCodeActivity;
|
||||
import com.uiuios.aios.activity.contact.ContactActivity;
|
||||
@@ -113,8 +117,15 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
ConstraintLayout cl_contact;
|
||||
@BindView(R.id.cl_ai)
|
||||
ConstraintLayout cl_ai;
|
||||
@BindView(R.id.cl_app)
|
||||
ConstraintLayout cl_app;
|
||||
@BindView(R.id.cl_appstore)
|
||||
ConstraintLayout cl_appstore;
|
||||
@BindView(R.id.cl_wifi)
|
||||
ConstraintLayout cl_wifi;
|
||||
@BindView(R.id.cl_activation)
|
||||
ConstraintLayout cl_activation;
|
||||
|
||||
// @BindView(R.id.cl_exit)
|
||||
// ConstraintLayout cl_exit;
|
||||
@BindView(R.id.cl_control)
|
||||
@@ -123,8 +134,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
// ConstraintLayout cl_battery;
|
||||
// @BindView(R.id.tv_add)
|
||||
// TextView tv_add;
|
||||
// @BindView(R.id.tv_battery)
|
||||
// TextView tv_battery;
|
||||
@BindView(R.id.tv_battery)
|
||||
TextView tv_battery;
|
||||
@BindView(R.id.tv_location)
|
||||
TextView tv_location;
|
||||
@BindView(R.id.tv_weather)
|
||||
@@ -141,18 +152,23 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
RecyclerView rv_noti;
|
||||
// @BindView(R.id.rv_clock)
|
||||
// RecyclerView rv_clock;
|
||||
// @BindView(R.id.wifi_ssid)
|
||||
// TextView wifi_ssid;
|
||||
@BindView(R.id.iv_wifi)
|
||||
ImageView iv_wifi;
|
||||
@BindView(R.id.wifi_ssid)
|
||||
TextView wifi_ssid;
|
||||
@BindView(R.id.iv_sos)
|
||||
ImageView iv_sos;
|
||||
@BindView(R.id.rv_sos)
|
||||
RecyclerView rv_sos;
|
||||
@BindView(R.id.iv_note_nodata)
|
||||
ImageView iv_note_nodata;
|
||||
TextView iv_note_nodata;
|
||||
// @BindView(R.id.iv_head)
|
||||
// ImageView iv_head;
|
||||
// @BindView(R.id.tv_name)
|
||||
// TextView tv_name;
|
||||
@BindView(R.id.tv_name)
|
||||
TextView tv_name;
|
||||
@BindView(R.id.iv_app)
|
||||
ImageView iv_app;
|
||||
|
||||
|
||||
private String TAG = CustomFragment.class.getSimpleName();
|
||||
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
||||
@@ -219,24 +235,31 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
// wifi_ssid.setText("WiFi未连接");
|
||||
wifi_ssid.setText("WiFi未连接");
|
||||
iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_disconnect));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
if (networkType == NetworkUtils.NetworkType.NETWORK_WIFI) {
|
||||
// wifi_ssid.setText(getConnectWifiSsid());
|
||||
iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_connect));
|
||||
if (isNetworkOnline1()) {
|
||||
wifi_ssid.setText(getConnectWifiSsid() + "(已连接)");
|
||||
} else {
|
||||
wifi_ssid.setText("(未连接)");
|
||||
}
|
||||
} else {
|
||||
// wifi_ssid.setText("WiFi未连接");
|
||||
wifi_ssid.setText("WiFi未连接");
|
||||
iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_disconnect));
|
||||
}
|
||||
}
|
||||
|
||||
private String getConnectWifiSsid() {
|
||||
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
Log.d("wifiInfo", wifiInfo.toString());
|
||||
Log.d("SSID", wifiInfo.getSSID());
|
||||
return wifiInfo.getSSID();
|
||||
Log.e("wifiInfo", wifiInfo.toString());
|
||||
Log.e("SSID", wifiInfo.getSSID());
|
||||
return wifiInfo.getSSID().replace("\"", "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,6 +273,18 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
return mWifiInfo.isConnected();
|
||||
}
|
||||
|
||||
public boolean isNetworkOnline1() {
|
||||
boolean isOnline = false;
|
||||
try {
|
||||
ConnectivityManager manager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkCapabilities capabilities = manager.getNetworkCapabilities(manager.getActiveNetwork()); // need ACCESS_NETWORK_STATE permission
|
||||
isOnline = capabilities != null && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
private void registerAlarmClockReceiver() {
|
||||
if (null == mAlarmClockReceiver) {
|
||||
mAlarmClockReceiver = new AlarmClockReceiver();
|
||||
@@ -306,7 +341,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
||||
int elec = (level * 100) / scale;
|
||||
Log.i(TAG, "electricity:=" + elec + "%");
|
||||
// tv_battery.setText(elec + "%");
|
||||
tv_battery.setText(elec + "%");
|
||||
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)
|
||||
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|
||||
|| Intent.ACTION_BATTERY_LOW.equals(action)
|
||||
@@ -358,6 +393,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
||||
registerBatteryReceiver();
|
||||
registerAlarmClockReceiver();
|
||||
wifi_ssid.requestFocus();
|
||||
|
||||
mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
if (Settings.Global.getInt(mCRv, "is_aihealth", 0) == 1) {
|
||||
cl_appstore.setVisibility(View.GONE);
|
||||
@@ -401,9 +438,15 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
rv_noti.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
rv_noti.setAdapter(notificationAdapter);
|
||||
if (isWifiConnect()) {
|
||||
// wifi_ssid.setText(getConnectWifiSsid());
|
||||
iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_connect));
|
||||
if (isNetworkOnline1()) {
|
||||
wifi_ssid.setText(getConnectWifiSsid() + "(已连接)");
|
||||
} else {
|
||||
wifi_ssid.setText("(未连接)");
|
||||
}
|
||||
} else {
|
||||
// wifi_ssid.setText("WiFi未连接");
|
||||
wifi_ssid.setText("WiFi未连接");
|
||||
iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_disconnect));
|
||||
}
|
||||
sosNnmberAdapter = new SOSNnmberAdapter();
|
||||
rv_sos.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
@@ -458,12 +501,42 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
openScheme(SchemeUtils.SCHEME_HAND);
|
||||
}
|
||||
});
|
||||
cl_app.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
} else {
|
||||
ApkUtils.openPackage(mContext, quickAppPackagesName);
|
||||
}
|
||||
}
|
||||
});
|
||||
cl_app.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
cl_appstore.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApkUtils.openApp(mContext, "com.uiuios.appstore");
|
||||
}
|
||||
});
|
||||
cl_wifi.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
cl_activation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApkUtils.openPackage(mContext, "com.uiuios.sn");
|
||||
}
|
||||
});
|
||||
// cl_exit.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
@@ -554,11 +627,11 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
NetInterfaceManager.getInstance().getContactList(new NetInterfaceManager.ContactCallback() {
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
if (contactList == null || contactList.size() == 0) {
|
||||
showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
} else {
|
||||
startActivity(new Intent(getActivity(), ContactActivity.class));
|
||||
}
|
||||
// if (contactList == null || contactList.size() == 0) {
|
||||
// showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -568,12 +641,12 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
|
||||
@Override
|
||||
public void setEmpty() {
|
||||
showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
// showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
startActivity(new Intent(mContext, ContactActivity.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -627,6 +700,36 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
// setAlarm();
|
||||
getAlarmClock();
|
||||
setSosNumber();
|
||||
setQuickApp();
|
||||
checkActivation();
|
||||
}
|
||||
|
||||
private void checkActivation() {
|
||||
int activation = Settings.Global.getInt(mContext.getContentResolver(), "uiui_activation", 0);
|
||||
if (activation == 0) {
|
||||
tv_name.setText("未" +
|
||||
"激活");
|
||||
} else {
|
||||
tv_name.setText("已激活");
|
||||
}
|
||||
}
|
||||
|
||||
private String quickAppPackagesName;
|
||||
|
||||
private void setQuickApp() {
|
||||
quickAppPackagesName = mMMKV.getString(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
if (!TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
ApplicationInfo applicationInfo = null;
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
try {
|
||||
applicationInfo = pm.getApplicationInfo(quickAppPackagesName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (applicationInfo != null) {
|
||||
iv_app.setImageDrawable(applicationInfo.loadIcon(pm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openScheme(String uri) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.uiuios.aios.fragment.second;
|
||||
|
||||
import com.uiuios.aios.base.BasePresenter;
|
||||
import com.uiuios.aios.base.BaseView;
|
||||
import com.uiuios.aios.bean.ActivityBean;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SecondContact {
|
||||
public interface Presenter extends BasePresenter<View> {
|
||||
void getGoods();
|
||||
void getArticle();
|
||||
void getActivityList();
|
||||
}
|
||||
|
||||
public interface View extends BaseView {
|
||||
void setGoods(List<GoodsInfo> goodsInfos);
|
||||
void setArticle(List<ArticleInfo> articleInfoList);
|
||||
void setActivityList(List<ActivityBean> activityList);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,33 @@
|
||||
package com.uiuios.aios.fragment;
|
||||
package com.uiuios.aios.fragment.second;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.InfoListActivity;
|
||||
import com.uiuios.aios.activity.SpikeListActivity;
|
||||
import com.uiuios.aios.adapter.ActivityAdapter;
|
||||
import com.uiuios.aios.adapter.ArticleAdapter;
|
||||
import com.uiuios.aios.adapter.GoodsAdapter;
|
||||
import com.uiuios.aios.base.BaseFragment;
|
||||
import com.uiuios.aios.bean.ActivityBean;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.DemandBean;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
@@ -37,31 +38,15 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* A simple {@link androidx.fragment.app.Fragment} subclass.
|
||||
* Use the {@link SecondFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
public class SecondFragment extends BaseFragment implements SecondContact.View, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = SecondFragment.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.iv_img)
|
||||
ImageView iv_img;
|
||||
@BindView(R.id.tv_goods_name)
|
||||
TextView tv_goods_name;
|
||||
@BindView(R.id.tv_goods_desc)
|
||||
TextView tv_goods_desc;
|
||||
@BindView(R.id.tv_buying_price)
|
||||
TextView tv_buying_price;
|
||||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.tv_snapup)
|
||||
TextView tv_snapup;
|
||||
|
||||
@BindView(R.id.iv_aimg)
|
||||
ImageView iv_aimg;
|
||||
@BindView(R.id.tv_title)
|
||||
@@ -105,8 +90,8 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
|
||||
@BindView(R.id.cl_demand)
|
||||
ConstraintLayout cl_demand;
|
||||
@BindView(R.id.cl1)
|
||||
ConstraintLayout cl1;
|
||||
// @BindView(R.id.cl1)
|
||||
// ConstraintLayout cl1;
|
||||
@BindView(R.id.cl2)
|
||||
ConstraintLayout cl2;
|
||||
@BindView(R.id.cl3)
|
||||
@@ -114,6 +99,14 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
@BindView(R.id.cl4)
|
||||
ConstraintLayout cl4;
|
||||
|
||||
@BindView(R.id.rv_goods)
|
||||
RecyclerView rv_goods;
|
||||
@BindView(R.id.rv_article)
|
||||
RecyclerView rv_article;
|
||||
@BindView(R.id.rv_activity)
|
||||
RecyclerView rv_activity;
|
||||
|
||||
|
||||
@BindView(R.id.nv_pic)
|
||||
NiceImageView nv_pic;
|
||||
@BindView(R.id.tv_like)
|
||||
@@ -121,9 +114,19 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
@BindView(R.id.tv_comment)
|
||||
TextView tv_comment;
|
||||
|
||||
private View rootView;
|
||||
@BindView(R.id.tv_spike_more)
|
||||
TextView tv_spike_more;
|
||||
@BindView(R.id.tv_info_more)
|
||||
TextView tv_info_more;
|
||||
|
||||
private android.view.View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
private SecondPresenter mPresenter;
|
||||
|
||||
private GoodsAdapter mGoodsAdapter;
|
||||
private ArticleAdapter mArticleAdapter;
|
||||
private ActivityAdapter mActivityAdapter;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -158,12 +161,12 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static SecondFragment newInstance(String param1, String param2) {
|
||||
SecondFragment fragment = new SecondFragment();
|
||||
SecondFragment secondFragment = new SecondFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
secondFragment.setArguments(args);
|
||||
return secondFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,22 +180,63 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
rootView = inflater.inflate(R.layout.fragment_second, container, false);
|
||||
mContext = rootView.getContext();
|
||||
mCRv = mContext.getContentResolver();
|
||||
mPresenter = new SecondPresenter(mContext);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mGoodsAdapter = new GoodsAdapter();
|
||||
mArticleAdapter = new ArticleAdapter();
|
||||
mActivityAdapter = new ActivityAdapter();
|
||||
|
||||
rv_goods.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
rv_goods.setAdapter(mGoodsAdapter);
|
||||
rv_article.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
rv_article.setAdapter(mArticleAdapter);
|
||||
rv_activity.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
rv_activity.setAdapter(mActivityAdapter);
|
||||
|
||||
cl_activity.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View view) {
|
||||
openApp(0);
|
||||
}
|
||||
});
|
||||
cl_demand.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View view) {
|
||||
openApp(1);
|
||||
}
|
||||
});
|
||||
tv_spike_more.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(mContext, SpikeListActivity.class));
|
||||
}
|
||||
});
|
||||
tv_info_more.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(mContext, InfoListActivity.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
getGoods();
|
||||
getArticle();
|
||||
getActivityList();
|
||||
mPresenter.getGoods();
|
||||
mPresenter.getArticle();
|
||||
mPresenter.getActivityList();
|
||||
getDemandList();
|
||||
}
|
||||
|
||||
@@ -206,16 +250,16 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
NetInterfaceManager.getInstance().getDemandList(true, lifecycleSubject, new NetInterfaceManager.DemandListCallback() {
|
||||
@Override
|
||||
public void setDemandList(List<DemandBean> demandBeans) {
|
||||
cl4.setVisibility(View.VISIBLE);
|
||||
iv4.setVisibility(View.GONE);
|
||||
cl4.setVisibility(android.view.View.VISIBLE);
|
||||
iv4.setVisibility(android.view.View.GONE);
|
||||
DemandBean demandBean = demandBeans.get(0);
|
||||
setDemand(demandBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
cl4.setVisibility(View.GONE);
|
||||
iv4.setVisibility(View.VISIBLE);
|
||||
cl4.setVisibility(android.view.View.GONE);
|
||||
iv4.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,34 +283,6 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
tv_address_d.setText(demandBean.getAddress());
|
||||
}
|
||||
|
||||
private void getActivityList() {
|
||||
NetInterfaceManager.getInstance().getActivityList(true, lifecycleSubject, new NetInterfaceManager.ActivitiesListCallback() {
|
||||
@Override
|
||||
public void setActivitiesList(List<ActivityBean> activityBeans) {
|
||||
cl3.setVisibility(View.VISIBLE);
|
||||
iv3.setVisibility(View.GONE);
|
||||
ActivityBean activityBean = activityBeans.get(0);
|
||||
setActivity(activityBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
cl3.setVisibility(View.GONE);
|
||||
iv3.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setActivity(ActivityBean activity) {
|
||||
Glide.with(iv_avatar_a).load(activity.getAvatar()).error(getResources().getDrawable(R.drawable.default_head)).into(iv_avatar_a);
|
||||
tv_title_a.setText(activity.getName());
|
||||
@@ -287,21 +303,6 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
return time;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
cl_activity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openApp(0);
|
||||
}
|
||||
});
|
||||
cl_demand.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openApp(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openApp(int position) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
@@ -316,95 +317,37 @@ public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetwo
|
||||
}
|
||||
}
|
||||
|
||||
private void getGoods() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getGoods", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<GoodsInfo>> listBaseResponse) {
|
||||
Log.e("getGoods", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
cl1.setVisibility(View.VISIBLE);
|
||||
iv1.setVisibility(View.GONE);
|
||||
List<GoodsInfo> goodsInfoList = listBaseResponse.data;
|
||||
if (goodsInfoList != null && goodsInfoList.size() != 0) {
|
||||
GoodsInfo goodsInfo = goodsInfoList.get(0);
|
||||
setGoodsInfo(goodsInfo);
|
||||
}
|
||||
} else {
|
||||
cl1.setVisibility(View.GONE);
|
||||
iv1.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getGoods", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getGoods", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void setGoods(List<GoodsInfo> goodsInfos) {
|
||||
if (goodsInfos != null && goodsInfos.size() != 0) {
|
||||
iv1.setVisibility(android.view.View.GONE);
|
||||
mGoodsAdapter.setGoodsInfoList(goodsInfos);
|
||||
} else {
|
||||
iv1.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setGoodsInfo(GoodsInfo goodsInfo) {
|
||||
Glide.with(iv_img).load(goodsInfo.getImg()).into(iv_img);
|
||||
tv_goods_name.setText(goodsInfo.getGoods_name());
|
||||
tv_goods_desc.setText(goodsInfo.getGoods_desc());
|
||||
tv_buying_price.setText(String.valueOf(goodsInfo.getBuying_price()));
|
||||
@Override
|
||||
public void setArticle(List<ArticleInfo> articleInfoList) {
|
||||
if (articleInfoList != null && articleInfoList.size() != 0) {
|
||||
// cl2.setVisibility(View.VISIBLE);
|
||||
iv2.setVisibility(android.view.View.GONE);
|
||||
mArticleAdapter.setArticleBeanList(articleInfoList);
|
||||
} else {
|
||||
// cl2.setVisibility(View.GONE);
|
||||
iv2.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void getArticle() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ArticleInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ArticleInfo>> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
cl2.setVisibility(View.VISIBLE);
|
||||
iv2.setVisibility(View.GONE);
|
||||
List<ArticleInfo> articleInfos = listBaseResponse.data;
|
||||
if (articleInfos != null && articleInfos.size() != 0) {
|
||||
ArticleInfo articleInfo = articleInfos.get(0);
|
||||
setArticleInfo(articleInfo);
|
||||
}
|
||||
} else {
|
||||
cl2.setVisibility(View.GONE);
|
||||
iv2.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getArticle", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getArticle", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void setActivityList(List<ActivityBean> activityList) {
|
||||
if (activityList != null && activityList.size() != 0) {
|
||||
// cl3.setVisibility(android.view.View.VISIBLE);
|
||||
iv3.setVisibility(android.view.View.GONE);
|
||||
mActivityAdapter.setActivityBeans(activityList);
|
||||
} else {
|
||||
// cl3.setVisibility(android.view.View.GONE);
|
||||
iv3.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setArticleInfo(ArticleInfo articleInfo) {
|
||||
Glide.with(iv_aimg).load(articleInfo.getImg()).into(iv_aimg);
|
||||
tv_title.setText(articleInfo.getTitle());
|
||||
tv_content.setText(articleInfo.getContent());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.uiuios.aios.fragment.second;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiuios.aios.bean.ActivityBean;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
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;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class SecondPresenter implements SecondContact.Presenter {
|
||||
|
||||
private static final String TAG = SecondPresenter.class.getSimpleName();
|
||||
private Context mContext;
|
||||
private SecondContact.View mView;
|
||||
|
||||
public SecondPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
private BehaviorSubject<FragmentEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<FragmentEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<FragmentEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull SecondContact.View view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGoods() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getGoods", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<GoodsInfo>> listBaseResponse) {
|
||||
Log.e("getGoods", "onNext: " + listBaseResponse);
|
||||
List<GoodsInfo> goodsInfos = listBaseResponse.data;
|
||||
mView.setGoods(goodsInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getGoods", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getGoods", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getArticle() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ArticleInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ArticleInfo>> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
mView.setArticle(listBaseResponse.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getArticle", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getArticle", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getActivityList() {
|
||||
NetInterfaceManager.getInstance().getActivityList(true, getLifecycle(), new NetInterfaceManager.ActivitiesListCallback() {
|
||||
@Override
|
||||
public void setActivitiesList(List<ActivityBean> activityBeans) {
|
||||
mView.setActivityList(activityBeans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
mView.setActivityList(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user