初始化消息界面
This commit is contained in:
parent
93acf4c8c6
commit
2976177e92
@ -88,4 +88,7 @@ dependencies {
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.5'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-core:2.18.5@aar'
|
||||
|
||||
implementation 'cn.rongcloud.sdk:call_kit:5.5.0' // 音视频通话能力 UI 组件
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,10 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.DslTabLayoutConfig;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activitys.fragments.BaseFragment;
|
||||
@ -20,6 +22,10 @@ import com.shayu.onetoone.activitys.fragments.MyFragment;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function4;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
List<BaseFragment> fragments = new ArrayList<>();
|
||||
private ViewPager2 viewPager;
|
||||
|
@ -8,13 +8,70 @@ import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.DslTabLayoutConfig;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activitys.message.MsgFriendFragment;
|
||||
import com.shayu.onetoone.activitys.message.MsgMessageFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function4;
|
||||
|
||||
public class MessageFragment extends BaseFragment {
|
||||
List<BaseFragment> fragments = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_msg, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_msg, container, false);
|
||||
initView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initView(View itemView) {
|
||||
ViewPager2 viewPager2 = itemView.findViewById(R.id.viewPager);
|
||||
DslTabLayout tabLayout = itemView.findViewById(R.id.dslTabLayout);
|
||||
//绑定ViewPager2到tabLayout
|
||||
ViewPager2Delegate.Companion.install(viewPager2, tabLayout, false);
|
||||
|
||||
fragments.add(new MsgMessageFragment());//消息 - 消息
|
||||
fragments.add(new MsgFriendFragment()); //消息 - 好友
|
||||
viewPager2.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
//设置点击事件
|
||||
tabLayout.configTabLayoutConfig(new Function1<DslTabLayoutConfig, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(DslTabLayoutConfig dslTabLayoutConfig) {
|
||||
dslTabLayoutConfig.setOnSelectItemView(new Function4<View, Integer, Boolean, Boolean, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(View itemView, Integer index, Boolean select, Boolean fromUse) {
|
||||
if (select) {//设置选择的Fragment
|
||||
viewPager2.setCurrentItem(index);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.shayu.onetoone.activitys.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activitys.fragments.BaseFragment;
|
||||
|
||||
public class MsgFriendFragment extends BaseFragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_msg_friend,container,false);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.shayu.onetoone.activitys.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activitys.fragments.BaseFragment;
|
||||
|
||||
public class MsgMessageFragment extends BaseFragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_msg_message, container, false);
|
||||
}
|
||||
}
|
@ -1,13 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_checked="true">
|
||||
<inset >
|
||||
<bitmap android:src="@mipmap/ic_tab_friends_select" />
|
||||
</inset>
|
||||
</item>
|
||||
<item android:state_checked="false">
|
||||
<inset>
|
||||
<bitmap android:src="@mipmap/ic_tab_friends" />
|
||||
</inset>
|
||||
</item>
|
||||
<item android:drawable="@mipmap/ic_tab_friends_select" android:state_selected="true" />
|
||||
<item android:drawable="@mipmap/ic_tab_friends" />
|
||||
</selector>
|
@ -12,7 +12,7 @@
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dslTabLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" >
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
</androidx.viewpager2.widget.ViewPager2>
|
||||
@ -20,39 +20,93 @@
|
||||
<com.angcyo.tablayout.DslTabLayout
|
||||
android:id="@+id/dslTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_height="64dp"
|
||||
android:background="@color/white"
|
||||
app:tab_item_is_equ_width="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:tab_draw_indicator="false"
|
||||
app:tab_item_is_equ_width="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="TextView"
|
||||
app:drawableTopCompat="@drawable/tab_friends" />
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/tab_friends" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="10sp"
|
||||
android:gravity="center"
|
||||
android:text="TextView1" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="TextView"
|
||||
app:drawableTopCompat="@drawable/tab_dynamic" />
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:src="@drawable/tab_dynamic" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="10sp"
|
||||
android:gravity="center"
|
||||
android:text="TextView1" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="TextView"
|
||||
app:drawableTopCompat="@drawable/tab_msg" />
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:src="@drawable/tab_msg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="10sp"
|
||||
android:gravity="center"
|
||||
android:text="TextView1" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="TextView"
|
||||
app:drawableTopCompat="@drawable/tab_my" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:src="@drawable/tab_my" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="10sp"
|
||||
android:gravity="center"
|
||||
android:text="TextView1" />
|
||||
</LinearLayout>
|
||||
</com.angcyo.tablayout.DslTabLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -3,13 +3,60 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="357dp"
|
||||
android:layout_marginEnd="142dp"
|
||||
android:text="Msg"
|
||||
android:layout_marginTop="42dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:src="@mipmap/ic_message_tab_more"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/dslTabLayout" />
|
||||
|
||||
<com.angcyo.tablayout.DslTabLayout
|
||||
android:id="@+id/dslTabLayout"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:background="#F7F7F7"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tab_indicator_drawable="@mipmap/ic_message_tab_indicator"
|
||||
app:tab_select_color="#000"
|
||||
app:tab_deselect_color="#666666"
|
||||
app:tab_enable_text_bold="true"
|
||||
app:tab_enable_gradient_scale="true"
|
||||
app:tab_text_max_size="20sp"
|
||||
|
||||
app:tab_indicator_height="6dp"
|
||||
app:tab_indicator_width="17dp"
|
||||
app:tab_indicator_style="STYLE_BOTTOM"
|
||||
app:tab_item_is_equ_width="true">
|
||||
|
||||
<TextView
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="消息" />
|
||||
|
||||
<TextView
|
||||
android:gravity="center"
|
||||
android:textSize="16sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="好友" />
|
||||
</com.angcyo.tablayout.DslTabLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
17
OneToOne/src/main/res/layout/fragment_msg_friend.xml
Normal file
17
OneToOne/src/main/res/layout/fragment_msg_friend.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="26dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
6
OneToOne/src/main/res/layout/fragment_msg_message.xml
Normal file
6
OneToOne/src/main/res/layout/fragment_msg_message.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_error.png
Normal file
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_indicator.png
Normal file
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_indicator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_more.png
Normal file
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_more.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_woman.png
Normal file
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_woman.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_you.png
Normal file
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_message_tab_you.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -111,8 +111,8 @@ android {
|
||||
applicationVariants.all { variant ->
|
||||
println "清空build文件夹";
|
||||
for (final def project in rootProject.getAllprojects()) {
|
||||
delete project.buildDir
|
||||
println project.buildDir
|
||||
// delete project.buildDir
|
||||
// println project.buildDir
|
||||
}
|
||||
String variantName = variant.name.capitalize()
|
||||
def processManifestTask = project.tasks.getByName("process${variantName}Manifest")
|
||||
|
Loading…
x
Reference in New Issue
Block a user