update:2019.12.03
fix: add:更新在fragment中接收广播消息更新界面
This commit is contained in:
@@ -47,7 +47,9 @@
|
|||||||
<activity android:name=".activity.MainActivity">
|
<activity android:name=".activity.MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||||
|
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||||
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ import android.util.Log;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.appstore.uiui.jpush.Logger;
|
import com.appstore.uiui.jpush.Logger;
|
||||||
|
import com.appstore.uiui.network.OKGOPost;
|
||||||
import com.appstore.uiui.utils.ApkUtils;
|
import com.appstore.uiui.utils.ApkUtils;
|
||||||
import com.appstore.uiui.utils.LogUtils;
|
import com.appstore.uiui.utils.LogUtils;
|
||||||
|
import com.appstore.uiui.utils.SPUtils;
|
||||||
import com.appstore.uiui.utils.ToastUtil;
|
import com.appstore.uiui.utils.ToastUtil;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
import com.lzy.okgo.callback.FileCallback;
|
import com.lzy.okgo.callback.FileCallback;
|
||||||
@@ -329,9 +331,9 @@ public class MyApplication extends Application {
|
|||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
//后台为0可能传过来null
|
//后台为0可能传过来null
|
||||||
if (is_lock == 1) {
|
if (is_lock == 1) {
|
||||||
pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
|
||||||
} else {
|
|
||||||
pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||||
|
} else {
|
||||||
|
pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -379,13 +381,18 @@ public class MyApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized private void unintallApk(String json) {
|
synchronized private void unintallApk(String json) {
|
||||||
|
String sn_id = (String) SPUtils.get(getApplicationContext(), "sn_id", "-1");
|
||||||
try {
|
try {
|
||||||
JSONObject object = new JSONObject(json);
|
JSONObject object = new JSONObject(json);
|
||||||
String packageName = object.getString("package");
|
String packageName = object.getString("package");
|
||||||
ToastUtil.debugShow("收到应用卸载消息:包名" + packageName);
|
ToastUtil.debugShow("收到应用卸载消息:包名" + packageName);
|
||||||
if (!packageName.equals("") && !packageName.equals(getAppContext().getPackageName())) {
|
if (!packageName.equals("") && !packageName.equals(getApplicationContext().getPackageName())) {
|
||||||
|
if (!ApkUtils.isAvailable(getApplicationContext(), packageName)) {
|
||||||
|
OKGOPost.setAppuninstallInfo(sn_id, packageName);
|
||||||
|
} else {
|
||||||
ApkUtils.deleteApkInSilence(packageName);
|
ApkUtils.deleteApkInSilence(packageName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LogUtils.e("unintallApk", e.getMessage());
|
LogUtils.e("unintallApk", e.getMessage());
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
package com.appstore.uiui.activity;
|
package com.appstore.uiui.activity;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Adapter;
|
import android.widget.Adapter;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.appstore.uiui.R;
|
import com.appstore.uiui.R;
|
||||||
|
import com.appstore.uiui.adapter.AppAdapter;
|
||||||
import com.appstore.uiui.adapter.DownloadManagerAdapter;
|
import com.appstore.uiui.adapter.DownloadManagerAdapter;
|
||||||
import com.appstore.uiui.base.BaseActivity;
|
import com.appstore.uiui.base.BaseActivity;
|
||||||
|
import com.appstore.uiui.bean.AppInfo;
|
||||||
|
import com.appstore.uiui.utils.ApkUtils;
|
||||||
import com.appstore.uiui.utils.ToastUtil;
|
import com.appstore.uiui.utils.ToastUtil;
|
||||||
|
import com.lzy.okgo.model.Progress;
|
||||||
import com.lzy.okserver.OkDownload;
|
import com.lzy.okserver.OkDownload;
|
||||||
|
import com.lzy.okserver.download.DownloadListener;
|
||||||
import com.lzy.okserver.task.XExecutor;
|
import com.lzy.okserver.task.XExecutor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class DownloadManagerActivity extends BaseActivity implements XExecutor.OnAllTaskEndListener {
|
public class DownloadManagerActivity extends BaseActivity implements XExecutor.OnAllTaskEndListener {
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private DownloadManagerAdapter adapter;
|
private DownloadManagerAdapter adapter;
|
||||||
@@ -31,8 +41,8 @@ public class DownloadManagerActivity extends BaseActivity implements XExecutor.O
|
|||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
okDownload = OkDownload.getInstance();
|
okDownload = OkDownload.getInstance();
|
||||||
adapter = new DownloadManagerAdapter(this);
|
adapter = new DownloadManagerAdapter(this, handler);
|
||||||
adapter.updateData(DownloadManagerAdapter.TYPE_ALL);
|
adapter.updateData(DownloadManagerAdapter.TYPE_ING);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
okDownload.addOnAllTaskEndListener(this);
|
okDownload.addOnAllTaskEndListener(this);
|
||||||
@@ -47,6 +57,8 @@ public class DownloadManagerActivity extends BaseActivity implements XExecutor.O
|
|||||||
@Override
|
@Override
|
||||||
public void onAllTaskEnd() {
|
public void onAllTaskEnd() {
|
||||||
ToastUtil.show("所有任务已完成");
|
ToastUtil.show("所有任务已完成");
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,4 +77,17 @@ public class DownloadManagerActivity extends BaseActivity implements XExecutor.O
|
|||||||
public void finish(View view) {
|
public void finish(View view) {
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(@NonNull Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
if (msg.what == 100) {
|
||||||
|
adapter.updateData(DownloadManagerAdapter.TYPE_ING);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ public class LocalManagerActivity extends BaseActivity implements RefreshManager
|
|||||||
LocalApp bean = new LocalApp();
|
LocalApp bean = new LocalApp();
|
||||||
bean.setAppName(resolveInfoList.get(i).loadLabel(getApplicationContext().getPackageManager()).toString());
|
bean.setAppName(resolveInfoList.get(i).loadLabel(getApplicationContext().getPackageManager()).toString());
|
||||||
String packageName = resolveInfoList.get(i).activityInfo.packageName;
|
String packageName = resolveInfoList.get(i).activityInfo.packageName;
|
||||||
|
if (packageName.equals(getApplicationContext().getPackageName())||packageName.equals("com.android.uiuios")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bean.setPackageName(packageName);
|
bean.setPackageName(packageName);
|
||||||
Drawable icon = resolveInfoList.get(i).loadIcon(getApplicationContext().getPackageManager());
|
Drawable icon = resolveInfoList.get(i).loadIcon(getApplicationContext().getPackageManager());
|
||||||
bean.setIcon(icon);
|
bean.setIcon(icon);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.appstore.uiui.adapter;
|
package com.appstore.uiui.adapter;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.telecom.Call;
|
import android.telecom.Call;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -18,7 +20,9 @@ import com.appstore.uiui.R;
|
|||||||
import com.appstore.uiui.activity.DetailsActivity;
|
import com.appstore.uiui.activity.DetailsActivity;
|
||||||
import com.appstore.uiui.bean.AppInfo;
|
import com.appstore.uiui.bean.AppInfo;
|
||||||
import com.appstore.uiui.listener.LogDownloadListener;
|
import com.appstore.uiui.listener.LogDownloadListener;
|
||||||
|
import com.appstore.uiui.network.OKGOPost;
|
||||||
import com.appstore.uiui.utils.ApkUtils;
|
import com.appstore.uiui.utils.ApkUtils;
|
||||||
|
import com.appstore.uiui.utils.LogUtils;
|
||||||
import com.appstore.uiui.utils.ToastUtil;
|
import com.appstore.uiui.utils.ToastUtil;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
@@ -45,6 +49,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
|
|
||||||
private boolean isNotLoadBitmap = false;
|
private boolean isNotLoadBitmap = false;
|
||||||
|
|
||||||
|
|
||||||
//order代表是否显示所在的位置,1.2.3.
|
//order代表是否显示所在的位置,1.2.3.
|
||||||
public AppAdapter(List<AppInfo> appInfoList, boolean isShowOrder, Context context) {
|
public AppAdapter(List<AppInfo> appInfoList, boolean isShowOrder, Context context) {
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
@@ -60,6 +65,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(Holder holder, final int position) {
|
public void onBindViewHolder(Holder holder, final int position) {
|
||||||
|
|
||||||
final AppInfo appInfo = mAppInfoList.get(position);
|
final AppInfo appInfo = mAppInfoList.get(position);
|
||||||
final DownloadTask downloadTask = OkDownload.getInstance().getTask(appInfo.getApp_url());
|
final DownloadTask downloadTask = OkDownload.getInstance().getTask(appInfo.getApp_url());
|
||||||
holder.setTag(appInfo.getApp_url());
|
holder.setTag(appInfo.getApp_url());
|
||||||
@@ -81,6 +87,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
} else {
|
} else {
|
||||||
holder.tvName.setText(appInfo.getApp_name());
|
holder.tvName.setText(appInfo.getApp_name());
|
||||||
}
|
}
|
||||||
|
holder.tvSize.setText(appInfo.getApp_size() + "M");
|
||||||
holder.ratingBar.setRating((float) appInfo.getApp_score());
|
holder.ratingBar.setRating((float) appInfo.getApp_score());
|
||||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -95,11 +102,17 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
if (appInfo.isInstall()) {
|
if (appInfo.isInstall()) {
|
||||||
if (appInfo.isUpdate()) {
|
if (appInfo.isUpdate()) {
|
||||||
holder.btnDownLoad.setText("更新");
|
holder.btnDownLoad.setText("更新");
|
||||||
|
holder.btnDownLoad.setTextColor(mContext.getColor(R.color.green));
|
||||||
|
holder.btnDownLoad.setBackground(mContext.getDrawable(R.drawable.btn_style_none));
|
||||||
} else {
|
} else {
|
||||||
holder.btnDownLoad.setText("打开");
|
holder.btnDownLoad.setText("打开");
|
||||||
|
holder.btnDownLoad.setTextColor(mContext.getColor(R.color.black));
|
||||||
|
holder.btnDownLoad.setBackground(mContext.getDrawable(R.drawable.btn_style_open));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.btnDownLoad.setText("下载");
|
holder.btnDownLoad.setText("下载");
|
||||||
|
holder.btnDownLoad.setTextColor(mContext.getColor(R.color.green));
|
||||||
|
holder.btnDownLoad.setBackground(mContext.getDrawable(R.drawable.btn_style_none));
|
||||||
if (downloadTask != null) {
|
if (downloadTask != null) {
|
||||||
holder.refresh(downloadTask.progress);
|
holder.refresh(downloadTask.progress);
|
||||||
}
|
}
|
||||||
@@ -141,11 +154,10 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
|
|
||||||
public class Holder extends RecyclerView.ViewHolder {
|
public class Holder extends RecyclerView.ViewHolder {
|
||||||
ImageView ivIcon;
|
ImageView ivIcon;
|
||||||
TextView tvCompany, tvName;
|
TextView tvCompany, tvName, tvSize;
|
||||||
Button btnDownLoad;
|
Button btnDownLoad;
|
||||||
RatingBar ratingBar;
|
RatingBar ratingBar;
|
||||||
// TextView tvInstalled;
|
// TextView tvInstalled;
|
||||||
CardView cardView;
|
|
||||||
|
|
||||||
private DownloadTask task;
|
private DownloadTask task;
|
||||||
private String tag;
|
private String tag;
|
||||||
@@ -155,10 +167,10 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
ivIcon = itemView.findViewById(R.id.app_iv_icon);
|
ivIcon = itemView.findViewById(R.id.app_iv_icon);
|
||||||
tvCompany = itemView.findViewById(R.id.app_tv_company);
|
tvCompany = itemView.findViewById(R.id.app_tv_company);
|
||||||
tvName = itemView.findViewById(R.id.app_tv_name);
|
tvName = itemView.findViewById(R.id.app_tv_name);
|
||||||
|
tvSize = itemView.findViewById(R.id.app_tv_size);
|
||||||
btnDownLoad = itemView.findViewById(R.id.app_btn_download);
|
btnDownLoad = itemView.findViewById(R.id.app_btn_download);
|
||||||
ratingBar = itemView.findViewById(R.id.app_rating_bar);
|
ratingBar = itemView.findViewById(R.id.app_rating_bar);
|
||||||
// tvInstalled = itemView.findViewById(R.id.app_tv_installed);
|
// tvInstalled = itemView.findViewById(R.id.app_tv_installed);
|
||||||
cardView = itemView.findViewById(R.id.app_card_view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
@@ -180,7 +192,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
btnDownLoad.setText("等待");
|
btnDownLoad.setText("等待");
|
||||||
break;
|
break;
|
||||||
case Progress.FINISH:
|
case Progress.FINISH:
|
||||||
btnDownLoad.setText("完成");
|
btnDownLoad.setText("安装中");
|
||||||
break;
|
break;
|
||||||
case Progress.LOADING:
|
case Progress.LOADING:
|
||||||
btnDownLoad.setText((int) (progress.fraction * 100) + "%");
|
btnDownLoad.setText((int) (progress.fraction * 100) + "%");
|
||||||
@@ -202,6 +214,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setNotLoadBitmap(boolean isNotLoadBitmap) {
|
public void setNotLoadBitmap(boolean isNotLoadBitmap) {
|
||||||
this.isNotLoadBitmap = isNotLoadBitmap;
|
this.isNotLoadBitmap = isNotLoadBitmap;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.appstore.uiui.adapter;
|
package com.appstore.uiui.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -40,10 +41,12 @@ public class DownloadManagerAdapter extends RecyclerView.Adapter<DownloadManager
|
|||||||
private int type;
|
private int type;
|
||||||
|
|
||||||
private final LayoutInflater mInflater;
|
private final LayoutInflater mInflater;
|
||||||
|
private Handler mhandler;
|
||||||
|
|
||||||
public DownloadManagerAdapter(Context context) {
|
public DownloadManagerAdapter(Context context, Handler handler) {
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
mInflater = LayoutInflater.from(mContext);
|
mInflater = LayoutInflater.from(mContext);
|
||||||
|
this.mhandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateData(int type) {
|
public void updateData(int type) {
|
||||||
@@ -241,11 +244,12 @@ public class DownloadManagerAdapter extends RecyclerView.Adapter<DownloadManager
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish(File file, Progress progress) {
|
public void onFinish(File file, Progress progress) {
|
||||||
|
mhandler.sendEmptyMessage(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove(Progress progress) {
|
public void onRemove(Progress progress) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public class LocalAppAdapter extends RecyclerView.Adapter<LocalAppAdapter.LocalA
|
|||||||
TextView tvCompany, tvName, tvVersion;
|
TextView tvCompany, tvName, tvVersion;
|
||||||
TextView tvUpdate;
|
TextView tvUpdate;
|
||||||
Button btnDownLoad;
|
Button btnDownLoad;
|
||||||
CardView cardView;
|
|
||||||
|
|
||||||
public LocalAppViewHolder(View itemView) {
|
public LocalAppViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@@ -88,7 +87,6 @@ public class LocalAppAdapter extends RecyclerView.Adapter<LocalAppAdapter.LocalA
|
|||||||
tvVersion = itemView.findViewById(R.id.local_app_version);
|
tvVersion = itemView.findViewById(R.id.local_app_version);
|
||||||
tvUpdate = itemView.findViewById(R.id.local_app_update);
|
tvUpdate = itemView.findViewById(R.id.local_app_update);
|
||||||
btnDownLoad = itemView.findViewById(R.id.local_app_btn_download);
|
btnDownLoad = itemView.findViewById(R.id.local_app_btn_download);
|
||||||
cardView = itemView.findViewById(R.id.local_app_card_view);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public class UpdateAppAdapter extends RecyclerView.Adapter<UpdateAppAdapter.Upda
|
|||||||
holder.tvName.setText(appInfo.getAppName());
|
holder.tvName.setText(appInfo.getAppName());
|
||||||
holder.tvVersion.setText(appInfo.getVersionName() + "->" + appInfo.getNewVersionName());
|
holder.tvVersion.setText(appInfo.getVersionName() + "->" + appInfo.getNewVersionName());
|
||||||
holder.btnDownLoad.setText("更新");
|
holder.btnDownLoad.setText("更新");
|
||||||
|
holder.btnDownLoad.setTextColor(context.getColor(R.color.green));
|
||||||
|
holder.btnDownLoad.setBackground(context.getDrawable(R.drawable.btn_style_none));
|
||||||
holder.btnDownLoad.setOnClickListener(new View.OnClickListener() {
|
holder.btnDownLoad.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -96,7 +98,6 @@ public class UpdateAppAdapter extends RecyclerView.Adapter<UpdateAppAdapter.Upda
|
|||||||
TextView tvName, tvVersion;
|
TextView tvName, tvVersion;
|
||||||
TextView tvUpdate;
|
TextView tvUpdate;
|
||||||
Button btnDownLoad;
|
Button btnDownLoad;
|
||||||
CardView cardView;
|
|
||||||
|
|
||||||
private DownloadTask task;
|
private DownloadTask task;
|
||||||
private String tag;
|
private String tag;
|
||||||
@@ -108,7 +109,6 @@ public class UpdateAppAdapter extends RecyclerView.Adapter<UpdateAppAdapter.Upda
|
|||||||
tvVersion = itemView.findViewById(R.id.local_app_version);
|
tvVersion = itemView.findViewById(R.id.local_app_version);
|
||||||
tvUpdate = itemView.findViewById(R.id.local_app_update);
|
tvUpdate = itemView.findViewById(R.id.local_app_update);
|
||||||
btnDownLoad = itemView.findViewById(R.id.local_app_btn_download);
|
btnDownLoad = itemView.findViewById(R.id.local_app_btn_download);
|
||||||
cardView = itemView.findViewById(R.id.local_app_card_view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.appstore.uiui.fragment;
|
package com.appstore.uiui.fragment;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -43,17 +47,46 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
|
|||||||
private SmartRefreshLayout mRefreshLayout;
|
private SmartRefreshLayout mRefreshLayout;
|
||||||
|
|
||||||
private List<AppInfos> appInfoList;//
|
private List<AppInfos> appInfoList;//
|
||||||
private List<AppInfo> newAppInfoList;
|
private List<AppInfo> newAppInfoList=new ArrayList<>();
|
||||||
private AppAdapter adapter;
|
private AppAdapter adapter;
|
||||||
|
|
||||||
private boolean isNotLoadBitmap;
|
private boolean isNotLoadBitmap;
|
||||||
|
|
||||||
|
private installReceiver myReceiver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutId() {
|
public int getLayoutId() {
|
||||||
return R.layout.fragment_featured;
|
return R.layout.fragment_featured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if (myReceiver != null) {
|
||||||
|
try {
|
||||||
|
getActivity().getApplication().unregisterReceiver(myReceiver);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("onStop", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
adapter.setData(checkUpdateOrInstalled(newAppInfoList));
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
if (myReceiver == null) {
|
||||||
|
myReceiver = new installReceiver();
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction("com.appstore.uiui.PACKAGE_ADDED");
|
||||||
|
filter.addAction("com.appstore.uiui.PACKAGE_REPLACED");
|
||||||
|
filter.addAction("com.appstore.uiui.PACKAGE_REMOVED");
|
||||||
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||||
|
getActivity().getApplication().registerReceiver(myReceiver, filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initViews(View view) {
|
public void initViews(View view) {
|
||||||
mRvResult = view.findViewById(R.id.featured_rv_result);
|
mRvResult = view.findViewById(R.id.featured_rv_result);
|
||||||
@@ -62,7 +95,7 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
|
|||||||
|
|
||||||
isNotLoadBitmap = false;
|
isNotLoadBitmap = false;
|
||||||
|
|
||||||
newAppInfoList = new ArrayList<>();
|
|
||||||
adapter = new AppAdapter(newAppInfoList, false, getContext());
|
adapter = new AppAdapter(newAppInfoList, false, getContext());
|
||||||
adapter.setHasStableIds(true);
|
adapter.setHasStableIds(true);
|
||||||
mRvResult.setAdapter(adapter);
|
mRvResult.setAdapter(adapter);
|
||||||
@@ -126,4 +159,17 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class installReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
//接收安装广播
|
||||||
|
if (action.equals("com.appstore.uiui.PACKAGE_ADDED") || action.equals("com.appstore.uiui.PACKAGE_REMOVED") || action.equals("com.appstore.uiui.PACKAGE_REPLACED")) {
|
||||||
|
adapter.setData(checkUpdateOrInstalled(newAppInfoList));
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class ManageFragment extends LazyLoadFragment {
|
|||||||
applist = (List<AppInfo>) msg.obj;
|
applist = (List<AppInfo>) msg.obj;
|
||||||
updateDta(applist);
|
updateDta(applist);
|
||||||
updateNum = updateAppInfoList.size();
|
updateNum = updateAppInfoList.size();
|
||||||
manage_tv_updateNum.setText(updateNum + "个应用可以升级");
|
manage_tv_updateNum.setText(updateNum + "");
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,19 @@ public class AppManagerReceiver extends BroadcastReceiver {
|
|||||||
action = intent.getAction();
|
action = intent.getAction();
|
||||||
//接收安装广播
|
//接收安装广播
|
||||||
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
||||||
|
if (action.equals(Intent.ACTION_PACKAGE_ADDED)){
|
||||||
|
Intent intents = new Intent("com.appstore.uiui.PACKAGE_ADDED");
|
||||||
|
context.sendBroadcast(intents);
|
||||||
|
}else {
|
||||||
|
Intent intents = new Intent("com.appstore.uiui.PACKAGE_REPLACED");
|
||||||
|
context.sendBroadcast(intents);
|
||||||
|
}
|
||||||
String packageName = intent.getDataString().replace("package:", "");
|
String packageName = intent.getDataString().replace("package:", "");
|
||||||
String name = ApkUtils.getApplicationName(context, packageName);
|
String name = ApkUtils.getApplicationName(context, packageName);
|
||||||
ToastUtil.show(name + ":安装成功");
|
ToastUtil.show(name + ":安装成功");
|
||||||
LogUtils.e(TAG, "安装了:" + packageName + "包名的程序");
|
LogUtils.e(TAG, "安装了:" + packageName + "包名的程序");
|
||||||
// ToastTool.show("安装成功");
|
// ToastTool.show("安装成功");
|
||||||
if (!packageName.equals(context.getPackageName())) {
|
if (!packageName.equals(context.getPackageName())&&!packageName.equals("com.android.uiuios")) {
|
||||||
if (member_id == -1 || sn_id.equals("-1")) {
|
if (member_id == -1 || sn_id.equals("-1")) {
|
||||||
OKGOPost.getUserInfo(context);
|
OKGOPost.getUserInfo(context);
|
||||||
} else {
|
} else {
|
||||||
@@ -43,7 +50,9 @@ public class AppManagerReceiver extends BroadcastReceiver {
|
|||||||
if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
|
if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
|
||||||
String packageName = intent.getDataString().replace("package:", "");
|
String packageName = intent.getDataString().replace("package:", "");
|
||||||
LogUtils.e(TAG, "卸载了:" + packageName + "包名的程序");
|
LogUtils.e(TAG, "卸载了:" + packageName + "包名的程序");
|
||||||
if (!packageName.equals(context.getPackageName())) {
|
Intent intents = new Intent("com.appstore.uiui.PACKAGE_REMOVED");
|
||||||
|
context.sendBroadcast(intents);
|
||||||
|
if (!packageName.equals(context.getPackageName())&&!packageName.equals("com.android.uiuios")) {
|
||||||
if (member_id == -1 || sn_id.equals("-1")) {
|
if (member_id == -1 || sn_id.equals("-1")) {
|
||||||
OKGOPost.getUserInfo(context);
|
OKGOPost.getUserInfo(context);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
36
app/src/main/res/drawable/btn_style_none.xml
Normal file
36
app/src/main/res/drawable/btn_style_none.xml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- 连框颜色值 -->
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#55b68a" />
|
||||||
|
<corners android:radius="@dimen/dp_25" />
|
||||||
|
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<!-- 主体背景颜色值 -->
|
||||||
|
<item
|
||||||
|
android:bottom="1dp"
|
||||||
|
android:left="1dp"
|
||||||
|
android:right="1dp"
|
||||||
|
android:top="1dp">
|
||||||
|
<shape>
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:centerColor="#FFFFFF"
|
||||||
|
android:centerX="0.5"
|
||||||
|
android:centerY="0.5"
|
||||||
|
android:endColor="#FFFFFF"
|
||||||
|
android:startColor="#FFFFFF"
|
||||||
|
android:type="linear" />
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:bottom="2dp"
|
||||||
|
android:left="2dp"
|
||||||
|
android:right="2dp"
|
||||||
|
android:top="2dp" />
|
||||||
|
<!-- 应该是圆角 -->
|
||||||
|
<corners android:radius="@dimen/dp_25" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
36
app/src/main/res/drawable/btn_style_open.xml
Normal file
36
app/src/main/res/drawable/btn_style_open.xml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- 连框颜色值 -->
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#000000" />
|
||||||
|
<corners android:radius="@dimen/dp_25" />
|
||||||
|
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<!-- 主体背景颜色值 -->
|
||||||
|
<item
|
||||||
|
android:bottom="1dp"
|
||||||
|
android:left="1dp"
|
||||||
|
android:right="1dp"
|
||||||
|
android:top="1dp">
|
||||||
|
<shape>
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:centerColor="#FFFFFF"
|
||||||
|
android:centerX="0.5"
|
||||||
|
android:centerY="0.5"
|
||||||
|
android:endColor="#FFFFFF"
|
||||||
|
android:startColor="#FFFFFF"
|
||||||
|
android:type="linear" />
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:bottom="2dp"
|
||||||
|
android:left="2dp"
|
||||||
|
android:right="2dp"
|
||||||
|
android:top="2dp" />
|
||||||
|
<!-- 应该是圆角 -->
|
||||||
|
<corners android:radius="@dimen/dp_25" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 1.8 KiB |
@@ -28,35 +28,37 @@
|
|||||||
android:background="@drawable/ic_kind_detail" />
|
android:background="@drawable/ic_kind_detail" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<include layout="@layout/include_line_horizontal" />
|
<include layout="@layout/include_line_horizontal" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/manage_tv_updateNum"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:text="0个应用可以升级"
|
android:orientation="horizontal">
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/include_line_horizontal" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_weight="1"
|
||||||
|
|
||||||
android:text="可升级应用"
|
android:text="可升级应用"
|
||||||
android:textSize="10sp" />
|
android:textSize="10sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/manage_tv_updateNum"
|
||||||
|
android:layout_width="@dimen/dp_40"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="0"
|
||||||
|
android:textSize="10sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<include layout="@layout/include_line_horizontal" />
|
<include layout="@layout/include_line_horizontal" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="70dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@@ -52,6 +52,15 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_tv_size"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="1.00M"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<RatingBar
|
<RatingBar
|
||||||
android:id="@+id/app_rating_bar"
|
android:id="@+id/app_rating_bar"
|
||||||
@@ -60,23 +69,20 @@
|
|||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/app_card_view"
|
|
||||||
android:layout_width="55dp"
|
|
||||||
android:layout_height="35dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
app:cardCornerRadius="5dp">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/app_btn_download"
|
android:id="@+id/app_btn_download"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="@dimen/dp_40"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="@dimen/dp_20"
|
||||||
|
android:textColor="#55b68a"
|
||||||
|
android:stateListAnimator="@null"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@drawable/btn_selector"
|
android:layout_marginRight="10dp"
|
||||||
android:text="下载"
|
android:background="@drawable/btn_style_none"
|
||||||
|
android:text="下载中"
|
||||||
|
android:textSize="@dimen/sp_10"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@mipmap/ic_launcher_round" />
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/kind_tv_name"
|
android:id="@+id/kind_tv_name"
|
||||||
|
|||||||
@@ -60,23 +60,16 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/local_app_card_view"
|
|
||||||
android:layout_width="55dp"
|
|
||||||
android:layout_height="35dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
app:cardCornerRadius="5dp">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/local_app_btn_download"
|
android:id="@+id/local_app_btn_download"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="@dimen/dp_40"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="@dimen/dp_20"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@drawable/btn_selector"
|
android:background="@drawable/btn_style_open"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:stateListAnimator="@null"
|
||||||
android:text="删除"
|
android:text="删除"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -9,5 +9,5 @@
|
|||||||
<color name="gray">#c1bcbc</color>
|
<color name="gray">#c1bcbc</color>
|
||||||
<color name="download">#d9d9d9</color>
|
<color name="download">#d9d9d9</color>
|
||||||
<color name="backgroundcolor">#d4d0d0</color>
|
<color name="backgroundcolor">#d4d0d0</color>
|
||||||
|
<color name="green">#55b68a</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user