Skip to content

Commit

Permalink
Handle profile navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
tien-awair committed May 29, 2022
1 parent e8507c1 commit aa06eca
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class BaseApplication extends MultiDexApplication {

private static final String APP_ID = "A602CBEC-EC8C-4EFA-83CE-CAE057853DD7";
private static final String APP_ID = "033D0C2B-1B69-4592-90E5-2B6D8D58A86B";
private static final MutableLiveData<InitState> initState = new MutableLiveData<>();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;

import com.sendbird.android.Member;
import com.sendbird.uikit.R;
import com.sendbird.uikit.SendBirdUIKit;
import com.sendbird.uikit.consts.StringSet;
Expand All @@ -18,6 +20,8 @@
import com.sendbird.uikit.utils.TextUtils;
import com.sendbird.uikit.widgets.AudioManager;

import java.util.List;

/**
* Activity displays a list of messages from a channel.
*/
Expand Down Expand Up @@ -59,29 +63,62 @@ public static Intent newIntentFromCustomActivity(@NonNull Context context, @NonN
}

private String url;
private View.OnClickListener onBackClickListener;
private View.OnClickListener onInfoClickListener;
private ChannelFragment channelFragment;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(SendBirdUIKit.isDarkMode() ? R.style.SendBird_Dark : R.style.SendBird);
setContentView(R.layout.sb_activity);
setContentView(getLayoutId());

initialize();

url = getIntent().getStringExtra(StringSet.KEY_CHANNEL_URL);
String title = getIntent().getStringExtra(StringSet.KEY_HEADER_TITLE);
if (TextUtils.isEmpty(url)) {
ContextUtils.toastError(this, R.string.sb_text_error_get_channel);
} else {
ChannelFragment fragment = createChannelFragment(url, title);
channelFragment = createChannelFragment(url, title);
FragmentManager manager = getSupportFragmentManager();
manager.popBackStack();
manager.beginTransaction()
.replace(R.id.sb_fragment_container, fragment)
.replace(R.id.sb_fragment_container, channelFragment)
.commit();
}

AudioManager.getInstance().attachLifecycle(getLifecycle());
}

public int getLayoutId() {
return R.layout.sb_activity;
}

public void initialize() {

}

public String getChannelUrl() {
return url;
}

public List<Member> getMembers() {
return channelFragment.getMembers();
}

public boolean isSingleChat() {
return channelFragment.isSingleChat();
}

public void setOnBackClickListener(View.OnClickListener backClickListener) {
this.onBackClickListener = backClickListener;
}

public void setOnInfoClickListener(View.OnClickListener infoClickListener) {
this.onInfoClickListener = infoClickListener;
}

@Override
protected void onResume() {
Intent intent = new Intent(StringSet.KEY_ACTION_CLEAR_CHAT_NOTIFICATION);
Expand Down Expand Up @@ -116,6 +153,9 @@ protected ChannelFragment createChannelFragment(@NonNull String channelUrl, @Nul
if (intent.hasExtra(StringSet.KEY_FROM_SEARCH_RESULT)) {
builder.setUseHeaderRightButton(intent.getBooleanExtra(StringSet.KEY_FROM_SEARCH_RESULT, false));
}

builder.setHeaderLeftButtonListener(onBackClickListener);
builder.setHeaderRightButtonListener(onInfoClickListener);
return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,14 @@ private void setOnListItemLongClickListener(OnIdentifiableItemLongClickListener<
this.listItemLongClickListener = listItemLongClickListener;
}

public boolean isSingleChat() {
return channel.getMemberCount() <= 2;
}

public List<Member> getMembers() {
return channel.getMembers();
}

public static class Builder {
private final Bundle bundle;
private ChannelFragment customFragment;
Expand Down

0 comments on commit aa06eca

Please sign in to comment.