From 031a9d06f24fd608b8b7bc8a4a338ebe7f90fec8 Mon Sep 17 00:00:00 2001 From: wangguoquan Date: Mon, 28 Mar 2016 22:09:54 +0800 Subject: [PATCH] adapt with 4.4, fix fragment reload and radio button issue --- src/com/clear/vodmobile/MainActivity.java | 33 ++++++++++++++----- .../clear/vodmobile/view/BaseFragment.java | 3 ++ .../clear/vodmobile/view/FragmentFactory.java | 5 +++ .../clear/vodmobile/view/LiveFragment.java | 3 ++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/com/clear/vodmobile/MainActivity.java b/src/com/clear/vodmobile/MainActivity.java index 3cad0cf..75c9324 100644 --- a/src/com/clear/vodmobile/MainActivity.java +++ b/src/com/clear/vodmobile/MainActivity.java @@ -49,6 +49,7 @@ public class MainActivity extends Activity { private FragmentManager fragManager; private RadioGroup radioGroup; + private int bottomTabPos = 0; private JSONObject entryJson = null; private JSONObject mainMenuJson; @@ -256,9 +257,9 @@ protected void initViews() { for(int i = 0; i < fragmentDataset.size(); i++) { RadioButton rb = new RadioButton(this); - + //rb.setButtonDrawable(null); + rb.setButtonDrawable(android.R.color.transparent); rb.setBackgroundResource(R.drawable.bottombar_itembg_selector); - rb.setButtonDrawable(null); rb.setGravity(Gravity.CENTER); /* TODO, FIXME, replace with default empty icon */ @@ -332,18 +333,20 @@ public void onCheckedChanged(RadioGroup group, int checkedId) { } } - @Override - protected void onStart() { - super.onStart(); - Log.i(TAG, "onStart called."); - } - @Override protected void onRestart() { Log.i(TAG, "onRestart called."); super.onRestart(); } + + @Override + protected void onStart() { + super.onStart(); + + Log.i(TAG, "onStart called."); + } + @Override protected void onResume() { Log.i(TAG, "onResume called."); @@ -376,4 +379,18 @@ protected void onDestroy() { super.onDestroy(); } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + bottomTabPos = savedInstanceState.getInt("bottomTabPos"); + + super.onRestoreInstanceState(savedInstanceState); + } + @Override + protected void onSaveInstanceState(Bundle outState) { + + outState.putInt("bottomTabPos", bottomTabPos); + } + + } diff --git a/src/com/clear/vodmobile/view/BaseFragment.java b/src/com/clear/vodmobile/view/BaseFragment.java index 6ccff6b..1bbe625 100644 --- a/src/com/clear/vodmobile/view/BaseFragment.java +++ b/src/com/clear/vodmobile/view/BaseFragment.java @@ -16,4 +16,7 @@ public class BaseFragment extends Fragment { private static String TAG = "BaseFragment"; + public BaseFragment() { + + } } diff --git a/src/com/clear/vodmobile/view/FragmentFactory.java b/src/com/clear/vodmobile/view/FragmentFactory.java index 3f5f85d..bbaf123 100644 --- a/src/com/clear/vodmobile/view/FragmentFactory.java +++ b/src/com/clear/vodmobile/view/FragmentFactory.java @@ -17,6 +17,11 @@ public class FragmentFactory { private static final String TAG = "FragmentFactory"; + /* TODO, FIXME, BUG, 4.4 Fragment reuse. only walkaround */ + private static Fragment lastLiveFragment=null; + private static Fragment lastMovieTopRecommandFragment=null; + private static Fragment lastPicTextSimpleFragment=null; + /* TODO, FIXME, keep the fragment with same type & menuJson */ public static Fragment getInstanceByType(JSONObject menuJson) { diff --git a/src/com/clear/vodmobile/view/LiveFragment.java b/src/com/clear/vodmobile/view/LiveFragment.java index 255dbe2..c5c0fbd 100644 --- a/src/com/clear/vodmobile/view/LiveFragment.java +++ b/src/com/clear/vodmobile/view/LiveFragment.java @@ -141,5 +141,8 @@ public void onItemClick(AdapterView arg0, View view, int pos, long id) { startActivity(intent); } }); + } + + }