Example usage for android.widget LinearLayout setOnClickListener

List of usage examples for android.widget LinearLayout setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:org.tomahawk.tomahawk_android.dialogs.RedirectConfigDialog.java

/**
 * Called when this {@link android.support.v4.app.DialogFragment} is being created
 *//*  ww w. j  a  va2s.  co  m*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() != null && getArguments().containsKey(TomahawkFragment.PREFERENCEID)) {
        String id = getArguments().getString(TomahawkFragment.PREFERENCEID);
        mScriptResolver = (ScriptResolver) PipeLine.get().getResolver(id);
        mAuthenticatorUtils = AuthenticatorManager.get().getAuthenticatorUtils(id);
    }

    TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
    headerTextView.setText(mScriptResolver.getDescription());

    int buttonBackgroundResId;
    int buttonTextColor;
    View.OnClickListener onClickListener;
    switch (mScriptResolver.getId()) {
    case TomahawkApp.PLUGINNAME_RDIO:
        buttonBackgroundResId = R.drawable.selectable_background_tomahawk_rectangle_gray;
        buttonTextColor = getResources().getColor(R.color.primary_textcolor);
        onClickListener = new RedirectButtonListener(TomahawkApp.PLUGINNAME_RDIO);
        break;
    case TomahawkApp.PLUGINNAME_SPOTIFY:
        buttonBackgroundResId = R.drawable.selectable_background_tomahawk_rectangle_gray;
        buttonTextColor = getResources().getColor(R.color.primary_textcolor);
        onClickListener = new RedirectButtonListener(TomahawkApp.PLUGINNAME_SPOTIFY);
        break;
    default:
        buttonBackgroundResId = R.drawable.selectable_background_deezer_button;
        buttonTextColor = getResources().getColor(R.color.primary_textcolor_inverted);
        onClickListener = new RedirectButtonListener(TomahawkApp.PLUGINNAME_DEEZER);
        break;
    }

    View buttonLayout = addScrollingViewToFrame(R.layout.config_redirect_button);
    LinearLayout button = ((LinearLayout) buttonLayout.findViewById(R.id.config_redirect_button));
    button.setBackgroundResource(buttonBackgroundResId);
    ImageView buttonImage = (ImageView) buttonLayout.findViewById(R.id.config_redirect_button_image);
    mScriptResolver.loadIcon(buttonImage, false);
    mRedirectButtonTextView = (TextView) button.findViewById(R.id.config_redirect_button_text);
    mRedirectButtonTextView.setTextColor(buttonTextColor);
    mRedirectButtonTextView.setText(mAuthenticatorUtils.isLoggedIn()
            ? getString(R.string.resolver_config_redirect_button_text_log_out_of)
            : getString(R.string.resolver_config_redirect_button_text_log_into));
    button.setOnClickListener(onClickListener);
    setDialogTitle(mScriptResolver.getName());
    hideNegativeButton();
    setStatus(mScriptResolver);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(getDialogView());
    return builder.create();
}

From source file:org.anhonesteffort.flock.SelectServiceProviderFragment.java

private void initRadioButtons(View fragmentView) {
    final LinearLayout rowSelectOws = (LinearLayout) fragmentView.findViewById(R.id.row_service_ows);
    final LinearLayout rowSelectOther = (LinearLayout) fragmentView.findViewById(R.id.row_service_other);
    final RadioButton radioButtonOws = (RadioButton) fragmentView.findViewById(R.id.radio_button_service_ows);
    final RadioButton radioButtonOther = (RadioButton) fragmentView
            .findViewById(R.id.radio_button_service_other);
    final TextView serviceDescription = (TextView) fragmentView.findViewById(R.id.sync_service_description);
    final Double costPerYearUsd = (double) getResources().getInteger(R.integer.cost_per_year_usd);

    rowSelectOws.setOnClickListener(new View.OnClickListener() {

        @Override/*from  w  ww.j a v  a  2  s .  c  o  m*/
        public void onClick(View view) {
            if (!radioButtonOws.isChecked()) {
                radioButtonOws.setChecked(true);
                radioButtonOther.setChecked(false);
                serviceDescription.setText(Html.fromHtml(
                        getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available,
                                costPerYearUsd)));
                serviceDescription.setMovementMethod(LinkMovementMethod.getInstance());
            }
        }

    });

    rowSelectOther.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (!radioButtonOther.isChecked()) {
                radioButtonOther.setChecked(true);
                radioButtonOws.setChecked(false);
                serviceDescription
                        .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server);
            }
        }

    });

    radioButtonOws.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                radioButtonOws.setChecked(true);
                radioButtonOther.setChecked(false);
                serviceDescription.setText(Html.fromHtml(
                        getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available,
                                costPerYearUsd)));
                serviceDescription.setMovementMethod(LinkMovementMethod.getInstance());
            }
        }

    });

    radioButtonOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                radioButtonOther.setChecked(true);
                radioButtonOws.setChecked(false);
                serviceDescription
                        .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server);
            }
        }

    });
}

From source file:com.astuetz.PagerSlidingTabStripPlus.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//  ww w  .j  a v  a 2s  . co  m
    tab.setPadding(tabPaddingLeft, tabPaddingTop, tabPaddingRight, tabPaddingBottom);
    LinearLayout tabLayout = new LinearLayout(getContext());
    tabLayout.setOrientation(LinearLayout.VERTICAL);
    tabLayout.setGravity(Gravity.CENTER);
    tabLayout.addView(tab, 0, defaultTabLayoutParams);
    tabLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tabLayout, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:provision.app.store.AppStore.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.appstore, null);

    /** Button **/

    LinearLayout a = (LinearLayout) root.findViewById(R.id.button1);
    LinearLayout b = (LinearLayout) root.findViewById(R.id.button2);
    LinearLayout c = (LinearLayout) root.findViewById(R.id.button3);
    LinearLayout d = (LinearLayout) root.findViewById(R.id.button4);
    LinearLayout e = (LinearLayout) root.findViewById(R.id.button5);
    ImageButton la = (ImageButton) root.findViewById(R.id.icon1);
    ImageButton lb = (ImageButton) root.findViewById(R.id.icon2);
    ImageButton lc = (ImageButton) root.findViewById(R.id.icon3);
    ImageButton ld = (ImageButton) root.findViewById(R.id.icon4);
    ImageButton le = (ImageButton) root.findViewById(R.id.icon5);

    a.setOnClickListener(new View.OnClickListener() {

        @Override//from  w w w .ja  va 2  s . c  o m
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setClass(getActivity(), AppInfo.class);
            intent.putExtra("app", "netfree");
            startActivity(intent);
        }
    });

    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setClass(getActivity(), AppInfo.class);
            intent.putExtra("app", "netpro");
            startActivity(intent);
        }
    });

    c.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setClass(getActivity(), AppInfo.class);
            intent.putExtra("app", "opfree");
            startActivity(intent);
        }
    });

    d.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setClass(getActivity(), AppInfo.class);
            intent.putExtra("app", "oppro");
            startActivity(intent);
        }
    });

    e.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setClass(getActivity(), AppInfo.class);
            intent.putExtra("app", "studio");
            startActivity(intent);
        }
    });

    la.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=provision.netspeed.optimizer"));//Provision 3g/4g netspeed optimizer free
            startActivity(intent);
        }
    });
    lb.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=provision.netspeed.optimizer.pro"));//Provision 3g/4g netspeed optimizer pro
            startActivity(intent);
        }
    });
    lc.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=provision.optimizer.patch.free"));//Provision optimizer free
            startActivity(intent);
        }
    });
    ld.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=provision.optimizer.patch"));//Provision optimizer pro
            startActivity(intent);
        }
    });
    le.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=provision.root.studio"));//Provision Root Studio
            startActivity(intent);
        }
    });

    return root;
}

From source file:com.example.cuisoap.agrimac.homePage.homeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_home, container, false);
    LinearLayout machine_new = (LinearLayout) view.findViewById(R.id.machine_new_layout);
    list = (ListView) view.findViewById(R.id.machine_listview);
    data = new ArrayList<>();
    adapter = new machineAdapter(mContext);
    list.setAdapter(adapter);/*from www .  j  a  va2 s  .com*/
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(mContext, machineDetailActivity.class);
            i.putExtra("data", (HashMap<String, String>) adapter.getItem(position));
            startActivityForResult(i, 1);
        }
    });
    machine_new.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivityForResult(new Intent(mContext, containerActivity.class), 0);
        }
    });
    //  test();
    new Thread(send).start();
    return view;
}

From source file:com.farmerbb.taskbar.service.StartMenuService.java

@SuppressLint("RtlHardcoded")
private void drawStartMenu() {
    IconCache.getInstance(this).clearCache();

    final SharedPreferences pref = U.getSharedPreferences(this);
    final boolean hasHardwareKeyboard = getResources()
            .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;

    switch (pref.getString("show_search_bar", "keyboard")) {
    case "always":
        shouldShowSearchBox = true;//from   w  w w  . j  av  a  2  s .c o m
        break;
    case "keyboard":
        shouldShowSearchBox = hasHardwareKeyboard;
        break;
    case "never":
        shouldShowSearchBox = false;
        break;
    }

    // Initialize layout params
    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    U.setCachedRotation(windowManager.getDefaultDisplay().getRotation());

    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            shouldShowSearchBox ? 0
                    : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            PixelFormat.TRANSLUCENT);

    // Determine where to show the start menu on screen
    switch (U.getTaskbarPosition(this)) {
    case "bottom_left":
        layoutId = R.layout.start_menu_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case "bottom_vertical_left":
        layoutId = R.layout.start_menu_vertical_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case "bottom_right":
        layoutId = R.layout.start_menu_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;
    case "bottom_vertical_right":
        layoutId = R.layout.start_menu_vertical_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;
    case "top_left":
        layoutId = R.layout.start_menu_top_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        break;
    case "top_vertical_left":
        layoutId = R.layout.start_menu_vertical_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        break;
    case "top_right":
        layoutId = R.layout.start_menu_top_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        break;
    case "top_vertical_right":
        layoutId = R.layout.start_menu_vertical_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        break;
    }

    // Initialize views
    int theme = 0;

    switch (pref.getString("theme", "light")) {
    case "light":
        theme = R.style.AppTheme;
        break;
    case "dark":
        theme = R.style.AppTheme_Dark;
        break;
    }

    ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme);
    layout = (StartMenuLayout) LayoutInflater.from(wrapper).inflate(layoutId, null);
    startMenu = (GridView) layout.findViewById(R.id.start_menu);

    if ((shouldShowSearchBox && !hasHardwareKeyboard)
            || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
        layout.viewHandlesBackButton();

    boolean scrollbar = pref.getBoolean("scrollbar", false);
    startMenu.setFastScrollEnabled(scrollbar);
    startMenu.setFastScrollAlwaysVisible(scrollbar);
    startMenu.setScrollBarStyle(scrollbar ? View.SCROLLBARS_OUTSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY);

    if (pref.getBoolean("transparent_start_menu", false))
        startMenu.setBackgroundColor(0);

    searchView = (SearchView) layout.findViewById(R.id.search);

    int backgroundTint = U.getBackgroundTint(this);

    FrameLayout startMenuFrame = (FrameLayout) layout.findViewById(R.id.start_menu_frame);
    FrameLayout searchViewLayout = (FrameLayout) layout.findViewById(R.id.search_view_layout);
    startMenuFrame.setBackgroundColor(backgroundTint);
    searchViewLayout.setBackgroundColor(backgroundTint);

    if (shouldShowSearchBox) {
        if (!hasHardwareKeyboard)
            searchView.setIconifiedByDefault(true);

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                if (!hasSubmittedQuery) {
                    ListAdapter adapter = startMenu.getAdapter();
                    if (adapter != null) {
                        hasSubmittedQuery = true;

                        if (adapter.getCount() > 0) {
                            View view = adapter.getView(0, null, startMenu);
                            LinearLayout layout = (LinearLayout) view.findViewById(R.id.entry);
                            layout.performClick();
                        } else {
                            if (pref.getBoolean("hide_taskbar", true)
                                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                                LocalBroadcastManager.getInstance(StartMenuService.this)
                                        .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_TASKBAR"));
                            else
                                LocalBroadcastManager.getInstance(StartMenuService.this)
                                        .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));

                            Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
                            intent.putExtra(SearchManager.QUERY, query);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            if (intent.resolveActivity(getPackageManager()) != null)
                                startActivity(intent);
                            else {
                                Uri uri = new Uri.Builder().scheme("https").authority("www.google.com")
                                        .path("search").appendQueryParameter("q", query).build();

                                intent = new Intent(Intent.ACTION_VIEW);
                                intent.setData(uri);
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                                try {
                                    startActivity(intent);
                                } catch (ActivityNotFoundException e) {
                                    /* Gracefully fail */ }
                            }
                        }
                    }
                }
                return true;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                searchView.setIconified(false);

                View closeButton = searchView.findViewById(R.id.search_close_btn);
                if (closeButton != null)
                    closeButton.setVisibility(View.GONE);

                refreshApps(newText, false);

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
                    new Handler().postDelayed(() -> {
                        EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
                        if (editText != null) {
                            editText.requestFocus();
                            editText.setSelection(editText.getText().length());
                        }
                    }, 50);
                }

                return true;
            }
        });

        searchView.setOnQueryTextFocusChangeListener((view, b) -> {
            if (!hasHardwareKeyboard) {
                ViewGroup.LayoutParams params1 = startMenu.getLayoutParams();
                params1.height = getResources().getDimensionPixelSize(b
                        && !U.isServiceRunning(this, "com.farmerbb.secondscreen.service.DisableKeyboardService")
                                ? R.dimen.start_menu_height_half
                                : R.dimen.start_menu_height);
                startMenu.setLayoutParams(params1);
            }

            if (!b) {
                if (hasHardwareKeyboard && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1)
                    LocalBroadcastManager.getInstance(StartMenuService.this)
                            .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));
                else {
                    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
                }
            }
        });

        searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);

        LinearLayout powerButton = (LinearLayout) layout.findViewById(R.id.power_button);
        powerButton.setOnClickListener(view -> {
            int[] location = new int[2];
            view.getLocationOnScreen(location);
            openContextMenu(location);
        });

        powerButton.setOnGenericMotionListener((view, motionEvent) -> {
            if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
                    && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
                int[] location = new int[2];
                view.getLocationOnScreen(location);
                openContextMenu(location);
            }
            return false;
        });

        searchViewLayout.setOnClickListener(view -> searchView.setIconified(false));

        startMenu.setOnItemClickListener((parent, view, position, id) -> {
            hideStartMenu();

            AppEntry entry = (AppEntry) parent.getAdapter().getItem(position);
            U.launchApp(StartMenuService.this, entry.getPackageName(), entry.getComponentName(),
                    entry.getUserId(StartMenuService.this), null, false, false);
        });

        if (pref.getBoolean("transparent_start_menu", false))
            layout.findViewById(R.id.search_view_child_layout).setBackgroundColor(0);
    } else
        searchViewLayout.setVisibility(View.GONE);

    textView = (TextView) layout.findViewById(R.id.no_apps_found);

    LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiverAlt);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver);

    LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver,
            new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU"));
    LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiverAlt,
            new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU_ALT"));
    LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver,
            new IntentFilter("com.farmerbb.taskbar.HIDE_START_MENU"));

    handler = new Handler();
    refreshApps(true);

    windowManager.addView(layout, params);
}

From source file:com.mobicage.rogerthat.plugins.friends.ServiceSearchActivity.java

private BroadcastReceiver getBroadCastReceiver() {
    return new SafeBroadcastReceiver() {

        @Override/*from www.j ava2 s  .  c  om*/
        public String[] onSafeReceive(Context context, Intent intent) {
            String action = intent.getAction();

            if (mSearchString != null && FriendsPlugin.SERVICE_SEARCH_RESULT_INTENT.equals(action)) {
                if (mSearchString.equals(intent.getStringExtra(SEARCH_STRING))) {
                    mProgressDialog.dismiss();
                    String jsonResult = intent.getStringExtra(SEARCH_RESULT);
                    @SuppressWarnings("unchecked")
                    Map<String, Object> jsonMap = (Map<String, Object>) JSONValue.parse(jsonResult);
                    try {
                        mResponseTO = new FindServiceResponseTO(jsonMap);
                    } catch (IncompleteMessageException e) {
                        L.bug(e);
                        showSearchFailedDialog();
                        return new String[] { action };
                    }

                    if (!TextUtils.isEmptyOrWhitespace(mResponseTO.error_string)) {
                        UIUtils.showAlertDialog(ServiceSearchActivity.this, null, mResponseTO.error_string);
                        return new String[] { action };
                    }

                    for (FindServiceCategoryTO category : mResponseTO.matches) {
                        if (mSearchInfoByCategory.containsKey(category.category)) {
                            SearchInfo si = mSearchInfoByCategory.get(category.category);
                            si.cursor = category.cursor;
                            si.loading = false;
                            si.adapter.addAll(category.items);
                        } else {
                            // Add Label
                            LinearLayout label = (LinearLayout) getLayoutInflater()
                                    .inflate(R.layout.search_category, null);
                            final boolean selected = mSearchCategoryLabels.getChildCount() == 0;
                            final TextView labelTextView = setCatorySelected(label, selected);
                            labelTextView.setText(category.category);
                            label.setOnClickListener(new OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    displayTab(mSearchCategoryLabels.indexOfChild(v));
                                }
                            });
                            mSearchCategoryLabels.addView(label);

                            // Add ListView
                            ListView results = (ListView) getLayoutInflater()
                                    .inflate(R.layout.search_category_results, null);
                            mSearchCategoryViewFlipper.addView(results);
                            SearchInfo si = new SearchInfo();
                            ServiceSearchAdapter adapter = new ServiceSearchAdapter(category.items, si);
                            si.cursor = category.cursor;
                            si.adapter = adapter;
                            si.label = label;
                            si.results = results;
                            mSearchInfoByCategory.put(category.category, si);
                            mSearchInfoByListView.put(results, si);

                            results.setAdapter(adapter);
                            results.setOnItemClickListener(mListItemClickListener);
                            results.setOnScrollListener(mListViewScrollListener);
                        }
                    }

                    return new String[] { action };
                }
            } else if (FriendsPlugin.SERVICE_SEARCH_FAILED_INTENT.equals(action)) {
                if (mSearchString.equals(intent.getStringExtra(SEARCH_STRING))) {
                    mProgressDialog.dismiss();
                    showSearchFailedDialog();
                    return new String[] { action };
                }
            } else {
                L.d(ServiceSearchActivity.class.getName() + " received " + action + " intent");
                for (SearchInfo si : mSearchInfoByCategory.values()) {
                    si.adapter.notifyDataSetChanged();
                }

                // not interested in older intents which also result in reloading the list
                return UPDATE_VIEW_INTENTS;
            }
            return null;
        }

    };
}

From source file:com.tpb.projects.repo.fragments.RepoInfoFragment.java

private View getUserView(User u) {
    final LinearLayout layout = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.shard_user,
            mCollaborators, false);//from w  w  w .  ja v  a 2  s  .c o  m
    layout.setId(View.generateViewId());
    final NetworkImageView avatar = ButterKnife.findById(layout, R.id.user_avatar);
    avatar.setId(View.generateViewId());
    avatar.setImageUrl(u.getAvatarUrl());
    avatar.setScaleType(ImageView.ScaleType.FIT_XY);
    final TextView login = ButterKnife.findById(layout, R.id.user_login);
    login.setId(View.generateViewId());
    if (u.getContributions() > 0) {
        login.setText(String.format(Locale.getDefault(), "%1$s\n%2$d", u.getLogin(), u.getContributions()));
    } else {
        login.setText(u.getLogin());
    }
    layout.setOnClickListener((v) -> {
        final Intent us = new Intent(getActivity(), UserActivity.class);
        us.putExtra(getString(R.string.intent_username), u.getLogin());
        UI.setDrawableForIntent(avatar, us);
        getActivity().startActivity(us,
                ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                        Pair.create(login, getString(R.string.transition_username)),
                        Pair.create(avatar, getString(R.string.transition_user_image))).toBundle());
    });
    return layout;
}

From source file:org.anurag.fragments.FileGallery.java

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(v, savedInstanceState);
    empty = (LinearLayout) v.findViewById(R.id.empty);
    ls = (ListView) v.findViewById(R.id.customListView);
    ls.setSelector(R.drawable.list_selector_hd);
    file_gallery = (LinearLayout) v.findViewById(R.id.file_gallery_layout);
    Utils.setContext(null, getActivity());

    //loading file list at last....
    //this allows other threads of other panel to load first as 
    //they need little time and this thread can take long time and blocking
    //other threads....

    //Utils.load();

    Utils.setView(v);// w  ww .  j a v a 2s . com
    is_gallery_opened = false;

    LinearLayout fav = (LinearLayout) v.findViewById(R.id.fav);
    LinearLayout music = (LinearLayout) v.findViewById(R.id.music);
    LinearLayout app = (LinearLayout) v.findViewById(R.id.apps);
    LinearLayout docs = (LinearLayout) v.findViewById(R.id.docs);
    LinearLayout photo = (LinearLayout) v.findViewById(R.id.photos);
    LinearLayout vids = (LinearLayout) v.findViewById(R.id.videos);
    LinearLayout zips = (LinearLayout) v.findViewById(R.id.zips);
    LinearLayout misc = (LinearLayout) v.findViewById(R.id.misc);

    music.setOnClickListener(this);
    fav.setOnClickListener(this);
    app.setOnClickListener(this);
    docs.setOnClickListener(this);
    photo.setOnClickListener(this);
    vids.setOnClickListener(this);
    zips.setOnClickListener(this);
    misc.setOnClickListener(this);

    ls.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            // TODO Auto-generated method stub
            item = (Item) ls.getAdapter().getItem(position);

            if (Constants.LONG_CLICK[0]) {

                if (ITEMS[position] != 1) {
                    ITEMS[position] = 1;
                    arg1.setBackgroundColor(getResources().getColor(R.color.white_grey));
                    ++counter;

                    //updating folder and file count while long press is active....
                    if (item.isDirectory())
                        folder_count++;
                    else
                        file_count++;

                    getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
                } else if (ITEMS[position] == 1) {
                    ITEMS[position] = 0;
                    arg1.setBackgroundColor(Color.WHITE);

                    //updating folder and file count while long press is active....
                    if (item.isDirectory())
                        folder_count--;
                    else
                        file_count--;

                    if (--counter == 0)
                        getActivity().sendBroadcast(new Intent("inflate_normal_menu"));
                    else
                        getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
                }

                return;
            }
            open_locked_item();
        }
    });

    ls.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            boolean sendBroadcast = false;
            item = (Item) ls.getAdapter().getItem(arg2);

            if (ITEMS == null) {
                ITEMS = new int[ls.getAdapter().getCount()];
                sendBroadcast = true;
            }

            if (ITEMS[arg2] != 1) {
                arg1.setBackgroundColor(getResources().getColor(R.color.white_grey));
                ITEMS[arg2] = 1;
                ++counter;

                //updating folder and file count while long press is active....
                if (item.isDirectory())
                    folder_count++;
                else
                    file_count++;

                getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
            } else if (ITEMS[arg2] == 1) {
                ITEMS[arg2] = 0;
                arg1.setBackgroundColor(Color.WHITE);

                //updating folder and file count while long press is active....
                if (item.isDirectory())
                    folder_count--;
                else
                    file_count--;

                if (--counter == 0)
                    getActivity().sendBroadcast(new Intent("inflate_normal_menu"));
                else
                    getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
            }

            if (sendBroadcast)
                getActivity().sendBroadcast(new Intent("inflate_long_click_menu"));

            return true;
        }
    });

    list_anim_helper = new JazzyHelper(getActivity(), null);
    setAnim(ls);
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

public void onEventMainThread(Events.ApplyDetailCompleteEvent event) {

    if (!event.success()) {
        CommonUtil.toastShort(ApplyDetailActivity.this, event.getMessage());
        return;//from  ww w.  j  a va  2  s  .  c  o m
    }

    ApplyDetail data = event.getEntity();
    ApplyTerminalDetail terminalDetail = data.getTerminalDetail();
    TerminalOpenInfo openInfo = data.getOpeningInfos();
    final List<ApplyChooseItem> merchants = data.getMerchants();
    List<ApplyMaterial> materials = data.getMaterials();
    List<ApplyCustomerDetail> customerDetails = data.getCustomerDetails();

    if (null != terminalDetail) {
        mPosBrand.setText(terminalDetail.getBrandName());
        mPosModel.setText(terminalDetail.getModelNumber());
        mSerialNum.setText(terminalDetail.getSerialNumber());
        mPayChannel.setText(terminalDetail.getChannelName());

        initTab(terminalDetail);
    }

    // set the choosing merchant listener
    View merchantChoose = mMerchantContainer.findViewWithTag(mMerchantKeys[0]);
    merchantChoose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ApplyDetailActivity.this,
                    com.posagent.activities.terminal.MerchantList.class);
            intent.putExtra(AGENT_NAME, mAgentName);
            intent.putExtra("terminalId", mTerminalId);

            startActivityForResult(intent, REQUEST_CHOOSE_MERCHANT);
        }
    });

    // prepare custom details
    mapMaterials.clear();
    if (null != materials) {
        //update map
        for (ApplyMaterial item : materials) {
            mapMaterials.put(item.getId(), item);
        }

        prepareMaterials(materials);
    }

    // set the customer details
    mapCustomerDetails.clear();
    if (null != customerDetails) {
        //update map
        for (ApplyCustomerDetail item : customerDetails) {
            mapCustomerDetails.put(item.getTarget_id(), item);
        }
        setCustomerDetail(customerDetails);
    }

    if (null != openInfo) {
        updateOpenInfo(openInfo);
    }

    // setup material choose item
    for (final ApplyMaterial item : materials) {
        if (TYPE_BANK == item.getInfo_type()) {
            LinearLayout ll = (LinearLayout) mContainer.findViewWithTag(item.getId());
            ll.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    customTag = item.getId();
                    Intent intent = new Intent(ApplyDetailActivity.this, BankList.class);
                    intent.putExtra(AGENT_NAME, mBankName);
                    intent.putExtra("terminalId", mTerminalId);
                    startActivityForResult(intent, REQUEST_CHOOSE_BANK);
                }
            });
        }
    }

    showHideSomeFields();

}