version:1.7
fix: update:增加抢购,修复bug
This commit is contained in:
@@ -782,7 +782,7 @@ public class ControlActivity extends AppCompatActivity {
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(brightness, 1, 255);
|
||||
Log.e(TAG, "getHardware: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
tv_brightness.setText(percentage + "%");
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
Log.e(TAG, "getHardware: percentage = " + percentage);
|
||||
seekbar_brightness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
@@ -793,7 +793,7 @@ public class ControlActivity extends AppCompatActivity {
|
||||
Log.e(TAG, "onProgressChanged: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
Log.e(TAG, "onProgressChanged: percentage = " + percentage);
|
||||
tv_brightness.setText(percentage + "%");
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
119
app/src/main/java/com/uiuios/aios/activity/DetailsActivity.java
Normal file
119
app/src/main/java/com/uiuios/aios/activity/DetailsActivity.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class DetailsActivity extends AppCompatActivity {
|
||||
@BindView(R.id.iv_details)
|
||||
ImageView iv_details;
|
||||
@BindView(R.id.iv_exit)
|
||||
ImageView iv_exit;
|
||||
@BindView(R.id.tv_buying_price)
|
||||
TextView tv_buying_price;
|
||||
@BindView(R.id.tv_original_price)
|
||||
TextView tv_original_price;
|
||||
@BindView(R.id.tv_stock)
|
||||
TextView tv_stock;
|
||||
@BindView(R.id.tv_subsidy)
|
||||
TextView tv_subsidy;
|
||||
@BindView(R.id.tv_price)
|
||||
TextView tv_price;
|
||||
@BindView(R.id.tv_title)
|
||||
TextView tv_title;
|
||||
@BindView(R.id.tv_details)
|
||||
TextView tv_details;
|
||||
@BindView(R.id.tv_certified)
|
||||
TextView tv_certified;
|
||||
@BindView(R.id.tv_ship)
|
||||
TextView tv_ship;
|
||||
@BindView(R.id.tv_insurance)
|
||||
TextView tv_insurance;
|
||||
@BindView(R.id.tv_sale)
|
||||
TextView tv_sale;
|
||||
@BindView(R.id.tv_type)
|
||||
TextView tv_type;
|
||||
@BindView(R.id.ll_buy)
|
||||
LinearLayout ll_buy;
|
||||
|
||||
private GoodsInfo mGoodsInfo;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
setContentView(R.layout.activity_details);
|
||||
ButterKnife.bind(this);
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) return;
|
||||
GoodsInfo goodsInfo = (GoodsInfo) intent.getSerializableExtra("GoodsInfo");
|
||||
if (goodsInfo == null) return;
|
||||
mGoodsInfo = goodsInfo;
|
||||
Glide.with(iv_details).load(mGoodsInfo.getDetails_img()).into(iv_details);
|
||||
ViewTreeObserver observer = iv_details.getViewTreeObserver();
|
||||
observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
ViewGroup.LayoutParams layoutParams = iv_details.getLayoutParams();
|
||||
int width = iv_details.getWidth();
|
||||
layoutParams.height = width;
|
||||
iv_details.setLayoutParams(layoutParams);
|
||||
}
|
||||
});
|
||||
iv_exit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
tv_stock.setText("库存:" + mGoodsInfo.getStock());
|
||||
tv_subsidy.setText("官方补贴" + (mGoodsInfo.getOriginal_price() - mGoodsInfo.getBuying_price()));
|
||||
tv_buying_price.setText("¥" + mGoodsInfo.getBuying_price());
|
||||
tv_original_price.setText("原价:" + mGoodsInfo.getOriginal_price() + "元");
|
||||
tv_price.setText("抢购:" + mGoodsInfo.getBuying_price() + "元");
|
||||
tv_title.setText(mGoodsInfo.getGoods_name());
|
||||
tv_details.setText(mGoodsInfo.getGoods_desc());
|
||||
tv_certified.setText(mGoodsInfo.getEnsure());
|
||||
tv_ship.setText(mGoodsInfo.getDeliver_goods());
|
||||
tv_insurance.setText(mGoodsInfo.getInsure());
|
||||
tv_sale.setText(mGoodsInfo.getAfter_sales());
|
||||
ll_buy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Uri uri = Uri.parse(goodsInfo.getJump_url());
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
tv_type.setText(mGoodsInfo.getType());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
|
||||
public class InfoListActivity extends BaseActivity {
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_info_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.AppSelectedAdapter;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.bean.AppSelectBean;
|
||||
import com.uiuios.aios.view.GridSpaceItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class QuickAppActivity extends BaseActivity {
|
||||
public static final String QUICK_APP_KEY = "QuickAppKey";
|
||||
private AppSelectedAdapter mAppSelectedAdapter;
|
||||
|
||||
@BindView(R.id.rv_goods)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_quick_app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mAppSelectedAdapter = new AppSelectedAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
recyclerView.addItemDecoration(new GridSpaceItemDecoration(3,50,50));
|
||||
} else {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
recyclerView.addItemDecoration(new GridSpaceItemDecoration(2,50,50));
|
||||
}
|
||||
recyclerView.setAdapter(mAppSelectedAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mAppSelectedAdapter.setAppSelectBeans(getPackageList());
|
||||
}
|
||||
|
||||
boolean listThirdParty = true;
|
||||
|
||||
private List<AppSelectBean> getPackageList() {
|
||||
PackageManager pm = getPackageManager();
|
||||
List<AppSelectBean> appSelectBeanList = new ArrayList<>();
|
||||
List<PackageInfo> applicationInfos = pm.getInstalledPackages(0);
|
||||
for (PackageInfo packageInfo : applicationInfos) {
|
||||
if (BuildConfig.APPLICATION_ID.equals(packageInfo.applicationInfo.packageName)) {
|
||||
continue;
|
||||
}
|
||||
final boolean isSystem = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||
if (!listThirdParty || !isSystem) {
|
||||
AppSelectBean appSelectBean = new AppSelectBean(packageInfo.applicationInfo.loadLabel(pm).toString(), packageInfo.applicationInfo.packageName, packageInfo.applicationInfo.loadIcon(pm));
|
||||
appSelectBeanList.add(appSelectBean);
|
||||
}
|
||||
}
|
||||
return appSelectBeanList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
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.adapter.GoodsAdapter;
|
||||
import com.uiuios.aios.adapter.GoodsListAdapter;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
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;
|
||||
|
||||
public class SpikeListActivity extends BaseActivity {
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.iv1)
|
||||
ImageView iv1;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
private GoodsListAdapter mGoodsAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
return R.layout.activity_spike_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mGoodsAdapter = new GoodsListAdapter();
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setAdapter(mGoodsAdapter);
|
||||
iv_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
getGoodsInfo();
|
||||
}
|
||||
|
||||
private void getGoodsInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.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;
|
||||
if (goodsInfos != null && goodsInfos.size() != 0) {
|
||||
iv1.setVisibility(android.view.View.GONE);
|
||||
mGoodsAdapter.setGoodsInfoList(goodsInfos);
|
||||
} else {
|
||||
iv1.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getGoods", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getGoods", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import cn.jzvd.Jzvd;
|
||||
public class AlarmClockActivity extends BaseActivity implements AlarmClockContact.ClockView {
|
||||
private static final String TAG = AlarmClockActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
@BindView(R.id.rv_goods)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
@@ -73,10 +73,15 @@ public class ContactActivity extends BaseActivity implements ContactContact.Cont
|
||||
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
if (contactList != null) {
|
||||
mContactAdapter.setContactList(contactList);
|
||||
if (contactList == null || contactList.size() == 0) {
|
||||
tv_people.setText("暂无数据");
|
||||
} else {
|
||||
tv_people.setText(contactList.size() + "人");
|
||||
}
|
||||
|
||||
Contact contact = new Contact();
|
||||
contact.setName("拨号");
|
||||
contact.setMobile(ContactAdapter.DIALER_PACKAGE);
|
||||
contactList.add(0, contact);
|
||||
mContactAdapter.setContactList(contactList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,19 @@ package com.uiuios.aios.activity.contact;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.Contact;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.network.URLAddress;
|
||||
import com.uiuios.aios.utils.GsonUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
@@ -19,6 +26,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
public class ContactPresenter implements ContactContact.Presenter {
|
||||
private Context mContext;
|
||||
private ContactContact.ContactView mView;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
@@ -58,12 +66,28 @@ public class ContactPresenter implements ContactContact.Presenter {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<Contact>> listBaseResponse) {
|
||||
Log.e("getContactList", "onNext: " + listBaseResponse);
|
||||
mView.setContact(listBaseResponse.data);
|
||||
if (listBaseResponse.code == 200) {
|
||||
mMMKV.putString(URLAddress.GET_MAIL_LIST, GsonUtils.toJsonString(listBaseResponse.data));
|
||||
mView.setContact(listBaseResponse.data);
|
||||
} else {
|
||||
mMMKV.putString(URLAddress.GET_MAIL_LIST, "");
|
||||
mView.setContact(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getContactList", "onError: " + e.getMessage());
|
||||
String jsonString = mMMKV.getString(URLAddress.GET_MAIL_LIST, null);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Contact>>() {
|
||||
}.getType();
|
||||
List<Contact> contacts = gson.fromJson(jsonString, type);
|
||||
if (contacts == null) {
|
||||
mView.setContact(new ArrayList<>());
|
||||
}else {
|
||||
mView.setContact(contacts);
|
||||
}
|
||||
onComplete();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.uiuios.aios.bean.DesktopIcon;
|
||||
import com.uiuios.aios.fragment.AppListFragment;
|
||||
import com.uiuios.aios.base.BaseFragmentPagerAdapter;
|
||||
import com.uiuios.aios.fragment.custom.CustomFragment;
|
||||
import com.uiuios.aios.fragment.SecondFragment;
|
||||
import com.uiuios.aios.fragment.second.SecondFragment;
|
||||
import com.uiuios.aios.service.NotificationService;
|
||||
import com.uiuios.aios.utils.ApkUtils;
|
||||
import com.uiuios.aios.utils.AppUsedTimeUtils;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.bean.ActivityBean;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityAdapter extends RecyclerView.Adapter<ActivityAdapter.Holder> {
|
||||
private static final String TAG = ActivityAdapter.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
private List<ActivityBean> mActivityBeans;
|
||||
|
||||
public void setActivityBeans(List<ActivityBean> list) {
|
||||
this.mActivityBeans = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new ActivityAdapter.Holder(LayoutInflater.from(mContext).inflate(R.layout.item_activity, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
ActivityBean activityBean = mActivityBeans.get(position);
|
||||
Glide.with(holder.iv_img).load(activityBean.getFile()).into(holder.iv_img);
|
||||
holder.tv_location.setText(activityBean.getLocation());
|
||||
holder.tv_desc.setText(getTime(activityBean.getAdd_time()));
|
||||
|
||||
}
|
||||
|
||||
private String getTime(long second) {
|
||||
long ms = second * 1000L;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日");
|
||||
Date date = new Date(ms);
|
||||
String time = sdf.format(date);
|
||||
Log.e(TAG, "getTime: " + time);
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mActivityBeans == null ? 0 : mActivityBeans.size();
|
||||
}
|
||||
|
||||
class Holder extends RecyclerView.ViewHolder {
|
||||
ImageView iv_img;
|
||||
TextView tv_location, tv_desc;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
iv_img = itemView.findViewById(R.id.iv_img);
|
||||
tv_location = itemView.findViewById(R.id.tv_location);
|
||||
tv_desc = itemView.findViewById(R.id.tv_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.QuickAppActivity;
|
||||
import com.uiuios.aios.bean.AppSelectBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.Holder> {
|
||||
|
||||
private Context mContext;
|
||||
private List<AppSelectBean> mAppSelectBeans;
|
||||
private int unselectedStatus = -1;
|
||||
private int selecedPosition = unselectedStatus;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
public void setAppSelectBeans(List<AppSelectBean> appSelectBeanList) {
|
||||
this.mAppSelectBeans = appSelectBeanList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_app_select, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
AppSelectBean appSelectBean = mAppSelectBeans.get(position);
|
||||
holder.iv_icon.setImageDrawable(appSelectBean.getIcon());
|
||||
holder.tv_name.setText(appSelectBean.getAppName());
|
||||
if (selecedPosition == position) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
}
|
||||
holder.iv_select.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (position != selecedPosition) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
selecedPosition = position;
|
||||
mMMKV.putString(QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
selecedPosition = -1;
|
||||
mMMKV.putString(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAppSelectBeans == null ? 0 : mAppSelectBeans.size();
|
||||
}
|
||||
|
||||
static class Holder extends RecyclerView.ViewHolder {
|
||||
ImageView iv_select, iv_icon;
|
||||
TextView tv_name;
|
||||
|
||||
Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
iv_select = itemView.findViewById(R.id.iv_select);
|
||||
iv_icon = itemView.findViewById(R.id.iv_icon);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArticleAdapter extends RecyclerView.Adapter<ArticleAdapter.Holder> {
|
||||
|
||||
private Context mContext;
|
||||
private List<ArticleInfo> mArticleBeanList;
|
||||
|
||||
public void setArticleBeanList(List<ArticleInfo> list) {
|
||||
this.mArticleBeanList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new ArticleAdapter.Holder(LayoutInflater.from(mContext).inflate(R.layout.item_article, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
ArticleInfo articleInfo = mArticleBeanList.get(position);
|
||||
Glide.with(holder.iv_img).load(articleInfo.getImg()).into(holder.iv_img);
|
||||
holder.tv_title.setText(articleInfo.getTitle());
|
||||
holder.tv_content.setText(articleInfo.getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mArticleBeanList == null ? 0 : mArticleBeanList.size();
|
||||
}
|
||||
|
||||
class Holder extends RecyclerView.ViewHolder {
|
||||
NiceImageView iv_img;
|
||||
TextView tv_title, tv_content;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
iv_img = itemView.findViewById(R.id.iv_img);
|
||||
tv_title = itemView.findViewById(R.id.tv_title);
|
||||
tv_content = itemView.findViewById(R.id.tv_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
private List<Contact> mContactList;
|
||||
private Context mContext;
|
||||
|
||||
public static final String DIALER_PACKAGE = "com.android.dialer";
|
||||
|
||||
public void setContactList(List<Contact> contactList) {
|
||||
this.mContactList = contactList;
|
||||
notifyDataSetChanged();
|
||||
@@ -44,7 +46,9 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
public void onClick(View view) {
|
||||
Intent intent1 = new Intent(Intent.ACTION_CALL);
|
||||
String phone = contact.getMobile();
|
||||
if (!TextUtils.isEmpty(phone)) {
|
||||
if (DIALER_PACKAGE.equals(phone)) {
|
||||
mContext.startActivity(new Intent(Intent.ACTION_DIAL));
|
||||
} else if (!TextUtils.isEmpty(phone)) {
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
intent1.setData(data);
|
||||
mContext.startActivity(intent1);
|
||||
@@ -52,22 +56,27 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
|
||||
}
|
||||
});
|
||||
Glide.with(contactHolder.iv_head).load(contact.getAvatar()).error(R.drawable.default_head).into(contactHolder.iv_head);
|
||||
contactHolder.tv_name.setText(contact.getName());
|
||||
contactHolder.tv_phone.setText(contact.getMobile());
|
||||
if (DIALER_PACKAGE.equals(contact.getMobile())) {
|
||||
contactHolder.tv_phone.setText("");
|
||||
Glide.with(contactHolder.iv_head).load(R.drawable.icon_dialer).error(R.drawable.icon_dialer).into(contactHolder.iv_head);
|
||||
} else {
|
||||
contactHolder.tv_phone.setText(contact.getMobile());
|
||||
Glide.with(contactHolder.iv_head).load(contact.getAvatar()).error(R.drawable.default_head).into(contactHolder.iv_head);
|
||||
}
|
||||
int index = position % 3;
|
||||
switch (index) {
|
||||
case 0:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_rain));
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.contact_bg1));
|
||||
break;
|
||||
case 1:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_sun));
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.contact_bg2));
|
||||
break;
|
||||
case 2:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_sunny));
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.contact_bg3));
|
||||
break;
|
||||
default:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_rain));
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.contact_bg1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
92
app/src/main/java/com/uiuios/aios/adapter/GoodsAdapter.java
Normal file
92
app/src/main/java/com/uiuios/aios/adapter/GoodsAdapter.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.DetailsActivity;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GoodsAdapter extends RecyclerView.Adapter<GoodsAdapter.GoodsHolder> {
|
||||
|
||||
private Context mContext;
|
||||
private List<GoodsInfo> goodsInfoList;
|
||||
|
||||
public void setGoodsInfoList(List<GoodsInfo> list) {
|
||||
this.goodsInfoList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GoodsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new GoodsAdapter.GoodsHolder(LayoutInflater.from(mContext).inflate(R.layout.item_goods, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull GoodsHolder holder, int position) {
|
||||
GoodsInfo goodsInfo = goodsInfoList.get(position);
|
||||
if (!TextUtils.isEmpty(goodsInfo.getJump_url())) {
|
||||
// holder.tv_name.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// Uri uri = Uri.parse(goodsInfo.getJump_url());
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
// mContext.startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
Glide.with(holder.iv_goods).load(goodsInfo.getImg()).into(holder.iv_goods);
|
||||
holder.tv_name.setText(goodsInfo.getGoods_name());
|
||||
holder.tv_desc.setText(goodsInfo.getGoods_desc());
|
||||
holder.tv_price.setText("¥" + goodsInfo.getBuying_price());
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mContext, DetailsActivity.class);
|
||||
intent.putExtra("GoodsInfo", goodsInfo);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.tv_type.setText(goodsInfo.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return goodsInfoList == null ? 0 : goodsInfoList.size();
|
||||
}
|
||||
|
||||
static class GoodsHolder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
NiceImageView iv_goods;
|
||||
TextView tv_name, tv_desc, tv_buying_price, tv_price,tv_type;
|
||||
|
||||
public GoodsHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
iv_goods = itemView.findViewById(R.id.iv_img);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_desc = itemView.findViewById(R.id.tv_desc);
|
||||
tv_buying_price = itemView.findViewById(R.id.tv_buying_price);
|
||||
tv_price = itemView.findViewById(R.id.tv_price);
|
||||
tv_type = itemView.findViewById(R.id.tv_type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.DetailsActivity;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GoodsListAdapter extends RecyclerView.Adapter<GoodsListAdapter.GoodsHolder> {
|
||||
|
||||
private Context mContext;
|
||||
private List<GoodsInfo> goodsInfoList;
|
||||
|
||||
public void setGoodsInfoList(List<GoodsInfo> list) {
|
||||
this.goodsInfoList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GoodsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new GoodsListAdapter.GoodsHolder(LayoutInflater.from(mContext).inflate(R.layout.item_goods_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull GoodsHolder holder, int position) {
|
||||
GoodsInfo goodsInfo = goodsInfoList.get(position);
|
||||
if (!TextUtils.isEmpty(goodsInfo.getJump_url())) {
|
||||
// holder.tv_name.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// Uri uri = Uri.parse(goodsInfo.getJump_url());
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
// mContext.startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
Glide.with(holder.iv_goods).load(goodsInfo.getImg()).into(holder.iv_goods);
|
||||
holder.tv_name.setText(goodsInfo.getGoods_name());
|
||||
holder.tv_desc.setText(goodsInfo.getGoods_desc());
|
||||
holder.tv_price.setText("全网低价¥" + goodsInfo.getOriginal_price());
|
||||
holder.tv_buying_price.setText("秒杀价格¥" + goodsInfo.getBuying_price());
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mContext, DetailsActivity.class);
|
||||
intent.putExtra("GoodsInfo", goodsInfo);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.tv_type.setText(goodsInfo.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return goodsInfoList == null ? 0 : goodsInfoList.size();
|
||||
}
|
||||
|
||||
static class GoodsHolder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
NiceImageView iv_goods;
|
||||
TextView tv_name, tv_desc, tv_buying_price, tv_price,tv_type;
|
||||
|
||||
public GoodsHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
iv_goods = itemView.findViewById(R.id.iv_img);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_desc = itemView.findViewById(R.id.tv_desc);
|
||||
tv_buying_price = itemView.findViewById(R.id.tv_buying_price);
|
||||
tv_price = itemView.findViewById(R.id.tv_price);
|
||||
tv_type = itemView.findViewById(R.id.tv_type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.MediaPlayer;
|
||||
import android.text.TextUtils;
|
||||
@@ -8,12 +9,15 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.bean.AlarmClockData;
|
||||
import com.uiuios.aios.utils.FFmpegUtils;
|
||||
@@ -70,6 +74,32 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte
|
||||
} else {
|
||||
holder.tv_time.setText(time);
|
||||
}
|
||||
String file = alarmClockData.getFile();
|
||||
if (TextUtils.isEmpty(file)) {
|
||||
Glide.with(holder.iv_cover).load(R.drawable.home_reminder_icon).into(holder.iv_cover);
|
||||
} else {
|
||||
FFmpegUtils.loadVideoScreenshot(file, new Observer<Bitmap>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull Bitmap bitmap) {
|
||||
Glide.with(holder.iv_cover).load(bitmap).into(holder.iv_cover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
String voice = alarmClockData.getVoice();
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -141,6 +171,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte
|
||||
TextView tv_voice;
|
||||
ConstraintLayout cl_voice;
|
||||
ConstraintLayout root;
|
||||
NiceImageView iv_cover;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@@ -149,6 +180,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapte
|
||||
tv_time = itemView.findViewById(R.id.tv_time);
|
||||
tv_voice = itemView.findViewById(R.id.tv_voice);
|
||||
cl_voice = itemView.findViewById(R.id.cl_voice);
|
||||
iv_cover = itemView.findViewById(R.id.iv_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
app/src/main/java/com/uiuios/aios/bean/AppSelectBean.java
Normal file
44
app/src/main/java/com/uiuios/aios/bean/AppSelectBean.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppSelectBean implements Serializable {
|
||||
private static final long serialVersionUID = 5054284058523960678L;
|
||||
|
||||
String appName;
|
||||
String packageName;
|
||||
Drawable icon;
|
||||
|
||||
public AppSelectBean(String appName, String packageName, Drawable icon) {
|
||||
this.appName = appName;
|
||||
this.packageName = packageName;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(Drawable icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,24 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DesktopIcon implements Serializable , Parcelable {
|
||||
public class DesktopIcon implements Serializable, Parcelable {
|
||||
private static final long serialVersionUID = 3358230413497783708L;
|
||||
|
||||
String packageName;
|
||||
String className;
|
||||
Drawable icon;
|
||||
String lable;
|
||||
int position;
|
||||
|
||||
private DesktopIcon() {
|
||||
public DesktopIcon() {
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +60,14 @@ public class DesktopIcon implements Serializable , Parcelable {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
@@ -83,22 +92,24 @@ public class DesktopIcon implements Serializable , Parcelable {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public static DesktopIcon creatDesktopIcon(Context context, ApplicationInfo applicationInfo) {
|
||||
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
DesktopIcon desktopIcon = new DesktopIcon();
|
||||
desktopIcon.setPackageName(applicationInfo.packageName);
|
||||
desktopIcon.setIcon(applicationInfo.loadIcon(pm));
|
||||
desktopIcon.setLable(applicationInfo.loadLabel(pm).toString());
|
||||
desktopIcon.setPackageName(resolveInfo.activityInfo.packageName);
|
||||
desktopIcon.setClassName(resolveInfo.activityInfo.name);
|
||||
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
||||
desktopIcon.setLable(resolveInfo.loadLabel(pm).toString());
|
||||
desktopIcon.setPosition(0);
|
||||
return desktopIcon;
|
||||
}
|
||||
|
||||
public static DesktopIcon creatDesktopIcon(Context context, ApplicationInfo applicationInfo, int position) {
|
||||
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo, int position) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
DesktopIcon desktopIcon = new DesktopIcon();
|
||||
desktopIcon.setPackageName(applicationInfo.packageName);
|
||||
desktopIcon.setIcon(applicationInfo.loadIcon(pm));
|
||||
desktopIcon.setLable(applicationInfo.loadLabel(pm).toString());
|
||||
desktopIcon.setPackageName(resolveInfo.activityInfo.packageName);
|
||||
desktopIcon.setClassName(resolveInfo.activityInfo.name);
|
||||
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
||||
desktopIcon.setLable(resolveInfo.loadLabel(pm).toString());
|
||||
desktopIcon.setPosition(position);
|
||||
return desktopIcon;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GoodsInfo implements Serializable {
|
||||
@@ -23,6 +25,13 @@ public class GoodsInfo implements Serializable {
|
||||
int stock;
|
||||
/*跳转链接*/
|
||||
String jump_url;
|
||||
String insure;
|
||||
String deliver_goods;
|
||||
String after_sales;
|
||||
String ensure;
|
||||
@SerializedName("class")
|
||||
String type;
|
||||
|
||||
|
||||
|
||||
public int getId() {
|
||||
@@ -104,4 +113,44 @@ public class GoodsInfo implements Serializable {
|
||||
public void setJump_url(String jump_url) {
|
||||
this.jump_url = jump_url;
|
||||
}
|
||||
|
||||
public String getInsure() {
|
||||
return insure;
|
||||
}
|
||||
|
||||
public void setInsure(String insure) {
|
||||
this.insure = insure;
|
||||
}
|
||||
|
||||
public String getDeliver_goods() {
|
||||
return deliver_goods;
|
||||
}
|
||||
|
||||
public void setDeliver_goods(String deliver_goods) {
|
||||
this.deliver_goods = deliver_goods;
|
||||
}
|
||||
|
||||
public String getAfter_sales() {
|
||||
return after_sales;
|
||||
}
|
||||
|
||||
public void setAfter_sales(String after_sales) {
|
||||
this.after_sales = after_sales;
|
||||
}
|
||||
|
||||
public String getEnsure() {
|
||||
return ensure;
|
||||
}
|
||||
|
||||
public void setEnsure(String ensure) {
|
||||
this.ensure = ensure;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.uiuios.aios.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -9,6 +10,7 @@ import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.baidu.location.LocationClientOption;
|
||||
import com.blankj.utilcode.util.SPUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -27,7 +29,6 @@ public class AmapManager {
|
||||
private LocationClientOption mOption;
|
||||
private BDLocation mLocation;
|
||||
private CacheHelper mCacheHelper;
|
||||
private MMKV mmkv = MMKV.defaultMMKV();
|
||||
|
||||
private static final String AMAPLOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String LONGITUDE_KEY = "map_longitude_key";
|
||||
@@ -38,6 +39,7 @@ public class AmapManager {
|
||||
private AmapManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
initAmap();
|
||||
}
|
||||
|
||||
@@ -58,7 +60,10 @@ public class AmapManager {
|
||||
}
|
||||
|
||||
public void initAmap() {
|
||||
mLocationClient = new LocationClient(mContext);
|
||||
if (mLocationClient == null) {
|
||||
mLocationClient = new LocationClient(mContext);
|
||||
}
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
mLocationClient.setLocOption(getDefaultLocationClientOption());
|
||||
mLocationClient.registerLocationListener(mListener);
|
||||
mLocationClient.stop();
|
||||
@@ -75,7 +80,7 @@ public class AmapManager {
|
||||
|
||||
public BDLocation getNowMapLocation() {
|
||||
if (mLocation == null) {
|
||||
String aMapLocationjson = mmkv.decodeString(AMAPLOCATION_JSON_KEY);
|
||||
String aMapLocationjson = SPUtils.getInstance().getString(AMAPLOCATION_JSON_KEY,"");
|
||||
if (TextUtils.isEmpty(aMapLocationjson)) {
|
||||
return null;
|
||||
}
|
||||
@@ -148,7 +153,7 @@ public class AmapManager {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
mmkv.encode(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
SPUtils.getInstance().put(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: longitude = " + location.getLongitude());
|
||||
Log.e(TAG, "onLocationChanged: latitude = " + location.getLatitude());
|
||||
@@ -282,6 +287,9 @@ public class AmapManager {
|
||||
// }
|
||||
Log.e(TAG, "AmapAddress: " + mCacheHelper.getAsString(ADDRESS_KEY));
|
||||
Log.e(TAG, "AmapError: " + mCacheHelper.getAsString(ERROR_KEY));
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-network");
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-gps");
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -299,7 +299,7 @@ public class NetInterfaceManager {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public Observer getUserIDObserver(onCompleteCallback callback) {
|
||||
public Observer<BaseResponse<UserId>> getUserIDObserver(onCompleteCallback callback) {
|
||||
return new Observer<BaseResponse<UserId>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -794,7 +794,7 @@ public class NetInterfaceManager {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SnInfo> snInfoBaseResponse) {
|
||||
Log.e("getSnInfo", "onNext: ");
|
||||
Log.e("getSnInfo", "onNext: " + snInfoBaseResponse);
|
||||
callback.setSnInfo(snInfoBaseResponse.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -59,11 +60,20 @@ public class ApkUtils {
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.android.uiuios");
|
||||
this.add("com.uiui.os");
|
||||
this.add("com.uiui.health");
|
||||
// this.add("com.uiui.health");
|
||||
this.add("com.tencent.android.qqdownloader");
|
||||
this.add("com.uiuios.appstore");
|
||||
// this.add("com.uiuios.appstore");
|
||||
this.add("com.joytv.live");
|
||||
}};
|
||||
|
||||
private static HashSet<String> excludeClassName = new HashSet<String>() {{
|
||||
this.add("com.android.dialer.app.calllog.CallLogActivity");
|
||||
}};
|
||||
|
||||
private static HashSet<String> showPackageName = new HashSet<String>() {{
|
||||
this.add("com.uiuios.sn");
|
||||
this.add("com.uiuios.browser");
|
||||
// this.add("com.uiuios.appstore");
|
||||
this.add("com.android.dialer");
|
||||
this.add("com.android.gallery3d");
|
||||
this.add("com.android.settings");
|
||||
@@ -72,7 +82,8 @@ public class ApkUtils {
|
||||
this.add("com.mediatek.camera");
|
||||
this.add("com.android.mms");
|
||||
this.add("com.uiui.city");
|
||||
this.add("com.alldocube.store");
|
||||
this.add("com.uiui.health");
|
||||
// this.add("com.alldocube.store");
|
||||
this.add("com.android.fmradio");
|
||||
this.add("com.android.documentsui");
|
||||
this.add("com.android.calculator2");
|
||||
@@ -146,8 +157,7 @@ public class ApkUtils {
|
||||
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除,但还有安装目录的
|
||||
ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
|
||||
List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
|
||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
@@ -158,69 +168,85 @@ public class ApkUtils {
|
||||
Set<String> allowPackages = new HashSet();
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.packageName);
|
||||
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.name);
|
||||
allowPackages.add(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
|
||||
for (ApplicationInfo app : appInfos) {
|
||||
if (appIsDisable(context, app.packageName)) {
|
||||
Log.e(TAG, "queryFilterAppInfo: disable = " + app.packageName);
|
||||
String appListString = Settings.System.getString(context.getContentResolver(), "only_jgy_shortcut_list");
|
||||
List<String> packageList = new ArrayList<>();
|
||||
if (!TextUtils.isEmpty(appListString)) {
|
||||
packageList = new ArrayList<>(Arrays.asList(appListString.split(",")));
|
||||
}
|
||||
int setting_other_appInstaller = Settings.Global.getInt(context.getContentResolver(), "setting_other_appInstaller", 1);
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
String pkg = resolveInfo.activityInfo.packageName;
|
||||
if (appIsDisable(context, pkg)) {
|
||||
Log.e(TAG, "queryFilterAppInfo: disable = " + pkg);
|
||||
continue;
|
||||
}
|
||||
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) > 0)//通过flag排除系统应用,会将电话、短信也排除掉
|
||||
if (isSystemApp(context, pkg))//通过flag排除系统应用,会将电话、短信也排除掉
|
||||
{
|
||||
if (showPackageName.contains(app.packageName)) {
|
||||
applicationInfos.add(app);
|
||||
if (showPackageName.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
} else {
|
||||
// if(app.uid > 10000){//通过uid排除系统应用,在一些手机上效果不好
|
||||
// applicationInfos.add(app);
|
||||
// }
|
||||
if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
|
||||
// if (allowPackages.contains(app.packageName)) {
|
||||
applicationInfos.add(app);
|
||||
if (setting_other_appInstaller == 0) {//不显示自己安装的
|
||||
if (packageList.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
} else {
|
||||
if (allowPackages.contains(pkg) && !excludePackageName.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
||||
applicationInfos.removeIf(applicationInfo -> "com.uiui.city".equals(applicationInfo.packageName));
|
||||
resolveInfos.removeIf(resolveInfo -> "com.uiui.city".equals(resolveInfo.activityInfo.packageName));
|
||||
// resolveInfos.removeIf(applicationInfo -> "com.uiui.sn".equals(applicationInfo.packageName));
|
||||
}
|
||||
|
||||
applicationInfos.sort(new Comparator<ApplicationInfo>() {
|
||||
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||
@Override
|
||||
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
||||
public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
|
||||
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
|
||||
}
|
||||
});
|
||||
applicationInfos.sort(new Comparator<ApplicationInfo>() {
|
||||
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||
@Override
|
||||
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
||||
if ((o1.flags & ApplicationInfo.FLAG_SYSTEM) <= (o2.flags & ApplicationInfo.FLAG_SYSTEM)) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||
try {
|
||||
if ((pm.getApplicationInfo(o1.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM) <= (pm.getApplicationInfo(o2.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM)) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
ArrayList<DesktopIcon> desktopIcons = new ArrayList<>();
|
||||
HashMap<String, ApplicationInfo> infoHashMap = new HashMap<>();
|
||||
for (ApplicationInfo applicationInfo : applicationInfos) {
|
||||
infoHashMap.put(applicationInfo.packageName, applicationInfo);
|
||||
}
|
||||
for (int i = 0; i < defaultSort.size(); i++) {
|
||||
ApplicationInfo info = infoHashMap.get(defaultSort.get(i));
|
||||
if (info != null) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, info, i));
|
||||
infoHashMap.remove(defaultSort.get(i));
|
||||
for (ResolveInfo applicationInfo : resolveInfos) {
|
||||
if (!excludeClassName.contains(applicationInfo.activityInfo.name)) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||
}
|
||||
}
|
||||
|
||||
for (ApplicationInfo applicationInfo : infoHashMap.values()) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||
}
|
||||
return desktopIcons;
|
||||
}
|
||||
|
||||
public static boolean isSystemApp(Context context, String pkg) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ApplicationInfo applicationInfo = null;
|
||||
try {
|
||||
applicationInfo = pm.getApplicationInfo(pkg, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (applicationInfo == null) return false;
|
||||
return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
|
||||
}
|
||||
|
||||
private static boolean appIsDisable(Context context, String pkg) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
return pm.getApplicationEnabledSetting(pkg) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
||||
@@ -508,4 +534,4 @@ public class ApkUtils {
|
||||
return uid / PER_USER_RANGE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ public class BitmapUtils {
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
return Utils.getRoundedBitmap(bitmap, context);
|
||||
} else {
|
||||
return ((BitmapDrawable) drawable).getBitmap();
|
||||
return Utils.getRoundedBitmap(((BitmapDrawable) drawable).getBitmap(), context);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GlideLoadUtils {
|
||||
if (fragment != null && fragment.getActivity() != null) {
|
||||
Glide.with(fragment).load(url).centerCrop().error(default_image).into(imageView);
|
||||
} else {
|
||||
Log.i(TAG, "Picture loading failed,android.app.Fragment is null");
|
||||
Log.i(TAG, "Picture loading failed,android.app.SecondFragment is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
@@ -20,6 +26,7 @@ import android.util.Log;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -203,5 +210,53 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getRoundedBitmap(Bitmap mBitmap, Context context) {
|
||||
Bitmap bgBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
Bitmap mask = BitmapFactory.decodeResource(context.getResources(), R.drawable.mask);
|
||||
int width = mask.getWidth();
|
||||
int height = mask.getHeight();
|
||||
Bitmap bitmapScale = Bitmap.createScaledBitmap(mBitmap, width, height, true);
|
||||
bitmapScale.setDensity(context.getResources().getDisplayMetrics().densityDpi);
|
||||
// Palette p = Palette.from(mBitmap).generate();
|
||||
// Palette.Swatch vibrant = p.getVibrantSwatch();//有活力的
|
||||
// int color = vibrant.getRgb(); //样本中的像素数量
|
||||
|
||||
Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas();
|
||||
Paint paint = new Paint();
|
||||
|
||||
canvas.setBitmap(result);
|
||||
// canvas.drawColor(color);
|
||||
canvas.drawBitmap(mask, 0, 0, paint);
|
||||
// paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmapScale, 0, 0, paint);
|
||||
// return result;
|
||||
|
||||
Bitmap result2 = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas2 = new Canvas();
|
||||
Paint paint2 = new Paint();
|
||||
canvas2.setBitmap(result2);
|
||||
canvas2.drawBitmap(mask, 0, 0, paint2);
|
||||
paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas2.drawBitmap(result, 0, 0, paint2);
|
||||
return result2;
|
||||
|
||||
|
||||
// Canvas mCanvas = new Canvas();
|
||||
// mCanvas.setBitmap(bgBitmap);
|
||||
// Paint mPaint = new Paint();
|
||||
// RectF mRectM = new RectF(scaleM, scaleM, mBitmap.getWidth() - scaleM, mBitmap.getHeight() - scaleM); //设置剪裁圆角的区域
|
||||
// Rect mRect = new Rect(0, 0, mBitmap.getWidth(), mBitmap.getHeight());
|
||||
// RectF mRectF = mRectM;
|
||||
//
|
||||
// float roundPx = 15; //圆角半径
|
||||
// mPaint.setAntiAlias(true);
|
||||
// //Log.d("wy"+TAG,"mBitmap.getWidth()="+mBitmap.getWidth()+", mBitmap.getHeight()="+mBitmap.getHeight());
|
||||
// mCanvas.drawRoundRect(mRectF, roundPx, roundPx, mPaint);
|
||||
// mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
// mCanvas.drawBitmap(mBitmap, mRect, mRect, mPaint);
|
||||
// return bgBitmap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
25
app/src/main/java/com/uiuios/aios/view/CenterImageSpan.java
Normal file
25
app/src/main/java/com/uiuios/aios/view/CenterImageSpan.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.uiuios.aios.view;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.style.ImageSpan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class CenterImageSpan extends ImageSpan {
|
||||
public CenterImageSpan(Drawable drawable) {
|
||||
super(drawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
|
||||
Drawable b = getDrawable();
|
||||
Paint.FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int transY = (y + fm.descent + y + fm.ascent) / 2 - b.getBounds().bottom / 2;
|
||||
canvas.save();
|
||||
canvas.translate(x, transY);
|
||||
b.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.uiuios.aios.view;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* 描述 : RecyclerView GridLayoutManager 等间距。
|
||||
* <p>
|
||||
* 等间距需满足两个条件:
|
||||
* 1.各个模块的大小相等,即 各列的left+right 值相等;
|
||||
* 2.各列的间距相等,即 前列的right + 后列的left = 列间距;
|
||||
* <p>
|
||||
* 在{@link #getItemOffsets(Rect, View, RecyclerView, RecyclerView.State)} 中针对 outRect 的left 和right 满足这两个条件即可
|
||||
* <p>
|
||||
* 作者 : shiguotao
|
||||
* 版本 : V1
|
||||
* 创建时间 : 2020/3/19 4:54 PM
|
||||
*/
|
||||
public class GridSpaceItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final String TAG = "GridSpaceItemDecoration";
|
||||
|
||||
private int mSpanCount;//横条目数量
|
||||
private int mRowSpacing;//行间距
|
||||
private int mColumnSpacing;// 列间距
|
||||
|
||||
/**
|
||||
* @param spanCount 列数
|
||||
* @param rowSpacing 行间距
|
||||
* @param columnSpacing 列间距
|
||||
*/
|
||||
public GridSpaceItemDecoration(int spanCount, int rowSpacing, int columnSpacing) {
|
||||
this.mSpanCount = spanCount;
|
||||
this.mRowSpacing = rowSpacing;
|
||||
this.mColumnSpacing = columnSpacing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view); // 获取view 在adapter中的位置。
|
||||
int column = position % mSpanCount; // view 所在的列
|
||||
|
||||
outRect.left = column * mColumnSpacing / mSpanCount; // column * (列间距 * (1f / 列数))
|
||||
outRect.right = mColumnSpacing - (column + 1) * mColumnSpacing / mSpanCount; // 列间距 - (column + 1) * (列间距 * (1f /列数))
|
||||
|
||||
Log.e(TAG, "position:" + position
|
||||
+ " columnIndex: " + column
|
||||
+ " left,right ->" + outRect.left + "," + outRect.right);
|
||||
|
||||
// 如果position > 行数,说明不是在第一行,则不指定行高,其他行的上间距为 top=mRowSpacing
|
||||
if (position >= mSpanCount) {
|
||||
outRect.top = mRowSpacing; // item top
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user