Java Code Examples for android.widget.ImageButton#getParent()

The following examples show how to use android.widget.ImageButton#getParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioPlayer.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
private void startStop(ImageButton playPause) {
    if (ContextCompat.checkSelfPermission(messageAdapter.getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(messageAdapter.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        pendingOnClickView.push(new WeakReference<>(playPause));
        ActivityCompat.requestPermissions(messageAdapter.getActivity(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, ConversationsActivity.REQUEST_PLAY_PAUSE);
        return;
    }
    initializeProximityWakeLock(playPause.getContext());
    final RelativeLayout audioPlayer = (RelativeLayout) playPause.getParent();
    final ViewHolder viewHolder = ViewHolder.get(audioPlayer);
    final Message message = (Message) audioPlayer.getTag();
    if (startStop(viewHolder, message)) {
        this.audioPlayerLayouts.clear();
        this.audioPlayerLayouts.addWeakReferenceTo(audioPlayer);
        stopRefresher(true);
    }
}
 
Example 2
Source File: AudioPlayer.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
private void startStop(ImageButton playPause) {
    if (ContextCompat.checkSelfPermission(messageAdapter.getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        pendingOnClickView.push(new WeakReference<>(playPause));
        ActivityCompat.requestPermissions(messageAdapter.getActivity(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, ConversationsActivity.REQUEST_PLAY_PAUSE);
        return;
    }
    initializeProximityWakeLock(playPause.getContext());
    final RelativeLayout audioPlayer = (RelativeLayout) playPause.getParent();
    final ViewHolder viewHolder = ViewHolder.get(audioPlayer);
    final Message message = (Message) audioPlayer.getTag();
    if (startStop(viewHolder, message)) {
        this.audioPlayerLayouts.clear();
        this.audioPlayerLayouts.addWeakReferenceTo(audioPlayer);
        stopRefresher(true);
    }
}
 
Example 3
Source File: MainActivity.java    From retroboy with MIT License 5 votes vote down vote up
@Override
protected void onPostExecute(Bitmap result) {
	ImageButton button = (ImageButton)findViewById(R.id.openGalleryButton);
	View layout = (View)button.getParent();
	
	button.setImageBitmap(result);
	button.setEnabled(result != null);
	layout.setVisibility(result != null ? View.VISIBLE : View.GONE);
}