mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-24 01:42:18 -05:00
ConversationFragment: Move indicator from layout to toolbar (replacing toolbar title).
This commit is contained in:
parent
3e4f8f57bd
commit
0de229c130
@ -185,6 +185,11 @@ public class MainActivity extends ActionBarActivity implements YaaicActivity, Se
|
||||
return binder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar getToolbar() {
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToolbarTitle(String title) {
|
||||
toolbar.setTitle(title);
|
||||
|
@ -20,6 +20,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.yaaic.activity;
|
||||
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import org.yaaic.irc.IRCBinder;
|
||||
import org.yaaic.model.Server;
|
||||
|
||||
@ -29,6 +31,8 @@ import org.yaaic.model.Server;
|
||||
public interface YaaicActivity {
|
||||
IRCBinder getBinder();
|
||||
|
||||
Toolbar getToolbar();
|
||||
|
||||
void setToolbarTitle(String title);
|
||||
|
||||
void onServerSelected(Server server);
|
||||
|
@ -21,6 +21,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.yaaic.fragment;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Fragment;
|
||||
@ -36,8 +37,13 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.speech.RecognizerIntent;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.InputType;
|
||||
import android.text.method.TextKeyListener;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
@ -185,8 +191,6 @@ public class ConversationFragment extends Fragment implements ServerListener, Co
|
||||
serverId = getArguments().getInt("serverId");
|
||||
server = Yaaic.getInstance().getServerById(serverId);
|
||||
|
||||
activity.setToolbarTitle(server.getTitle());
|
||||
|
||||
scrollback = new Scrollback();
|
||||
}
|
||||
|
||||
@ -206,11 +210,19 @@ public class ConversationFragment extends Fragment implements ServerListener, Co
|
||||
pagerAdapter = new ConversationPagerAdapter(getActivity(), server);
|
||||
pager.setAdapter(pagerAdapter);
|
||||
|
||||
tabLayout = (ConversationTabLayout) view.findViewById(R.id.indicator);
|
||||
tabLayout = new ConversationTabLayout(container.getContext());
|
||||
tabLayout.setViewPager(pager);
|
||||
tabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
|
||||
tabLayout.setDividerColors(getResources().getColor(R.color.divider));
|
||||
|
||||
Toolbar.LayoutParams params = new Toolbar.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
);
|
||||
params.gravity = Gravity.BOTTOM;
|
||||
|
||||
activity.getToolbar().addView(tabLayout, params);
|
||||
|
||||
if (server.getStatus() == Status.PRE_CONNECTING) {
|
||||
server.clearConversations();
|
||||
pagerAdapter.clearConversations();
|
||||
@ -270,6 +282,13 @@ public class ConversationFragment extends Fragment implements ServerListener, Co
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
activity.getToolbar().removeView(tabLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* On resume
|
||||
*/
|
||||
|
@ -25,12 +25,6 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.yaaic.view.ConversationTabLayout
|
||||
android:id="@+id/indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/primary" />
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
Loading…
Reference in New Issue
Block a user