@ -20,6 +20,7 @@ import android.content.Intent;
import android.graphics.drawable.Drawable ;
import android.graphics.drawable.Drawable ;
import android.os.Bundle ;
import android.os.Bundle ;
import android.support.annotation.Nullable ;
import android.support.annotation.Nullable ;
import android.support.design.widget.Snackbar ;
import android.support.design.widget.TabLayout ;
import android.support.design.widget.TabLayout ;
import android.support.v7.widget.DividerItemDecoration ;
import android.support.v7.widget.DividerItemDecoration ;
import android.support.v7.widget.LinearLayoutManager ;
import android.support.v7.widget.LinearLayoutManager ;
@ -257,7 +258,7 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
@Override
@Override
public void onResponse ( Call < Relationship > call , Response < Relationship > response ) {
public void onResponse ( Call < Relationship > call , Response < Relationship > response ) {
if ( response . isSuccessful ( ) ) {
if ( response . isSuccessful ( ) ) {
onMuteSuccess ( mute , position ) ;
onMuteSuccess ( mute , id , position ) ;
} else {
} else {
onMuteFailure ( mute , id ) ;
onMuteFailure ( mute , id ) ;
}
}
@ -279,9 +280,22 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
call . enqueue ( callback ) ;
call . enqueue ( callback ) ;
}
}
private void onMuteSuccess ( boolean muted , int position ) {
private void onMuteSuccess ( boolean muted , final String id , final int position ) {
MutesAdapter mutesAdapter = ( MutesAdapter ) adapter ;
if ( muted ) {
mutesAdapter . setMuted ( muted , position ) ;
return ;
}
final MutesAdapter mutesAdapter = ( MutesAdapter ) adapter ;
final Account unmutedUser = mutesAdapter . removeItem ( position ) ;
View . OnClickListener listener = new View . OnClickListener ( ) {
@Override
public void onClick ( View v ) {
mutesAdapter . addItem ( unmutedUser , position ) ;
onMute ( true , id , position ) ;
}
} ;
Snackbar . make ( recyclerView , R . string . confirmation_unmuted , Snackbar . LENGTH_LONG )
. setAction ( R . string . action_undo , listener )
. show ( ) ;
}
}
private void onMuteFailure ( boolean mute , String id ) {
private void onMuteFailure ( boolean mute , String id ) {
@ -307,7 +321,7 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
@Override
@Override
public void onResponse ( Call < Relationship > call , Response < Relationship > response ) {
public void onResponse ( Call < Relationship > call , Response < Relationship > response ) {
if ( response . isSuccessful ( ) ) {
if ( response . isSuccessful ( ) ) {
onBlockSuccess ( block , position ) ;
onBlockSuccess ( block , id , position ) ;
} else {
} else {
onBlockFailure ( block , id ) ;
onBlockFailure ( block , id ) ;
}
}
@ -329,9 +343,22 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
call . enqueue ( cb ) ;
call . enqueue ( cb ) ;
}
}
private void onBlockSuccess ( boolean blocked , int position ) {
private void onBlockSuccess ( boolean blocked , final String id , final int position ) {
BlocksAdapter blocksAdapter = ( BlocksAdapter ) adapter ;
if ( blocked ) {
blocksAdapter . setBlocked ( blocked , position ) ;
return ;
}
final BlocksAdapter blocksAdapter = ( BlocksAdapter ) adapter ;
final Account unblockedUser = blocksAdapter . removeItem ( position ) ;
View . OnClickListener listener = new View . OnClickListener ( ) {
@Override
public void onClick ( View v ) {
blocksAdapter . addItem ( unblockedUser , position ) ;
onBlock ( true , id , position ) ;
}
} ;
Snackbar . make ( recyclerView , R . string . confirmation_unblocked , Snackbar . LENGTH_LONG )
. setAction ( R . string . action_undo , listener )
. show ( ) ;
}
}
private void onBlockFailure ( boolean block , String id ) {
private void onBlockFailure ( boolean block , String id ) {