Compare commits
5 Commits
2e6bf877fe
...
SNFLaunche
| Author | SHA1 | Date | |
|---|---|---|---|
| ad72e265c1 | |||
| 2f7539febb | |||
| c7600b014a | |||
| c7f0f1ef7b | |||
| 724d4cff36 |
@@ -27,6 +27,7 @@
|
|||||||
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS"/>
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.INSTALL_PACKAGES"/>
|
android:name="android.permission.INSTALL_PACKAGES"/>
|
||||||
<uses-permission android:name="permission.REQUEST_DELETE_PACKAGES" />
|
<uses-permission android:name="permission.REQUEST_DELETE_PACKAGES" />
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.view.View;
|
|||||||
import com.android.device.MediaStateChangeObserver;
|
import com.android.device.MediaStateChangeObserver;
|
||||||
import com.android.eventbaus.MessageEvent;
|
import com.android.eventbaus.MessageEvent;
|
||||||
import com.android.util.LogUtils;
|
import com.android.util.LogUtils;
|
||||||
|
import com.android.util.SharedPreferencesUtil;
|
||||||
import com.ik.mboxlauncher.R;
|
import com.ik.mboxlauncher.R;
|
||||||
import com.ik.mboxlauncher.ui.base.FragmentActivity;
|
import com.ik.mboxlauncher.ui.base.FragmentActivity;
|
||||||
import com.ik.mboxlauncher.ui.fragment.AppsFragment;
|
import com.ik.mboxlauncher.ui.fragment.AppsFragment;
|
||||||
@@ -73,6 +74,11 @@ public class CategoryActivity extends FragmentActivity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentsDisableRefreshDataFlag() {
|
||||||
|
FragmentManager.getInstance().pressBackUpdateAllFragmentDisableRefreshDataFlag();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void popBackStackFragment() {
|
public void popBackStackFragment() {
|
||||||
|
|
||||||
@@ -94,6 +100,21 @@ public class CategoryActivity extends FragmentActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
onResumeResetDisableFreshDataFlag();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onResumeResetDisableFreshDataFlag() {
|
||||||
|
if(SharedPreferencesUtil.getSharePrefrencesBoolean(this,SharedPreferencesUtil.CONFIG_RESET_DISABLE_FRESHDATA_FLAG)){
|
||||||
|
SharedPreferencesUtil.setSharePrefrencesBoolean(this,SharedPreferencesUtil.CONFIG_RESET_DISABLE_FRESHDATA_FLAG,false);
|
||||||
|
FragmentManager.getInstance().pressBackUpdateAllFragmentDisableRefreshDataFlag();
|
||||||
|
if(currentFragment!=null){
|
||||||
|
currentFragment.onResumeFragment(new MessageEvent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// public void setPopWindow(int top, int bottom){
|
// public void setPopWindow(int top, int bottom){
|
||||||
@@ -122,6 +143,7 @@ public class CategoryActivity extends FragmentActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
FragmentManager.getInstance().destory();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,9 +157,16 @@ public class CategoryActivity extends FragmentActivity {
|
|||||||
if(currentFragment.onKeyDown(keyCode,event)){
|
if(currentFragment.onKeyDown(keyCode,event)){
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
|
//currentFragment.resetDisableRefreshDataFlag();
|
||||||
|
FragmentManager.getInstance().pressBackUpdateAllFragmentDisableRefreshDataFlag();
|
||||||
return super.onKeyDown(keyCode,event);
|
return super.onKeyDown(keyCode,event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(keyCode==KeyEvent.KEYCODE_HOME){
|
||||||
|
LogUtils.loge("onKeyDown===>KEYCODE_HOME");
|
||||||
|
currentFragment.onDetach();
|
||||||
|
FragmentManager.getInstance().pressBackUpdateAllFragmentDisableRefreshDataFlag();
|
||||||
|
}
|
||||||
return super.onKeyDown(keyCode,event);
|
return super.onKeyDown(keyCode,event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ik.mboxlauncher.ui;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.util.LogUtils;
|
||||||
import com.ik.mboxlauncher.ui.base.BaseFragment;
|
import com.ik.mboxlauncher.ui.base.BaseFragment;
|
||||||
import com.ik.mboxlauncher.ui.base.NotifyInterface;
|
import com.ik.mboxlauncher.ui.base.NotifyInterface;
|
||||||
import com.ik.mboxlauncher.ui.fragment.AppsFragment;
|
import com.ik.mboxlauncher.ui.fragment.AppsFragment;
|
||||||
@@ -55,9 +56,10 @@ public class FragmentManager {
|
|||||||
|
|
||||||
public static void init(Context context, NotifyInterface notifyInterface){
|
public static void init(Context context, NotifyInterface notifyInterface){
|
||||||
if(mInstance==null){
|
if(mInstance==null){
|
||||||
|
LogUtils.loge("FragmentManager init null");
|
||||||
mInstance = new FragmentManager(context,notifyInterface);
|
mInstance = new FragmentManager(context,notifyInterface);
|
||||||
}
|
}
|
||||||
|
LogUtils.loge("FragmentManager init end");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FragmentManager getInstance(){
|
public static FragmentManager getInstance(){
|
||||||
@@ -82,6 +84,25 @@ public class FragmentManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public void destory(){
|
public void destory(){
|
||||||
|
// 清空所有 Fragment 引用
|
||||||
|
if(mAppsFragment != null) {
|
||||||
|
mAppsFragment = null;
|
||||||
|
}
|
||||||
|
if(mLocalFragment != null) {
|
||||||
|
mLocalFragment = null;
|
||||||
|
}
|
||||||
|
if(mMainFragment != null) {
|
||||||
|
mMainFragment = null;
|
||||||
|
}
|
||||||
|
if(mMusicFragment != null) {
|
||||||
|
mMusicFragment = null;
|
||||||
|
}
|
||||||
|
if(mRecommendFragment != null) {
|
||||||
|
mRecommendFragment = null;
|
||||||
|
}
|
||||||
|
if(mVideoFragment != null) {
|
||||||
|
mVideoFragment = null;
|
||||||
|
}
|
||||||
mInstance = null;
|
mInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,4 +112,34 @@ public class FragmentManager {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
//按返回键 home键 等必须恢复 刷新数据处理
|
||||||
|
public void pressBackUpdateAllFragmentDisableRefreshDataFlag(){
|
||||||
|
if(mAppsFragment!=null){
|
||||||
|
mAppsFragment.resetDisableRefreshDataFlag();
|
||||||
|
}else {
|
||||||
|
LogUtils.loge("mAppsFragment==null");
|
||||||
|
}
|
||||||
|
if(mLocalFragment!=null){
|
||||||
|
mLocalFragment.resetDisableRefreshDataFlag();
|
||||||
|
}else {
|
||||||
|
LogUtils.loge("mLocalFragment==null");
|
||||||
|
}
|
||||||
|
if(mVideoFragment!=null){
|
||||||
|
mVideoFragment.resetDisableRefreshDataFlag();
|
||||||
|
}else {
|
||||||
|
LogUtils.loge("mVideoFragment==null");
|
||||||
|
}
|
||||||
|
if(mMusicFragment!=null){
|
||||||
|
mMusicFragment.resetDisableRefreshDataFlag();
|
||||||
|
}else {
|
||||||
|
LogUtils.loge("mMusicFragment==null");
|
||||||
|
}
|
||||||
|
if(mRecommendFragment!=null){
|
||||||
|
mRecommendFragment.resetDisableRefreshDataFlag();
|
||||||
|
}else {
|
||||||
|
LogUtils.loge("mRecommendFragment==null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,6 +293,10 @@ public class Launcher extends FragmentActivity implements SplashView.SplashAdLi
|
|||||||
|
|
||||||
ADSWindowManager.init(this);
|
ADSWindowManager.init(this);
|
||||||
bindAdsWindowMultiView();
|
bindAdsWindowMultiView();
|
||||||
|
//内存不足时释放单列所有Fragment 打开设置按Home出现单个Fragment异常
|
||||||
|
if(FragmentManager.getInstance()!=null){
|
||||||
|
FragmentManager.getInstance().destory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -711,6 +715,7 @@ public boolean onGenericMotionEvent(MotionEvent event) {
|
|||||||
displayStatus();
|
displayStatus();
|
||||||
}else if(MessageEvent.ACTION_UPADATE_APPS_SOURCE.equals(event.action)){
|
}else if(MessageEvent.ACTION_UPADATE_APPS_SOURCE.equals(event.action)){
|
||||||
if(currentFragment!=null&¤tFragment instanceof AppsFragment){
|
if(currentFragment!=null&¤tFragment instanceof AppsFragment){
|
||||||
|
LogUtils.loge("Launcher onMessageEvent===>"+event.action);
|
||||||
currentFragment.onResumeFragment(event);
|
currentFragment.onResumeFragment(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,6 +723,11 @@ public boolean onGenericMotionEvent(MotionEvent event) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentsDisableRefreshDataFlag() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void displayStatus() {
|
private void displayStatus() {
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@@ -880,7 +890,7 @@ public boolean onGenericMotionEvent(MotionEvent event) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
translateAnimation.setDuration(380);
|
translateAnimation.setDuration(300);
|
||||||
translateAnimation.setFillAfter(true);
|
translateAnimation.setFillAfter(true);
|
||||||
content_view.startAnimation(translateAnimation);
|
content_view.startAnimation(translateAnimation);
|
||||||
|
|
||||||
@@ -897,11 +907,12 @@ public boolean onGenericMotionEvent(MotionEvent event) {
|
|||||||
cuttentModel = MODEL_NORMAL;
|
cuttentModel = MODEL_NORMAL;
|
||||||
LogUtils.loge("coustom_view.getHeight():"+coustom_view.getLayoutParams().height);
|
LogUtils.loge("coustom_view.getHeight():"+coustom_view.getLayoutParams().height);
|
||||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f,(float)(0 - coustom_view.getLayoutParams().height - gv_shortcut.getHeight()),0.0f);
|
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f,(float)(0 - coustom_view.getLayoutParams().height - gv_shortcut.getHeight()),0.0f);
|
||||||
translateAnimation.setDuration(380);
|
translateAnimation.setDuration(300);
|
||||||
translateAnimation.setAnimationListener(new Animation.AnimationListener() {
|
translateAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animation animation) {
|
public void onAnimationStart(Animation animation) {
|
||||||
coustom_view.setTranslationZ(0);
|
coustom_view.setTranslationZ(0);
|
||||||
|
grid_coustom_apps.disScrollFocus();
|
||||||
loadShortAppList();
|
loadShortAppList();
|
||||||
coustom_view.clearFocus();
|
coustom_view.clearFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ik.mboxlauncher.ui;
|
package com.ik.mboxlauncher.ui;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@@ -18,6 +20,7 @@ import com.android.nebulasdk.AppManager;
|
|||||||
import com.android.util.EventBusType;
|
import com.android.util.EventBusType;
|
||||||
import com.android.util.LogManager;
|
import com.android.util.LogManager;
|
||||||
import com.android.util.LogUtils;
|
import com.android.util.LogUtils;
|
||||||
|
import com.android.util.SharedPreferencesUtil;
|
||||||
import com.ik.mboxlauncher.SystemService;
|
import com.ik.mboxlauncher.SystemService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -102,10 +105,39 @@ public class StartupBroadcast extends BroadcastReceiver {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
EventBusUtils.postMsg(messageEvent);
|
EventBusUtils.postMsg(messageEvent);
|
||||||
|
if(!isTopAppPackage(context)){
|
||||||
|
LogUtils.loge("three app activity on top of layer");
|
||||||
|
boolean sharePrefrencesBoolean = SharedPreferencesUtil.getSharePrefrencesBoolean(context, SharedPreferencesUtil.CONFIG_RESET_DISABLE_FRESHDATA_FLAG);
|
||||||
|
if(!sharePrefrencesBoolean){
|
||||||
|
SharedPreferencesUtil.setSharePrefrencesBoolean(context,SharedPreferencesUtil.CONFIG_RESET_DISABLE_FRESHDATA_FLAG,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取顶层应用的包名
|
||||||
|
* @param context 上下文
|
||||||
|
* @return 顶层应用包名,如果获取失败返回 null
|
||||||
|
*/
|
||||||
|
public static boolean isTopAppPackage(Context context) {
|
||||||
|
try {
|
||||||
|
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
if (activityManager != null) {
|
||||||
|
List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1);
|
||||||
|
if (runningTasks != null && !runningTasks.isEmpty()) {
|
||||||
|
ActivityManager.RunningTaskInfo taskInfo = runningTasks.get(0);
|
||||||
|
ComponentName topActivity = taskInfo.topActivity;
|
||||||
|
LogUtils.loge("topActivity packagename: " + topActivity.getPackageName());
|
||||||
|
return topActivity.getPackageName().equalsIgnoreCase(context.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.loge("Error getting top app package name: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定包名应用的Launcher Activity信息
|
* 获取指定包名应用的Launcher Activity信息
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.android.eventbaus.MessageEvent;
|
import com.android.eventbaus.MessageEvent;
|
||||||
|
import com.android.util.LogUtils;
|
||||||
|
|
||||||
/** A fragment which slides when it is entering/exiting. */
|
/** A fragment which slides when it is entering/exiting. */
|
||||||
public abstract class BaseFragment extends Fragment {
|
public abstract class BaseFragment extends Fragment {
|
||||||
@@ -38,6 +39,8 @@ public abstract class BaseFragment extends Fragment {
|
|||||||
protected static final int MODEL_NORMAL = 0x00;
|
protected static final int MODEL_NORMAL = 0x00;
|
||||||
protected static final int MODEL_CUSTOM = 0x01;
|
protected static final int MODEL_CUSTOM = 0x01;
|
||||||
protected int cuttentModel=MODEL_NORMAL;
|
protected int cuttentModel=MODEL_NORMAL;
|
||||||
|
private View view;
|
||||||
|
|
||||||
public NotifyInterface getNotifyInterface() {
|
public NotifyInterface getNotifyInterface() {
|
||||||
return notifyInterface;
|
return notifyInterface;
|
||||||
}
|
}
|
||||||
@@ -110,7 +113,12 @@ public abstract class BaseFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(getLayoutResourceId(), container, false);
|
if(view==null){
|
||||||
|
view = inflater.inflate(getLayoutResourceId(), container, false);
|
||||||
|
LogUtils.loge("onCreateView()==>view=null"+getClass().getSimpleName());
|
||||||
|
}else {
|
||||||
|
LogUtils.loge("onCreateView()==>view!=null"+getClass().getSimpleName());
|
||||||
|
}
|
||||||
initView( view);
|
initView( view);
|
||||||
handler.post(inidataRunnable);
|
handler.post(inidataRunnable);
|
||||||
return view;
|
return view;
|
||||||
@@ -152,7 +160,7 @@ public abstract class BaseFragment extends Fragment {
|
|||||||
protected abstract void initView(View view);
|
protected abstract void initView(View view);
|
||||||
protected abstract void initData();
|
protected abstract void initData();
|
||||||
|
|
||||||
|
public abstract void resetDisableRefreshDataFlag();
|
||||||
@Override
|
@Override
|
||||||
public void setEnterTransition(Transition transition) {
|
public void setEnterTransition(Transition transition) {
|
||||||
super.setEnterTransition(transition);
|
super.setEnterTransition(transition);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.app.FragmentTransaction;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.android.eventbaus.MessageEvent;
|
import com.android.eventbaus.MessageEvent;
|
||||||
|
import com.android.util.LogUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,16 +43,19 @@ public abstract class FragmentActivity extends BaseActivity implements NotifyInt
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getlayoutId());
|
setContentView(getlayoutId());
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
LogUtils.loge("savedInstanceState===>null");
|
||||||
|
showInitialFragment();
|
||||||
|
} else {
|
||||||
|
mShowInitialFragment = false;
|
||||||
|
LogUtils.loge("savedInstanceState===>not null");
|
||||||
|
}
|
||||||
mFragmentManager = getFragmentManager();
|
mFragmentManager = getFragmentManager();
|
||||||
initView();
|
initView();
|
||||||
initData();
|
initData();
|
||||||
// Show initial fragment only when the saved state is not restored, because the last
|
// Show initial fragment only when the saved state is not restored, because the last
|
||||||
// fragment is restored if savesInstanceState is not null.
|
// fragment is restored if savesInstanceState is not null.
|
||||||
if (savedInstanceState == null) {
|
|
||||||
showInitialFragment();
|
|
||||||
} else {
|
|
||||||
mShowInitialFragment = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -95,10 +99,11 @@ public abstract class FragmentActivity extends BaseActivity implements NotifyInt
|
|||||||
protected FragmentTransaction showFragment(Fragment fragment, boolean addToBackStack) {
|
protected FragmentTransaction showFragment(Fragment fragment, boolean addToBackStack) {
|
||||||
currentFragment = (BaseFragment) fragment;
|
currentFragment = (BaseFragment) fragment;
|
||||||
currentFragment.setNotifyInterface(this);
|
currentFragment.setNotifyInterface(this);
|
||||||
|
LogUtils.loge("showFragment===>mFragmentManager1");
|
||||||
if (mFragmentManager == null) {
|
if (mFragmentManager == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
LogUtils.loge("showFragment===>mFragmentManager2");
|
||||||
FragmentTransaction ft = mFragmentManager.beginTransaction();
|
FragmentTransaction ft = mFragmentManager.beginTransaction();
|
||||||
// ft.setCustomAnimations(
|
// ft.setCustomAnimations(
|
||||||
// R.anim.slide_left_in,
|
// R.anim.slide_left_in,
|
||||||
@@ -128,6 +133,7 @@ public abstract class FragmentActivity extends BaseActivity implements NotifyInt
|
|||||||
}
|
}
|
||||||
if (!fragment.isAdded()) {
|
if (!fragment.isAdded()) {
|
||||||
ft.replace(getFramlayoutId(), fragment, tag).commit();
|
ft.replace(getFramlayoutId(), fragment, tag).commit();
|
||||||
|
LogUtils.loge("showFragment===>replace");
|
||||||
} else {
|
} else {
|
||||||
ft.show(fragment).commit();
|
ft.show(fragment).commit();
|
||||||
}
|
}
|
||||||
@@ -139,7 +145,9 @@ public abstract class FragmentActivity extends BaseActivity implements NotifyInt
|
|||||||
@Override
|
@Override
|
||||||
public void onMessageEvent(MessageEvent event) {
|
public void onMessageEvent(MessageEvent event) {
|
||||||
super.onMessageEvent(event);
|
super.onMessageEvent(event);
|
||||||
// if(MessageEvent.ACTION_UPADATE_DATA_SOURCE.equals(event.action)){
|
if(MessageEvent.ACTION_UPADATE_APPS_SOURCE.equals(event.action)){
|
||||||
|
setFragmentsDisableRefreshDataFlag();
|
||||||
|
}
|
||||||
// 更新UI
|
// 更新UI
|
||||||
if(currentFragment!=null){
|
if(currentFragment!=null){
|
||||||
currentFragment.onResumeFragment(event);
|
currentFragment.onResumeFragment(event);
|
||||||
@@ -147,7 +155,7 @@ public abstract class FragmentActivity extends BaseActivity implements NotifyInt
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public abstract void setFragmentsDisableRefreshDataFlag();
|
||||||
protected boolean isShowDisplay() {
|
protected boolean isShowDisplay() {
|
||||||
int count = mFragmentManager.getBackStackEntryCount();
|
int count = mFragmentManager.getBackStackEntryCount();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
|||||||
@@ -153,7 +153,10 @@ public abstract class CategoryFragment extends BaseFragment implements AppnetCal
|
|||||||
mCategoryAppPresenter.loadAppByCategory(category);
|
mCategoryAppPresenter.loadAppByCategory(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetDisableRefreshDataFlag() {
|
||||||
|
disableFreshData=false;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void toNextPage();
|
protected abstract void toNextPage();
|
||||||
|
|
||||||
|
|||||||
@@ -135,9 +135,10 @@ public class MainFragment extends BaseFragment implements ShortAppInfoAdapter.On
|
|||||||
ADSWindowManager.getInstance().startVideo();
|
ADSWindowManager.getInstance().startVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetDisableRefreshDataFlag() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
@SuppressLint("UnsafeOptInUsageError")
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ public class RecommendFragment extends CategoryFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResumeFragment(MessageEvent event) {
|
public void onResumeFragment(MessageEvent event) {
|
||||||
super.onResumeFragment(event);
|
super.onResumeFragment(event);
|
||||||
|
disableFreshData=false;
|
||||||
loadAppInfoByCategory(AppManager.CATEGORY_RECOMMEND);//重新加载数据
|
loadAppInfoByCategory(AppManager.CATEGORY_RECOMMEND);//重新加载数据
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class VideoFragment extends CategoryFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
|
LogUtils.loge("VideoFragment===>initData()");
|
||||||
loadAppInfoByCategory(AppManager.CATEGORY_VIDEO);
|
loadAppInfoByCategory(AppManager.CATEGORY_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +161,7 @@ public class VideoFragment extends CategoryFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResumeFragment(MessageEvent event) {
|
public void onResumeFragment(MessageEvent event) {
|
||||||
super.onResumeFragment(event);
|
super.onResumeFragment(event);
|
||||||
|
LogUtils.loge("VideoFragment===>onResumeFragment()");
|
||||||
disableFreshData=false;
|
disableFreshData=false;
|
||||||
loadAppInfoByCategory(AppManager.CATEGORY_VIDEO);//重新加载数据
|
loadAppInfoByCategory(AppManager.CATEGORY_VIDEO);//重新加载数据
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.content.res.TypedArray;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.FocusFinder;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -227,7 +228,7 @@ public class CustomRecyclerViewer extends RecyclerView {
|
|||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
|
|
||||||
// int keyCode = event.getKeyCode();
|
int keyCode = event.getKeyCode();
|
||||||
// if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
// if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||||
// long current = System.currentTimeMillis();
|
// long current = System.currentTimeMillis();
|
||||||
// boolean res;
|
// boolean res;
|
||||||
@@ -240,32 +241,40 @@ public class CustomRecyclerViewer extends RecyclerView {
|
|||||||
// return res;
|
// return res;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
if(keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||||
|
|
||||||
// View focusedView = getFocusedChild(); // 获取当前获得焦点的view
|
|
||||||
// View nextFocusView;
|
View focusedView = getFocusedChild(); // 获取当前获得焦点的view
|
||||||
// try {
|
View nextFocusView;
|
||||||
// if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
try {
|
||||||
// // 通过findNextFocus获取下一个需要得到焦点的view
|
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||||
// nextFocusView = FocusFinder.getInstance().findNextFocus(this, focusedView, View.FOCUS_DOWN);
|
// 通过findNextFocus获取下一个需要得到焦点的view
|
||||||
// } else {
|
nextFocusView = FocusFinder.getInstance().findNextFocus(this, focusedView, View.FOCUS_DOWN);
|
||||||
// // 通过findNextFocus获取下一个需要得到焦点的view
|
} else {
|
||||||
// nextFocusView = FocusFinder.getInstance().findNextFocus(this, focusedView, View.FOCUS_UP);
|
// 通过findNextFocus获取下一个需要得到焦点的view
|
||||||
// }
|
nextFocusView = FocusFinder.getInstance().findNextFocus(this, focusedView, View.FOCUS_UP);
|
||||||
//
|
}
|
||||||
//
|
|
||||||
// LogUtils.loge("nextFocusView===>"+nextFocusView);
|
|
||||||
//
|
LogUtils.loge("nextFocusView===>" + nextFocusView);
|
||||||
// } catch (Exception e) {
|
|
||||||
// nextFocusView = null;
|
} catch (Exception e) {
|
||||||
// }
|
nextFocusView = null;
|
||||||
//
|
}
|
||||||
// // 如果获取失败(也就是说需要交给系统来处理焦点, 消耗掉事件,不让系统处理, 并让先前获取焦点的view获取焦点)
|
|
||||||
// if (nextFocusView == null) {
|
// 如果获取失败(也就是说需要交给系统来处理焦点, 消耗掉事件,不让系统处理, 并让先前获取焦点的view获取焦点)
|
||||||
// focusedView.requestFocus();
|
if (nextFocusView == null) {
|
||||||
// return true;
|
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||||
//
|
focusedView.requestFocus(View.FOCUS_DOWN);
|
||||||
// }
|
}
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||||
|
focusedView.requestFocus(View.FOCUS_UP);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ public class TvRecyclerView extends RecyclerView {
|
|||||||
LogUtils.loge("TvRecyclerView gainFocus="+gainFocus);
|
LogUtils.loge("TvRecyclerView gainFocus="+gainFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//防止失去焦点还是会继续滚动再度获取焦点
|
||||||
|
public void disScrollFocus(){
|
||||||
|
hasResetFocus=false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFocus() {
|
public boolean hasFocus() {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class SharedPreferencesUtil {
|
|||||||
|
|
||||||
public static final String CONFIG_LOCAL_BOOKMARK_APP="config_local_bookmark_app";//本地配置 收藏夹
|
public static final String CONFIG_LOCAL_BOOKMARK_APP="config_local_bookmark_app";//本地配置 收藏夹
|
||||||
public static final String CONFIG_NET_DEFEND_BOOKMARK_APP="config_net_defend_bookmark_app";//网络隔离 收藏夹
|
public static final String CONFIG_NET_DEFEND_BOOKMARK_APP="config_net_defend_bookmark_app";//网络隔离 收藏夹
|
||||||
|
public static final String CONFIG_RESET_DISABLE_FRESHDATA_FLAG="config_reset_disable_freshdata_flag";//重置设备禁止刷新数据为true可刷新
|
||||||
public static String getSharePrefrencesString(Context context,String key){
|
public static String getSharePrefrencesString(Context context,String key){
|
||||||
SharedPreferences sharedPreferences=context.getSharedPreferences(SHARE_NAME,0);
|
SharedPreferences sharedPreferences=context.getSharedPreferences(SHARE_NAME,0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user