Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

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

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:org.telegram.ui.NotificationsSettingsActivity.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  a va  2  s. c  o m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

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

    listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    frameLayout.addView(listView);
    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, final View view, final int i, long l) {
            boolean enabled = false;
            if (i == messageAlertRow || i == groupAlertRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                if (i == messageAlertRow) {
                    enabled = preferences.getBoolean("EnableAll", true);
                    editor.putBoolean("EnableAll", !enabled);
                } else if (i == groupAlertRow) {
                    enabled = preferences.getBoolean("EnableGroup", true);
                    editor.putBoolean("EnableGroup", !enabled);
                }
                editor.commit();
                updateServerNotificationsSettings(i == groupAlertRow);
            } else if (i == messagePreviewRow || i == groupPreviewRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                if (i == messagePreviewRow) {
                    enabled = preferences.getBoolean("EnablePreviewAll", true);
                    editor.putBoolean("EnablePreviewAll", !enabled);
                } else if (i == groupPreviewRow) {
                    enabled = preferences.getBoolean("EnablePreviewGroup", true);
                    editor.putBoolean("EnablePreviewGroup", !enabled);
                }
                editor.commit();
                updateServerNotificationsSettings(i == groupPreviewRow);
            } else if (i == messageSoundRow || i == groupSoundRow) {
                try {
                    SharedPreferences preferences = ApplicationLoader.applicationContext
                            .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                    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));
                    Uri currentSound = null;

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

                    if (i == messageSoundRow) {
                        String path = preferences.getString("GlobalSoundPath", defaultPath);
                        if (path != null && !path.equals("NoSound")) {
                            if (path.equals(defaultPath)) {
                                currentSound = defaultUri;
                            } else {
                                currentSound = Uri.parse(path);
                            }
                        }
                    } else if (i == groupSoundRow) {
                        String path = preferences.getString("GroupSoundPath", 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, i);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
            } else if (i == resetNotificationsRow) {
                if (reseting) {
                    return;
                }
                reseting = true;
                TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings();
                ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                    @Override
                    public void run(TLObject response, TLRPC.TL_error error) {
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            @Override
                            public void run() {
                                MessagesController.getInstance().enableJoined = true;
                                reseting = false;
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                SharedPreferences.Editor editor = preferences.edit();
                                editor.clear();
                                editor.commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                                if (getParentActivity() != null) {
                                    Toast toast = Toast
                                            .makeText(getParentActivity(),
                                                    LocaleController.getString("ResetNotificationsText",
                                                            R.string.ResetNotificationsText),
                                                    Toast.LENGTH_SHORT);
                                    toast.show();
                                }
                            }
                        });
                    }
                });
            } else if (i == inappSoundRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableInAppSounds", true);
                editor.putBoolean("EnableInAppSounds", !enabled);
                editor.commit();
            } else if (i == inappVibrateRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableInAppVibrate", true);
                editor.putBoolean("EnableInAppVibrate", !enabled);
                editor.commit();
            } else if (i == inappPreviewRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableInAppPreview", true);
                editor.putBoolean("EnableInAppPreview", !enabled);
                editor.commit();
            } else if (i == inchatSoundRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableInChatSound", true);
                editor.putBoolean("EnableInChatSound", !enabled);
                editor.commit();
                NotificationsController.getInstance().setInChatSoundEnabled(!enabled);
            } else if (i == inappPriorityRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableInAppPriority", false);
                editor.putBoolean("EnableInAppPriority", !enabled);
                editor.commit();
            } else if (i == contactJoinedRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableContactJoined", true);
                MessagesController.getInstance().enableJoined = !enabled;
                editor.putBoolean("EnableContactJoined", !enabled);
                editor.commit();
            } else if (i == pinnedMessageRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("PinnedMessages", true);
                editor.putBoolean("PinnedMessages", !enabled);
                editor.commit();
            } else if (i == androidAutoAlertRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("EnableAutoNotifications", false);
                editor.putBoolean("EnableAutoNotifications", !enabled);
                editor.commit();
            } else if (i == badgeNumberRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                SharedPreferences.Editor editor = preferences.edit();
                enabled = preferences.getBoolean("badgeNumber", true);
                editor.putBoolean("badgeNumber", !enabled);
                editor.commit();
                NotificationsController.getInstance().setBadgeEnabled(!enabled);
            } else if (i == notificationsServiceConnectionRow) {
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                enabled = preferences.getBoolean("pushConnection", true);
                SharedPreferences.Editor editor = preferences.edit();
                editor.putBoolean("pushConnection", !enabled);
                editor.commit();
                if (!enabled) {
                    ConnectionsManager.getInstance().setPushConnectionEnabled(true);
                } else {
                    ConnectionsManager.getInstance().setPushConnectionEnabled(false);
                }
            } else if (i == notificationsServiceRow) {
                final SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                enabled = preferences.getBoolean("pushService", true);
                SharedPreferences.Editor editor = preferences.edit();
                editor.putBoolean("pushService", !enabled);
                editor.commit();
                if (!enabled) {
                    ApplicationLoader.startPushService();
                } else {
                    ApplicationLoader.stopPushService();
                }
                /*if (!enabled) {
                        
                } else {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo));
                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) {
                        
                        final SharedPreferences.Editor editor = preferences.edit();
                        editor.putBoolean("pushService", false);
                        editor.commit();
                        listView.invalidateViews();
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        ((TextCheckCell) view).setChecked(true);
                    }
                });
                showDialog(builder.create());
                }*/
            } else if (i == messageLedRow || i == groupLedRow) {
                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 (i == messageLedRow) {
                    colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
                } else if (i == groupLedRow) {
                    colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 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();
                                TextColorCell textCell = (TextColorCell) view;
                                if (i == messageLedRow) {
                                    editor.putInt("MessagesLed", colorPickerView.getColor());
                                    textCell.setTextAndColor(
                                            LocaleController.getString("LedColor", R.string.LedColor),
                                            colorPickerView.getColor(), true);
                                } else if (i == groupLedRow) {
                                    editor.putInt("GroupLed", colorPickerView.getColor());
                                    textCell.setTextAndColor(
                                            LocaleController.getString("LedColor", R.string.LedColor),
                                            colorPickerView.getColor(), true);
                                }
                                editor.commit();
                            }
                        });
                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();
                                TextColorCell textCell = (TextColorCell) view;
                                if (i == messageLedRow) {
                                    editor.putInt("MessagesLed", 0);
                                    textCell.setTextAndColor(
                                            LocaleController.getString("LedColor", R.string.LedColor), 0, true);
                                } else if (i == groupLedRow) {
                                    editor.putInt("GroupLed", 0);
                                    textCell.setTextAndColor(
                                            LocaleController.getString("LedColor", R.string.LedColor), 0, true);
                                }
                                editor.commit();
                                listView.invalidateViews();
                            }
                        });
                showDialog(builder.create());
            } else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
                builder.setItems(
                        new CharSequence[] { LocaleController.getString("NoPopup", R.string.NoPopup),
                                LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn),
                                LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff),
                                LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup) },
                        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 (i == messagePopupNotificationRow) {
                                    editor.putInt("popupAll", which);
                                } else if (i == groupPopupNotificationRow) {
                                    editor.putInt("popupGroup", which);
                                }
                                editor.commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == messageVibrateRow || i == groupVibrateRow) {
                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("VibrationDefault", R.string.VibrationDefault),
                                LocaleController.getString("Short", R.string.Short),
                                LocaleController.getString("Long", R.string.Long),
                                LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent) },
                        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();
                                String param = "vibrate_messages";
                                if (i == groupVibrateRow) {
                                    param = "vibrate_group";
                                }
                                if (which == 0) {
                                    editor.putInt(param, 2);
                                } else if (which == 1) {
                                    editor.putInt(param, 0);
                                } else if (which == 2) {
                                    editor.putInt(param, 1);
                                } else if (which == 3) {
                                    editor.putInt(param, 3);
                                } else if (which == 4) {
                                    editor.putInt(param, 4);
                                }
                                editor.commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == messagePriorityRow || i == groupPriorityRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(
                        LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority));
                builder.setItems(new CharSequence[] {
                        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) {
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                if (i == messagePriorityRow) {
                                    preferences.edit().putInt("priority_messages", which).commit();
                                } else if (i == groupPriorityRow) {
                                    preferences.edit().putInt("priority_group", which).commit();
                                }
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == repeatRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(
                        LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
                builder.setItems(
                        new CharSequence[] {
                                LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled),
                                LocaleController.formatPluralString("Minutes", 5),
                                LocaleController.formatPluralString("Minutes", 10),
                                LocaleController.formatPluralString("Minutes", 30),
                                LocaleController.formatPluralString("Hours", 1),
                                LocaleController.formatPluralString("Hours", 2),
                                LocaleController.formatPluralString("Hours", 4) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                int minutes = 0;
                                if (which == 1) {
                                    minutes = 5;
                                } else if (which == 2) {
                                    minutes = 10;
                                } else if (which == 3) {
                                    minutes = 30;
                                } else if (which == 4) {
                                    minutes = 60;
                                } else if (which == 5) {
                                    minutes = 60 * 2;
                                } else if (which == 6) {
                                    minutes = 60 * 4;
                                }
                                SharedPreferences preferences = ApplicationLoader.applicationContext
                                        .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
                                preferences.edit().putInt("repeat_messages", minutes).commit();
                                if (listView != null) {
                                    listView.invalidateViews();
                                }
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            }
            if (view instanceof TextCheckCell) {
                ((TextCheckCell) view).setChecked(!enabled);
            }
        }
    });

    return fragmentView;
}

From source file:com.github.jvanhie.discogsscrobbler.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mList = new ExpandableListView(getActivity());
    mList.setAdapter(mAdapter);/*from ww w  .  ja va2s. c  om*/

    mList.setOnGroupClickListener(new GroupClickHandler());

    mList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, final int i, int i2,
                long l) {
            if (l == 0) {
                //it's a loader (yes, hackish afterthought) get the necessary data from it
                DiscogsSearchLoader loader = (DiscogsSearchLoader) mAdapter.getChild(i, i2);
                mCallbacks.setRefreshVisible(true);
                if (loader.parenttype.equals("artist")) {
                    mDiscogs.getArtistReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("label")) {
                    mDiscogs.getLabelReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("master")) {
                    mDiscogs.getMasterReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                }
            } else {
                //normal release selected
                onItemSelected(l);
            }

            return false;
        }
    });

    //create superframe for adding list and empty view
    FrameLayout superFrame = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    superFrame.setLayoutParams(layoutparams);
    View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
    mEmptyHeading = ((TextView) emptyView.findViewById(R.id.empty_heading));
    mEmptyHeading.setText("Start searching Discogs");
    mEmptyText = ((TextView) emptyView.findViewById(R.id.empty_text));
    mEmptyText.setText("Enter a query or scan a barcode");

    if (mDiscogs == null)
        mDiscogs = Discogs.getInstance(getActivity());

    mList.setGroupIndicator(null);

    superFrame.addView(emptyView);
    mList.setEmptyView(emptyView);
    superFrame.addView(mList);

    return superFrame;
}

From source file:com.prey.activities.CheckPasswordActivity.java

@Override
protected void onResume() {
    super.onResume();
    bindPasswordControls();//from ww w.java  2s .co  m
    TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text);
    final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password);

    Button password_btn_login = (Button) findViewById(R.id.password_btn_login);
    EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt);

    TextView textView1 = (TextView) findViewById(R.id.textView1);
    TextView textView2 = (TextView) findViewById(R.id.textView2);

    Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Regular.ttf");
    Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Bold.ttf");
    Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(),
            "fonts/MagdaClean/magdacleanmono-regular.ttf");

    textView1.setTypeface(magdacleanmonoRegular);
    textView2.setTypeface(magdacleanmonoRegular);

    device_ready_h2_text.setTypeface(titilliumWebRegular);
    textForgotPassword.setTypeface(titilliumWebBold);
    password_btn_login.setTypeface(titilliumWebBold);
    password_pass_txt.setTypeface(magdacleanmonoRegular);

    try {

        textForgotPassword.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                try {
                    String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl();
                    Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
                    startActivity(browserIntent);
                } catch (Exception e) {
                }
            }
        });
    } catch (Exception e) {
    }

    TextView textView5_1 = (TextView) findViewById(R.id.textView5_1);
    TextView textView5_2 = (TextView) findViewById(R.id.textView5_2);

    textView5_1.setTypeface(magdacleanmonoRegular);
    textView5_2.setTypeface(titilliumWebBold);

    TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall);
    LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour);
    textViewUninstall.setTypeface(titilliumWebBold);

    if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) {
        linearLayoutTour.setVisibility(View.GONE);
        textViewUninstall.setVisibility(View.VISIBLE);

        textViewUninstall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl();

                Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
                startActivity(browserIntent);

                finish();
            }
        });
    } else {

        linearLayoutTour.setVisibility(View.VISIBLE);
        textViewUninstall.setVisibility(View.GONE);
        try {

            linearLayoutTour.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getApplication(), TourActivity1.class);
                    Bundle b = new Bundle();
                    b.putInt("id", 1);
                    intent.putExtras(b);
                    startActivity(intent);
                    finish();
                }
            });
        } catch (Exception e) {

        }
    }

    boolean showLocation = false;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this);
        boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this);
        boolean canAccessCamera = PreyPermission.canAccessCamera(this);
        boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this);
        boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this);

        if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState
                || !canAccessReadExternalStorage) {

            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            final FrameLayout frameView = new FrameLayout(this);
            builder.setView(frameView);

            final AlertDialog alertDialog = builder.create();
            LayoutInflater inflater = alertDialog.getLayoutInflater();
            View dialoglayout = inflater.inflate(R.layout.warning, frameView);

            TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title);
            TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body);

            warning_title.setTypeface(magdacleanmonoRegular);
            warning_body.setTypeface(titilliumWebBold);

            Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok);
            Button button_close = (Button) dialoglayout.findViewById(R.id.button_close);
            button_ok.setTypeface(titilliumWebBold);
            button_close.setTypeface(titilliumWebBold);

            final Activity thisActivity = this;
            button_ok.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PreyLogger.d("askForPermission");
                    askForPermission();
                    alertDialog.dismiss();

                }
            });

            button_close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PreyLogger.d("close ask");

                    alertDialog.dismiss();
                }
            });

            alertDialog.show();
            showLocation = false;

        } else {
            showLocation = true;
        }

    } else {
        showLocation = true;
    }
    if (showLocation) {
        LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (isGpsEnabled || isNetworkEnabled) {
            PreyLogger.d("isGpsEnabled || isNetworkEnabled");

        } else {
            PreyLogger.d("no gps ni red");
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            final AlertDialog alertDialog = builder.create();
            TextView textview = new TextView(this);
            textview.setText(getString(R.string.location_settings));
            textview.setMaxLines(10);
            textview.setTextSize(18F);
            textview.setPadding(20, 0, 20, 20);
            textview.setTextColor(Color.BLACK);
            builder.setView(textview);
            builder.setPositiveButton(getString(R.string.go_to_settings),
                    new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialoginterface, int i) {
                            dialoginterface.dismiss();
                            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                            startActivityForResult(intent, 0);
                            return;

                        }

                    });
            builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialoginterface, int i) {
                    dialoginterface.dismiss();
                }

            });
            builder.create().show();
        }
    }

}

From source file:gr.plushost.prototypeapp.widgets.LabelView.java

private boolean replaceLayout(View target) {
    if (getParent() != null || target == null || target.getParent() == null || _labelViewContainerID != -1) {
        return false;
    }/*w w  w . ja  va 2s .c om*/

    ViewGroup parentContainer = (ViewGroup) target.getParent();

    if (target.getParent() instanceof FrameLayout) {
        ((FrameLayout) target.getParent()).addView(this);
    } else if (target.getParent() instanceof ViewGroup) {

        int groupIndex = parentContainer.indexOfChild(target);
        _labelViewContainerID = generateViewId();

        // relativeLayout need copy rule
        if (target.getParent() instanceof RelativeLayout) {
            for (int i = 0; i < parentContainer.getChildCount(); i++) {
                if (i == groupIndex) {
                    continue;
                }
                View view = parentContainer.getChildAt(i);
                RelativeLayout.LayoutParams para = (RelativeLayout.LayoutParams) view.getLayoutParams();
                for (int j = 0; j < para.getRules().length; j++) {
                    if (para.getRules()[j] == target.getId()) {
                        para.getRules()[j] = _labelViewContainerID;
                    }
                }
                view.setLayoutParams(para);
            }
        }
        parentContainer.removeView(target);

        // new dummy layout
        FrameLayout labelViewContainer = new FrameLayout(getContext());
        ViewGroup.LayoutParams targetLayoutParam = target.getLayoutParams();
        labelViewContainer.setLayoutParams(targetLayoutParam);
        target.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        // add target and label in dummy layout
        labelViewContainer.addView(target);
        labelViewContainer.addView(this);
        labelViewContainer.setId(_labelViewContainerID);

        // add dummy layout in parent container
        parentContainer.addView(labelViewContainer, groupIndex, targetLayoutParam);
    }
    return true;
}

From source file:org.artoolkit.ar.unity.UnityARPlayerActivity.java

@Override
protected void onResume() {
    Log.i(TAG, "onResume()");

    super.onResume();

    ////w  ww . j a  v  a  2 s  . co m
    // Wrap the Unity application's view and the camera preview in a FrameLayout;
    //

    //View focusView = getCurrentFocus(); // Save the focus, in case we inadvertently change it.
    //Log.i(TAG, "Focus view is " + focusView.toString() + ".");

    ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
    unityView = (ViewGroup) decorView.getChildAt(0);
    if (unityView == null) {
        Log.e(TAG, "Error: Could not find top view.");
        return;
    }
    //Log.i(TAG, "Top view is " + unityView.toString() + ".");

    // Create a placeholder for us to insert the camera preview capture object to the
    // view hierarchy.
    previewInserter = new FrameLayout(this);
    decorView.removeView(unityView); // We must remove the root view from its parent before we can add it somewhere else.
    decorView.addView(previewInserter);

    //focusView.requestFocus(); // Restore focus.

    // Create the camera preview.
    previewView = new CameraSurface(this);
    previewInserter.addView(previewView, new LayoutParams(128, 128));

    // Now add Unity view back in.
    // In order to ensure that Unity's view covers the camera preview each time onResume
    // is called, find the SurfaceView inside the Unity view hierachy, and
    // set the media overlay mode on it. Add the Unity view AFTER adding the previewView.
    SurfaceView sv = findSurfaceView(unityView);
    if (sv == null) {
        Log.w(TAG, "No SurfaceView found in Unity view hierarchy.");
    } else {
        Log.i(TAG, "Found SurfaceView " + sv.toString() + ".");
        sv.setZOrderMediaOverlay(true);
    }
    previewInserter.addView(unityView);
}

From source file:com.actionbarsherlock.internal.view.menu.MenuPopupHelper.java

private int measureContentWidth(ListAdapter adapter) {
    // Menus don't tend to be long, so this is more sane than it looks.
    int width = 0;
    View itemView = null;/*from  w  ww . ja  v a2 s.  c  o m*/
    int itemType = 0;
    final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        if (mMeasureParent == null) {
            mMeasureParent = new FrameLayout(mContext);
        }
        itemView = adapter.getView(i, itemView, mMeasureParent);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        width = Math.max(width, itemView.getMeasuredWidth());
    }
    return width;
}

From source file:com.example.mapsample.view.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);// w w w .j  a v a2s .c  o m
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:net.bluehack.ui.WallpapersActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("ChatBackground", R.string.ChatBackground));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//ww w.ja v  a 2  s . c o m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                boolean done;
                TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
                if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
                    int width = AndroidUtilities.displaySize.x;
                    int height = AndroidUtilities.displaySize.y;
                    if (width > height) {
                        int temp = width;
                        width = height;
                        height = temp;
                    }
                    TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes,
                            Math.min(width, height));
                    String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
                    File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE),
                            fileName);
                    File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg");
                    try {
                        done = AndroidUtilities.copyFile(f, toFile);
                    } catch (Exception e) {
                        done = false;
                        FileLog.e("tmessages", e);
                    }
                } else {
                    if (selectedBackground == -1) {
                        File fromFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg");
                        File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg");
                        done = fromFile.renameTo(toFile);
                    } else {
                        done = true;
                    }
                }

                if (done) {
                    SharedPreferences preferences = ApplicationLoader.applicationContext
                            .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
                    SharedPreferences.Editor editor = preferences.edit();
                    editor.putInt("selectedBackground", selectedBackground);
                    editor.putInt("selectedColor", selectedColor);
                    editor.commit();
                    ApplicationLoader.reloadWallpaper();
                }
                finishFragment();
            }
        }
    });

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

    FrameLayout frameLayout = new FrameLayout(context);
    fragmentView = frameLayout;

    backgroundImage = new ImageView(context);
    backgroundImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
    frameLayout.addView(backgroundImage,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    backgroundImage.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.INVISIBLE);
    frameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 52));

    progressViewBackground = new View(context);
    progressViewBackground.setBackgroundResource(R.drawable.system_loader);
    progressView.addView(progressViewBackground, LayoutHelper.createFrame(36, 36, Gravity.CENTER));

    ProgressBar progressBar = new ProgressBar(context);
    try {
        progressBar.setIndeterminateDrawable(context.getResources().getDrawable(R.drawable.loading_animation));
    } catch (Exception e) {
        //don't promt
    }
    progressBar.setIndeterminate(true);
    AndroidUtilities.setProgressBarAnimationDuration(progressBar, 1500);
    progressView.addView(progressBar, LayoutHelper.createFrame(32, 32, Gravity.CENTER));

    RecyclerListView listView = new RecyclerListView(context);
    listView.setClipToPadding(false);
    listView.setTag(8);
    listView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), 0);
    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    listView.setLayoutManager(layoutManager);
    listView.setDisallowInterceptTouchEvents(true);
    listView.setOverScrollMode(RecyclerListView.OVER_SCROLL_NEVER);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 102, Gravity.LEFT | Gravity.BOTTOM));
    listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (position == 0) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());

                CharSequence[] items = new CharSequence[] {
                        LocaleController.getString("FromCamera", R.string.FromCamera),
                        LocaleController.getString("FromGalley", R.string.FromGalley),
                        LocaleController.getString("Cancel", R.string.Cancel) };

                builder.setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        try {
                            if (i == 0) {
                                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                                File image = AndroidUtilities.generatePicturePath();
                                if (image != null) {
                                    if (Build.VERSION.SDK_INT >= 24) {
                                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                                                FileProvider.getUriForFile(getParentActivity(),
                                                        BuildConfig.APPLICATION_ID + ".provider", image));
                                        takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                                        takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                                    } else {
                                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                                                Uri.fromFile(image));
                                    }
                                    currentPicturePath = image.getAbsolutePath();
                                }
                                startActivityForResult(takePictureIntent, 10);
                            } else if (i == 1) {
                                Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
                                photoPickerIntent.setType("image/*");
                                startActivityForResult(photoPickerIntent, 11);
                            }
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                    }
                });
                showDialog(builder.create());
            } else {
                if (position - 1 < 0 || position - 1 >= wallPapers.size()) {
                    return;
                }
                TLRPC.WallPaper wallPaper = wallPapers.get(position - 1);
                selectedBackground = wallPaper.id;
                listAdapter.notifyDataSetChanged();
                processSelectedBackground();
            }
        }
    });

    processSelectedBackground();

    return fragmentView;
}

From source file:com.gome.haoyuangong.views.MyViewPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;/*from w  w  w  . j  a v  a2 s .c  o  m*/
    tabView.setTag("tavView");
    tabView.setId(index);
    //      tabView.setFocusable(true);
    //      tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);
    //tabView.setPadding(pointSize, 0, pointSize, 0);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    tabView.setMaxLines(1);
    tabView.setGravity(Gravity.CENTER);
    XmlPullParser xrp = getResources().getXml(R.drawable.tab_button);
    try {
        ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp);
        tabView.setTextColor(csl);
    } catch (Exception e) {

    }

    if (iconResId != 0) {
        //tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }

    FrameLayout.LayoutParams tabTvL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    tabView.setLayoutParams(tabTvL);

    //measureView(tabView);

    LinearLayout layoutWraper1 = new LinearLayout(getContext());
    LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1);
    layoutWraper1.setLayoutParams(lp1);
    layoutWraper1.setGravity(Gravity.CENTER);
    layoutWraper1.setFocusable(true);
    layoutWraper1.setOnClickListener(mTabClickListener);
    layoutWraper1.setPadding(0, 0, 0, 0);
    layoutWraper1.setBackgroundResource(R.drawable.tab_btn_red);

    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setTag("framelayout");
    //      FrameLayout.LayoutParams fl2 = new FrameLayout.LayoutParams(tabView.getMeasuredWidth() + padding, tabView.getMeasuredHeight()+ (int)(padding * 1.5));
    FrameLayout.LayoutParams fl2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    //      frameLayout.setPadding(padding, padding, padding, padding);
    frameLayout.setLayoutParams(fl2);
    //      frameLayout.addView(tabView);

    View hasNew = new View(getContext());
    FrameLayout.LayoutParams hasNewL = new FrameLayout.LayoutParams(pointSize, pointSize);
    hasNew.setLayoutParams(hasNewL);
    hasNewL.gravity = Gravity.TOP | Gravity.RIGHT;
    hasNew.setBackgroundResource(R.drawable.shape_circle);

    FrameLayout tabTvframe = new FrameLayout(getContext());
    FrameLayout.LayoutParams tabTvframeL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    tabTvframeL.gravity = Gravity.CENTER;
    tabTvframe.setLayoutParams(tabTvframeL);
    tabTvframe.addView(tabView);
    tabTvframe.addView(hasNew);
    hasNew.setVisibility(View.GONE);

    frameLayout.addView(tabTvframe);

    layoutWraper1.addView(frameLayout);

    tabView.setTagView(hasNew);

    mTabLayout.addView(layoutWraper1, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java

public BufferTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    ThemeUtils.checkAppCompatTheme(context);
    setOrientation(VERTICAL);//from w w  w.  j  a  va  2s.  c o m
    setWillNotDraw(false);
    setAddStatesFromChildren(true);
    inputFrame = new FrameLayout(context);
    inputFrame.setAddStatesFromChildren(true);
    addView(inputFrame);
    collapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    collapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator());
    collapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START);
    isHintExpanded = collapsingTextHelper.getExpansionFraction() == 1f;
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.BufferTextInputLayout, defStyleAttr, R.style.BufferTextInputLayout);
    isHintEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_hintEnabled, true);
    setHint(a.getText(R.styleable.BufferTextInputLayout_android_hint));
    hintAnimationEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_hintAnimationEnabled, true);
    if (a.hasValue(R.styleable.BufferTextInputLayout_android_textColorHint)) {
        defaultTextColor = focusedTextColor = a
                .getColorStateList(R.styleable.BufferTextInputLayout_android_textColorHint);
    }
    final int hintAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_hintTextAppearance, -1);
    if (hintAppearance != -1) {
        setHintTextAppearance(a.getResourceId(R.styleable.BufferTextInputLayout_hintTextAppearance, 0));
    }
    errorTextAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_errorTextAppearance, 0);
    final boolean errorEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_errorEnabled, false);
    final boolean counterEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_counterEnabled, false);
    setCounterMaxLength(a.getInt(R.styleable.BufferTextInputLayout_counterMaxLength, INVALID_MAX_LENGTH));
    counterTextAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_counterTextAppearance, 0);
    counterOverflowTextAppearance = a
            .getResourceId(R.styleable.BufferTextInputLayout_counterOverflowTextAppearance, 0);
    counterVisible = counterEnabled;

    counterMode = CounterMode.fromId(a.getInt(R.styleable.BufferTextInputLayout_counterMode, 2));

    charactersRemainingUntilCounterDisplay = a.getInt(R.styleable.BufferTextInputLayout_displayFromCount,
            getCounterMaxLength());

    a.recycle();
    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);
    setCounterVisible(counterVisible && (charactersRemainingUntilCounterDisplay == getCounterMaxLength()));
    applyPasswordToggleTint();
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        // Make sure we're important for accessibility if we haven't been explicitly not
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate());
}