Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:cat.wuyingren.rorhelper.fragments.dialogs.ManageSenatorDialogFragment.java

@NonNull
@Override//from  w  ww  .j  av  a  2 s  .c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    final View v = inflater.inflate(R.layout.dialog_managesenator, null);

    final TextView randomKillTitle = (TextView) v.findViewById(R.id.managesenator_randomTitle);
    final ToggleButton randomKillButton = (ToggleButton) v.findViewById(R.id.managesenator_randomToggle);
    final LinearLayout selectors = (LinearLayout) v.findViewById(R.id.managesenator_selectors);

    dataSource = MainActivity.getDataSource();
    context = MainActivity.getContext();

    currentGameId = getArguments().getLong(ARG_GAMEID);
    killMode = getArguments().getBoolean(ARG_MODE);
    statesman = getArguments().getBoolean(ARG_TYPE);

    result.setKill(killMode);
    result.setStatesman(statesman);

    final Spinner senatorSpinner = (Spinner) v.findViewById(R.id.managesenator_senatorSpinner);

    randomKillButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            result.setRandomKill(isChecked);
            if (isChecked) {
                selectors.setVisibility(View.GONE);
            } else {
                selectors.setVisibility(View.VISIBLE);
            }
        }
    });

    if (!killMode) {

        randomKillTitle.setVisibility(View.GONE);
        randomKillButton.setVisibility(View.GONE);

        String[] keys = getArguments().getStringArray(ARG_ARRAY);
        ArrayList<String> values = getArguments().getStringArrayList(ARG_VALUES);
        /*ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(MainActivity.getContext(),
            android.R.layout.simple_spinner_item, keys);*/
        SenatorAdapter adapter = new SenatorAdapter(MainActivity.getContext(),
                android.R.layout.simple_spinner_item, keys, values);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        senatorSpinner.setAdapter(adapter);
    } else {
        randomKillTitle.setVisibility(View.VISIBLE);
        randomKillButton.setVisibility(View.VISIBLE);

    }

    senatorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            result.setSenatorID(parent.getSelectedItem().toString());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    final Spinner factionSpinner = SystemUtils.configureSpinner(v, R.id.managesenator_factionSpinner,
            R.array.faction_nameID);
    factionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            long factionID = dataSource.getFactionId(currentGameId,
                    getResources().getStringArray(R.array.faction_nameID)[position]);
            result.setFactionID(factionID);
            if (killMode) {
                ArrayList<Senator> senators = dataSource.getAllSenatorsOfFaction(factionID);
                Iterator<Senator> ite = senators.iterator();
                ArrayList<CharSequence> array = new ArrayList<CharSequence>();
                ArrayList<String> values = new ArrayList<String>();
                while (ite.hasNext()) {
                    Senator s = ite.next();
                    array.add(String.valueOf(s.getId()));
                    values.add(String.valueOf(s.getName()));
                }
                String[] keys = new String[array.size()];
                keys = array.toArray(keys);
                //ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item, array);
                SenatorAdapter adapter = new SenatorAdapter(context, android.R.layout.simple_spinner_item, keys,
                        values);

                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                senatorSpinner.setAdapter(adapter);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    builder.setView(v).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mListener.onManageSenatorDialogPositiveClick(result);
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            getDialog().cancel();
        }
    });
    String stringA, stringB;
    if (killMode) {
        stringA = getString(R.string.dialog_managesenator_kill_title);
    } else {
        stringA = getString(R.string.dialog_managesenator_title);
    }
    if (statesman) {
        stringB = getString(R.string.statesman);
    } else {
        stringB = getString(R.string.senator);
    }
    builder.setTitle(stringA + " " + stringB);

    return builder.create();
}

From source file:com.arctech.stikyhive.ChattingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    recipientStkid = getIntent().getExtras().getString("recipientStkid");
    chatRecipient = getIntent().getExtras().getString("chatRecipient");
    chatRecipientUrl = getIntent().getExtras().getString("chatRecipientUrl");
    senderToken = getIntent().getExtras().getString("senderToken");
    recipientToken = getIntent().getExtras().getString("recipientToken");
    noti = getIntent().getExtras().getBoolean("noti");
    message = getIntent().getExtras().getString("message");
    rows = getIntent().getExtras().getInt("rows");

    pref = PreferenceManager.getDefaultSharedPreferences(this);
    ws = new JsonWebService();
    dbHelper = new DBHelper(this);
    dialog = new ProgressDialog(this);
    listChatContact = new ArrayList<>();
    listChatContact = dbHelper.getChatContact();
    Log.i(" Chat Contact ", " " + listChatContact.size());
    //to change font
    faceSemi_bold = Typeface.createFromAsset(getAssets(), fontOSSemi_bold);
    Typeface faceLight = Typeface.createFromAsset(getAssets(), fontOSLight);
    faceRegular = Typeface.createFromAsset(getAssets(), fontOSRegular);

    imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited()) {
        imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    }//from w  ww. ja  va 2s .com

    start = new Date();
    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
    timeSend = oFormat.format(start);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat);

    txtUserName = (TextView) findViewById(R.id.txtChatName);
    edTxtMsg = (EditText) findViewById(R.id.edTxtMsg);
    imgViewProfile = (ImageView) findViewById(R.id.imgViewChat);
    imgViewAddCon = (ImageView) findViewById(R.id.imgAddContact);
    lv = (ListView) findViewById(R.id.listView1);
    layoutLabel = (LinearLayout) findViewById(R.id.layoutLabel);
    txtLabel1 = (TextView) findViewById(R.id.txtLabel1);
    txtLabel2 = (TextView) findViewById(R.id.txtLabel2);
    txtLabel3 = (TextView) findViewById(R.id.txtLabel3);
    txtLabel2.setText(" " + chatRecipient + " ");
    txtLabel1.setTypeface(faceLight);
    txtLabel2.setTypeface(faceRegular);
    txtLabel3.setTypeface(faceLight);
    // lv.smoothScrollToPosition(adapter.getCount() - 1);

    for (ChatContact contact : listChatContact) {
        if (contact.getContactId().equals(recipientStkid)) {
            imgViewAddCon.setVisibility(View.INVISIBLE);
            layoutLabel.setVisibility(View.GONE);
            break;
        }
    }
    Log.i(TAG, " come back again");
    adapter = new ChatArrayAdapter(getApplicationContext(), R.layout.messaging_listview, faceSemi_bold,
            faceRegular);
    lv.setAdapter(adapter);
    // adapter.add(new StikyChat(chatRecipientUrl, "Hello", false, "12.10.2015", "12.1.2014"));

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    // BEGIN_INCLUDE (change_colors)
    // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
    swipeRefreshLayout.setColorScheme(R.color.swipe_color_1, R.color.swipe_color_2, R.color.swipe_color_3,
            R.color.swipe_color_4);
    limitMsg = 7;
    // END_INCLUDE (change_colors)
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.i(" Refresh Layout ", "onRefresh called from SwipeRefreshLayout");
            if (limitMsg < rows) {
                Log.i("Limit Message ", " " + limitMsg);
                limitMsg *= 2;
                fetchRecords();
            } else if (limitMsg > rows && (limitMsg - rows < 7)) {
                fetchRecords();
            } else {
                Log.i("No data ", "to refresh");
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(getApplicationContext(), "No data to refresh!", Toast.LENGTH_SHORT).show();
            }

            // initiateRefresh();
        }
    });

    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout headerLayout = (LinearLayout) findViewById(R.id.header);
    View header = inflator.inflate(R.layout.header, null);

    TextView textView = (TextView) header.findViewById(R.id.textView1);
    textView.setText("StikyChat");
    textView.setTypeface(faceSemi_bold);
    textView.setVisibility(View.VISIBLE);
    headerLayout.addView(header);
    LinearLayout layoutRight = (LinearLayout) header.findViewById(R.id.layoutRight);
    layoutRight.setVisibility(View.GONE);

    txtUserName.setText(chatRecipient);
    Log.i(TAG, "Activity Name " + txtUserName.getText().toString());
    txtUserName.setTypeface(faceSemi_bold);

    String url = "";
    if (chatRecipientUrl.contains("http")) {
        url = chatRecipientUrl;
    } else {
        url = this.getResources().getString(R.string.url) + "/" + chatRecipientUrl;
    }
    addAndroidUniversalImageLoader(imgViewProfile, url);
    //        if (noti && (!message.equals(""))) {
    //            adapter.add(new StikyChat(chatRecipientUrl, message, true, timeSend, ""));
    //            lv.smoothScrollToPosition(adapter.getCount() - 1);
    //        }

    //to show history chats between two users(sender & recipient)
    dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat2 = new SimpleDateFormat("dd MMM HH:mm");
    listHistory = dbHelper.getStikyChat();
    if (listHistory.size() > 0) {
        Collections.reverse(listHistory);
        for (StikyChatTb chatTb : listHistory) {
            String getDate = chatTb.getSendDate();
            String fromStikyBee = chatTb.getSender();
            try {
                String createDate = dateFormat2.format(dateFormat.parse(getDate));
                if (fromStikyBee.equals(pref.getString("stkid", ""))) {
                    adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, ""));
                } else {
                    adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, ""));
                }
                lv.smoothScrollToPosition(adapter.getCount() - 1);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            messageGCM = sharedPreferences.getString("message", "");
            recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", "");
            recipientNameGCM = sharedPreferences.getString("chatRecipientName", "");
            recipientStkidGCM = sharedPreferences.getString("recipientStkid", "");
            recipientTokenGCM = sharedPreferences.getString("recipientToken", "");
            senderTokenGCM = sharedPreferences.getString("senderToken", "");

            Log.i(TAG, "..." + recipientStkidGCM.trim() + " STKID " + recipientStkid.trim() + ":");
            if (firstConnect) {
                if (recipientStkidGCM.trim() == recipientStkid.trim()
                        || recipientStkidGCM.equals(recipientStkid)) {
                    MyGcmListenerService.flagSendNoti = false;
                    Log.i(TAG, " " + message);
                    // (1) get today's date
                    start = new Date();
                    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
                    timeSend = oFormat.format(start);

                    Log.i(TAG, "First connect " + firstConnect);
                    StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, "");
                    Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend);
                    Log.i(TAG, "User " + txtUserName.getText().toString());
                    //txtUserName.setText(message);
                    Log.i(TAG, "User 2 " + txtUserName.getText().toString());
                    adapter.add(stikyChat);
                    adapter.notifyDataSetChanged();
                    //new regTask2().execute("Obj ");
                    lv.smoothScrollToPosition(adapter.getCount() - 1);
                } else {
                    Log.i(TAG, "..." + recipientStkidGCM.trim());
                    Log.i(TAG, "&&&" + recipientStkid.trim());
                    Log.i(TAG, "else casee");
                    //notificaton send
                    flagNotifi = true;
                    new regTask2().execute("Notification");
                }
                firstConnect = false;
            }
        }
    };
}

From source file:shetye.prathamesh.notifyme.Utilities.java

public void hideView(final LinearLayout lview) {
    // get the center for the clipping circle
    int cx = (lview.getLeft() + lview.getRight()) / 2;
    int cy = (lview.getTop() + lview.getBottom()) / 2;
    // get the initial radius for the clipping circle
    int initialRadius = lview.getWidth();
    // create the animation (the final radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(lview, cx, cy, initialRadius, 0);
    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {
        @Override//ww  w .j  a  v  a 2s.c om
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            lview.setVisibility(View.INVISIBLE);
        }
    });
    anim.start();
}

From source file:nl.hnogames.domoticz.Welcome.SetupServerSettings.java

private void getLayoutReferences() {
    useSameAddress = (Switch) v.findViewById(R.id.localServer_switch);
    saveButton = (Button) v.findViewById(R.id.save_server);
    server_name_input = (FloatingLabelEditText) v.findViewById(R.id.server_name_input);
    remote_server_input = (FloatingLabelEditText) v.findViewById(R.id.remote_server_input);
    remote_port_input = (FloatingLabelEditText) v.findViewById(R.id.remote_port_input);
    remote_username_input = (FloatingLabelEditText) v.findViewById(R.id.remote_username_input);
    remote_password_input = (FloatingLabelEditText) v.findViewById(R.id.remote_password_input);
    remote_directory_input = (FloatingLabelEditText) v.findViewById(R.id.remote_directory_input);
    remote_protocol_spinner = (Spinner) v.findViewById(R.id.remote_protocol_spinner);
    local_server_input = (FloatingLabelEditText) v.findViewById(R.id.local_server_input);
    local_port_input = (FloatingLabelEditText) v.findViewById(R.id.local_port_input);
    local_username_input = (FloatingLabelEditText) v.findViewById(R.id.local_username_input);
    local_password_input = (FloatingLabelEditText) v.findViewById(R.id.local_password_input);
    local_directory_input = (FloatingLabelEditText) v.findViewById(R.id.local_directory_input);
    local_protocol_spinner = (Spinner) v.findViewById(R.id.local_protocol_spinner);
    local_wifi_spinner = (MultiSelectionSpinner) v.findViewById(R.id.local_wifi);
    cbShowPassword = (CheckBox) v.findViewById(R.id.showpassword);
    cbShowPasswordLocal = (CheckBox) v.findViewById(R.id.showpasswordlocal);

    startScreen_spinner = (Spinner) v.findViewById(R.id.startScreen_spinner);

    btnManualSSID = (Button) v.findViewById(R.id.set_ssid);
    btnManualSSID.setOnClickListener(new View.OnClickListener() {
        @Override/*www. j av a  2 s.  c  o  m*/
        public void onClick(View v) {
            new MaterialDialog.Builder(getContext()).title(R.string.welcome_ssid_button_prompt)
                    .content(R.string.welcome_msg_no_ssid_found)
                    .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .input(null, null, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            Set<String> ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid();
                            final ArrayList<String> ssidListFromPrefs = new ArrayList<>();
                            if (ssidFromPrefs != null) {
                                if (ssidFromPrefs.size() > 0) {
                                    for (String wifi : ssidFromPrefs) {
                                        ssidListFromPrefs.add(wifi);
                                    }
                                }
                            }
                            ssidListFromPrefs.add(String.valueOf(input));
                            mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs);

                            setSsid_spinner();
                        }
                    }).show();
        }
    });

    startScreen_spinner.setVisibility(View.GONE);
    v.findViewById(R.id.startScreen_title).setVisibility(View.GONE);
    v.findViewById(R.id.server_settings_title).setVisibility(View.GONE);

    useSameAddress.setChecked(false);
    final LinearLayout localServerSettingsLayout = (LinearLayout) v.findViewById(R.id.local_server_settings);
    localServer_switch = (Switch) v.findViewById(R.id.localServer_switch);
    localServer_switch.setChecked(false);//default setting
    localServer_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked)
                localServerSettingsLayout.setVisibility(View.VISIBLE);
            else
                localServerSettingsLayout.setVisibility(View.GONE);
        }
    });

    final LinearLayout advancedSettings_layout = (LinearLayout) v.findViewById(R.id.advancedSettings_layout);
    advancedSettings_switch = (Switch) v.findViewById(R.id.advancedSettings_switch);
    advancedSettings_layout.setVisibility(View.INVISIBLE);
    advancedSettings_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSharedPrefs.setAdvancedSettingsEnabled(isChecked);

            if (isChecked)
                advancedSettings_layout.setVisibility(View.VISIBLE);
            else
                advancedSettings_layout.setVisibility(View.GONE);
        }
    });
    advancedSettings_layout.setVisibility(View.GONE);
    advancedSettings_switch.setChecked(false);
    cbShowPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });
    cbShowPasswordLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                local_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                local_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });

    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnectionData();
        }
    });
}

From source file:org.glucosio.android.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GlucosioApplication application = (GlucosioApplication) getApplication();

    initPresenters(application);/* w ww.ja  v a 2  s.  com*/
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
    tabLayout = (TabLayout) findViewById(R.id.activity_main_tab_layout);
    viewPager = (ViewPager) findViewById(R.id.activity_main_pager);

    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setElevation(0);
        getSupportActionBar().setTitle("");
        getSupportActionBar().setLogo(R.drawable.ic_logo);
    }

    homePagerAdapter = new HomePagerAdapter(getSupportFragmentManager(), getApplicationContext());

    viewPager.setAdapter(homePagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            super.onTabSelected(tab);
        }
    });

    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            if (position == 2) {
                hideFabAnimation();
                LinearLayout emptyLayout = (LinearLayout) findViewById(R.id.activity_main_empty_layout);
                ViewPager pager = (ViewPager) findViewById(R.id.activity_main_pager);
                if (pager.getVisibility() == View.GONE) {
                    pager.setVisibility(View.VISIBLE);
                    emptyLayout.setVisibility(View.INVISIBLE);
                }
            } else {
                showFabAnimation();
                checkIfEmptyLayout();
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    FloatingActionButton fabAddReading = (FloatingActionButton) findViewById(
            R.id.activity_main_fab_add_reading);
    fabAddReading.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            bottomSheetAddDialog.show();
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }
    });

    bottomSheetAddDialog = new BottomSheetDialog(this);

    // Add Nav Drawer
    final PrimaryDrawerItem itemSettings = new PrimaryDrawerItem().withName(R.string.action_settings)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_settings_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemExport = new PrimaryDrawerItem().withName(R.string.sidebar_backup_export)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_backup_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemFeedback = new PrimaryDrawerItem().withName(R.string.menu_support)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_announcement_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemAbout = new PrimaryDrawerItem().withName(R.string.preferences_about_glucosio)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_info_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemInvite = new PrimaryDrawerItem().withName(R.string.action_invite)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_face_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemDonate = new PrimaryDrawerItem().withName(R.string.about_donate)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_favorite_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemA1C = new PrimaryDrawerItem().withName(R.string.activity_converter_title)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_calculator_a1c_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
    final PrimaryDrawerItem itemReminders = new PrimaryDrawerItem().withName(R.string.activity_reminders_title)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_alarm_grey_24dp, null))
            .withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);

    DrawerBuilder drawerBuilder = new DrawerBuilder().withActivity(this).withTranslucentStatusBar(false)
            .withToolbar(toolbar).withActionBarDrawerToggle(true)
            .withAccountHeader(new AccountHeaderBuilder().withActivity(this)
                    .withHeaderBackground(R.drawable.drawer_header).build())
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem.equals(itemSettings)) {
                        // Settings
                        openPreferences();
                    } else if (drawerItem.equals(itemAbout)) {
                        // About
                        startAboutActivity();
                    } else if (drawerItem.equals(itemFeedback)) {
                        // Feedback
                        openSupportDialog();
                    } else if (drawerItem.equals(itemInvite)) {
                        // Invite
                        showInviteDialog();
                    } else if (drawerItem.equals(itemExport)) {
                        // Export
                        startExportActivity();
                    } else if (drawerItem.equals(itemDonate)) {
                        // Donate
                        openDonateIntent();
                    } else if (drawerItem.equals(itemA1C)) {
                        openA1CCalculator();
                    } else if (drawerItem.equals(itemReminders)) {
                        openRemindersActivity();
                    }
                    return false;
                }
            });

    if (isPlayServicesAvailable()) {
        drawerBuilder.addDrawerItems(itemA1C, itemReminders, itemExport, itemSettings, itemFeedback, itemAbout,
                itemDonate, itemInvite).withSelectedItem(-1).build();
    } else {
        drawerBuilder.addDrawerItems(itemA1C, itemReminders, itemExport, itemSettings, itemFeedback, itemAbout,
                itemDonate).withSelectedItem(-1).build();
    }

    // Restore pager position
    Bundle b = getIntent().getExtras();
    if (b != null) {
        viewPager.setCurrentItem(b.getInt("pager"));
    }

    checkIfEmptyLayout();
    bottomSheetAddDialog.setContentView(bottomSheetAddDialogView);
    bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetAddDialogView.getParent());
    bottomSheetBehavior.setHideable(false);

    Analytics analytics = application.getAnalytics();
    Log.i("MainActivity", "Setting screen name: " + "main");
    analytics.reportScreen("Main Activity");
}

From source file:com.mobicage.rogerthat.plugins.messaging.widgets.AdvancedOrderWidget.java

@Override
public void initializeWidget() {
    T.UI();//  ww  w  .j  av  a2s.  c om

    if (!isEnabled()) {
        LinearLayout advancedOrderContainer = (LinearLayout) findViewById(R.id.advanced_order_container);
        advancedOrderContainer.setVisibility(View.GONE);
        TextView advancedOrderLocked = (TextView) findViewById(R.id.advanced_order_locked);
        advancedOrderLocked.setVisibility(View.VISIBLE);
        advancedOrderLocked.setText(AdvancedOrderWidget.valueString(mActivity, mWidgetMap));
        return;
    }

    mCachedDownloader = CachedDownloader.getInstance(mActivity.getMainService());
    mLayoutInFlater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mAdvancedOrderDictionary = new HashMap<String, Map<String, AdvancedOrderItem>>();
    try {
        mAdvancedOrder = new AdvancedOrderTO(mWidgetMap);
        for (AdvancedOrderCategory category : mAdvancedOrder.categories) {
            Map<String, AdvancedOrderItem> items = new HashMap<String, AdvancedOrderItem>();
            for (AdvancedOrderItem item : category.items) {
                items.put(item.id, item);
            }
            mAdvancedOrderDictionary.put(category.id, items);
        }
    } catch (IncompleteMessageException e) {
        L.bug(e);
        return;
    }

    mResultDictionary = new HashMap<String, Map<String, AdvancedOrderItem>>();
    @SuppressWarnings("unchecked")
    Map<String, Object> result = (Map<String, Object>) mWidgetMap.get("value");
    if (result != null) {
        try {
            AdvancedOrderWidgetResult r = new AdvancedOrderWidgetResult(result);
            for (AdvancedOrderCategory category : r.categories) {
                Map<String, AdvancedOrderItem> items = new HashMap<String, AdvancedOrderItem>();
                for (AdvancedOrderItem item : category.items) {
                    items.put(item.id, item);
                }
                mResultDictionary.put(category.id, items);
            }
        } catch (IncompleteMessageException e) {
            L.bug(e); // Should never happen
        }
    } else {
        for (AdvancedOrderCategory category : mAdvancedOrder.categories) {
            Map<String, AdvancedOrderItem> items = new HashMap<String, AdvancedOrderItem>();
            for (AdvancedOrderItem item : category.items) {
                if (item.value > 0) {
                    items.put(item.id, item);
                }
                if (items.size() > 0) {
                    mResultDictionary.put(category.id, items);
                }
            }
        }
    }
    renderListData();

    if (mFontAwesomeTypeFace == null) {
        mFontAwesomeTypeFace = new FontAwesome().getTypeface(mActivity);
    }
    mBasketBtn = (TextView) findViewById(R.id.basket);
    mBasketBtn.setText(R.string.fa_shopping_cart);
    mBasketBtn.setTypeface(mFontAwesomeTypeFace);

    if (numberOfItemsInBasket() > 0) {
        mBasketBtn.setEnabled(true);
        mBasketBtn.setTextColor(mTextColor);
    } else {
        mBasketBtn.setEnabled(false);
        mBasketBtn.setTextColor(ContextCompat.getColor(mActivity, R.color.mc_divider_gray));
    }

    mBasketBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            renderBasketListData();
            showAdvancedOrderBasket();
        }
    });

    mListView = (ListView) findViewById(R.id.list_view);
    mListView.setAdapter(mListAdapter);
    mListView.setScrollContainer(false);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mListAdapter.onItemClick(parent, view, position, id);
        }
    });

    mActivity.getMainService().postOnUIHandler(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            UIUtils.setListViewHeightBasedOnItems(mListView);
        }
    });

    mBroadcastReceiver = getBroadcastReceiver();
    final IntentFilter filter = getIntentFilter();
    mActivity.registerReceiver(mBroadcastReceiver, filter);
}

From source file:org.solovyev.android.messenger.BaseListFragment.java

@Nonnull
private View createListView() {
    final Context context = getThemeContext();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout progressContainer = new LinearLayout(context);
    progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    progressContainer.setOrientation(VERTICAL);
    progressContainer.setVisibility(GONE);
    progressContainer.setGravity(CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    progressContainer.addView(progress, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));

    root.addView(progressContainer, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout listViewContainer = new FrameLayout(context);
    listViewContainer.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView emptyListCaption = new TextView(context);
    emptyListCaption.setId(INTERNAL_EMPTY_ID);
    emptyListCaption.setGravity(CENTER);
    listViewContainer.addView(emptyListCaption, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    final ListViewAwareOnRefreshListener topRefreshListener = getTopPullRefreshListener();
    final ListViewAwareOnRefreshListener bottomRefreshListener = getBottomPullRefreshListener();

    final View listView;

    if (topRefreshListener == null && bottomRefreshListener == null) {
        pullToRefreshMode = null;/* w  w  w.  java2s. c  om*/
        listView = createListView(context);
    } else {
        listView = createPullToRefreshListView(context, topRefreshListener, bottomRefreshListener);
    }

    listViewContainer.addView(listView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    root.addView(listViewContainer, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    return root;
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

protected void initBlankTable(int pageNum, int length, boolean nameOrCodeFlag) throws JSONException {
    LinearLayout localLinearLayout1 = (LinearLayout) this.findViewById(R.id.zr_htable_lock1);
    LinearLayout localLinearLayout2 = (LinearLayout) this.findViewById(R.id.zr_htable_lock2);
    LinearLayout localLinearLayout = (LinearLayout) this.findViewById(R.id.zr_htable_linearlayout);

    this.mLinerLock = localLinearLayout1;
    this.mLinerLock2 = localLinearLayout2;
    this.mLinerHScroll = localLinearLayout;
    this.mLinerLock.removeAllViews();
    this.mLinerLock2.removeAllViews();
    this.mLinerHScroll.removeAllViews();

    this.nameOrCodeFlag = nameOrCodeFlag;

    if (nameOrCodeFlag) {// ?(????)
        localLinearLayout2.setVisibility(View.GONE);
        if (nameOrcode)
            AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock, -100, 0, 0, true);
        else/*w  ww. jav a 2 s  .  c  o  m*/
            AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock, -100, 0, 0, true);
    } else {
        AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock, 0, 0, 0, true);
        AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock2, -1, 0, 0, true);
    }

    LinearLayout l1 = new LinearLayout(this);
    for (int i = 2; i < length; i++) {
        if (i == length - 1)
            AddViewItem(Utils.getTextColor(mContext, 0), l1, -i, 100, 0, true);
        else
            AddViewItem(Utils.getTextColor(mContext, 0), l1, -i, i - 1, 0, true);
    }
    l1.setTag(0);
    mLinerHScroll.addView(l1);
    for (int i = 1; i <= pageNum; i++) {
        if (nameOrCodeFlag) {
            localLinearLayout2.setVisibility(View.GONE);
            if (nameOrcode)
                AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
            else
                AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
        } else {
            AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
            AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock2, i, 0, i, true);
        }

        l1 = new LinearLayout(this);
        l1.setTag(i);
        for (int j = 1; j <= length - 2; j++) {
            if (j == length - 2)
                AddViewItem(Utils.getTextColor(mContext, 0), l1, i, 100, i, true);
            else
                AddViewItem(Utils.getTextColor(mContext, 0), l1, i, j, i, true);
        }
        mLinerHScroll.addView(l1);
    }
}

From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java

/** Presents additional information about a specific assistant.
 * @return a dynamically generated linear layout
 */// w  w w  . j  av a2s .c  om
private LinearLayout getServiceDescLayout() {
    final LinearLayout output = new LinearLayout(this);
    final RelativeLayout topButtonsLayout = new RelativeLayout(this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    final Button btnBack = new Button(this);
    btnBack.setText(R.string.btnAllServices);
    btnBack.setId(5);
    btnBack.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            output.setVisibility(View.GONE);
            getListView().setVisibility(View.VISIBLE);
            lblAvAssist.setVisibility(View.VISIBLE);
        }
    });

    topButtonsLayout.addView(btnBack);

    final Button btnInvoke = new Button(this);
    btnInvoke.setText(R.string.btnInvokeLabel);
    btnInvoke.setId(6);

    btnInvoke.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            new InvocationTask().execute();
        }
    });

    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId());
    btnInvoke.setLayoutParams(layoutParams);
    topButtonsLayout.addView(btnInvoke);

    output.addView(topButtonsLayout);

    TableLayout serviceInfoTbl = new TableLayout(this);
    output.addView(serviceInfoTbl);

    serviceInfoTbl.setColumnShrinkable(1, true);

    /* FIRST ROW */
    TableRow rowServiceName = new TableRow(this);

    TextView lblServiceName = new TextView(this);
    lblServiceName.setText(R.string.lblServiceName);
    lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText);

    TextView txtServiceName = new TextView(this);
    txtServiceName.setText(selectedService);
    txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText);
    txtServiceName.setPadding(10, 0, 0, 0);

    rowServiceName.addView(lblServiceName);
    rowServiceName.addView(txtServiceName);

    /* SECOND ROW */
    TableRow rowServiceDesc = new TableRow(this);

    TextView lblServiceDesc = new TextView(this);
    lblServiceDesc.setText(R.string.lblServiceDesc);
    lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText);

    TextView txtServiceDesc = new TextView(this);
    txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText);
    txtServiceDesc.setPadding(10, 0, 0, 0);
    List<GateRuntimeParameter> params = null;
    ServiceInfoForClientArray list = getServices();
    for (int i = 0; i < list.getItem().size(); i++) {
        if (list.getItem().get(i).getServiceName().equals(selectedService)) {
            txtServiceDesc.setText(list.getItem().get(i).getServiceDescription());
            params = list.getItem().get(i).getParams();
            break;
        }
    }

    TextView lblParams = new TextView(this);
    lblParams.setText(R.string.lblServiceParams);
    lblParams.setTextAppearance(getApplicationContext(), R.style.titleText);
    output.addView(lblParams);

    LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    LinearLayout paramsLayout = new LinearLayout(this);
    paramsLayout.setId(0);

    if (params.size() > 0) {
        ScrollView scroll = new ScrollView(this);
        scroll.setLayoutParams(txtParamsAttrbs);
        paramsLayout.setOrientation(LinearLayout.VERTICAL);
        scroll.addView(paramsLayout);
        for (int j = 0; j < params.size(); j++) {
            TextView lblParamName = new TextView(this);
            lblParamName.setText(params.get(j).getParamName());
            EditText tview = new EditText(this);
            tview.setId(1);
            tview.setText(params.get(j).getDefaultValueString());
            LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT);
            tview.setLayoutParams(txtViewLayoutParams);
            paramsLayout.addView(lblParamName);
            paramsLayout.addView(tview);
        }
        output.addView(scroll);
    } else {
        TextView lblParamName = new TextView(this);
        lblParamName.setText(R.string.lblRTParams);
        output.addView(lblParamName);
    }

    rowServiceDesc.addView(lblServiceDesc);
    rowServiceDesc.addView(txtServiceDesc);

    serviceInfoTbl.addView(rowServiceName);
    serviceInfoTbl.addView(rowServiceDesc);

    output.setOrientation(LinearLayout.VERTICAL);
    output.setGravity(Gravity.TOP);

    return output;
}

From source file:com.master.metehan.filtereagle.ActivityMain.java

@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
    Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name));
    if ("enabled".equals(name)) {
        // Get enabled
        boolean enabled = prefs.getBoolean(name, false);

        // Display disabled warning
        TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
        tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE);

        // Check switch state
        SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView()
                .findViewById(R.id.swEnabled);
        if (swEnabled.isChecked() != enabled)
            swEnabled.setChecked(enabled);

    } else if ("whitelist_wifi".equals(name) || "screen_wifi".equals(name) || "whitelist_other".equals(name)
            || "screen_other".equals(name) || "whitelist_roaming".equals(name) || "show_user".equals(name)
            || "show_system".equals(name) || "show_nointernet".equals(name) || "show_disabled".equals(name)
            || "sort".equals(name) || "imported".equals(name))
        updateApplicationList(null);// ww  w. j a v a 2 s . c o m

    else if ("manage_system".equals(name)) {
        invalidateOptionsMenu();
        updateApplicationList(null);
        LinearLayout llSystem = (LinearLayout) findViewById(R.id.llSystem);
        boolean system = prefs.getBoolean("manage_system", false);
        boolean hint = prefs.getBoolean("hint_system", true);
        llSystem.setVisibility(!system && hint ? View.VISIBLE : View.GONE);

    } else if ("theme".equals(name) || "dark_theme".equals(name))
        recreate();
}