14 changed files with 269 additions and 23 deletions
@ -0,0 +1,34 @@ |
|||||||
|
package cc.niushuai.dididone.ui.statistic; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.fragment.app.Fragment; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.fragment.app.FragmentPagerAdapter; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import cc.niushuai.dididone.ui.statistic.charts.BaseChartFragment; |
||||||
|
|
||||||
|
public class MyPagerAdapter extends FragmentPagerAdapter { |
||||||
|
List<BaseChartFragment> fragmentList; |
||||||
|
|
||||||
|
//构造方法,方便之后赋值调用
|
||||||
|
public MyPagerAdapter(FragmentManager fm, List<BaseChartFragment> fragmentList){ |
||||||
|
super(fm); |
||||||
|
this.fragmentList = fragmentList; |
||||||
|
} |
||||||
|
|
||||||
|
//根据Item的位置返回对应位置的Fragment,绑定item和Fragment
|
||||||
|
@NonNull |
||||||
|
@Override |
||||||
|
public BaseChartFragment getItem(int position) { |
||||||
|
return fragmentList.get(position); |
||||||
|
} |
||||||
|
|
||||||
|
//设置item的数量
|
||||||
|
|
||||||
|
@Override |
||||||
|
public int getCount() { |
||||||
|
return fragmentList.size(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package cc.niushuai.dididone.ui.statistic.charts; |
||||||
|
|
||||||
|
import cc.niushuai.dididone.ui.base.BaseFragment; |
||||||
|
|
||||||
|
public class BaseChartFragment extends BaseFragment { |
||||||
|
|
||||||
|
private String mTitle; |
||||||
|
|
||||||
|
public BaseChartFragment(String mTitle) { |
||||||
|
this.mTitle = mTitle; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTitle() { |
||||||
|
return mTitle; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package cc.niushuai.dididone.ui.statistic.charts; |
||||||
|
|
||||||
|
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 cc.niushuai.dididone.R; |
||||||
|
|
||||||
|
public class ListFragment extends BaseChartFragment { |
||||||
|
|
||||||
|
|
||||||
|
public ListFragment() { |
||||||
|
super("列表视图"); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate(R.layout.fragment_stat_list, container, false); |
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package cc.niushuai.dididone.ui.statistic.charts; |
||||||
|
|
||||||
|
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 cc.niushuai.dididone.R; |
||||||
|
|
||||||
|
public class MonthFragment extends BaseChartFragment{ |
||||||
|
|
||||||
|
public MonthFragment() { |
||||||
|
super("月视图"); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate(R.layout.fragment_stat_month, container, false); |
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package cc.niushuai.dididone.ui.statistic.charts; |
||||||
|
|
||||||
|
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 cc.niushuai.dididone.R; |
||||||
|
|
||||||
|
public class OtherFragment extends BaseChartFragment{ |
||||||
|
|
||||||
|
public OtherFragment() { |
||||||
|
super("其他"); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate(R.layout.fragment_stat_other, container, false); |
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package cc.niushuai.dididone.ui.statistic.charts; |
||||||
|
|
||||||
|
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 cc.niushuai.dididone.R; |
||||||
|
|
||||||
|
public class WeekFragment extends BaseChartFragment { |
||||||
|
|
||||||
|
public WeekFragment() { |
||||||
|
super("周视图"); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate(R.layout.fragment_stat_week, container, false); |
||||||
|
return view; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
<LinearLayout |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center_horizontal" |
||||||
|
android:textSize="50sp" |
||||||
|
android:text="list"/> |
||||||
|
|
||||||
|
</LinearLayout> |
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center_horizontal" |
||||||
|
android:textSize="50sp" |
||||||
|
android:text="month"/> |
||||||
|
|
||||||
|
</LinearLayout> |
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center_horizontal" |
||||||
|
android:textSize="50sp" |
||||||
|
android:text="other"/> |
||||||
|
|
||||||
|
</LinearLayout> |
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center_horizontal" |
||||||
|
android:textSize="50sp" |
||||||
|
android:text="week"/> |
||||||
|
|
||||||
|
</LinearLayout> |
@ -1,22 +1,33 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
xmlns:tl="http://schemas.android.com/apk/res-auto" |
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|
||||||
xmlns:tools="http://schemas.android.com/tools" |
|
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent" |
android:layout_height="match_parent" |
||||||
tools:context=".ui.statistic.StatisticFragment"> |
android:orientation="vertical"> |
||||||
|
|
||||||
<TextView |
<!-- stat_tab_layout --> |
||||||
android:id="@+id/text_gallery" |
<com.flyco.tablayout.SlidingTabLayout |
||||||
|
android:id="@+id/stat_tab_layout" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="wrap_content" |
android:layout_height="48dp" |
||||||
android:layout_marginStart="8dp" |
android:background="#EEEEEE" |
||||||
android:layout_marginTop="8dp" |
tl:tl_divider_color="#1A000000" |
||||||
android:layout_marginEnd="8dp" |
tl:tl_divider_padding="13dp" |
||||||
android:textAlignment="center" |
tl:tl_divider_width="1dp" |
||||||
android:textSize="20sp" |
tl:tl_indicator_color="#000000" |
||||||
app:layout_constraintBottom_toBottomOf="parent" |
tl:tl_indicator_height="1.5dp" |
||||||
app:layout_constraintEnd_toEndOf="parent" |
tl:tl_indicator_width_equal_title="true" |
||||||
app:layout_constraintStart_toStartOf="parent" |
tl:tl_tab_padding="22dp" |
||||||
app:layout_constraintTop_toTopOf="parent" /> |
tl:tl_tab_space_equal="true" |
||||||
</androidx.constraintlayout.widget.ConstraintLayout> |
tl:tl_textBold="SELECT" |
||||||
|
tl:tl_textSelectColor="@color/red" |
||||||
|
tl:tl_textUnselectColor="@color/gray_light_less" |
||||||
|
tl:tl_underline_height="2dp" /> |
||||||
|
|
||||||
|
<androidx.viewpager.widget.ViewPager |
||||||
|
android:id="@+id/stat_viewpager" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="0px" |
||||||
|
android:layout_weight="1" |
||||||
|
android:background="@android:color/white" /> |
||||||
|
|
||||||
|
</LinearLayout> |
Loading…
Reference in new issue