mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Add "Created by" to ActionBar
This commit is contained in:
@@ -2,6 +2,8 @@ package org.briarproject.android.privategroup.conversation;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@@ -43,6 +45,23 @@ public class GroupActivity extends
|
|||||||
return R.layout.activity_forum;
|
return R.layout.activity_forum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setActionBarTitle(@Nullable String title) {
|
||||||
|
if (title != null) setTitle(title);
|
||||||
|
loadGroupItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onGroupItemLoaded(PrivateGroup group) {
|
||||||
|
super.onGroupItemLoaded(group);
|
||||||
|
// Created by
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setSubtitle(getString(R.string.groups_created_by,
|
||||||
|
group.getAuthor().getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GroupMessageAdapter createAdapter(
|
protected GroupMessageAdapter createAdapter(
|
||||||
LinearLayoutManager layoutManager) {
|
LinearLayoutManager layoutManager) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.support.annotation.CallSuper;
|
|||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
|
import android.support.annotation.UiThread;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
@@ -63,8 +64,7 @@ public abstract class ThreadListActivity<G extends BaseGroup, I extends ThreadIt
|
|||||||
groupId = new GroupId(b);
|
groupId = new GroupId(b);
|
||||||
getController().setGroupId(groupId);
|
getController().setGroupId(groupId);
|
||||||
String groupName = i.getStringExtra(GROUP_NAME);
|
String groupName = i.getStringExtra(GROUP_NAME);
|
||||||
if (groupName != null) setTitle(groupName);
|
setActionBarTitle(groupName);
|
||||||
else loadAndSetTitle();
|
|
||||||
|
|
||||||
textInput = (TextInputView) findViewById(R.id.text_input_container);
|
textInput = (TextInputView) findViewById(R.id.text_input_container);
|
||||||
textInput.setVisibility(GONE);
|
textInput.setVisibility(GONE);
|
||||||
@@ -86,12 +86,17 @@ public abstract class ThreadListActivity<G extends BaseGroup, I extends ThreadIt
|
|||||||
|
|
||||||
protected abstract A createAdapter(LinearLayoutManager layoutManager);
|
protected abstract A createAdapter(LinearLayoutManager layoutManager);
|
||||||
|
|
||||||
private void loadAndSetTitle() {
|
protected void setActionBarTitle(@Nullable String title) {
|
||||||
|
if (title != null) setTitle(title);
|
||||||
|
else loadGroupItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadGroupItem() {
|
||||||
getController().loadGroupItem(
|
getController().loadGroupItem(
|
||||||
new UiResultExceptionHandler<G, DbException>(this) {
|
new UiResultExceptionHandler<G, DbException>(this) {
|
||||||
@Override
|
@Override
|
||||||
public void onResultUi(G groupItem) {
|
public void onResultUi(G groupItem) {
|
||||||
setTitle(groupItem.getName());
|
onGroupItemLoaded(groupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,6 +107,12 @@ public abstract class ThreadListActivity<G extends BaseGroup, I extends ThreadIt
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
|
@UiThread
|
||||||
|
protected void onGroupItemLoaded(G groupItem) {
|
||||||
|
setTitle(groupItem.getName());
|
||||||
|
}
|
||||||
|
|
||||||
private void loadItems() {
|
private void loadItems() {
|
||||||
getController().loadItems(
|
getController().loadItems(
|
||||||
new UiResultExceptionHandler<Collection<I>, DbException>(
|
new UiResultExceptionHandler<Collection<I>, DbException>(
|
||||||
|
|||||||
Reference in New Issue
Block a user