update:2019.12.03
fix: add:1.0.0发版
This commit is contained in:
@@ -16,9 +16,9 @@ android {
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionName "1.0.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
//极光
|
||||
//极光
|
||||
ndk {
|
||||
//选择要添加的对应 cpu 类型的 .so 库。
|
||||
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
|
||||
@@ -101,6 +101,11 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
|
||||
//github第三方控件maven
|
||||
implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
|
||||
@@ -132,12 +137,8 @@ dependencies {
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
|
||||
implementation 'io.reactivex:rxjava:1.2.2'
|
||||
implementation 'io.reactivex:rxandroid:1.2.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
//极光推送
|
||||
implementation 'cn.jiguang.sdk:jpush:3.4.1' // 此处以JPush 3.4.1 版本为例。
|
||||
implementation 'cn.jiguang.sdk:jcore:2.2.4' // 此处以JCore 2.2.4 版本为例。
|
||||
|
||||
@@ -10,11 +10,9 @@
|
||||
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.MASTER_CLEAR" />
|
||||
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
|
||||
<!--系统权限,有系统签名可以使用-->
|
||||
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> <!-- 系统权限,有系统签名可以使用 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
@@ -35,10 +33,12 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity android:name=".activity.SearcherActivity"></activity>
|
||||
|
||||
<service
|
||||
android:name=".service.InitJpushServer"
|
||||
android:enabled="true"
|
||||
android:exported="true"></service>
|
||||
android:exported="true" />
|
||||
|
||||
<activity android:name=".activity.KindDetailActivity" />
|
||||
<activity android:name=".activity.DetailsActivity" />
|
||||
@@ -90,8 +90,7 @@
|
||||
android:name="cn.jpush.android.ui.PopWinActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/MyDialogStyle"
|
||||
tools:replace="android:exported" />
|
||||
<!-- Required SDK核心功能 -->
|
||||
tools:replace="android:exported" /> <!-- Required SDK核心功能 -->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PushActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
|
||||
@@ -178,7 +178,6 @@ public class MyApplication extends Application {
|
||||
intallApk(EXTRA);
|
||||
break;
|
||||
case JIGUANG_FORCE_UNINSTALLAPK:
|
||||
ToastUtil.debugShow("收到应用卸载消息");
|
||||
unintallApk(EXTRA);
|
||||
break;
|
||||
}
|
||||
@@ -294,14 +293,23 @@ public class MyApplication extends Application {
|
||||
if (jsonArray.length() > 0) {
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsonArray);
|
||||
String packageName = extra.getString("package");
|
||||
int is_network = extra.getInt("is_network");
|
||||
if (is_network == 1) {
|
||||
// Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", net_not);
|
||||
|
||||
String package0 = extra.getString("package0");
|
||||
String package1 = extra.getString("package1");
|
||||
if (package0.length() != 0) {
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", package0);
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_allow"));
|
||||
} else {
|
||||
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", "invalid");
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_allow"));
|
||||
}
|
||||
if (package1.length() != 0) {
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", package1);
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_disallow"));
|
||||
} else {
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", "invalid");
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_disallow"));
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.e("setAppNetworkstate", e.getMessage());
|
||||
@@ -375,7 +383,7 @@ public class MyApplication extends Application {
|
||||
JSONObject object = new JSONObject(json);
|
||||
String packageName = object.getString("package");
|
||||
ToastUtil.debugShow("收到应用卸载消息:包名" + packageName);
|
||||
if (!packageName.equals("")) {
|
||||
if (!packageName.equals("") && !packageName.equals(getAppContext().getPackageName())) {
|
||||
ApkUtils.deleteApkInSilence(packageName);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
||||
@@ -6,15 +6,33 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.base.BaseActivity;
|
||||
import com.appstore.uiui.base.RefreshManager;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.SPUtils;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class KindDetailActivity extends BaseActivity {
|
||||
public class KindDetailActivity extends BaseActivity implements RefreshManager.RefreshInterface {
|
||||
private TextView title;
|
||||
private String name;
|
||||
private int subject;
|
||||
private int subject, grade, type = 0;
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
private RecyclerView detail_rv;
|
||||
private AppAdapter adapter;
|
||||
private List<AppInfo> AppInfoList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,14 +43,34 @@ public class KindDetailActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void initView() {
|
||||
title = findViewById(R.id.detail_tv_title);
|
||||
detail_rv = findViewById(R.id.detail_rv);
|
||||
mRefreshLayout = findViewById(R.id.detail_refresh_layout);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
subject = getIntent().getIntExtra("kind", 0);
|
||||
name = getIntent().getStringExtra("name");
|
||||
if (name.equals("娱乐")) {
|
||||
type = 1;
|
||||
}
|
||||
grade = (int) SPUtils.get(this, "sn_grade", 0);
|
||||
title.setText(name);
|
||||
|
||||
RefreshManager.getInstance().register(this);
|
||||
adapter = new AppAdapter(AppInfoList, false, getApplicationContext());
|
||||
adapter.setHasStableIds(true);
|
||||
detail_rv.setAdapter(adapter);
|
||||
detail_rv.setLayoutManager(new LinearLayoutManager(this));
|
||||
mRefreshLayout.setEnableLoadMore(false);
|
||||
mRefreshLayout.setEnableRefresh(true);
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshlayout) {
|
||||
OKGOPost.getSortApp(handler, type, grade, subject);
|
||||
}
|
||||
});
|
||||
OKGOPost.getSortApp(handler, type, grade, subject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,9 +88,29 @@ public class KindDetailActivity extends BaseActivity {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
|
||||
AppInfoList = (List<AppInfo>) msg.obj;
|
||||
adapter.setData(checkUpdateOrInstalled(AppInfoList));
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
|
||||
}
|
||||
};
|
||||
public List<AppInfo> checkUpdateOrInstalled(List<AppInfo> list) {
|
||||
for (AppInfo appInfo : list) {
|
||||
appInfo.setInstall(ApkUtils.isAvailable(getApplicationContext(), appInfo.getApp_package()));
|
||||
appInfo.setUpdate(ApkUtils.checkIsUpdate(getApplicationContext(), appInfo.getApp_package(), Integer.parseInt(appInfo.getApp_version_code())));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mRefreshLayout.autoRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadBitMap(boolean isLoad) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MainActivity extends BaseActivity {
|
||||
search_layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
startActivity(new Intent(MainActivity.this, SearcherActivity.class));
|
||||
}
|
||||
});
|
||||
mSlidingTabLayout = findViewById(R.id.main_sliding_tab_layout);
|
||||
@@ -300,7 +300,7 @@ public class MainActivity extends BaseActivity {
|
||||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "POStemp";
|
||||
File file = new File(path);
|
||||
file.mkdirs();
|
||||
} else {
|
||||
} else {
|
||||
ToastUtil.show("需要授予所有权限才能正常使用本程序!");
|
||||
}
|
||||
}
|
||||
@@ -354,6 +354,7 @@ public class MainActivity extends BaseActivity {
|
||||
UserInfo userInfo = (UserInfo) msg.obj;
|
||||
SPUtils.put(MainActivity.this, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(MainActivity.this, "sn_id", userInfo.getId());
|
||||
SPUtils.put(MainActivity.this, "sn_grade", userInfo.getSn_grade());
|
||||
break;
|
||||
case 2:
|
||||
SPUtils.put(MainActivity.this, "isLogined", 2);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.appstore.uiui.activity;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.base.BaseActivity;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SearcherActivity extends BaseActivity {
|
||||
private SearchView search;
|
||||
private List<AppInfo> mAppInfoList = new ArrayList<>();
|
||||
private RecyclerView recyclerView;
|
||||
private AppAdapter madapter;
|
||||
|
||||
@Override
|
||||
protected int setLayoutResourceID() {
|
||||
return R.layout.activity_searcher;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
search = findViewById(R.id.search);
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
madapter = new AppAdapter(mAppInfoList, false, getApplicationContext());
|
||||
madapter.setHasStableIds(true);
|
||||
recyclerView.setAdapter(madapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setListener() {
|
||||
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
LogUtils.e("search", query);
|
||||
OKGOPost.searchAppbyName(handler, query);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
madapter.setData(new ArrayList<AppInfo>());
|
||||
madapter.notifyDataSetChanged();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void finish(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
mAppInfoList = (List<AppInfo>) msg.obj;
|
||||
madapter.setData(checkUpdateOrInstalled(mAppInfoList));
|
||||
madapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public List<AppInfo> checkUpdateOrInstalled(List<AppInfo> list) {
|
||||
for (AppInfo appInfo : list) {
|
||||
appInfo.setInstall(ApkUtils.isAvailable(getApplicationContext(), appInfo.getApp_package()));
|
||||
appInfo.setUpdate(ApkUtils.checkIsUpdate(getApplicationContext(), appInfo.getApp_package(), Integer.parseInt(appInfo.getApp_version_code())));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,9 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
||||
}
|
||||
} else {
|
||||
holder.btnDownLoad.setText("下载");
|
||||
if (downloadTask != null) {
|
||||
holder.refresh(downloadTask.progress);
|
||||
}
|
||||
}
|
||||
holder.btnDownLoad.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -178,7 +181,6 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
||||
break;
|
||||
case Progress.FINISH:
|
||||
btnDownLoad.setText("完成");
|
||||
|
||||
break;
|
||||
case Progress.LOADING:
|
||||
btnDownLoad.setText((int) (progress.fraction * 100) + "%");
|
||||
|
||||
@@ -83,7 +83,7 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
|
||||
@Override
|
||||
public void loadData(Bundle savedInstanceState) {
|
||||
// initData();
|
||||
initAPPData(handler);
|
||||
// initAPPData(handler);
|
||||
}
|
||||
|
||||
synchronized private void initAPPData(final Handler handler) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.appstore.uiui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
@@ -15,6 +17,10 @@ import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.base.LazyLoadFragment;
|
||||
import com.appstore.uiui.base.RefreshManager;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
|
||||
@@ -32,14 +38,9 @@ import java.util.List;
|
||||
public class RankFragment extends LazyLoadFragment implements RefreshManager.RefreshInterface {
|
||||
private RecyclerView mRvResult;
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
|
||||
private int page = 1;
|
||||
private List<AppInfo> mAppInfoList;
|
||||
private AppAdapter mAppAdapter;
|
||||
|
||||
private boolean isNotLoadBitmap;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.fragment_rank;
|
||||
@@ -55,117 +56,59 @@ public class RankFragment extends LazyLoadFragment implements RefreshManager.Ref
|
||||
|
||||
@Override
|
||||
public void loadData(Bundle savedInstanceState) {
|
||||
mRefreshLayout.autoRefresh();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
OKGOPost.getRankApp(handler);
|
||||
LogUtils.e("fht", "RankFragment onStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
LogUtils.e("fht", "RankFragment onResume");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
LogUtils.e("fht", "RankFragment onPause");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
LogUtils.e("fht", "RankFragment onStop");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.e("fht", "RankFragment onDestroy");
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
isNotLoadBitmap = false;
|
||||
|
||||
mAppInfoList = new ArrayList<>();
|
||||
mAppAdapter = new AppAdapter(mAppInfoList, true, getContext());
|
||||
mRvResult.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mRvResult.setAdapter(mAppAdapter);
|
||||
|
||||
mRefreshLayout.setEnableRefresh(true);
|
||||
mRefreshLayout.setEnableLoadMore(true);
|
||||
|
||||
mRefreshLayout.setEnableLoadMore(false);
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshlayout) {
|
||||
// RetrofitManager.getInstance(getActivity()).getRankList(1)
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Subscriber<List<AppInfo>>() {
|
||||
// @Override
|
||||
// public void onCompleted() {
|
||||
// getDetailData(true);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.d("test", e.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<AppInfo> appInfos) {
|
||||
//
|
||||
// mAppInfoList.clear();
|
||||
// mAppInfoList.addAll(appInfos);
|
||||
// mAppAdapter.notifyDataSetChanged();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
|
||||
mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
// RetrofitManager.getInstance(getActivity()).getRankList(++page)
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Subscriber<List<AppInfo>>() {
|
||||
// @Override
|
||||
// public void onCompleted() {
|
||||
// getDetailData(false);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.d("test", e.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<AppInfo> appInfos) {
|
||||
// mAppInfoList.addAll(appInfos);
|
||||
// mAppAdapter.notifyDataSetChanged();
|
||||
// }
|
||||
// });
|
||||
OKGOPost.getRankApp(handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// private void getDetailData(final boolean isRefresh) {
|
||||
// for (int i = 0; i < mAppInfoList.size(); i++) {
|
||||
// final int position = i;
|
||||
// RetrofitManager.getInstance(getActivity()).getDetailInfo(mAppInfoList.get(i))
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Subscriber<AppInfo>() {
|
||||
// @Override
|
||||
// public void onCompleted() {
|
||||
// mAppAdapter.notifyItemChanged(position);
|
||||
// mAppAdapter.notifyDataSetChanged();
|
||||
// if (mAppInfoList.size() - 1 == position) {
|
||||
// if (isRefresh) {
|
||||
// page = 1;
|
||||
// mRefreshLayout.finishRefresh();
|
||||
// } else {
|
||||
// mRefreshLayout.finishLoadMore();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.d("test", "onError:" + e.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(AppInfo appInfo) {
|
||||
// boolean isInstall = LocalAppManager.getInstance(getActivity()).isInstall(appInfo);
|
||||
// appInfo.setInstall(isInstall);
|
||||
// //判断是否需要升级
|
||||
// if (isInstall) {
|
||||
// boolean isUpdate = LocalAppManager.getInstance(getActivity()).isNeedUpdate(appInfo);
|
||||
// appInfo.setUpdate(isUpdate);
|
||||
// }
|
||||
// mAppInfoList.set(position, appInfo);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
@@ -174,6 +117,29 @@ public class RankFragment extends LazyLoadFragment implements RefreshManager.Ref
|
||||
|
||||
@Override
|
||||
public void onLoadBitMap(boolean isLoad) {
|
||||
mAppAdapter.setNotLoadBitmap(isLoad);
|
||||
|
||||
}
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
mAppInfoList = (List<AppInfo>) msg.obj;
|
||||
mAppAdapter.setData(checkUpdateOrInstalled(mAppInfoList));
|
||||
mAppAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
};
|
||||
|
||||
public List<AppInfo> checkUpdateOrInstalled(List<AppInfo> list) {
|
||||
for (AppInfo appInfo : list) {
|
||||
appInfo.setInstall(ApkUtils.isAvailable(getContext(), appInfo.getApp_package()));
|
||||
appInfo.setUpdate(ApkUtils.checkIsUpdate(getContext(), appInfo.getApp_package(), Integer.parseInt(appInfo.getApp_version_code())));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ public class OKGOPost {
|
||||
}
|
||||
};
|
||||
|
||||
//msg.what=0
|
||||
synchronized public static void getAllAppInfo(final Handler handler) {
|
||||
OkGo.<String>post(Url.GET_ALL_APPINFO).execute(new StringCallback() {
|
||||
@Override
|
||||
@@ -75,6 +74,43 @@ public class OKGOPost {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<String> response) {
|
||||
super.onError(response);
|
||||
LogUtils.e("onError", response.getException().toString());
|
||||
ToastUtil.show("网络连接失败,检查网络连接");
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public static void getRankApp(final Handler handler) {
|
||||
OkGo.<String>get(Url.GET_ALL_RANK).execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(Response<String> response) {
|
||||
try {
|
||||
JSONObject body = JSON.parseObject(response.body());
|
||||
// LogUtils.e("onSuccess", body.toString());
|
||||
LogUtils.e("fht", "getAllAppInfo onSuccess");
|
||||
int code = body.getInteger("code");
|
||||
String msg = body.getString("msg");
|
||||
String data = body.getString("data");
|
||||
List<AppInfo> applist = JSON.parseArray(data, AppInfo.class);
|
||||
if (code == MessageWhat.CODE_SUCCESSFUL) {
|
||||
Message message = new Message();
|
||||
message.what = 1;
|
||||
message.obj = applist;
|
||||
handler.sendMessage(message);
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Exception", e.getMessage());
|
||||
ToastUtil.show("服务器错误,请稍后重试");
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<String> response) {
|
||||
@@ -82,14 +118,52 @@ public class OKGOPost {
|
||||
LogUtils.e("onError", response.getException().toString());
|
||||
ToastUtil.show("网络连接失败,检查网络连接");
|
||||
handler.sendEmptyMessage(0);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//msg.what=1
|
||||
synchronized public static void searchAppbyName(final Handler handler, String app_name) {
|
||||
OkGo.<String>post(Url.GET_APPSEARCHE)
|
||||
.params("app_name", app_name)
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(Response<String> response) {
|
||||
try {
|
||||
JSONObject body = JSON.parseObject(response.body());
|
||||
LogUtils.e("onSuccess", body.toString());
|
||||
LogUtils.e("fht", "searchAppbyName onSuccess");
|
||||
int code = body.getInteger("code");
|
||||
String msg = body.getString("msg");
|
||||
String data = body.getString("data");
|
||||
List<AppInfo> applist = JSON.parseArray(data, AppInfo.class);
|
||||
if (code == MessageWhat.CODE_SUCCESSFUL) {
|
||||
Message message = new Message();
|
||||
message.what = 1;
|
||||
message.obj = applist;
|
||||
handler.sendMessage(message);
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Exception", e.getMessage());
|
||||
ToastUtil.show("服务器错误,请稍后重试");
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<String> response) {
|
||||
super.onError(response);
|
||||
LogUtils.e("onError", response.getException().toString());
|
||||
ToastUtil.show("网络连接失败,检查网络连接");
|
||||
handler.sendEmptyMessage(0);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
synchronized public static void getUserInfo(final Handler handler) {
|
||||
String sn = Utils.getSerial();
|
||||
OkGo.<String>post(Url.GET_INFO_FROMESN)
|
||||
@@ -122,7 +196,6 @@ public class OKGOPost {
|
||||
});
|
||||
}
|
||||
|
||||
//msg.what=2
|
||||
synchronized public static void getUserInfo(final Context context) {
|
||||
OkGo.<String>post(Url.GET_INFO_FROMESN)
|
||||
.params("sn", Utils.getSerial())
|
||||
@@ -138,6 +211,7 @@ public class OKGOPost {
|
||||
UserInfo userInfo = JSON.parseObject(data, UserInfo.class);
|
||||
SPUtils.put(context, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(context, "sn_id", userInfo.getId());
|
||||
SPUtils.put(context, "sn_grade", userInfo.getSn_grade());
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
@@ -152,7 +226,6 @@ public class OKGOPost {
|
||||
});
|
||||
}
|
||||
|
||||
//msg.what=3
|
||||
synchronized public static void getSortApp(final Handler handler, int type, int grade, int subject) {
|
||||
OkGo.<String>post(Url.GET_SORT_APP)
|
||||
.params("app_type", type)//应用分类 0学习 1娱乐
|
||||
@@ -163,6 +236,7 @@ public class OKGOPost {
|
||||
public void onSuccess(Response<String> response) {
|
||||
LogUtils.e("fht", "getSortApp onSuccess");
|
||||
JSONObject jsonObject = JSON.parseObject(response.body());
|
||||
LogUtils.e("fht", jsonObject.toString());
|
||||
int code = jsonObject.getInteger("code");
|
||||
String msg = jsonObject.getString("msg");
|
||||
if (code == MessageWhat.CODE_SUCCESSFUL) {
|
||||
@@ -174,6 +248,7 @@ public class OKGOPost {
|
||||
handler.sendMessage(message);
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,11 +257,11 @@ public class OKGOPost {
|
||||
super.onError(response);
|
||||
LogUtils.e("onError", response.getException().toString());
|
||||
ToastUtil.show("网络连接失败,检查网络连接");
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//msg.what=4
|
||||
synchronized public static void setAppinstallInfo(int member_id, String sn_id, String app_name, String packageName) {
|
||||
OkGo.<String>post(Url.SET_APP_INSTALL_INFO)
|
||||
.params("member_id", member_id)
|
||||
@@ -216,7 +291,6 @@ public class OKGOPost {
|
||||
|
||||
}
|
||||
|
||||
//msg.what=5
|
||||
synchronized public static void setAppuninstallInfo(String sn_id, String packageName) {
|
||||
OkGo.<String>post(Url.SET_APP_UNINSTALL_INFO)
|
||||
.params("sn_id", sn_id)
|
||||
@@ -227,10 +301,11 @@ public class OKGOPost {
|
||||
JSONObject object = JSON.parseObject(response.body());
|
||||
int code = object.getInteger("code");
|
||||
String msg = object.getString("msg");
|
||||
LogUtils.e("setAppinstallInfo", msg);
|
||||
if (code == MessageWhat.CODE_SUCCESSFUL) {
|
||||
LogUtils.e("setAppinstallInfo", msg);
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,5 +319,6 @@ public class OKGOPost {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ public class Url {
|
||||
|
||||
public final static String GET_ALL_APPINFO = NETWORK_HOME_ADDRESS + "/App/allInfo";
|
||||
//获取所有应用
|
||||
public final static String GET_ALL_RANK = NETWORK_HOME_ADDRESS + "/App/rankings";
|
||||
//获取所有应用排行
|
||||
public final static String GET_APPSEARCHE = NETWORK_HOME_ADDRESS + "/App/appSearch";
|
||||
//搜索应用
|
||||
public final static String GET_INFO_FROMESN = NETWORK_HOME_ADDRESS + "/Member/snInfo";
|
||||
//通过SN获取绑定信息
|
||||
public final static String GET_SORT_APP = NETWORK_HOME_ADDRESS + "/App/sortApp";
|
||||
|
||||
@@ -30,10 +30,12 @@ public class AppManagerReceiver extends BroadcastReceiver {
|
||||
ToastUtil.show(name + ":安装成功");
|
||||
LogUtils.e(TAG, "安装了:" + packageName + "包名的程序");
|
||||
// ToastTool.show("安装成功");
|
||||
if (member_id == -1 || sn_id.equals("-1")) {
|
||||
OKGOPost.getUserInfo(context);
|
||||
} else {
|
||||
OKGOPost.setAppinstallInfo(member_id, sn_id, name, packageName);
|
||||
if (!packageName.equals(context.getPackageName())) {
|
||||
if (member_id == -1 || sn_id.equals("-1")) {
|
||||
OKGOPost.getUserInfo(context);
|
||||
} else {
|
||||
OKGOPost.setAppinstallInfo(member_id, sn_id, name, packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +43,12 @@ public class AppManagerReceiver extends BroadcastReceiver {
|
||||
if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
|
||||
String packageName = intent.getDataString().replace("package:", "");
|
||||
LogUtils.e(TAG, "卸载了:" + packageName + "包名的程序");
|
||||
if (member_id == -1 || sn_id.equals("-1")) {
|
||||
OKGOPost.getUserInfo(context);
|
||||
} else {
|
||||
OKGOPost.setAppuninstallInfo(sn_id, packageName);
|
||||
if (!packageName.equals(context.getPackageName())) {
|
||||
if (member_id == -1 || sn_id.equals("-1")) {
|
||||
OKGOPost.getUserInfo(context);
|
||||
} else {
|
||||
OKGOPost.setAppuninstallInfo(sn_id, packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
app/src/main/res/drawable/icon_serach.png
Normal file
BIN
app/src/main/res/drawable/icon_serach.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
9
app/src/main/res/drawable/shap_search_left.xml
Normal file
9
app/src/main/res/drawable/shap_search_left.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 内部颜色 -->
|
||||
<solid android:color="#EBEBEB" />
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners
|
||||
android:bottomLeftRadius="@dimen/dp_25"
|
||||
android:topLeftRadius="@dimen/dp_25" />
|
||||
</shape>
|
||||
11
app/src/main/res/drawable/shap_search_right.xml
Normal file
11
app/src/main/res/drawable/shap_search_right.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 内部颜色 -->
|
||||
<solid
|
||||
android:color="#EBEBEB" />
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners
|
||||
android:topRightRadius="@dimen/dp_25"
|
||||
android:bottomRightRadius="@dimen/dp_25" />
|
||||
</shape>
|
||||
@@ -38,22 +38,41 @@
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="#d4d0d0"
|
||||
app:cardCornerRadius="15dp">
|
||||
|
||||
<androidx.appcompat.widget.SearchView
|
||||
android:id="@+id/search_view"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/search_ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:background="#ffffff" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_12"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/shap_search_left" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="#EBEBEB"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/icon_serach"></ImageView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:background="@drawable/shap_search_right"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/search_edit"
|
||||
android:textColor="#c1bfbf">
|
||||
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
56
app/src/main/res/layout/activity_searcher.xml
Normal file
56
app/src/main/res/layout/activity_searcher.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.SearcherActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="@dimen/dp_10"
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="finish"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_back" />
|
||||
|
||||
<androidx.appcompat.widget.SearchView
|
||||
android:id="@+id/search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_40"
|
||||
app:iconifiedByDefault="false"
|
||||
app:queryHint="@string/search_edit">
|
||||
|
||||
</androidx.appcompat.widget.SearchView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.scwang.smartrefresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/featured_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
tools:listitem="@layout/item_app" />
|
||||
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,4 +2,6 @@
|
||||
<string name="app_name">应用市场</string>
|
||||
<string name="download_btn_had">打开</string>
|
||||
<string name="open_app_fail">打开失败!</string>
|
||||
<string name="search_edit">请输入应用名称或关键字</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user