Search in sources :

Example 66 with OnClickListener

use of android.view.View.OnClickListener in project robolectric by robolectric.

the class ShadowViewTest method shouldClickAndNotClick.

public void shouldClickAndNotClick() throws Exception {
    assertThat(view.isClickable()).isFalse();
    view.setClickable(true);
    assertThat(view.isClickable()).isTrue();
    view.setClickable(false);
    assertThat(view.isClickable()).isFalse();
    view.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ;
        }
    });
    assertThat(view.isClickable()).isTrue();
}
Also used : TestOnClickListener(org.robolectric.android.TestOnClickListener) OnClickListener(android.view.View.OnClickListener)

Example 67 with OnClickListener

use of android.view.View.OnClickListener in project howabout-android by recomio.

the class MusicPlaylistActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    imageLoader = ImageLoader.getInstance();
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    setAdsContainer(R.id.adView);
    HowaboutApplication application = (HowaboutApplication) getApplication();
    playlistAdapter = application.getPlaylistAdapter();
    if (MusicPlayerService.isLoading()) {
        loadingProgressBar.setVisibility(View.VISIBLE);
        playPauseToggleButton.setVisibility(View.GONE);
    } else {
        if (MusicPlayerService.isPlaying()) {
            playPauseToggleButton.setImageDrawable(pauseIcon);
        } else {
            playPauseToggleButton.setImageDrawable(playIcon);
        }
        loadingProgressBar.setVisibility(View.GONE);
        playPauseToggleButton.setVisibility(View.VISIBLE);
    }
    listView.setAdapter(playlistAdapter);
    playlistAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            try {
                Track track = playlistAdapter.getCurrentItem();
                actionBar.setTitle(track.getTrackTitle());
                actionBar.setSubtitle(track.getArtistName());
                if (MusicPlayerService.isLoading()) {
                    loadingProgressBar.setVisibility(View.VISIBLE);
                    playPauseToggleButton.setVisibility(View.GONE);
                } else {
                    if (MusicPlayerService.isPlaying()) {
                        playPauseToggleButton.setImageDrawable(pauseIcon);
                    } else {
                        playPauseToggleButton.setImageDrawable(playIcon);
                    }
                    loadingProgressBar.setVisibility(View.GONE);
                    playPauseToggleButton.setVisibility(View.VISIBLE);
                }
                imageLoader.displayImage(track.getThumbnailUrl(), songImageView, new ImageLoadingListener() {

                    @Override
                    public void onLoadingStarted(String imageUri, View view) {
                    }

                    @Override
                    public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                    }

                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    }

                    @Override
                    public void onLoadingCancelled(String imageUri, View view) {
                    }
                });
                String lyrics = playlistAdapter.getCurrentLyrics();
                if (lyrics == null) {
                    lyricsScrollView.setVisibility(View.GONE);
                    lyricsTextView.setText("");
                } else {
                    lyricsScrollView.setVisibility(View.VISIBLE);
                    lyricsTextView.setText(lyrics);
                }
                listView.invalidate();
            } catch (Exception e) {
            }
        }

        @Override
        public void onInvalidated() {
        }
    });
    playlistAdapter.notifyDataSetChanged();
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            playlistAdapter.play(position);
            playlistAdapter.notifyDataSetChanged();
        }
    });
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            playlistAdapter.remove(position);
            return true;
        }
    });
    playPauseToggleButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playPauseToggle();
            if (MusicPlayerService.isPlaying()) {
                playPauseToggleButton.setImageDrawable(pauseIcon);
            } else {
                playPauseToggleButton.setImageDrawable(playIcon);
            }
        }
    });
    prevButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playPrev();
        }
    });
    nextButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playNext();
        }
    });
    UpdateCurrentPositionTask updateCurrentPositionTask = new UpdateCurrentPositionTask();
    updateCurrentPositionTimer.scheduleAtFixedRate(updateCurrentPositionTask, 0, 1000);
}
Also used : ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) HowaboutApplication(io.recom.howabout.HowaboutApplication) DataSetObserver(android.database.DataSetObserver) ContentView(roboguice.inject.ContentView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) ActionBar(com.actionbarsherlock.app.ActionBar) Track(io.recom.howabout.category.music.model.Track)

Example 68 with OnClickListener

use of android.view.View.OnClickListener in project howabout-android by recomio.

the class MusicBottomBarFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_music_bottom_bar, container, false);
    rootView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), MusicPlaylistActivity.class);
            Bundle bundle = new Bundle();
            intent.putExtras(bundle);
            intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
        }
    });
    imageView = (ImageView) rootView.findViewById(R.id.image);
    trackTitle = (TextView) rootView.findViewById(R.id.trackTitle);
    artistName = (TextView) rootView.findViewById(R.id.artistName);
    isLoading = (ProgressBar) rootView.findViewById(R.id.isLoading);
    isPlaying = (ImageView) rootView.findViewById(R.id.isPlaying);
    isPlaying.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
            MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
            playlistAdapter.playPauseToggle();
        }
    });
    playlistObserver = new DataSetObserver() {

        @Override
        public void onChanged() {
            updateTrack();
        }

        @Override
        public void onInvalidated() {
            updateTrack();
        }
    };
    HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
    MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
    playlistAdapter.registerDataSetObserver(playlistObserver);
    return rootView;
}
Also used : Bundle(android.os.Bundle) MusicPlaylistAdapter(io.recom.howabout.category.music.adapter.MusicPlaylistAdapter) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) MusicPlaylistActivity(io.recom.howabout.category.music.activity.MusicPlaylistActivity) HowaboutApplication(io.recom.howabout.HowaboutApplication) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) DataSetObserver(android.database.DataSetObserver)

Example 69 with OnClickListener

use of android.view.View.OnClickListener in project cube-sdk by liaohuqiu.

the class TitleBaseFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(getFrameLayoutId(), null);
    LinearLayout contentContainer = (LinearLayout) view.findViewById(R.id.cube_mints_content_frame_content);
    mTitleHeaderBar = (TitleHeaderBar) view.findViewById(R.id.cube_mints_content_frame_title_header);
    if (enableDefaultBack()) {
        mTitleHeaderBar.setLeftOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    } else {
        mTitleHeaderBar.getLeftViewContainer().setVisibility(View.INVISIBLE);
    }
    mContentContainer = contentContainer;
    View contentView = createView(inflater, view, savedInstanceState);
    contentView.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
    contentContainer.addView(contentView);
    return view;
}
Also used : ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 70 with OnClickListener

use of android.view.View.OnClickListener in project coursera-android by aporter.

the class BoomUserActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.boom_user_layout);
    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener() {

        // Called when the user clicks on the Detonate Button
        @Override
        public void onClick(View v) {
            // Create an implicit Intent using the Action String ACTION_BOOM
            // Launch an Activity that can receive the Intent using Activity.startActivity()  
            startActivity(new Intent(ACTION_BOOM));
        }
    });
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) View(android.view.View)

Aggregations

OnClickListener (android.view.View.OnClickListener)794 View (android.view.View)792 TextView (android.widget.TextView)492 Button (android.widget.Button)265 ImageView (android.widget.ImageView)256 Intent (android.content.Intent)183 ListView (android.widget.ListView)112 AdapterView (android.widget.AdapterView)91 ScrollView (android.widget.ScrollView)52 LinearLayout (android.widget.LinearLayout)49 Bundle (android.os.Bundle)43 LayoutInflater (android.view.LayoutInflater)35 ViewGroup (android.view.ViewGroup)30 ArrayList (java.util.ArrayList)30 BindView (butterknife.BindView)29 KeyEvent (android.view.KeyEvent)28 EditText (android.widget.EditText)28 DialogInterface (android.content.DialogInterface)27 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)25 FragmentManager (android.support.v4.app.FragmentManager)23