Example usage for android.widget LinearLayout getLayoutParams

List of usage examples for android.widget LinearLayout getLayoutParams

Introduction

In this page you can find the example usage for android.widget LinearLayout getLayoutParams.

Prototype

@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
public ViewGroup.LayoutParams getLayoutParams() 

Source Link

Document

Get the LayoutParams associated with this view.

Usage

From source file:roommateapp.info.droid.ActivityBuilding.java

/**
 * Hide the filter statusbar.//www.  ja  v a  2s  . c om
 */
public void hideFilterStatusbar() {

    LinearLayout filterBar = (LinearLayout) findViewById(R.id.filterStatus);
    ViewGroup.LayoutParams params = filterBar.getLayoutParams();
    params.height = 0;
    filterBar.setLayoutParams(new LinearLayout.LayoutParams(params));
}

From source file:roommateapp.info.droid.ActivityBuilding.java

/**
 * Display the filter statusbar./* ww  w.  ja va2 s.co  m*/
 * 
 * @param message to be displayed
 */
public void showFilterStatusbar(String message) {

    // Set message
    TextView filterText = (TextView) findViewById(R.id.filterMsgText);
    filterText.setText(message);

    // Make statusbar visible 
    LinearLayout filterBar = (LinearLayout) findViewById(R.id.filterStatus);
    ViewGroup.LayoutParams params = filterBar.getLayoutParams();

    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    filterBar.setLayoutParams(new LinearLayout.LayoutParams(params));
}

From source file:info.tellmetime.TellmetimeActivity.java

private void resizeClock() {
    final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock);

    // Set width of #mClock layout to the screen's shorter edge size, so clock is not
    // expanded in landscape mode, but has rather somewhat a square shape.
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.width = mShorterEdge;/*from  w w w . j a v a2s  .com*/
    mClock.setLayoutParams(lp);

    final float mItemSize = mShorterEdge / mClock.getChildCount();
    final int mRowMargin = (int) -(mItemSize / 2.2);

    // Scale text size according to shorter edge and set spacing between rows.
    for (int i = 0; i < mClock.getChildCount(); i++) {
        LinearLayout row = (LinearLayout) mClock.getChildAt(i);

        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams();
        params.bottomMargin = mRowMargin;
        row.setLayoutParams(params);

        for (int j = 0; j < row.getChildCount(); j++)
            ((TextView) row.getChildAt(j)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize);
    }
    LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams();
    params.bottomMargin = 0;
    lastRow.setLayoutParams(params);

    TextView twenty = (TextView) findViewById(R.id.twenty);
    params = (LinearLayout.LayoutParams) twenty.getLayoutParams();
    params.leftMargin = 0;
    twenty.setLayoutParams(params);

    // Inflates minutes indicators and attaches them to main view.
    FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators);
    minutesLayout.removeAllViews();
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final boolean isLandscape = getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT);
    if (!isLandscape) {
        layoutParams.addRule(RelativeLayout.BELOW, R.id.clock);
        layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3,
                getResources().getDisplayMetrics());
    }
    minutesLayout.setLayoutParams(layoutParams);

    ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots);
    for (int i = 0; i < minutesDots.getChildCount(); i++)
        ((TextView) minutesDots.getChildAt(i)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize);
}

From source file:org.telegram.ui.ProfileNotificationsActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from  w w  w  .j  ava2 s  .c om
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));

    listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5));
    frameLayout.addView(listView);
    final FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(new ListAdapter(context));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i == settingsVibrateRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
                builder.setItems(
                        new CharSequence[] {
                                LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
                                LocaleController.getString("SettingsDefault", R.string.SettingsDefault),
                                LocaleController.getString("SystemDefault", R.string.SystemDefault),
                                LocaleController.getString("Short", R.string.Short),
                                LocaleController.getString("Long", R.string.Long) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                SharedPreferences.Editor editor = preferences.edit();
                                if (which == 0) {
                                    editor.putInt("vibrate_" + dialog_id, 2);
                                } else if (which == 1) {
                                    editor.putInt("vibrate_" + dialog_id, 0);
                                } else if (which == 2) {
                                    editor.putInt("vibrate_" + dialog_id, 4);
                                } else if (which == 3) {
                                    editor.putInt("vibrate_" + dialog_id, 1);
                                } else if (which == 4) {
                                    editor.putInt("vibrate_" + dialog_id, 3);
                                }
                                editor.commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == settingsNotificationsRow) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setItems(
                        new CharSequence[] { LocaleController.getString("Default", R.string.Default),
                                LocaleController.getString("Enabled", R.string.Enabled),
                                LocaleController.getString("NotificationsDisabled",
                                        R.string.NotificationsDisabled) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface d, int which) {
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                SharedPreferences.Editor editor = preferences.edit();
                                editor.putInt("notify2_" + dialog_id, which);
                                if (which == 2) {
                                    NotificationsController.getInstance()
                                            .removeNotificationsForDialog(dialog_id);
                                }
                                MessagesStorage.getInstance().setDialogFlags(dialog_id, which == 2 ? 1 : 0);
                                editor.commit();
                                TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict
                                        .get(dialog_id);
                                if (dialog != null) {
                                    dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
                                    if (which == 2) {
                                        dialog.notify_settings.mute_until = Integer.MAX_VALUE;
                                    }
                                }
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                                NotificationsController.updateServerNotificationsSettings(dialog_id);
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == settingsSoundRow) {
                try {
                    Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
                    tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
                    tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
                    tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                            RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
                    SharedPreferences preferences = ApplicationLoader.applicationContext
                            .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                    Uri currentSound = null;

                    String defaultPath = null;
                    Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
                    if (defaultUri != null) {
                        defaultPath = defaultUri.getPath();
                    }

                    String path = preferences.getString("sound_path_" + dialog_id, defaultPath);
                    if (path != null && !path.equals("NoSound")) {
                        if (path.equals(defaultPath)) {
                            currentSound = defaultUri;
                        } else {
                            currentSound = Uri.parse(path);
                        }
                    }

                    tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
                    startActivityForResult(tmpIntent, 12);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
            } else if (i == settingsLedRow) {
                if (getParentActivity() == null) {
                    return;
                }

                LinearLayout linearLayout = new LinearLayout(getParentActivity());
                linearLayout.setOrientation(LinearLayout.VERTICAL);
                final ColorPickerView colorPickerView = new ColorPickerView(getParentActivity());
                linearLayout.addView(colorPickerView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
                        LayoutHelper.WRAP_CONTENT, Gravity.CENTER));

                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                if (preferences.contains("color_" + dialog_id)) {
                    colorPickerView.setOldCenterColor(preferences.getInt("color_" + dialog_id, 0xff00ff00));
                } else {
                    if ((int) dialog_id < 0) {
                        colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
                    } else {
                        colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
                    }
                }

                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
                builder.setView(linearLayout);
                builder.setPositiveButton(LocaleController.getString("Set", R.string.Set),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int which) {
                                final SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                SharedPreferences.Editor editor = preferences.edit();
                                editor.putInt("color_" + dialog_id, colorPickerView.getColor());
                                editor.commit();
                                listView.invalidateViews();
                            }
                        });
                builder.setNeutralButton(LocaleController.getString("LedDisabled", R.string.LedDisabled),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                final SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                SharedPreferences.Editor editor = preferences.edit();
                                editor.putInt("color_" + dialog_id, 0);
                                editor.commit();
                                listView.invalidateViews();
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Default", R.string.Default),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                final SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                SharedPreferences.Editor editor = preferences.edit();
                                editor.remove("color_" + dialog_id);
                                editor.commit();
                                listView.invalidateViews();
                            }
                        });
                showDialog(builder.create());
            } else if (i == settingsPriorityRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(
                        LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority));
                builder.setItems(
                        new CharSequence[] {
                                LocaleController.getString("SettingsDefault", R.string.SettingsDefault),
                                LocaleController.getString("NotificationsPriorityDefault",
                                        R.string.NotificationsPriorityDefault),
                                LocaleController.getString("NotificationsPriorityHigh",
                                        R.string.NotificationsPriorityHigh),
                                LocaleController.getString("NotificationsPriorityMax",
                                        R.string.NotificationsPriorityMax) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                if (which == 0) {
                                    which = 3;
                                } else {
                                    which--;
                                }
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                preferences.edit().putInt("priority_" + dialog_id, which).commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == smartRow) {
                if (getParentActivity() == null) {
                    return;
                }
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                int notifyMaxCount = preferences.getInt("smart_max_count_" + dialog_id, 2);
                int notifyDelay = preferences.getInt("smart_delay_" + dialog_id, 3 * 60);
                if (notifyMaxCount == 0) {
                    notifyMaxCount = 2;
                }

                LinearLayout linearLayout = new LinearLayout(getParentActivity());
                linearLayout.setOrientation(LinearLayout.VERTICAL);

                LinearLayout linearLayout2 = new LinearLayout(getParentActivity());
                linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
                linearLayout.addView(linearLayout2);
                LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) linearLayout2
                        .getLayoutParams();
                layoutParams1.width = LayoutHelper.WRAP_CONTENT;
                layoutParams1.height = LayoutHelper.WRAP_CONTENT;
                layoutParams1.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
                linearLayout2.setLayoutParams(layoutParams1);

                TextView textView = new TextView(getParentActivity());
                textView.setText(LocaleController.getString("SmartNotificationsSoundAtMost",
                        R.string.SmartNotificationsSoundAtMost));
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
                linearLayout2.addView(textView);
                layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams();
                layoutParams1.width = LayoutHelper.WRAP_CONTENT;
                layoutParams1.height = LayoutHelper.WRAP_CONTENT;
                layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
                textView.setLayoutParams(layoutParams1);

                final NumberPicker numberPickerTimes = new NumberPicker(getParentActivity());
                numberPickerTimes.setMinValue(1);
                numberPickerTimes.setMaxValue(10);
                numberPickerTimes.setValue(notifyMaxCount);
                linearLayout2.addView(numberPickerTimes);
                layoutParams1 = (LinearLayout.LayoutParams) numberPickerTimes.getLayoutParams();
                layoutParams1.width = AndroidUtilities.dp(50);
                numberPickerTimes.setLayoutParams(layoutParams1);

                textView = new TextView(getParentActivity());
                textView.setText(LocaleController.getString("SmartNotificationsTimes",
                        R.string.SmartNotificationsTimes));
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
                linearLayout2.addView(textView);
                layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams();
                layoutParams1.width = LayoutHelper.WRAP_CONTENT;
                layoutParams1.height = LayoutHelper.WRAP_CONTENT;
                layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
                textView.setLayoutParams(layoutParams1);

                linearLayout2 = new LinearLayout(getParentActivity());
                linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
                linearLayout.addView(linearLayout2);
                layoutParams1 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams();
                layoutParams1.width = LayoutHelper.WRAP_CONTENT;
                layoutParams1.height = LayoutHelper.WRAP_CONTENT;
                layoutParams1.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
                linearLayout2.setLayoutParams(layoutParams1);

                textView = new TextView(getParentActivity());
                textView.setText(LocaleController.getString("SmartNotificationsWithin",
                        R.string.SmartNotificationsWithin));
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
                linearLayout2.addView(textView);
                layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams();
                layoutParams1.width = LayoutHelper.WRAP_CONTENT;
                layoutParams1.height = LayoutHelper.WRAP_CONTENT;
                layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
                textView.setLayoutParams(layoutParams1);

                final NumberPicker numberPickerMinutes = new NumberPicker(getParentActivity());
                numberPickerMinutes.setMinValue(1);
                numberPickerMinutes.setMaxValue(10);
                numberPickerMinutes.setValue(notifyDelay / 60);
                linearLayout2.addView(numberPickerMinutes);
                layoutParams1 = (LinearLayout.LayoutParams) numberPickerMinutes.getLayoutParams();
                layoutParams1.width = AndroidUtilities.dp(50);
                numberPickerMinutes.setLayoutParams(layoutParams1);

                textView = new TextView(getParentActivity());
                textView.setText(LocaleController.getString("SmartNotificationsMinutes",
                        R.string.SmartNotificationsMinutes));
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
                linearLayout2.addView(textView);
                layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams();
                layoutParams1.width = LayoutHelper.WRAP_CONTENT;
                layoutParams1.height = LayoutHelper.WRAP_CONTENT;
                layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
                textView.setLayoutParams(layoutParams1);

                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("SmartNotifications", R.string.SmartNotifications));
                builder.setView(linearLayout);
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                preferences.edit()
                                        .putInt("smart_max_count_" + dialog_id, numberPickerTimes.getValue())
                                        .commit();
                                preferences.edit()
                                        .putInt("smart_delay_" + dialog_id, numberPickerMinutes.getValue() * 60)
                                        .commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("SmartNotificationsDisabled",
                        R.string.SmartNotificationsDisabled), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                preferences.edit().putInt("smart_max_count_" + dialog_id, 0).commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                showDialog(builder.create());
            }
        }
    });

    return fragmentView;
}

From source file:net.momodalo.app.vimtouch.VimTouch.java

public void showCmdHistory() {

    final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim);

    // Setting dialogview
    Window window = dialog.getWindow();
    window.setGravity(Gravity.BOTTOM);/*from   www.j a va2  s.c o m*/

    window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    dialog.setTitle(null);
    dialog.setContentView(R.layout.hist_list);
    dialog.setCancelable(true);

    LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout);
    if (AndroidCompat.SDK >= 11) {
        layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE
                | LinearLayout.SHOW_DIVIDER_END);
    }
    LayoutParams params = layout.getLayoutParams();
    params.width = mScreenWidth;
    layout.setLayoutParams(params);

    LayoutInflater inflater = LayoutInflater.from(this);
    boolean exists = false;

    for (int i = 1; i <= 10; i++) {
        TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false);
        String cmd = Exec.getCmdHistory(i);
        if (cmd.length() == 0)
            break;
        exists = true;
        button.setText(":" + cmd);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                TextView text = (TextView) v;
                CharSequence cmd = text.getText();
                Exec.doCommand(cmd.subSequence(1, cmd.length()).toString());
                dialog.dismiss();
            }
        });
        layout.addView((View) button);
    }

    if (exists)
        dialog.show();
}

From source file:org.nativescript.widgets.TabLayout.java

private void setupItem(LinearLayout ll, TextView textView, ImageView imgView, TabItemSpec tabItem) {
    float density = getResources().getDisplayMetrics().density;

    if (tabItem.iconId != 0) {
        imgView.setImageResource(tabItem.iconId);
        imgView.setVisibility(VISIBLE);/*from  w ww . j a  v a  2s  .  co  m*/
    } else if (tabItem.iconDrawable != null) {
        imgView.setImageDrawable(tabItem.iconDrawable);
        imgView.setVisibility(VISIBLE);
    } else {
        imgView.setVisibility(GONE);
    }

    if (tabItem.title != null && !tabItem.title.isEmpty()) {
        textView.setText(tabItem.title);
        textView.setVisibility(VISIBLE);
    } else {
        textView.setVisibility(GONE);
    }

    if (imgView.getVisibility() == VISIBLE && textView.getVisibility() == VISIBLE) {
        ll.setMinimumHeight((int) (LARGE_MIN_HEIGHT * density));
    } else {
        ll.setMinimumHeight((int) (SMALL_MIN_HEIGHT * density));
    }

    if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
    }
}

From source file:cx.ring.fragments.CallListFragment.java

public void setGridViewHeight(GridView gridView, LinearLayout llMain) {
    ListAdapter listAdapter = gridView.getAdapter();
    if (listAdapter == null) {
        return;//from   w  w  w  . j  a  v  a2  s .  c  om
    }

    int totalHeight = 0;
    int firstHeight = 0;
    int desiredWidth = View.MeasureSpec.makeMeasureSpec(gridView.getWidth(), View.MeasureSpec.AT_MOST);

    int rows = (listAdapter.getCount() + gridView.getNumColumns() - 1) / gridView.getNumColumns();

    for (int i = 0; i < rows; i++) {
        if (i == 0) {
            View listItem = listAdapter.getView(i, null, gridView);
            listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
            firstHeight = listItem.getMeasuredHeight();
        }
        totalHeight += firstHeight;
    }

    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llMain.getLayoutParams();

    params.height = (int) (totalHeight
            + (getResources().getDimension(R.dimen.contact_vertical_spacing) * (rows - 1)
                    + llMain.getPaddingBottom() + llMain.getPaddingTop()));
    llMain.setLayoutParams(params);
    mHeader.requestLayout();
}

From source file:org.telegram.ui.TwoStepVerificationActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(false);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*from  ww  w  . j  a va  2 s  .c o m*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                processDone();
            }
        }
    });

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    ActionBarMenu menu = actionBar.createMenu();
    doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    scrollView = new ScrollView(context);
    scrollView.setFillViewport(true);
    frameLayout.addView(scrollView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) scrollView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    scrollView.setLayoutParams(layoutParams);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    scrollView.addView(linearLayout);
    ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
    layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT;
    layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT;
    linearLayout.setLayoutParams(layoutParams2);

    titleTextView = new TextView(context);
    //titleTextView.setTextColor(0xff757575);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    linearLayout.addView(titleTextView);
    LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) titleTextView.getLayoutParams();
    layoutParams3.width = LayoutHelper.WRAP_CONTENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.gravity = Gravity.CENTER_HORIZONTAL;
    layoutParams3.topMargin = AndroidUtilities.dp(38);
    titleTextView.setLayoutParams(layoutParams3);

    passwordEditText = new EditText(context);
    passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    //passwordEditText.setTextColor(0xff000000);
    passwordEditText.setMaxLines(1);
    passwordEditText.setLines(1);
    passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordEditText.setSingleLine(true);
    passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setTypeface(Typeface.DEFAULT);
    AndroidUtilities.clearCursorDrawable(passwordEditText);
    linearLayout.addView(passwordEditText);
    layoutParams3 = (LinearLayout.LayoutParams) passwordEditText.getLayoutParams();
    layoutParams3.topMargin = AndroidUtilities.dp(32);
    layoutParams3.height = AndroidUtilities.dp(36);
    layoutParams3.leftMargin = AndroidUtilities.dp(40);
    layoutParams3.rightMargin = AndroidUtilities.dp(40);
    layoutParams3.gravity = Gravity.TOP | Gravity.LEFT;
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    passwordEditText.setLayoutParams(layoutParams3);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) {
                processDone();
                return true;
            }
            return false;
        }
    });
    passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }
    });

    bottomTextView = new TextView(context);
    //bottomTextView.setTextColor(0xff757575);
    bottomTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    bottomTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    bottomTextView.setText(LocaleController.getString("YourEmailInfo", R.string.YourEmailInfo));
    linearLayout.addView(bottomTextView);
    layoutParams3 = (LinearLayout.LayoutParams) bottomTextView.getLayoutParams();
    layoutParams3.width = LayoutHelper.WRAP_CONTENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
    layoutParams3.topMargin = AndroidUtilities.dp(30);
    layoutParams3.leftMargin = AndroidUtilities.dp(40);
    layoutParams3.rightMargin = AndroidUtilities.dp(40);
    bottomTextView.setLayoutParams(layoutParams3);

    LinearLayout linearLayout2 = new LinearLayout(context);
    linearLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL);
    linearLayout.addView(linearLayout2);
    layoutParams3 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.MATCH_PARENT;
    linearLayout2.setLayoutParams(layoutParams3);

    bottomButton = new TextView(context);
    bottomButton.setTextColor(0xff4d83b3);
    bottomButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    bottomButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM);
    bottomButton.setText(LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip));
    bottomButton.setPadding(0, AndroidUtilities.dp(10), 0, 0);
    linearLayout2.addView(bottomButton);
    layoutParams3 = (LinearLayout.LayoutParams) bottomButton.getLayoutParams();
    layoutParams3.width = LayoutHelper.WRAP_CONTENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
    layoutParams3.bottomMargin = AndroidUtilities.dp(14);
    layoutParams3.leftMargin = AndroidUtilities.dp(40);
    layoutParams3.rightMargin = AndroidUtilities.dp(40);
    bottomButton.setLayoutParams(layoutParams3);
    bottomButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (type == 0) {
                if (currentPassword.has_recovery) {
                    needShowProgress();
                    TLRPC.TL_auth_requestPasswordRecovery req = new TLRPC.TL_auth_requestPasswordRecovery();
                    ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                        @Override
                        public void run(final TLObject response, final TLRPC.TL_error error) {
                            AndroidUtilities.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    needHideProgress();
                                    if (error == null) {
                                        final TLRPC.TL_auth_passwordRecovery res = (TLRPC.TL_auth_passwordRecovery) response;
                                        AlertDialog.Builder builder = new AlertDialog.Builder(
                                                getParentActivity());
                                        builder.setMessage(LocaleController.formatString("RestoreEmailSent",
                                                R.string.RestoreEmailSent, res.email_pattern));
                                        builder.setTitle(
                                                LocaleController.getString("AppName", R.string.AppName));
                                        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialogInterface,
                                                            int i) {
                                                        TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(
                                                                1);
                                                        fragment.currentPassword = currentPassword;
                                                        fragment.currentPassword.email_unconfirmed_pattern = res.email_pattern;
                                                        fragment.passwordSetState = 4;
                                                        presentFragment(fragment);
                                                    }
                                                });
                                        Dialog dialog = showDialog(builder.create());
                                        if (dialog != null) {
                                            dialog.setCanceledOnTouchOutside(false);
                                            dialog.setCancelable(false);
                                        }
                                    } else {
                                        if (error.text.startsWith("FLOOD_WAIT")) {
                                            int time = Utilities.parseInt(error.text);
                                            String timeString;
                                            if (time < 60) {
                                                timeString = LocaleController.formatPluralString("Seconds",
                                                        time);
                                            } else {
                                                timeString = LocaleController.formatPluralString("Minutes",
                                                        time / 60);
                                            }
                                            showAlertWithText(
                                                    LocaleController.getString("AppName", R.string.AppName),
                                                    LocaleController.formatString("FloodWaitTime",
                                                            R.string.FloodWaitTime, timeString));
                                        } else {
                                            showAlertWithText(
                                                    LocaleController.getString("AppName", R.string.AppName),
                                                    error.text);
                                        }
                                    }
                                }
                            });
                        }
                    }, ConnectionsManager.RequestFlagFailOnServerErrors
                            | ConnectionsManager.RequestFlagWithoutLogin);
                } else {
                    showAlertWithText(
                            LocaleController.getString("RestorePasswordNoEmailTitle",
                                    R.string.RestorePasswordNoEmailTitle),
                            LocaleController.getString("RestorePasswordNoEmailText",
                                    R.string.RestorePasswordNoEmailText));
                }
            } else {
                if (passwordSetState == 4) {
                    showAlertWithText(
                            LocaleController.getString("RestorePasswordNoEmailTitle",
                                    R.string.RestorePasswordNoEmailTitle),
                            LocaleController.getString("RestoreEmailTroubleText",
                                    R.string.RestoreEmailTroubleText));
                } else {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setMessage(LocaleController.getString("YourEmailSkipWarningText",
                            R.string.YourEmailSkipWarningText));
                    builder.setTitle(
                            LocaleController.getString("YourEmailSkipWarning", R.string.YourEmailSkipWarning));
                    builder.setPositiveButton(
                            LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    email = "";
                                    setNewPassword(false);
                                }
                            });
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    showDialog(builder.create());
                }
            }
        }
    });

    if (type == 0) {
        progressView = new FrameLayout(context);
        frameLayout.addView(progressView);
        layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
        layoutParams.width = LayoutHelper.MATCH_PARENT;
        layoutParams.height = LayoutHelper.MATCH_PARENT;
        progressView.setLayoutParams(layoutParams);
        progressView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });

        ProgressBar progressBar = new ProgressBar(context);
        progressView.addView(progressBar);
        layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
        layoutParams.width = LayoutHelper.WRAP_CONTENT;
        layoutParams.height = LayoutHelper.WRAP_CONTENT;
        layoutParams.gravity = Gravity.CENTER;
        progressView.setLayoutParams(layoutParams);

        listView = new ListView(context);
        listView.setDivider(null);
        listView.setEmptyView(progressView);
        listView.setDividerHeight(0);
        listView.setVerticalScrollBarEnabled(false);
        listView.setDrawSelectorOnTop(true);
        frameLayout.addView(listView);
        layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        layoutParams.width = LayoutHelper.MATCH_PARENT;
        layoutParams.height = LayoutHelper.MATCH_PARENT;
        layoutParams.gravity = Gravity.TOP;
        listView.setLayoutParams(layoutParams);
        listView.setAdapter(listAdapter = new ListAdapter(context));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
                if (i == setPasswordRow || i == changePasswordRow) {
                    TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1);
                    fragment.currentPasswordHash = currentPasswordHash;
                    fragment.currentPassword = currentPassword;
                    presentFragment(fragment);
                } else if (i == setRecoveryEmailRow || i == changeRecoveryEmailRow) {
                    TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1);
                    fragment.currentPasswordHash = currentPasswordHash;
                    fragment.currentPassword = currentPassword;
                    fragment.emailOnly = true;
                    fragment.passwordSetState = 3;
                    presentFragment(fragment);
                } else if (i == turnPasswordOffRow || i == abortPasswordRow) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setMessage(LocaleController.getString("TurnPasswordOffQuestion",
                            R.string.TurnPasswordOffQuestion));
                    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    setNewPassword(true);
                                }
                            });
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    showDialog(builder.create());
                }
            }
        });

        updateRows();

        actionBar.setTitle(LocaleController.getString("TwoStepVerification", R.string.TwoStepVerification));
        titleTextView.setText(
                LocaleController.getString("PleaseEnterCurrentPassword", R.string.PleaseEnterCurrentPassword));
    } else if (type == 1) {
        setPasswordSetState(passwordSetState);
    }

    return fragmentView;
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v;//from   w ww . ja v  a2 s .c  o  m

    if (getArguments().containsKey("isLandscapeLarge"))
        isLandscapeLarge = getArguments().getBoolean("isLandscapeLarge");

    hasTitle = getArguments().containsKey("hasTitle") && getArguments().getBoolean("hasTitle");

    if (hasTitle)
        v = inflater.inflate(R.layout.post_layout, container, false);
    else
        v = inflater.inflate(R.layout.post_page_layout, container, false);

    mParent = (NotifyingScrollView) v.findViewById(R.id.post_parent);

    LinearLayout post_layout = (LinearLayout) v.findViewById(R.id.post_layout);
    lay = (LinearLayout) v.findViewById(R.id.post_body);
    img_container = (FrameLayout) v.findViewById(R.id.post_img_container);

    if (getArguments().containsKey("isLandscapeLarge") && getArguments().getBoolean("isLandscapeLarge"))
        v.findViewById(R.id.goto_comments_container).setVisibility(View.GONE);
    else {
        FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.comments_fab);
        fab.setOnClickListener(this);
    }

    if (hasTitle) {
        title = (TextView) v.findViewById(R.id.title);
        author = (TextView) v.findViewById(R.id.author);
        img = (ImageView) v.findViewById(R.id.img);
        subtitle = (TextView) v.findViewById(R.id.subtitle);
        video_card = (CardView) v.findViewById(R.id.video_card);

        if (!getArguments().containsKey(Constants.KEY_TYPE)
                || !getArguments().getString(Constants.KEY_TYPE).equals(Constants.VIDEO)
                        && !getArguments().getString(Constants.KEY_TYPE).equals(Constants.RECENSIONI))
            video_card.setVisibility(View.GONE);
        else if (getArguments().getString(Constants.KEY_TYPE).equals(Constants.VIDEO)) {
            video_lay = (FrameLayout) v.findViewById(R.id.video_layout);
            subtitle.setVisibility(View.GONE);
            thumb = (YouTubeThumbnailView) v.findViewById(R.id.video_thumb);
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) post_layout.getLayoutParams();
            params.topMargin += 120;
            post_layout.setLayoutParams(params);
        } else if (getArguments().getString(Constants.KEY_TYPE).equals(Constants.RECENSIONI)) {
            subtitle.setVisibility(View.GONE);
            video_card.setVisibility(View.GONE);
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) post_layout.getLayoutParams();
            params.topMargin += 120;
            post_layout.setLayoutParams(params);
        }
    }

    return v;
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

public DrawerForm(Context context, Context unstyledContext, Callback callback,
        WatcherService.Client watcherServiceClient) {
    this.context = context;
    this.unstyledContext = unstyledContext;
    this.callback = callback;
    this.watcherServiceClient = watcherServiceClient;
    float density = ResourceUtils.obtainDensity(context);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT,
            SortableListView.LayoutParams.WRAP_CONTENT));
    LinearLayout editTextContainer = new LinearLayout(context);
    editTextContainer.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(editTextContainer);
    searchEdit = new SafePasteEditText(context);
    searchEdit.setOnKeyListener((v, keyCode, event) -> {
        if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
            v.clearFocus();/* w  w w .jav  a 2  s. c om*/
        }
        return false;
    });
    searchEdit.setHint(context.getString(R.string.text_code_number_address));
    searchEdit.setOnEditorActionListener(this);
    searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle);
    searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0));
    searchIcon.setScaleType(ImageView.ScaleType.CENTER);
    searchIcon.setOnClickListener(this);
    editTextContainer.addView(searchEdit,
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density));
    if (C.API_LOLLIPOP) {
        editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0);
    } else {
        editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density));
    }
    LinearLayout selectorContainer = new LinearLayout(context);
    selectorContainer.setBackgroundResource(
            ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0));
    selectorContainer.setOrientation(LinearLayout.HORIZONTAL);
    selectorContainer.setGravity(Gravity.CENTER_VERTICAL);
    selectorContainer.setOnClickListener(v -> {
        hideKeyboard();
        setChanSelectMode(!chanSelectMode);
    });
    linearLayout.addView(selectorContainer);
    selectorContainer.setMinimumHeight((int) (40f * density));
    if (C.API_LOLLIPOP) {
        selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0);
        ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density);
    } else {
        selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0);
    }
    chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem);
    chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f);
    if (C.API_LOLLIPOP) {
        chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM);
    } else {
        chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
    }
    selectorContainer.addView(chanNameView,
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    chanSelectorIcon = new ImageView(context);
    chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0));
    selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density));
    ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL
            | Gravity.END;
    headerView = linearLayout;
    inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null));
    int color = ResourceUtils.getColor(context, R.attr.drawerIconColor);
    ChanManager manager = ChanManager.getInstance();
    Collection<String> availableChans = manager.getAvailableChanNames();
    for (String chanName : availableChans) {
        ChanConfiguration configuration = ChanConfiguration.get(chanName);
        if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) {
            watcherSupportSet.add(chanName);
        }
        Drawable drawable = manager.getIcon(chanName, color);
        chanIcons.put(chanName, drawable);
        chans.add(
                new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable));
    }
    if (availableChans.size() == 1) {
        selectorContainer.setVisibility(View.GONE);
    }
}