do not crash if inflating feeds/cats headerview failed (android!!1)

This commit is contained in:
Andrew Dolgov 2015-02-17 22:29:56 +03:00
parent ea717ae7da
commit ae91427987
2 changed files with 32 additions and 20 deletions

View File

@ -15,6 +15,7 @@ import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -222,6 +223,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
// TODO: better check
if (m_activity.findViewById(R.id.headlines_drawer) != null) {
try {
View layout = inflater.inflate(R.layout.drawer_header, m_list, false);
m_list.addHeaderView(layout, null, false);
@ -234,6 +236,10 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
} catch (MalformedURLException e) {
server.setText("");
}
} catch (InflateException e) {
// welp couldn't inflate header i guess
e.printStackTrace();
}
}
m_list.setAdapter(m_adapter);

View File

@ -16,6 +16,7 @@ import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -300,6 +301,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
} else {
// TODO: better check
if (m_activity.findViewById(R.id.headlines_drawer) != null) {
try {
View layout = inflater.inflate(R.layout.drawer_header, m_list, false);
m_list.addHeaderView(layout, null, false);
@ -312,6 +314,10 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
} catch (MalformedURLException e) {
server.setText("");
}
} catch (InflateException e) {
// welp couldn't inflate header i guess
e.printStackTrace();
}
}
}