管控功能移植
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
package com.mjsheng.myappstore.activity;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.AppUtils;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.base.BaseActivity;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
public class AboutActivity extends BaseActivity {
|
||||
private TextView mTv_version_code;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
mTv_version_code = (TextView) findViewById(R.id.tv_version_code);
|
||||
mTv_version_code.setText("版本号:" + AppUtils.getAppVersionName() + "");
|
||||
mTv_version_code.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String registrationID = JPushInterface.getRegistrationID(AboutActivity.this);
|
||||
Log.e("mjsheng", registrationID + "------------------------");
|
||||
// ToastUtils.showLong("registrationID::" + registrationID);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -1,644 +0,0 @@
|
||||
package com.mjsheng.myappstore.activity;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.AppUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.cache.CacheMode;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.adapter.AppUpdateListAdapter;
|
||||
import com.mjsheng.myappstore.adapter.DownloadListAdapter;
|
||||
import com.mjsheng.myappstore.adapter.UninstallListAdapter;
|
||||
import com.mjsheng.myappstore.base.BaseActivity;
|
||||
import com.mjsheng.myappstore.bean.AppContentInfo;
|
||||
import com.mjsheng.myappstore.bean.AppDownloadInfo;
|
||||
import com.mjsheng.myappstore.bean.AppUpdateInfo;
|
||||
import com.mjsheng.myappstore.bean.JsonCallback;
|
||||
import com.mjsheng.myappstore.bean.LocalAppInfo;
|
||||
import com.mjsheng.myappstore.bean.LzyResponse;
|
||||
import com.mjsheng.myappstore.utils.AppsManagerUtils;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SpacesItemDecoration;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
import com.mjsheng.myappstore.view.RecycleGridLayoutManager;
|
||||
import com.mjsheng.myappstore.widget.Sound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class DownloadActivity extends BaseActivity implements OnCheckedChangeListener, Runnable {
|
||||
|
||||
private static final int DOWNLOAD_RADID_BTTON_INDEX = 10;
|
||||
private static final int UNINSTALL_RADID_BTTON_INDEX = 11;
|
||||
private static final int UPDATE_RADID_BTTON_INDEX = 12;
|
||||
private static final int ABOUT_RADID_BTTON_INDEX = 13;
|
||||
|
||||
private DownloadListAdapter mDownloadListAdapter;
|
||||
private UninstallListAdapter mUninstallListAdapter;
|
||||
private AppUpdateListAdapter mUpdateAppListAdapter;
|
||||
private RelativeLayout reLayout1, reLayout2, reLayout3;
|
||||
private RecyclerView mDownloadListView, mUninstallListView, mAppupdateListView;
|
||||
private RadioButton mDownloadRadioButton, mUpdateRadioButton, mUninstallRadioButton;
|
||||
// , mAboutRadioButton;
|
||||
private RelativeLayout mLoadingLayout;
|
||||
private ImageView mLoadImg;
|
||||
private Integer index = 0;
|
||||
private RadioGroup mManageRadioGroup;
|
||||
private Integer LastCheckedId;
|
||||
private List<AppContentInfo> updateAllList = new ArrayList<>();
|
||||
private List<LocalAppInfo> uninstallAllList = new ArrayList<>();
|
||||
private Sound sound;
|
||||
private DownloadReceiver downloadReceiver;
|
||||
private ExecutorService mExecutorService;
|
||||
private TextView mManage_load_tv;
|
||||
private RecycleGridLayoutManager mManager;
|
||||
private RecycleGridLayoutManager mGridLayoutManager;
|
||||
private TextView mTv_version_code;
|
||||
private Button manage_about_tab;
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
initParameter();
|
||||
initViews();
|
||||
switch (index) {
|
||||
case DOWNLOAD_RADID_BTTON_INDEX:
|
||||
mDownloadRadioButton.setChecked(true);
|
||||
break;
|
||||
case UNINSTALL_RADID_BTTON_INDEX:
|
||||
mUpdateRadioButton.setChecked(true);
|
||||
break;
|
||||
case UPDATE_RADID_BTTON_INDEX:
|
||||
mUninstallRadioButton.setChecked(true);
|
||||
break;
|
||||
// case ABOUT_RADID_BTTON_INDEX:
|
||||
// mAboutRadioButton.setChecked(true);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
private Handler mHandler = new Handler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case DOWNLOAD_RADID_BTTON_INDEX:
|
||||
if (mDownloadListAdapter.getItemCount() == 0) {
|
||||
// int width = (int) getResources().getDimension(R.dimen.managepage_notask_Width);
|
||||
// ;
|
||||
// int hight = (int) getResources().getDimension(R.dimen.managepage_notask_Hight);
|
||||
// ;
|
||||
// mLoadImg.setMaxWidth(width);
|
||||
// mLoadImg.setMaxHeight(hight);
|
||||
// ImageLoader.getDefault().load(DownloadActivity.this, R.drawable.manage_notask, mLoadImg);
|
||||
mManage_load_tv.setText("没有任务");
|
||||
mLoadingLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
case UNINSTALL_RADID_BTTON_INDEX:
|
||||
if (mUninstallListAdapter.getItemCount() == 0) {
|
||||
int width = (int) getResources().getDimension(R.dimen.managepage_notask_Width);
|
||||
;
|
||||
int hight = (int) getResources().getDimension(R.dimen.managepage_notask_Hight);
|
||||
;
|
||||
mManage_load_tv.setText("没有任务");
|
||||
// mLoadImg.setMaxWidth(width);
|
||||
// mLoadImg.setMaxHeight(hight);
|
||||
// ImageLoader.getDefault().load(DownloadActivity.this, R.drawable.manage_notask, mLoadImg);
|
||||
mLoadingLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
case UPDATE_RADID_BTTON_INDEX:
|
||||
if (mUpdateAppListAdapter.getItemCount() == 0) {
|
||||
// int width = (int) getResources().getDimension(R.dimen.managepage_noupdate_Width);
|
||||
// ;
|
||||
// int hight = (int) getResources().getDimension(R.dimen.managepage_notask_Hight);
|
||||
// ;
|
||||
// mLoadImg.setMaxWidth(width);
|
||||
// mLoadImg.setMaxHeight(hight);
|
||||
// ImageLoader.getDefault().load(DownloadActivity.this, R.drawable.manage_noupdate, mLoadImg);
|
||||
mManage_load_tv.setText("没有更新");
|
||||
mLoadingLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
case ABOUT_RADID_BTTON_INDEX:
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
break;
|
||||
case Configure.SUCCESS:
|
||||
Bundle data = msg.getData();
|
||||
String httTag = data.getString("httpTag");
|
||||
if (httTag.equals(Configure.RANKING_TYPE_UPDATE)) {
|
||||
if (msg.obj != null) {
|
||||
List<AppContentInfo> list = (List<AppContentInfo>) msg.obj;
|
||||
if (!list.isEmpty()) {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
updateAllList.addAll(list);
|
||||
mUpdateAppListAdapter.setDatas(updateAllList);
|
||||
mUpdateRadioButton.setText("可更新(" + list.size() + ")");
|
||||
} else {
|
||||
mUpdateRadioButton.setText("可更新(0)");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
private RecycleGridLayoutManager mLayoutManager;
|
||||
|
||||
|
||||
protected void initParameter() {
|
||||
setContentView(R.layout.manage_page_layout);
|
||||
sound = new Sound(DownloadActivity.this);
|
||||
mExecutorService = Executors.newCachedThreadPool();
|
||||
|
||||
downloadReceiver = new DownloadReceiver();
|
||||
/* 注册广播 */
|
||||
IntentFilter mScreenOnFilter = new IntentFilter();
|
||||
mScreenOnFilter.addAction(Utils.DOWNLOAD_SERVICE_ACTION);
|
||||
mScreenOnFilter.addAction(Utils.DOWNLOAD_ALLSERVICE_ACTION);
|
||||
mScreenOnFilter.addAction(Utils.DOWNLOAD_NEWSERVICE_ACTION);
|
||||
mScreenOnFilter.addAction(Utils.ACTION_PACKAGE_REPLACED);
|
||||
mScreenOnFilter.addAction(Utils.ACTION_PACKAGE_REMOVED);
|
||||
mScreenOnFilter.addAction(Utils.ACTION_PACKAGE_ADDED);
|
||||
registerReceiver(downloadReceiver, mScreenOnFilter);
|
||||
|
||||
}
|
||||
|
||||
protected void initViews() {
|
||||
reLayout1 = (RelativeLayout) findViewById(R.id.manage_rLayout1);
|
||||
reLayout2 = (RelativeLayout) findViewById(R.id.manage_rLayout2);
|
||||
reLayout3 = (RelativeLayout) findViewById(R.id.manage_rLayout3);
|
||||
|
||||
mDownloadListView = (RecyclerView) findViewById(R.id.download_manage_listview);
|
||||
mUninstallListView = (RecyclerView) findViewById(R.id.uninstall_manage_listview);
|
||||
mAppupdateListView = (RecyclerView) findViewById(R.id.appupdate_manage_listview);
|
||||
|
||||
mManageRadioGroup = (RadioGroup) findViewById(R.id.manage_radio_group);
|
||||
mManageRadioGroup.setOnCheckedChangeListener(this);
|
||||
|
||||
mDownloadRadioButton = findViewById(R.id.manage_download_tab);
|
||||
mUpdateRadioButton = findViewById(R.id.manage_update_tab);
|
||||
mUninstallRadioButton = findViewById(R.id.manage_uninstall_tab);
|
||||
// mAboutRadioButton = findViewById(R.id.manage_about_tab);
|
||||
|
||||
mLoadingLayout = (RelativeLayout) findViewById(R.id.manage_linearlayout);
|
||||
mLoadImg = (ImageView) findViewById(R.id.manage_load_img);
|
||||
|
||||
mManage_load_tv = (TextView) findViewById(R.id.manage_load_tv);
|
||||
|
||||
findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mTv_version_code = (TextView) findViewById(R.id.tv_version_code);
|
||||
mTv_version_code.setText("版本号:" + AppUtils.getAppVersionName() + "");
|
||||
mTv_version_code.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String registrationID = JPushInterface.getRegistrationID(DownloadActivity.this);
|
||||
Log.e("mjsheng", registrationID + "------------------------");
|
||||
// ToastUtils.showLong("registrationID::" + registrationID);
|
||||
}
|
||||
});
|
||||
manage_about_tab = findViewById(R.id.manage_about_tab);
|
||||
manage_about_tab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(DownloadActivity.this, AboutActivity.class));
|
||||
}
|
||||
});
|
||||
reLayout1.setVisibility(View.GONE);
|
||||
reLayout2.setVisibility(View.GONE);
|
||||
mDownloadRadioButton.setChecked(true);
|
||||
|
||||
mExecutorService.execute(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
// 注销广播接收
|
||||
if (downloadReceiver != null) {
|
||||
unregisterReceiver(downloadReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
// sound.playSoundEffect();
|
||||
RadioButton button = (RadioButton) findViewById(checkedId);
|
||||
// button.setTextColor(getResources().getColor(R.color.main_color));
|
||||
if (checkedId == R.id.manage_download_tab) {
|
||||
index = DOWNLOAD_RADID_BTTON_INDEX;
|
||||
} else if (checkedId == R.id.manage_uninstall_tab) {
|
||||
index = UNINSTALL_RADID_BTTON_INDEX;
|
||||
} else if (checkedId == R.id.manage_update_tab) {
|
||||
index = UPDATE_RADID_BTTON_INDEX;
|
||||
}
|
||||
// else if (checkedId == R.id.manage_about_tab) {
|
||||
// index = ABOUT_RADID_BTTON_INDEX;
|
||||
// }
|
||||
showContentList(index);
|
||||
if (LastCheckedId != null && LastCheckedId != checkedId) {
|
||||
RadioButton radioButton = (RadioButton) findViewById(LastCheckedId);
|
||||
// radioButton.setBackgroundColor(Color.TRANSPARENT);
|
||||
// radioButton.setTextColor(getResources().getColor(R.color.textColor));
|
||||
}
|
||||
LastCheckedId = checkedId;
|
||||
}
|
||||
|
||||
|
||||
private void initUpdateAppDatas() {
|
||||
List<AppUpdateInfo> upadteApps = AppsManagerUtils.getUpadteApps(this);
|
||||
String update = new Gson().toJson(upadteApps);
|
||||
OkGo.post(Configure.HTTP_TAG_APPBAOMING)
|
||||
.params("baoming", java.net.URLEncoder.encode(update))
|
||||
.tag(this)
|
||||
.cacheKey(Configure.HTTP_TAG_APPBAOMING + java.net.URLEncoder.encode(update))
|
||||
.cacheMode(CacheMode.NO_CACHE)
|
||||
.execute(new JsonCallback<LzyResponse<List<AppContentInfo>>>() {
|
||||
@Override
|
||||
public void onSuccess(LzyResponse<List<AppContentInfo>> listLzyResponse, Call call, Response response) {
|
||||
Message msg = new Message();
|
||||
msg.what = Configure.SUCCESS;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("httpTag", Configure.RANKING_TYPE_UPDATE);
|
||||
msg.obj = listLzyResponse.data;
|
||||
msg.setData(bundle);
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
mUpdateRadioButton.setText("可更新(0)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showContentList(int index) {
|
||||
if (index == DOWNLOAD_RADID_BTTON_INDEX) {
|
||||
mDownloadListView.setVisibility(View.VISIBLE);
|
||||
reLayout1.setVisibility(View.GONE);
|
||||
reLayout2.setVisibility(View.GONE);
|
||||
reLayout3.setVisibility(View.GONE);
|
||||
|
||||
mDownloadListView.smoothScrollToPosition(0);
|
||||
mHandler.sendEmptyMessage(DOWNLOAD_RADID_BTTON_INDEX);
|
||||
} else if (index == UNINSTALL_RADID_BTTON_INDEX) {
|
||||
mDownloadListView.setVisibility(View.GONE);
|
||||
reLayout2.setVisibility(View.GONE);
|
||||
reLayout1.setVisibility(View.VISIBLE);
|
||||
reLayout3.setVisibility(View.GONE);
|
||||
|
||||
mUninstallListView.smoothScrollToPosition(0);
|
||||
mHandler.sendEmptyMessage(UNINSTALL_RADID_BTTON_INDEX);
|
||||
} else if (index == UPDATE_RADID_BTTON_INDEX) {
|
||||
mDownloadListView.setVisibility(View.GONE);
|
||||
reLayout1.setVisibility(View.GONE);
|
||||
reLayout2.setVisibility(View.VISIBLE);
|
||||
reLayout3.setVisibility(View.GONE);
|
||||
|
||||
mAppupdateListView.smoothScrollToPosition(0);
|
||||
mHandler.sendEmptyMessage(UPDATE_RADID_BTTON_INDEX);
|
||||
}
|
||||
// else if (index == ABOUT_RADID_BTTON_INDEX) {
|
||||
// mDownloadListView.setVisibility(View.GONE);
|
||||
// reLayout1.setVisibility(View.GONE);
|
||||
// reLayout2.setVisibility(View.GONE);
|
||||
// reLayout3.setVisibility(View.VISIBLE);
|
||||
// mHandler.sendEmptyMessage(ABOUT_RADID_BTTON_INDEX);
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int orientation = getResources().getConfiguration().orientation;
|
||||
|
||||
mDownloadListAdapter = new DownloadListAdapter(this, new DownloadListAdapter.setItemSizeListener() {
|
||||
@Override
|
||||
public void setItemSize(int size) {
|
||||
mDownloadRadioButton.setText("新任务(" + size + ")");
|
||||
if (index == DOWNLOAD_RADID_BTTON_INDEX) {
|
||||
mHandler.sendEmptyMessage(DOWNLOAD_RADID_BTTON_INDEX);
|
||||
}
|
||||
}
|
||||
});
|
||||
switch (orientation) {
|
||||
case Configuration.ORIENTATION_PORTRAIT:
|
||||
mManager = new RecycleGridLayoutManager(this, 1);
|
||||
break;
|
||||
case Configuration.ORIENTATION_LANDSCAPE:
|
||||
mManager = new RecycleGridLayoutManager(this, 2);
|
||||
break;
|
||||
}
|
||||
mManager.setOrientation(GridLayoutManager.VERTICAL);
|
||||
mManager.setSmoothScrollbarEnabled(true);
|
||||
mDownloadListView.setLayoutManager(mManager);
|
||||
mDownloadListView.setNestedScrollingEnabled(false);
|
||||
mDownloadListView.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.PX5x), getResources().getDimensionPixelSize(R.dimen.PX5x),
|
||||
getResources().getDimensionPixelSize(R.dimen.PX10x), getResources().getDimensionPixelSize(R.dimen.PX10x)));
|
||||
((DefaultItemAnimator) mDownloadListView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mDownloadListView.setAdapter(mDownloadListAdapter);
|
||||
}
|
||||
});
|
||||
|
||||
mUninstallListAdapter = new UninstallListAdapter(this, new UninstallListAdapter.setItemSizeListener() {
|
||||
@Override
|
||||
public void setItemSize(int size) {
|
||||
mUninstallRadioButton.setText("已安装(" + uninstallAllList.size() + ")");
|
||||
if (index == UNINSTALL_RADID_BTTON_INDEX) {
|
||||
mHandler.sendEmptyMessage(UNINSTALL_RADID_BTTON_INDEX);
|
||||
}
|
||||
}
|
||||
});
|
||||
switch (orientation) {
|
||||
case Configuration.ORIENTATION_PORTRAIT:
|
||||
mLayoutManager = new RecycleGridLayoutManager(this, 1);
|
||||
break;
|
||||
case Configuration.ORIENTATION_LANDSCAPE:
|
||||
mLayoutManager = new RecycleGridLayoutManager(this, 3);
|
||||
break;
|
||||
}
|
||||
mLayoutManager.setOrientation(GridLayoutManager.VERTICAL);
|
||||
mLayoutManager.setSmoothScrollbarEnabled(true);
|
||||
mUninstallListView.setLayoutManager(mLayoutManager);
|
||||
mUninstallListView.setNestedScrollingEnabled(false);
|
||||
mUninstallListView.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.PX5x), getResources().getDimensionPixelSize(R.dimen.PX5x),
|
||||
getResources().getDimensionPixelSize(R.dimen.PX10x), getResources().getDimensionPixelSize(R.dimen.PX10x)));
|
||||
((DefaultItemAnimator) mUninstallListView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mUninstallListView.setAdapter(mUninstallListAdapter);
|
||||
}
|
||||
});
|
||||
|
||||
mUpdateAppListAdapter = new AppUpdateListAdapter(this, new AppUpdateListAdapter.setItemSizeListener() {
|
||||
@Override
|
||||
public void setItemSize(int size) {
|
||||
mUpdateRadioButton.setText("可更新(" + updateAllList.size() + ")");
|
||||
if (index == UNINSTALL_RADID_BTTON_INDEX) {
|
||||
mHandler.sendEmptyMessage(UPDATE_RADID_BTTON_INDEX);
|
||||
}
|
||||
}
|
||||
});
|
||||
switch (orientation) {
|
||||
case Configuration.ORIENTATION_PORTRAIT:
|
||||
mGridLayoutManager = new RecycleGridLayoutManager(this, 1);
|
||||
break;
|
||||
case Configuration.ORIENTATION_LANDSCAPE:
|
||||
mGridLayoutManager = new RecycleGridLayoutManager(this, 3);
|
||||
break;
|
||||
}
|
||||
mGridLayoutManager.setOrientation(GridLayoutManager.VERTICAL);
|
||||
mGridLayoutManager.setSmoothScrollbarEnabled(true);
|
||||
mAppupdateListView.setLayoutManager(mGridLayoutManager);
|
||||
mAppupdateListView.setNestedScrollingEnabled(false);
|
||||
mAppupdateListView.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.PX5x), getResources().getDimensionPixelSize(R.dimen.PX5x),
|
||||
getResources().getDimensionPixelSize(R.dimen.PX10x), getResources().getDimensionPixelSize(R.dimen.PX10x)));
|
||||
((DefaultItemAnimator) mAppupdateListView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mAppupdateListView.setAdapter(mUpdateAppListAdapter);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mUninstallListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
switch (newState) {
|
||||
case RecyclerView.SCROLL_STATE_DRAGGING:
|
||||
case RecyclerView.SCROLL_STATE_SETTLING:
|
||||
// 当ListView处于滑动状态时,停止加载图片,保证操作界面流畅
|
||||
Glide.with(DownloadActivity.this).pauseRequests();
|
||||
break;
|
||||
case RecyclerView.SCROLL_STATE_IDLE:
|
||||
// 当ListView处于静止状态时,继续加载图片
|
||||
Glide.with(DownloadActivity.this).resumeRequests();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mUninstallListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
switch (newState) {
|
||||
case RecyclerView.SCROLL_STATE_DRAGGING:
|
||||
case RecyclerView.SCROLL_STATE_SETTLING:
|
||||
// 当ListView处于滑动状态时,停止加载图片,保证操作界面流畅
|
||||
Glide.with(DownloadActivity.this).pauseRequests();
|
||||
break;
|
||||
case RecyclerView.SCROLL_STATE_IDLE:
|
||||
// 当ListView处于静止状态时,继续加载图片
|
||||
Glide.with(DownloadActivity.this).resumeRequests();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Intent allIntent = new Intent();
|
||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||
sendBroadcast(allIntent);
|
||||
|
||||
uninstallAllList = AppsManagerUtils.getUserApps(this);
|
||||
if (uninstallAllList != null && !uninstallAllList.isEmpty()) {
|
||||
|
||||
if (mUninstallListAdapter != null) {
|
||||
mUninstallListView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mUninstallListAdapter.setDatas(uninstallAllList);
|
||||
mUninstallRadioButton.setText("已安装(" + uninstallAllList.size() + ")");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
initUpdateAppDatas();
|
||||
}
|
||||
|
||||
private void getUpdateAppDatas(String packageName) {
|
||||
List<AppUpdateInfo> upadteApps = new ArrayList<>();
|
||||
upadteApps.add(AppsManagerUtils.getUpAppsByPackageName(this, packageName));
|
||||
String update = new Gson().toJson(upadteApps);
|
||||
OkGo.post(Configure.HTTP_TAG_APPBAOMING)
|
||||
.params("baoming", java.net.URLEncoder.encode(update))
|
||||
.tag(this)
|
||||
.cacheKey(Configure.HTTP_TAG_APPBAOMING + java.net.URLEncoder.encode(update))
|
||||
.cacheMode(CacheMode.NO_CACHE)
|
||||
.execute(new JsonCallback<LzyResponse<List<AppContentInfo>>>() {
|
||||
@Override
|
||||
public void onSuccess(LzyResponse<List<AppContentInfo>> listLzyResponse, Call call, Response response) {
|
||||
List<AppContentInfo> infoList = listLzyResponse.data;
|
||||
if (!infoList.isEmpty() && infoList.get(0) != null) {
|
||||
updateAllList.addAll(infoList);
|
||||
mUpdateAppListAdapter.addDatas(infoList.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class DownloadReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Utils.DOWNLOAD_SERVICE_ACTION.equals(intent.getAction())) {
|
||||
AppDownloadInfo downloadInfo = (AppDownloadInfo) intent.getSerializableExtra("DownloadInfo");
|
||||
if (downloadInfo == null)
|
||||
return;
|
||||
if (downloadInfo.getState() == 10) {
|
||||
mDownloadListAdapter.removeItem(downloadInfo);
|
||||
if (updateAllList != null) {
|
||||
Iterator<AppContentInfo> it = updateAllList.iterator();
|
||||
int number = -1;
|
||||
while (it.hasNext()) {
|
||||
number++;
|
||||
AppContentInfo value = it.next();
|
||||
if (downloadInfo.getPackageName().equals(value.getApp_baoming())) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mDownloadListAdapter.updateProgress(downloadInfo);
|
||||
}
|
||||
int position = -1;
|
||||
for (int i = 0; i < mDownloadListAdapter.allTask.size(); i++) {
|
||||
if (downloadInfo.getUrl().equals(mDownloadListAdapter.allTask.get(i).getUrl())) {
|
||||
position = i;
|
||||
}
|
||||
}
|
||||
if (position != -1) {
|
||||
mDownloadListAdapter.allTask.set(position, downloadInfo);
|
||||
}
|
||||
if (position == 0) {
|
||||
mDownloadListAdapter.notifyItemChanged(0);
|
||||
}
|
||||
|
||||
mUpdateAppListAdapter.updateProgress(downloadInfo); //更新进度
|
||||
} else if (Utils.DOWNLOAD_ALLSERVICE_ACTION.equals(intent.getAction())) {
|
||||
List<AppDownloadInfo> list = (List<AppDownloadInfo>) intent.getSerializableExtra("allTask");
|
||||
|
||||
mDownloadListAdapter.setDatas(list);
|
||||
} else if (Utils.DOWNLOAD_NEWSERVICE_ACTION.equals(intent.getAction())) {
|
||||
AppDownloadInfo downloadInfo = (AppDownloadInfo) intent.getSerializableExtra("addTask");
|
||||
mDownloadListAdapter.addDatas(downloadInfo);
|
||||
} else if (Utils.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
|
||||
String packageName = intent.getStringExtra("packageName");
|
||||
Log.e("fht", "安装成功" + packageName);
|
||||
mDownloadListAdapter.removeItem(packageName);
|
||||
SaveListUtils.getDownLoadList().remove(packageName);//移除下载列表
|
||||
LocalAppInfo info = AppsManagerUtils.getAppsByPackageName(DownloadActivity.this, packageName);
|
||||
if (uninstallAllList != null) {
|
||||
uninstallAllList.add(info);
|
||||
}
|
||||
mUninstallListAdapter.addDatas(info);
|
||||
|
||||
getUpdateAppDatas(packageName);
|
||||
} else if (Utils.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
|
||||
String packageName = intent.getStringExtra("packageName");
|
||||
Log.e("aaaaa", "卸载成功" + packageName);
|
||||
if (uninstallAllList != null) {
|
||||
Iterator<LocalAppInfo> it = uninstallAllList.iterator();
|
||||
int number = -1;
|
||||
while (it.hasNext()) {
|
||||
number++;
|
||||
LocalAppInfo value = it.next();
|
||||
if (packageName.equals(value.getPackageName())) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
mUninstallListAdapter.removeItem(packageName);
|
||||
|
||||
if (updateAllList != null) {
|
||||
Iterator<AppContentInfo> it = updateAllList.iterator();
|
||||
int number = -1;
|
||||
while (it.hasNext()) {
|
||||
number++;
|
||||
AppContentInfo value = it.next();
|
||||
if (packageName.equals(value.getApp_baoming())) {
|
||||
it.remove();
|
||||
mUpdateAppListAdapter.removeUpItem(packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Utils.ACTION_PACKAGE_REPLACED.equals(intent.getAction())) {
|
||||
String packageName = intent.getStringExtra("packageName");
|
||||
Log.e("aaaaa", "替换成功" + packageName);
|
||||
if (uninstallAllList != null) {
|
||||
int position = -1;
|
||||
for (int i = 0; i < mUninstallListAdapter.mDataList.size(); i++) {
|
||||
if (packageName.equals(mUninstallListAdapter.mDataList.get(i).getPackageName())) {
|
||||
position = i;
|
||||
}
|
||||
}
|
||||
if (position != -1) {
|
||||
LocalAppInfo info = AppsManagerUtils.getAppsByPackageName(DownloadActivity.this, packageName);
|
||||
mUninstallListAdapter.notifyItem(position, info);
|
||||
uninstallAllList.set(position, info);
|
||||
}
|
||||
}
|
||||
|
||||
getUpdateAppDatas(packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,26 +5,24 @@ import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.PersistableBundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -35,26 +33,23 @@ import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermission;
|
||||
import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okserver.download.DownloadManager;
|
||||
import com.lzy.okserver.download.DownloadService;
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.base.BaseFragmentActivity;
|
||||
import com.mjsheng.myappstore.base.MyApplication;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadBean;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadData;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchData;
|
||||
import com.mjsheng.myappstore.bean.UploadAppInfo;
|
||||
import com.mjsheng.myappstore.bean.UserInfo;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import com.mjsheng.myappstore.dialog.ExitDialog;
|
||||
import com.mjsheng.myappstore.fragment.BrandFragment;
|
||||
import com.mjsheng.myappstore.fragment.CategoryPageFragment;
|
||||
import com.mjsheng.myappstore.fragment.HomePageFragment;
|
||||
import com.mjsheng.myappstore.fragment.ProjectFragment;
|
||||
import com.mjsheng.myappstore.fragment.RankingPageFragment;
|
||||
import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.network.Network;
|
||||
import com.mjsheng.myappstore.network.api.AppLimitApi;
|
||||
import com.mjsheng.myappstore.network.api.DeselectBrowserIDApi;
|
||||
@@ -62,23 +57,26 @@ import com.mjsheng.myappstore.network.api.DeselectIDApi;
|
||||
import com.mjsheng.myappstore.network.api.ForceDownloadApi;
|
||||
import com.mjsheng.myappstore.network.api.NetAndLaunchApi;
|
||||
import com.mjsheng.myappstore.network.api.SystemSettingApi;
|
||||
import com.mjsheng.myappstore.network.api.UpdateApi;
|
||||
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.server.MyDownloadService;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.ExampleUtil;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
import com.mjsheng.myappstore.utils.update.AllDialogShowStrategy;
|
||||
import com.mjsheng.myappstore.utils.update.NotificationDownloadCreator;
|
||||
import com.mjsheng.myappstore.utils.update.OkhttpCheckWorker;
|
||||
import com.mjsheng.myappstore.utils.update.ToastCallback;
|
||||
import com.mjsheng.myappstore.widget.Sound;
|
||||
import com.tianma.netdetector.lib.NetStateChangeObserver;
|
||||
import com.tianma.netdetector.lib.NetworkType;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.lzh.framework.updatepluginlib.UpdateBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -98,46 +96,24 @@ import rx.Observable;
|
||||
import rx.functions.Action1;
|
||||
|
||||
|
||||
public class AppStoreActivity extends BaseFragmentActivity implements OnClickListener,
|
||||
OnCheckedChangeListener {
|
||||
public class MainActivity extends AppCompatActivity implements NetStateChangeObserver {
|
||||
|
||||
private Fragment[] mFragments;
|
||||
private FragmentManager mFragmentManager;
|
||||
private ImageView mBackIv;
|
||||
private LinearLayout mAgeLl, mSearchLl;
|
||||
private RelativeLayout mHomeLl, mCategoryLl, mRatingLl, mSpecialLl, mBrandLl, mDownloadLl;
|
||||
private RelativeLayout mSelect = null;
|
||||
private String ageSystem;
|
||||
private Sound sound;
|
||||
private ExitDialog exitDialog = null;
|
||||
private View mHome_page_line, mCategory_line, mRating_line, mSpecial_line, mBrand_line;
|
||||
private View mSelectView;
|
||||
private TextView mHome_page_tv, mCategory_tv, mRating_tv, mSpecial_tv, mBrand_tv;
|
||||
private TextView mSelectTv;
|
||||
private ToastCallback callback;
|
||||
private Bundle savedInstanceState;
|
||||
private int fragmentTag = 0;
|
||||
private long mPreClickTime;
|
||||
private Context mContext;
|
||||
private ImageView mHome_page_iv_recommend;
|
||||
private ImageView mHome_page_iv_category;
|
||||
private ImageView mHome_page_iv_rating;
|
||||
private ImageView mHome_page_iv_brand;
|
||||
private ImageView mHome_page_iv_special;
|
||||
private ImageView mHome_page_iv_download;
|
||||
private final String ACTION_HrReceiver_JGY_DIS = "qch_jgy_network_disallow";
|
||||
private final String ACTION_HrReceiver_JGY = "qch_jgy_network_allow";
|
||||
private int[] normal_icon = {R.drawable.top_recommend_normal, R.drawable.top_category_normal, R.drawable.top_rating_normal, R.drawable.top_brand_normal, R.drawable.top_special_normal};
|
||||
private int[] press_icon = {R.drawable.top_recommend_press, R.drawable.top_category_press, R.drawable.top_rating_press, R.drawable.top_brand_press, R.drawable.top_special_press};
|
||||
private List<ImageView> mTopList;
|
||||
private DownloadManager downloadManager;
|
||||
public static boolean isForeground = false;
|
||||
private ImageView imageView;
|
||||
private TextView tv_devsn, tv_devmac, tv_version;
|
||||
private int DeviceInfo;
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
setContentView(R.layout.activity_appstore);
|
||||
setContentView(R.layout.activity_main);
|
||||
mContext = this;
|
||||
initView(savedInstanceState, fragmentTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,7 +121,6 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
// super.onSaveInstanceState(outState, outPersistentState);
|
||||
}
|
||||
|
||||
private LocationReceiver mLocationReceiver;
|
||||
|
||||
private class LocationReceiver extends BroadcastReceiver {
|
||||
|
||||
@@ -162,139 +137,34 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
savedInstanceState.remove("android:support:fragments");
|
||||
savedInstanceState.remove("android:fragments");
|
||||
}
|
||||
|
||||
// if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
// }
|
||||
requestPermission();
|
||||
registerMessageReceiver(); // used for receive msg
|
||||
HTTPInterface.checkDevicesInfo(handler);
|
||||
startService(new Intent(MainActivity.this, MyDownloadService.class));
|
||||
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_appstore);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Aria.download(this).removeAllTask(false);
|
||||
// Aria.download(this).register();
|
||||
// IntentFilter intentFilter = new IntentFilter();
|
||||
// intentFilter.addAction("qch_jgy_network_disallow");
|
||||
// intentFilter.addAction("qch_jgy_network_allow");
|
||||
// intentFilter.addAction("qch_hide_statusBar");
|
||||
// intentFilter.addAction("qch_show_NavigationBar");
|
||||
// intentFilter.addAction("qch_hide_NavigationBar");
|
||||
// intentFilter.addAction("qch_action_usb_usb_midi");
|
||||
// intentFilter.addAction("qch_action_usb_usb_mtp");
|
||||
// intentFilter.addAction("qch_action_usb_usb_charge");
|
||||
// intentFilter.addAction("qch_camera_open");
|
||||
// intentFilter.addAction("qch_camera_forbid");
|
||||
mLocationReceiver = new LocationReceiver();
|
||||
// registerReceiver(mLocationReceiver, intentFilter);
|
||||
|
||||
this.savedInstanceState = savedInstanceState;
|
||||
MyApplication.addActivity(this);
|
||||
MyApplication.mainActivity = this;
|
||||
|
||||
|
||||
ageSystem = getIntent().getStringExtra("ageSystem");
|
||||
|
||||
sound = new Sound(this);
|
||||
callback = new ToastCallback(this);
|
||||
initView(savedInstanceState, fragmentTag);
|
||||
initView();
|
||||
initData();
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// MyApplication.getInstance().updateTask();
|
||||
// Log.e("fht", "AppStoreActivity updateTask");
|
||||
//
|
||||
// }
|
||||
// }).run();
|
||||
Log.e("fht", "AppStoreActivity onCreate");
|
||||
|
||||
downloadManager = DownloadService.getDownloadManager();
|
||||
downloadManager.startAllTask();
|
||||
Intent allIntent = new Intent();
|
||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||
sendBroadcast(allIntent);
|
||||
}
|
||||
|
||||
private void initView(Bundle savedInstanceState, int fragmentTag) {
|
||||
|
||||
setChangeBySystem();
|
||||
if (savedInstanceState == null) {
|
||||
mFragments = new Fragment[5];
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
}
|
||||
// initManagePageFragment();
|
||||
mBackIv = (ImageView) findViewById(R.id.back_iv);
|
||||
mAgeLl = (LinearLayout) findViewById(R.id.age_selected_ll);
|
||||
mDownloadLl = (RelativeLayout) findViewById(R.id.download_ll);
|
||||
mSearchLl = (LinearLayout) findViewById(R.
|
||||
id.search_ll);
|
||||
mHomeLl = (RelativeLayout) findViewById(R.id.home_page_ll);
|
||||
mCategoryLl = (RelativeLayout) findViewById(R.id.category_ll);
|
||||
mRatingLl = (RelativeLayout) findViewById(R.id.rating_ll);
|
||||
mSpecialLl = (RelativeLayout) findViewById(R.id.special_ll);
|
||||
mBrandLl = (RelativeLayout) findViewById(R.id.brand_ll);
|
||||
|
||||
mHome_page_line = (View) findViewById(R.id.home_page_line);
|
||||
mCategory_line = (View) findViewById(R.id.category_line);
|
||||
mRating_line = (View) findViewById(R.id.rating_line);
|
||||
mSpecial_line = (View) findViewById(R.id.special_line);
|
||||
mBrand_line = (View) findViewById(R.id.brand_line);
|
||||
|
||||
mHome_page_tv = (TextView) findViewById(R.id.home_page_tv);
|
||||
mCategory_tv = (TextView) findViewById(R.id.category_tv);
|
||||
mRating_tv = (TextView) findViewById(R.id.rating_tv);
|
||||
mSpecial_tv = (TextView) findViewById(R.id.special_tv);
|
||||
mBrand_tv = (TextView) findViewById(R.id.brand_tv);
|
||||
|
||||
mTopList = new ArrayList<>();
|
||||
mHome_page_iv_recommend = (ImageView) findViewById(R.id.home_page_iv_recommend);
|
||||
mHome_page_iv_category = (ImageView) findViewById(R.id.home_page_iv_category);
|
||||
mHome_page_iv_rating = (ImageView) findViewById(R.id.home_page_iv_rating);
|
||||
mHome_page_iv_brand = (ImageView) findViewById(R.id.home_page_iv_brand);
|
||||
mHome_page_iv_special = (ImageView) findViewById(R.id.home_page_iv_special);
|
||||
mTopList.add(mHome_page_iv_recommend);
|
||||
mTopList.add(mHome_page_iv_category);
|
||||
mTopList.add(mHome_page_iv_rating);
|
||||
mTopList.add(mHome_page_iv_brand);
|
||||
mTopList.add(mHome_page_iv_special);
|
||||
|
||||
mSelect = mCategoryLl;
|
||||
mSelectView = mCategory_line;
|
||||
mSelectTv = mCategory_tv;
|
||||
|
||||
mBackIv.setOnClickListener(this);
|
||||
mAgeLl.setOnClickListener(this);
|
||||
mDownloadLl.setOnClickListener(this);
|
||||
mSearchLl.setOnClickListener(this);
|
||||
mHomeLl.setOnClickListener(this);
|
||||
mCategoryLl.setOnClickListener(this);
|
||||
mRatingLl.setOnClickListener(this);
|
||||
mSpecialLl.setOnClickListener(this);
|
||||
mBrandLl.setOnClickListener(this);
|
||||
|
||||
|
||||
Log.e("mjsehng", "fragmentTag====" + fragmentTag);
|
||||
switch (fragmentTag) {
|
||||
case 0:
|
||||
mHomeLl.performClick();
|
||||
break;
|
||||
case 1:
|
||||
mCategoryLl.performClick();
|
||||
break;
|
||||
case 2:
|
||||
mRatingLl.performClick();
|
||||
break;
|
||||
case 3:
|
||||
mSpecialLl.performClick();
|
||||
break;
|
||||
case 4:
|
||||
mBrandLl.performClick();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Log.e("mjhsneg", "gagagag--------------------------" + Utils.getSerial());
|
||||
getLockedState();
|
||||
initJpush();//初始化极光推送
|
||||
update();//接口更新app
|
||||
sendMACaddress();
|
||||
Log.e("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress());
|
||||
}
|
||||
|
||||
synchronized public void sendMACaddress() {
|
||||
String rid = JPushInterface.getRegistrationID(getApplicationContext());
|
||||
@@ -322,6 +192,198 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
imageView = findViewById(R.id.imageView);
|
||||
tv_devsn = findViewById(R.id.tv_devsn);
|
||||
tv_devsn.setText("设备SN:" + Utils.getSerial());
|
||||
tv_devmac = findViewById(R.id.tv_devmac);
|
||||
tv_devmac.setText("设备MAC:" + com.blankj.utilcode.util.DeviceUtils.getMacAddress());
|
||||
tv_version = findViewById(R.id.version);
|
||||
tv_version.setText("版本:" + BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Log.e("mjhsneg", "gagagag--------------------------" + Utils.getSerial());
|
||||
getLockedState();
|
||||
initJpush();//初始化极光推送
|
||||
// update();//接口更新app
|
||||
sendMACaddress();
|
||||
|
||||
Log.e("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress());
|
||||
DeviceInfo = (int) SPUtils.get(this, "isLogined", 2);
|
||||
switch (DeviceInfo) {
|
||||
case 0:
|
||||
setImageAndText(imageView, "设备未绑定");
|
||||
break;
|
||||
case 1:
|
||||
setImageAndText(imageView, "设备已绑定");
|
||||
break;
|
||||
case 2:
|
||||
setImageAndText(imageView, "未经验证的设备,请联系客服");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setImageAndText(ImageView imageView, String text) {
|
||||
Bitmap bitmap = Utils.createQRImage(Utils.getSn(), 250, 250);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
|
||||
private String getGrade(String grade) {
|
||||
String s;
|
||||
switch (grade) {
|
||||
case "1":
|
||||
s = "一年级";
|
||||
break;
|
||||
case "2":
|
||||
s = "二年级";
|
||||
break;
|
||||
case "3":
|
||||
s = "三年级";
|
||||
break;
|
||||
case "4":
|
||||
s = "四年级";
|
||||
break;
|
||||
case "5":
|
||||
s = "五年级";
|
||||
break;
|
||||
case "6":
|
||||
s = "六年级";
|
||||
break;
|
||||
case "7":
|
||||
s = "初一";
|
||||
break;
|
||||
case "8":
|
||||
s = "初二";
|
||||
break;
|
||||
case "9":
|
||||
s = "初三";
|
||||
break;
|
||||
case "10":
|
||||
s = "高一";
|
||||
break;
|
||||
case "11":
|
||||
s = "高二";
|
||||
break;
|
||||
case "12":
|
||||
s = "高三";
|
||||
break;
|
||||
default:
|
||||
s = "一年级";
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 0:
|
||||
SPUtils.put(MainActivity.this, "isLogined", 0);
|
||||
setImageAndText(imageView, "设备未绑定");
|
||||
break;
|
||||
case 1:
|
||||
UserInfo userInfo = (UserInfo) msg.obj;
|
||||
SPUtils.put(MainActivity.this, "isLogined", 1);
|
||||
SPUtils.put(MainActivity.this, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(MainActivity.this, "sn_id", userInfo.getId());
|
||||
setImageAndText(imageView, "设备已绑定");
|
||||
break;
|
||||
case 2:
|
||||
SPUtils.put(MainActivity.this, "isLogined", 2);
|
||||
setImageAndText(imageView, "未经验证的设备,请联系客服");
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private String[] permission = new String[]{
|
||||
// Permission.SYSTEM_ALERT_WINDOW,
|
||||
// Permission.CAMERA,
|
||||
// Permission.READ_SMS,
|
||||
// Permission.RECEIVE_SMS,
|
||||
// Permission.SEND_SMS,
|
||||
Permission.REQUEST_INSTALL_PACKAGES,
|
||||
Permission.READ_EXTERNAL_STORAGE,
|
||||
Permission.WRITE_EXTERNAL_STORAGE,
|
||||
// Permission.READ_PHONE_STATE
|
||||
};
|
||||
|
||||
public void requestPermission() {
|
||||
XXPermissions.with(this)
|
||||
// 可设置被拒绝后继续申请,直到用户授权或者永久拒绝
|
||||
.constantRequest()
|
||||
// 支持请求6.0悬浮窗权限8.0请求安装权限
|
||||
//.permission(Permission.REQUEST_INSTALL_PACKAGES)
|
||||
// 不指定权限则自动获取清单中的危险权限
|
||||
.permission(permission)
|
||||
.request(new OnPermission() {
|
||||
|
||||
@Override
|
||||
public void hasPermission(List<String> granted, boolean isAll) {
|
||||
if (isAll) {
|
||||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "POStemp";
|
||||
File file = new File(path);
|
||||
file.mkdirs();
|
||||
} else {
|
||||
ToastUtil.show("需要授予所有权限才能正常使用本程序!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noPermission(List<String> denied, boolean quick) {
|
||||
if (quick) {
|
||||
ToastUtil.show("被永久拒绝授权,请手动授予权限!");
|
||||
//如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.gotoPermissionSettings(MainActivity.this);
|
||||
} else {
|
||||
ToastUtil.show("获取权限失败");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//for receive customer msg from jpush server
|
||||
private MessageReceiver mMessageReceiver;
|
||||
public static final String MESSAGE_RECEIVED_ACTION = "com.example.jpushdemo.MESSAGE_RECEIVED_ACTION";
|
||||
public static final String KEY_TITLE = "title";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_EXTRAS = "extras";
|
||||
|
||||
public void registerMessageReceiver() {
|
||||
mMessageReceiver = new MessageReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(MESSAGE_RECEIVED_ACTION);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, filter);
|
||||
}
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
if (MESSAGE_RECEIVED_ACTION.equals(intent.getAction())) {
|
||||
String messge = intent.getStringExtra(KEY_MESSAGE);
|
||||
String extras = intent.getStringExtra(KEY_EXTRAS);
|
||||
StringBuilder showMsg = new StringBuilder();
|
||||
showMsg.append(KEY_MESSAGE + " : " + messge + "\n");
|
||||
if (!ExampleUtil.isEmpty(extras)) {
|
||||
showMsg.append(KEY_EXTRAS + " : " + extras + "\n");
|
||||
}
|
||||
// setCostomMsg(showMsg.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean locked = false;
|
||||
|
||||
public void getLockedState() {
|
||||
@@ -380,15 +442,8 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
getForceDownload();//强制下载apk
|
||||
resetDevice();//恢复出厂设置
|
||||
// fromNetToUpdate();
|
||||
String registrationID = JPushInterface.getRegistrationID(AppStoreActivity.this);
|
||||
String registrationID = JPushInterface.getRegistrationID(MainActivity.this);
|
||||
Log.e("mjsheng", registrationID + "------------------------");
|
||||
// ToastUtils.showLong("registrationID::" + registrationID);
|
||||
// Log.e("mjsheng", "getAndroidID" + "------------------------" + DeviceUtils.getAndroidID());
|
||||
// Log.e("mjsheng", "getMacAddress" + "------------------------" + DeviceUtils.getMacAddress());
|
||||
// Log.e("mjsheng", "getSerial" + "------------------------" + PhoneUtils.getSerial());
|
||||
// Log.e("mjsheng", "getIMEI" + "------------------------" + PhoneUtils.getIMEI());
|
||||
// Log.e("mjsheng", "getMEID" + "------------------------" + PhoneUtils.getMEID());
|
||||
// Log.e("mjsheng", "getIMSI" + "------------------------" + PhoneUtils.getIMSI());
|
||||
List<String> list = SaveListUtils.getList();
|
||||
if (list == null) {
|
||||
return;
|
||||
@@ -426,29 +481,6 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public void setChangeBySystem() {
|
||||
if (ageSystem.equals("3")) {
|
||||
MyApplication.ageType = 1;
|
||||
} else if (ageSystem.equals("6")) {
|
||||
MyApplication.ageType = 2;
|
||||
} else if (ageSystem.equals("10")) {
|
||||
MyApplication.ageType = 3;
|
||||
} else {
|
||||
MyApplication.ageType = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预加载管理界面,以防这是点击下载,任务未能显示出来
|
||||
*/
|
||||
private void initManagePageFragment() {
|
||||
if (mFragmentManager != null && mFragments != null) {
|
||||
FragmentTransaction transaction = mFragmentManager
|
||||
.beginTransaction();
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
@@ -458,274 +490,16 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
sendBroadcast(allIntent);
|
||||
}
|
||||
|
||||
// 切换显示内容
|
||||
public void switchContent(int index) {
|
||||
FragmentTransaction transaction = mFragmentManager.beginTransaction();
|
||||
hideFragments(transaction);
|
||||
try {
|
||||
switch (index) {
|
||||
case 0:
|
||||
if (mFragments[0] == null) {
|
||||
// 首页 推荐页面
|
||||
mFragments[0] = new HomePageFragment();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("ageSystem", ageSystem);
|
||||
mFragments[0].setArguments(bundle);
|
||||
transaction.add(R.id.content,
|
||||
mFragments[0], 0 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[0]);
|
||||
Intent allIntent = new Intent();
|
||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||
sendBroadcast(allIntent);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (mFragments[1] == null) {
|
||||
// 分类
|
||||
mFragments[1] = new CategoryPageFragment();
|
||||
transaction.add(R.id.content, mFragments[1], 1 + "");
|
||||
} else {
|
||||
|
||||
transaction.show(mFragments[1]);
|
||||
Intent allIntent = new Intent();
|
||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||
sendBroadcast(allIntent);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (mFragments[2] == null) {
|
||||
// 排行 3个RadioButton
|
||||
mFragments[2] = new RankingPageFragment();
|
||||
transaction.add(R.id.content,
|
||||
mFragments[2], 2 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[2]);
|
||||
Intent allIntent = new Intent();
|
||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||
sendBroadcast(allIntent);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (mFragments[3] == null) {
|
||||
// 专题
|
||||
mFragments[3] = new ProjectFragment();
|
||||
transaction.add(R.id.content,
|
||||
mFragments[3], 3 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[3]);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (mFragments[4] == null) {
|
||||
// 品牌
|
||||
mFragments[4] = new BrandFragment();
|
||||
transaction.add(R.id.content,
|
||||
mFragments[4], 4 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[4]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
transaction.commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 将所有的Fragment都置为隐藏状态。
|
||||
private void hideFragments(FragmentTransaction transaction) {
|
||||
if (mFragments != null) {
|
||||
for (int i = 0; i < mFragments.length; i++) {
|
||||
if (mFragments[i] != null) {
|
||||
transaction.hide(mFragments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sound.playSoundEffect();
|
||||
switch (v.getId()) {
|
||||
case R.id.back_iv:
|
||||
lazyExit();
|
||||
// if (exitDialog == null) {
|
||||
// exitDialog = new ExitDialog(this, new ExitDialog.PriorityListener() {
|
||||
// @Override
|
||||
// public void refreshPriorityUI(String string) {
|
||||
// if (string.equals("YES")) {
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// exitDialog.show();
|
||||
// } else {
|
||||
// exitDialog.show();
|
||||
// }
|
||||
break;
|
||||
// 搜索应用界面
|
||||
case R.id.search_ll:
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, SearchActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
|
||||
break;
|
||||
// 下载界面
|
||||
case R.id.download_ll:
|
||||
Intent download = new Intent();
|
||||
download.setClass(this, DownloadActivity.class);
|
||||
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(download);
|
||||
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
|
||||
break;
|
||||
// 设置界面
|
||||
case R.id.age_selected_ll:
|
||||
Intent setting = new Intent();
|
||||
setting.setClass(this, SettingActivity.class);
|
||||
setting.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(setting);
|
||||
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
|
||||
break;
|
||||
case R.id.home_page_ll:
|
||||
fragmentTag = 0;
|
||||
switchContent(0);
|
||||
changeIcon(0);
|
||||
// mHomeLl.setBackgroundResource(R.drawable.appstoreactivity_itembg);
|
||||
// mHome_page_line.setVisibility(View.VISIBLE);
|
||||
mHome_page_tv.setTextColor(getResources().getColor(R.color.appstore_selecte_color));
|
||||
|
||||
if (mSelect != mHomeLl) {
|
||||
mSelect.setBackgroundResource(0);
|
||||
mSelect = mHomeLl;
|
||||
// mSelectView.setVisibility(View.GONE);
|
||||
mSelectView = mHome_page_line;
|
||||
|
||||
mSelectTv.setTextColor(getResources().getColor(R.color.textColor));
|
||||
mSelectTv = mHome_page_tv;
|
||||
}
|
||||
break;
|
||||
case R.id.category_ll:
|
||||
fragmentTag = 1;
|
||||
switchContent(1);
|
||||
changeIcon(1);
|
||||
// mCategoryLl.setBackgroundResource(R.drawable.appstoreactivity_itembg);
|
||||
// mCategory_line.setVisibility(View.VISIBLE);
|
||||
mCategory_tv.setTextColor(getResources().getColor(R.color.appstore_selecte_color));
|
||||
mCategory_tv.setTextColor(getResources().getColor(R.color.appstore_selecte_color));
|
||||
|
||||
if (mSelect != mCategoryLl) {
|
||||
mSelect.setBackgroundResource(0);
|
||||
mSelect = mCategoryLl;
|
||||
|
||||
// mSelectView.setVisibility(View.GONE);
|
||||
mSelectView = mCategory_line;
|
||||
|
||||
mSelectTv.setTextColor(getResources().getColor(R.color.textColor));
|
||||
mSelectTv = mCategory_tv;
|
||||
}
|
||||
break;
|
||||
case R.id.rating_ll:
|
||||
fragmentTag = 2;
|
||||
switchContent(2);
|
||||
changeIcon(2);
|
||||
// mRatingLl.setBackgroundResource(R.drawable.appstoreactivity_itembg);
|
||||
// mRating_line.setVisibility(View.VISIBLE);
|
||||
mRating_tv.setTextColor(getResources().getColor(R.color.appstore_selecte_color));
|
||||
|
||||
if (mSelect != mRatingLl) {
|
||||
mSelect.setBackgroundResource(0);
|
||||
mSelect = mRatingLl;
|
||||
|
||||
mSelectView.setVisibility(View.GONE);
|
||||
mSelectView = mRating_line;
|
||||
|
||||
mSelectTv.setTextColor(getResources().getColor(R.color.textColor));
|
||||
mSelectTv = mRating_tv;
|
||||
}
|
||||
break;
|
||||
case R.id.special_ll:
|
||||
fragmentTag = 3;
|
||||
switchContent(3);
|
||||
changeIcon(4);
|
||||
// mSpecialLl.setBackgroundResource(R.drawable.appstoreactivity_itembg);
|
||||
// mSpecial_line.setVisibility(View.VISIBLE);
|
||||
mSpecial_tv.setTextColor(getResources().getColor(R.color.appstore_selecte_color));
|
||||
|
||||
if (mSelect != mSpecialLl) {
|
||||
mSelect.setBackgroundResource(0);
|
||||
mSelect = mSpecialLl;
|
||||
|
||||
mSelectView.setVisibility(View.GONE);
|
||||
mSelectView = mSpecial_line;
|
||||
|
||||
mSelectTv.setTextColor(getResources().getColor(R.color.textColor));
|
||||
mSelectTv = mSpecial_tv;
|
||||
}
|
||||
break;
|
||||
case R.id.brand_ll:
|
||||
fragmentTag = 4;
|
||||
switchContent(4);
|
||||
changeIcon(3);
|
||||
// mBrandLl.setBackgroundResource(R.drawable.appstoreactivity_itembg);
|
||||
// mBrand_line.setVisibility(View.VISIBLE);
|
||||
mBrand_tv.setTextColor(getResources().getColor(R.color.appstore_selecte_color));
|
||||
|
||||
if (mSelect != mBrandLl) {
|
||||
mSelect.setBackgroundResource(0);
|
||||
mSelect = mBrandLl;
|
||||
|
||||
mSelectView.setVisibility(View.GONE);
|
||||
mSelectView = mBrand_line;
|
||||
|
||||
mSelectTv.setTextColor(getResources().getColor(R.color.textColor));
|
||||
mSelectTv = mBrand_tv;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
// sound.playSoundEffect();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
// if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
// if (exitDialog == null) {
|
||||
// exitDialog = new ExitDialog(AppStoreActivity.this, new ExitDialog.PriorityListener() {
|
||||
// @Override
|
||||
// public void refreshPriorityUI(String string) {
|
||||
// if (string.equals("YES")) {
|
||||
// finish();
|
||||
// // moveTaskToBack(false);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// exitDialog.show();
|
||||
// } else {
|
||||
// exitDialog.show();
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return super.onKeyDown(keyCode, event);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
|
||||
}
|
||||
|
||||
private void getAppInfo() {
|
||||
@@ -960,34 +734,6 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
});
|
||||
}
|
||||
|
||||
private void fromNetToUpdate() {
|
||||
UpdateApi updateApi = Network.getUpdateApi();
|
||||
updateApi.getUpdateApi(BuildConfig.APPLICATION_ID, Configure.HTTP_KEY)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(ResponseBody responseBody) {
|
||||
// autoUpdate(responseBody);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("mjsheng", "UpdateApi=onError:");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void autoUpdate(ResponseBody responseBody) {
|
||||
try {
|
||||
@@ -1492,21 +1238,17 @@ public class AppStoreActivity extends BaseFragmentActivity implements OnClickLis
|
||||
return num;
|
||||
}
|
||||
|
||||
private void changeIcon(int postion) {
|
||||
mTopList.get(postion).setBackgroundResource(press_icon[postion]);
|
||||
for (int i = 0; i < mTopList.size(); i++) {
|
||||
if (i == postion) {
|
||||
continue;
|
||||
}
|
||||
mTopList.get(i).setBackgroundResource(normal_icon[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetConnected(NetworkType networkType) {
|
||||
super.onNetConnected(networkType);
|
||||
// ToastUtils.showLong("网络链接了");
|
||||
initJpush();
|
||||
Aria.download(this).resumeAllTask();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
package com.mjsheng.myappstore.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.cache.CacheMode;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.adapter.SearchHistoryAdapter;
|
||||
import com.mjsheng.myappstore.base.BaseActivity;
|
||||
import com.mjsheng.myappstore.bean.AppData;
|
||||
import com.mjsheng.myappstore.bean.AppDateInfo;
|
||||
import com.mjsheng.myappstore.bean.JsonCallback;
|
||||
import com.mjsheng.myappstore.bean.LzyResponse;
|
||||
import com.mjsheng.myappstore.bean.SearchBean;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
import com.mjsheng.myappstore.widget.Sound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.internal.Util;
|
||||
|
||||
public class SearchActivity extends BaseActivity implements View.OnClickListener, AdapterView.OnItemClickListener {
|
||||
private EditText mSearchEditText;
|
||||
private ListView mListView;
|
||||
private SearchHistoryAdapter adapter;
|
||||
|
||||
private Sound sound;
|
||||
private Handler mHandler = new Handler() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
Bundle data = msg.getData();
|
||||
switch (msg.what) {
|
||||
case Configure.SUCCESS:
|
||||
if (data != null) {
|
||||
String httTag = data.getString("httpTag");
|
||||
if (TextUtils.isEmpty(httTag)) {
|
||||
Utils.showToast(SearchActivity.this,"没有搜索到相关内容!");
|
||||
return;
|
||||
}
|
||||
if (null == msg.obj)
|
||||
return;
|
||||
if (httTag.equals(Configure.HTTP_TAG_SEARCH)) {
|
||||
ArrayList<AppDateInfo> serachList = (ArrayList<AppDateInfo>) msg.obj;
|
||||
if (serachList != null && !serachList.isEmpty()) {
|
||||
showSearchResultPageActivity(serachList);
|
||||
} else {
|
||||
Utils.showToast(SearchActivity.this,"没有搜索到相关内容!");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private void showSearchResultPageActivity(ArrayList<AppDateInfo> serachList) {
|
||||
LogUtils.e(serachList);
|
||||
Intent intent = new Intent(SearchActivity.this, SubjectMoreActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("AppDateInfo", serachList);
|
||||
bundle.putString("title", "search_result");
|
||||
intent.putExtras(bundle);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_search);
|
||||
sound = new Sound(this);
|
||||
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
mSearchEditText = (EditText) findViewById(R.id.search_edit);
|
||||
findViewById(R.id.search_btn).setOnClickListener(this);
|
||||
mListView = (ListView) findViewById(R.id.search_ListView);
|
||||
adapter = new SearchHistoryAdapter(this);
|
||||
mListView.setOnItemClickListener(this);
|
||||
mListView.setAdapter(adapter);
|
||||
findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
private void initData() {
|
||||
adapter.histories = AppData.getSearchData(this);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sound.playSoundEffect();
|
||||
switch (v.getId()) {
|
||||
case R.id.search_btn:
|
||||
Utils.CloseKeyBoard(this);
|
||||
doSearch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String value = (String) adapter.getItem(position);
|
||||
mSearchEditText.setText(value);
|
||||
doSearch();
|
||||
}
|
||||
|
||||
private void doSearch() {
|
||||
if (mSearchEditText != null
|
||||
&& !TextUtils.isEmpty(mSearchEditText.getText())) {
|
||||
|
||||
doPost(mSearchEditText.getText().toString());
|
||||
for (int i = 0; i < adapter.histories.size(); i++){
|
||||
SearchBean info = adapter.histories.get(i);
|
||||
if (info.getCategory().equals(mSearchEditText.getText().toString())){
|
||||
adapter. histories.remove(info);
|
||||
}
|
||||
}
|
||||
SearchBean bean = new SearchBean();
|
||||
bean.setCategory(mSearchEditText.getText().toString());
|
||||
bean.setSearch_time((int) System.currentTimeMillis());
|
||||
AppData.upSearchData(this, mSearchEditText.getText().toString(), (int) System.currentTimeMillis());
|
||||
adapter.histories.add(0,bean);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void doPost(String keyWord) {
|
||||
|
||||
OkGo.post(Configure.HTTP_TAG_SEARCH_URL)
|
||||
.tag(this)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("key", Configure.HTTP_KEY)
|
||||
.params("page", "1")
|
||||
.params("keywords", keyWord)
|
||||
.cacheKey(Configure.HTTP_TAG_SEARCH_URL)
|
||||
.cacheMode(CacheMode.NO_CACHE)
|
||||
.execute(new JsonCallback<LzyResponse<List<AppDateInfo>>>() {
|
||||
@Override
|
||||
public void onSuccess(LzyResponse<List<AppDateInfo>> listLzyResponse, Call call, Response response) {
|
||||
Message msg = new Message();
|
||||
msg.what = Configure.SUCCESS;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("httpTag", Configure.HTTP_TAG_SEARCH);
|
||||
msg.obj = listLzyResponse.data;
|
||||
msg.setData(bundle);
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
if (response.code() != 200){
|
||||
Utils.showToast(SearchActivity.this, "网络连接不稳定,请稍后重试!");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
View v = getCurrentFocus();
|
||||
if (Utils.isShouldHideInput(v, ev)) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
// 必不可少,否则所有的组件都不会有TouchEvent了
|
||||
if (getWindow().superDispatchTouchEvent(ev)) {
|
||||
return true;
|
||||
}
|
||||
return onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.mjsheng.myappstore.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.base.BaseActivity;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.view.ToggleButton;
|
||||
import com.mjsheng.myappstore.widget.Sound;
|
||||
|
||||
|
||||
/**
|
||||
* Created by chris on 2015/12/4.
|
||||
*/
|
||||
public class SettingActivity extends BaseActivity implements View.OnClickListener {
|
||||
private boolean selector = false;
|
||||
private boolean mIsPasswordLock;
|
||||
private ImageView toBackImg;
|
||||
private TextView statementTv;
|
||||
private ToggleButton toggleBtn;
|
||||
|
||||
private Sound sound;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setting);
|
||||
sound = new Sound(this);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
toBackImg = (ImageView) findViewById(R.id.iv_selecter_back);
|
||||
statementTv = (TextView) findViewById(R.id.tv_statement);
|
||||
statementTv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
|
||||
statementTv.getPaint().setAntiAlias(true);//抗锯齿
|
||||
mIsPasswordLock = MySQLData.GetBooleanData(SettingActivity.this, CommonDatas.SP_PASSWORD_LOCK);
|
||||
|
||||
toggleBtn = (ToggleButton) findViewById(R.id.iv_setting);
|
||||
toggleBtn.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
if (selector == false) {
|
||||
selector = true;
|
||||
} else {
|
||||
selector = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (mIsPasswordLock) {
|
||||
selector = true;
|
||||
toggleBtn.setToggleOn();
|
||||
} else {
|
||||
selector = false;
|
||||
toggleBtn.setToggleOff();
|
||||
}
|
||||
|
||||
toBackImg.setOnClickListener(this);
|
||||
statementTv.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sound.playSoundEffect();
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_statement:
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, StatementActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
|
||||
break;
|
||||
case R.id.iv_selecter_back:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
MySQLData.SetBooleanData(SettingActivity.this, CommonDatas.SP_PASSWORD_LOCK, selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.mjsheng.myappstore.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.base.BaseActivity;
|
||||
import com.mjsheng.myappstore.widget.Sound;
|
||||
|
||||
/**
|
||||
* Created by chris on 2015/12/9.
|
||||
*/
|
||||
public class StatementActivity extends BaseActivity {
|
||||
private WebView webView;
|
||||
|
||||
private Sound sound;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_statement);
|
||||
sound = new Sound(this);
|
||||
webView = (WebView) findViewById(R.id.web);
|
||||
webView.loadUrl("file:///android_asset/description.html");
|
||||
findViewById(R.id.iv_statement_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sound.playSoundEffect();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
|
||||
}
|
||||
}
|
||||
@@ -1,516 +0,0 @@
|
||||
package com.mjsheng.myappstore.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.cache.CacheMode;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.adapter.SubjectMoreAdapter;
|
||||
import com.mjsheng.myappstore.base.BaseFragmentActivity;
|
||||
import com.mjsheng.myappstore.bean.AppDateInfo;
|
||||
import com.mjsheng.myappstore.bean.JsonCallback;
|
||||
import com.mjsheng.myappstore.bean.LzyResponse;
|
||||
import com.mjsheng.myappstore.callback.MyItemClickListener;
|
||||
import com.mjsheng.myappstore.dialog.AppDetailDialog;
|
||||
import com.mjsheng.myappstore.listener.AutoLoadListener;
|
||||
import com.mjsheng.myappstore.network.Network;
|
||||
import com.mjsheng.myappstore.network.api.AppLimitApi;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.SpacesItemDecoration;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
import com.mjsheng.myappstore.view.RecycleGridLayoutManager;
|
||||
import com.mjsheng.myappstore.view.VaryViewHelper;
|
||||
import com.mjsheng.myappstore.widget.Sound;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import rx.Observable;
|
||||
import rx.functions.Action1;
|
||||
|
||||
|
||||
public class SubjectMoreActivity extends BaseFragmentActivity implements View.OnClickListener, Runnable {
|
||||
|
||||
private String title, url, httpmethod;
|
||||
private TextView titleImgView;
|
||||
private ImageView mBackBtn;
|
||||
private List<AppDateInfo> mList = new ArrayList<>();
|
||||
private List<AppDateInfo> allList = new ArrayList<>();
|
||||
private RecyclerView mRecycleView;
|
||||
private SubjectMoreAdapter mAdapter;
|
||||
private TextView numberTV;
|
||||
private VaryViewHelper mVaryViewHelper;
|
||||
private Sound sound;
|
||||
private ExecutorService mExecutorService;
|
||||
private List<AppDateInfo> pageList = new ArrayList<>();
|
||||
private int page = 1;
|
||||
private Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
Bundle data = msg.getData();
|
||||
switch (msg.what) {
|
||||
case Configure.SUCCESS:
|
||||
String httTag = data.getString("httpTag");
|
||||
if (httTag.equals(Configure.RANKING_TYPE_MOREAPP)) {
|
||||
if (msg.obj != null) {
|
||||
List<AppDateInfo> contentList = (List<AppDateInfo>) msg.obj;
|
||||
Log.e("mjsheng", "contentList===" + contentList.size());
|
||||
if (contentList.size() <= 0 || contentList == null) {
|
||||
// Utils.showToast(SubjectMoreActivity.this, "没有数据!");
|
||||
if (page == 1) {
|
||||
mVaryViewHelper.showEmptyView();
|
||||
numberTV.setText("0款应用");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (contentList.size() >= 8 && !title.equals("all_apps")) {
|
||||
pageList.addAll(contentList.subList(0, 8));
|
||||
} else {
|
||||
pageList.addAll(contentList);
|
||||
}
|
||||
Log.e("mjsheng", "pageList===" + pageList.size());
|
||||
setList(pageList);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private String id;
|
||||
private RecycleGridLayoutManager mLayoutManager;
|
||||
|
||||
@Override
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_subject_more);
|
||||
sound = new Sound(this);
|
||||
Bundle bundle = this.getIntent().getExtras();
|
||||
title = bundle.getString("title");
|
||||
url = bundle.getString("URL");
|
||||
id = bundle.getString("id");
|
||||
Log.e("mjsheng", "rul----------" + url);
|
||||
httpmethod = bundle.getString("HTTP");
|
||||
mList = (List<AppDateInfo>) bundle.getSerializable("AppDateInfo");
|
||||
mExecutorService = Executors.newCachedThreadPool();
|
||||
|
||||
numberTV = (TextView) findViewById(R.id.subject_number_tv);
|
||||
if (title.equals("all_apps")) {
|
||||
numberTV.setVisibility(View.VISIBLE);
|
||||
} else numberTV.setVisibility(View.GONE);
|
||||
findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mVaryViewHelper = new VaryViewHelper.Builder()
|
||||
.setContent(this)
|
||||
.setDataView(findViewById(R.id.subject_refreshLayout))//放数据的父布局,逻辑处理在该Activity中处理
|
||||
.setLoadingView(LayoutInflater.from(this).inflate(R.layout.layout_loadingview, null))//加载页,无实际逻辑处理
|
||||
.setEmptyView(LayoutInflater.from(this).inflate(R.layout.layout_emptyview, null))//空页面,无实际逻辑处理
|
||||
.setErrorView(LayoutInflater.from(this).inflate(R.layout.layout_errorview, null))//错误页面
|
||||
.setRefreshListener(new SubjectMoreActivity.ErrorClickListener())//错误页点击刷新实现
|
||||
.build();
|
||||
|
||||
mVaryViewHelper.showLoadingView();
|
||||
initView();
|
||||
|
||||
mExecutorService.execute(this);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
int orientation = getResources().getConfiguration().orientation;
|
||||
|
||||
mRecycleView = (RecyclerView) findViewById(R.id.subject_recycleView);
|
||||
|
||||
// AutoLoadListener autoLoadListener = new AutoLoadListener(mCallBack);
|
||||
// mRecycleView.addOnScrollListener(autoLoadListener);
|
||||
|
||||
switch (orientation) {
|
||||
case Configuration.ORIENTATION_PORTRAIT:
|
||||
mLayoutManager = new RecycleGridLayoutManager(this, 1);
|
||||
break;
|
||||
case Configuration.ORIENTATION_LANDSCAPE:
|
||||
mLayoutManager = new RecycleGridLayoutManager(this, 3);
|
||||
break;
|
||||
}
|
||||
mLayoutManager.setOrientation(GridLayoutManager.VERTICAL);
|
||||
mLayoutManager.setSmoothScrollbarEnabled(true);
|
||||
mRecycleView.setLayoutManager(mLayoutManager);
|
||||
// mRecycleView.setNestedScrollingEnabled(false);
|
||||
mRecycleView.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.PX5x), getResources().getDimensionPixelSize(R.dimen.PX5x),
|
||||
getResources().getDimensionPixelSize(R.dimen.PX5x), getResources().getDimensionPixelSize(R.dimen.PX5x)));
|
||||
((DefaultItemAnimator) mRecycleView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
|
||||
titleImgView = (TextView) findViewById(R.id.tv_subject_img);
|
||||
if (title.equals("new_more")) {
|
||||
titleImgView.setText("最新上架");
|
||||
} else if (title.equals("recommend_more")) {
|
||||
titleImgView.setText("热门推荐");
|
||||
} else if (title.equals("top_special")) {
|
||||
titleImgView.setText("专题推荐");
|
||||
} else if (title.equals("top_brand")) {
|
||||
titleImgView.setText("品牌推荐");
|
||||
} else if (title.equals("search_result")) {
|
||||
titleImgView.setText("搜索应用");
|
||||
} else if (title.equals("all_apps")) {
|
||||
titleImgView.setText("全部应用");
|
||||
} else {
|
||||
titleImgView.setText(title);
|
||||
}
|
||||
|
||||
|
||||
// mBackBtn = (ImageView) findViewById(R.id.iv_subject_back);
|
||||
// mBackBtn.setOnClickListener(this);
|
||||
mAdapter = new SubjectMoreAdapter(SubjectMoreActivity.this, allList, new MyItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int postion) {
|
||||
|
||||
sound.playSoundEffect();
|
||||
AppDateInfo info = mAdapter.getData(postion);
|
||||
if (info != null) {
|
||||
getAppDetail(info.getApp_baoming());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
AutoLoadListener.AutoLoadCallBack mCallBack = new AutoLoadListener.AutoLoadCallBack() {
|
||||
@Override
|
||||
public void execute() {
|
||||
if (title.equals("new_more") || title.equals("recommend_more")) {
|
||||
httpPostMethodHomePage(++page);
|
||||
} else {
|
||||
|
||||
httpPostMethod(++page);
|
||||
}
|
||||
Log.e("mjsheng", "nextpage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopLoad() {
|
||||
Glide.with(SubjectMoreActivity.this).pauseRequests();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startLoad() {
|
||||
Glide.with(SubjectMoreActivity.this).resumeRequests();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (mList != null && !mList.isEmpty()) {
|
||||
setList(mList);
|
||||
} else {
|
||||
loadDatas();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setList(final List<AppDateInfo> mList) {
|
||||
if (mList != null && !mList.isEmpty()) {
|
||||
allList.clear();
|
||||
allList.addAll(mList);
|
||||
if (mAdapter != null) {
|
||||
mRecycleView.setAdapter(mAdapter);
|
||||
mAdapter.setmDatas(allList);
|
||||
numberTV.setText(allList.size() + "款应用");
|
||||
mVaryViewHelper.showDataView();
|
||||
}
|
||||
} else {
|
||||
mVaryViewHelper.showEmptyView();
|
||||
numberTV.setText("0款应用");
|
||||
}
|
||||
|
||||
|
||||
// runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// mRecycleView.setAdapter(mAdapter);
|
||||
// if (allList != null && !allList.isEmpty()) {
|
||||
// mVaryViewHelper.showDataView();
|
||||
// } else {
|
||||
// mVaryViewHelper.showEmptyView();
|
||||
// numberTV.setText("0款应用");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// mRecycleView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
// @Override
|
||||
// public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
// switch (newState) {
|
||||
// case RecyclerView.SCROLL_STATE_DRAGGING:
|
||||
// case RecyclerView.SCROLL_STATE_SETTLING:
|
||||
// // 当ListView处于滑动状态时,停止加载图片,保证操作界面流畅
|
||||
// Glide.with(SubjectMoreActivity.this).pauseRequests();
|
||||
// Log.e("msjheng","------------SCROLL_STATE_SETTLING");
|
||||
// break;
|
||||
// case RecyclerView.SCROLL_STATE_IDLE:
|
||||
// // 当ListView处于静止状态时,继续加载图片
|
||||
// Glide.with(SubjectMoreActivity.this).resumeRequests();
|
||||
// Log.e("msjheng","------------SCROLL_STATE_IDLE");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void loadDatas() {
|
||||
// if (httpmethod == null || httpmethod.equals("")) {
|
||||
// httpGetMethod();
|
||||
// } else {
|
||||
// httpPostMethod();
|
||||
// }
|
||||
if (title.equals("new_more") || title.equals("recommend_more")) {
|
||||
httpPostMethodHomePage(page);
|
||||
} else {
|
||||
|
||||
httpPostMethod(page);
|
||||
}
|
||||
lazyLoading();
|
||||
}
|
||||
|
||||
private void httpPostMethod(int page) {
|
||||
|
||||
OkGo.post(url)
|
||||
.tag(this)
|
||||
.params("key", Configure.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("page", page)
|
||||
.params("id", id)
|
||||
.cacheKey(url + id)
|
||||
.cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)
|
||||
.execute(new JsonCallback<LzyResponse<List<AppDateInfo>>>() {
|
||||
@Override
|
||||
public void onSuccess(LzyResponse<List<AppDateInfo>> listLzyResponse, Call call, Response response) {
|
||||
Message msg = new Message();
|
||||
msg.what = Configure.SUCCESS;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("httpTag", Configure.RANKING_TYPE_MOREAPP);
|
||||
msg.obj = listLzyResponse.data;
|
||||
msg.setData(bundle);
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCacheSuccess(LzyResponse<List<AppDateInfo>> listLzyResponse, Call call) {
|
||||
onSuccess(listLzyResponse, call, null);
|
||||
if (!Utils.isIntent(SubjectMoreActivity.this)) {
|
||||
Utils.showToast(SubjectMoreActivity.this, "网络连接不稳定,请稍后重试!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void httpPostMethodHomePage(int page) {
|
||||
//不需要按页数
|
||||
OkGo.post(url)
|
||||
.tag(this)
|
||||
.params("key", Configure.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
// .params("page", page)
|
||||
.cacheKey(url)
|
||||
.cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)
|
||||
.execute(new JsonCallback<LzyResponse<List<AppDateInfo>>>() {
|
||||
@Override
|
||||
public void onSuccess(LzyResponse<List<AppDateInfo>> listLzyResponse, Call call, Response response) {
|
||||
Message msg = new Message();
|
||||
msg.what = Configure.SUCCESS;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("httpTag", Configure.RANKING_TYPE_MOREAPP);
|
||||
msg.obj = listLzyResponse.data;
|
||||
msg.setData(bundle);
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCacheSuccess(LzyResponse<List<AppDateInfo>> listLzyResponse, Call call) {
|
||||
onSuccess(listLzyResponse, call, null);
|
||||
if (!Utils.isIntent(SubjectMoreActivity.this)) {
|
||||
Utils.showToast(SubjectMoreActivity.this, "网络连接不稳定,请稍后重试!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void lazyLoading() {
|
||||
Observable.timer(2000, TimeUnit.MILLISECONDS)
|
||||
.observeOn(rx.android.schedulers.AndroidSchedulers.mainThread())
|
||||
.subscribe(new Action1<Long>() {
|
||||
@Override
|
||||
public void call(Long aLong) {
|
||||
getAppLimitApi();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getAppLimitApi() {
|
||||
AppLimitApi appLimitApi = Network.getAppLimitApi();
|
||||
appLimitApi.getAppLimitApi(Configure.HTTP_KEY, Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(ResponseBody responseBody) {
|
||||
try {
|
||||
String responString = responseBody.string();
|
||||
Log.e("mjhseng", responString);
|
||||
JSONObject jsonObject = new JSONObject(responString);
|
||||
Integer code = jsonObject.optInt("code");
|
||||
switch (code) {
|
||||
case 200:
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String result = data.optString("result");
|
||||
writeAppPackageList(result);
|
||||
break;
|
||||
default:
|
||||
Log.e("mjhseng", "getAppLimitApi---code is -200");
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("mjhseng", "getAppLimitApi---woring----" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("mjsheng", "getAppLimitApi=onError:");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void writeAppPackageList(String result) {
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
LogUtils.e(result);
|
||||
Settings.System.putString(getContentResolver(), "qch_app_forbid", result);
|
||||
} else {
|
||||
Log.e("mjsheng", "writeAppPackageList is null:");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.iv_subject_back:
|
||||
sound.playSoundEffect();
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void getAppDetail(String appBaoming) {
|
||||
String detailTitle = new String();
|
||||
if (title.equals("new_more")) {
|
||||
detailTitle = "最新上架";
|
||||
} else if (title.equals("recommend_more")) {
|
||||
detailTitle = "热门推荐";
|
||||
} else if (title.equals("top_special")) {
|
||||
detailTitle = "应用专题";
|
||||
} else if (title.equals("top_brand")) {
|
||||
detailTitle = "应用品牌";
|
||||
} else if (title.equals("search_result")) {
|
||||
detailTitle = "搜索应用";
|
||||
} else if (title.equals("all_apps")) {
|
||||
detailTitle = "全部应用";
|
||||
} else {
|
||||
detailTitle = title;
|
||||
}
|
||||
Intent intent = new Intent(this, AppDetailDialog.class);
|
||||
intent.putExtra("title", detailTitle);
|
||||
intent.putExtra("appBaoming", appBaoming);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mAdapter != null) {
|
||||
mAdapter.UnregisterReceiver();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
if (mAdapter != null) {
|
||||
mAdapter.UnregisterReceiver();
|
||||
}
|
||||
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
|
||||
}
|
||||
|
||||
|
||||
private class ErrorClickListener implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sound.playSoundEffect();
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_errorview_layout:
|
||||
if (url != null && !url.isEmpty()) {
|
||||
loadDatas();
|
||||
}
|
||||
break;
|
||||
case R.id.iv_emptyview_layout:
|
||||
if (url != null && !url.isEmpty()) {
|
||||
loadDatas();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user