|
23 | 23 |
|
24 | 24 | import android.content.Context;
|
25 | 25 | import android.content.Intent;
|
| 26 | +import android.content.res.Configuration; |
26 | 27 | import android.os.AsyncTask;
|
27 | 28 | import android.os.Bundle;
|
28 | 29 | import android.view.LayoutInflater;
|
|
51 | 52 | import nl.hnogames.domoticz.utils.SerializableManager;
|
52 | 53 | import nl.hnogames.domoticz.utils.SharedPrefUtil;
|
53 | 54 | import nl.hnogames.domoticz.utils.UsefulBits;
|
| 55 | +import nl.hnogames.domoticz.utils.ViewUtils; |
54 | 56 | import nl.hnogames.domoticzapi.Containers.PlanInfo;
|
55 | 57 | import nl.hnogames.domoticzapi.Interfaces.PlansReceiver;
|
56 | 58 | import nl.hnogames.domoticzapi.Utils.PhoneConnectionUtil;
|
@@ -142,9 +144,27 @@ private void createListView() {
|
142 | 144 | if (mRecyclerView == null) {
|
143 | 145 | mRecyclerView = getView().findViewById(R.id.my_recycler_view);
|
144 | 146 | mSwipeRefreshLayout = getView().findViewById(R.id.swipe_refresh_layout);
|
145 |
| - mRecyclerView.setHasFixedSize(true); |
146 |
| - StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); |
| 147 | + |
| 148 | + StaggeredGridLayoutManager mLayoutManager; |
| 149 | + boolean isPortrait = false; |
| 150 | + if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) |
| 151 | + isPortrait = true; |
| 152 | + if (ViewUtils.isTablet(getContext())) { |
| 153 | + if (isPortrait) { |
| 154 | + mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); |
| 155 | + } else { |
| 156 | + mLayoutManager = new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.VERTICAL); |
| 157 | + } |
| 158 | + } else { |
| 159 | + if (isPortrait) { |
| 160 | + mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); |
| 161 | + } else { |
| 162 | + mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); |
| 163 | + } |
| 164 | + } |
| 165 | + |
147 | 166 | mRecyclerView.setLayoutManager(mLayoutManager);
|
| 167 | + mRecyclerView.setHasFixedSize(false); |
148 | 168 | }
|
149 | 169 |
|
150 | 170 | if (mAdapter == null) {
|
|
0 commit comments