Skip to content

Commit

Permalink
fix: ClassCastException with LG Devices
Browse files Browse the repository at this point in the history
resolve: #17
  • Loading branch information
kosratdev committed Jul 18, 2017
1 parent 861dc3f commit e11f513
Showing 1 changed file with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
package uk.verscreative.materialsettings;

import android.app.Dialog;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.preference.Preference;

import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.preference.RingtonePreference;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.AppCompatRadioButton;
import android.support.v7.widget.AppCompatSpinner;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.net.Uri;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.View;
import android.os.Build;
import android.os.Bundle;
import android.content.pm.PackageManager;
import android.widget.LinearLayout;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v7.widget.Toolbar;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.util.TypedValue;
import android.preference.PreferenceScreen;
import android.app.Dialog;


public class SettingsExampleActivity extends PreferenceActivity {
Expand Down Expand Up @@ -215,7 +214,25 @@ public void setUpNestedScreen(PreferenceScreen preferenceScreen) {
ViewGroup mRootView = (ViewGroup) dialog.findViewById(android.R.id.content);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent().getParent();
LinearLayout root = null;
try {
root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent();
} catch (Exception e) {
e.printStackTrace();
}

try {
root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent().getParent();
} catch (Exception e) {
e.printStackTrace();
}

try {
root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent().getParent().getParent();
} catch (Exception e) {
e.printStackTrace();
}

appBar = (AppBarLayout) LayoutInflater.from(this).inflate(R.layout.toolbar_settings, root, false);
root.addView(appBar, 0);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Expand Down

0 comments on commit e11f513

Please sign in to comment.