Browse Source

no message

master
lh 8 years ago
parent
commit
2a250e5b0f
10 changed files with 288 additions and 4 deletions
  1. +155
    -0
      app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseActivity.java
  2. +30
    -0
      app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseAllFragment.java
  3. +30
    -0
      app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseNoFragment.java
  4. +30
    -0
      app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseYesFragment.java
  5. +1
    -1
      app/src/main/res/layout/act_inhouse.xml
  6. +12
    -0
      app/src/main/res/layout/frag_inhouse_all.xml
  7. +12
    -0
      app/src/main/res/layout/frag_inhouse_no.xml
  8. +10
    -0
      app/src/main/res/layout/frag_inhouse_yes.xml
  9. +3
    -3
      app/src/main/res/layout/include_inhousetab_bar.xml
  10. +5
    -0
      app/src/main/res/values/styles.xml

+ 155
- 0
app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseActivity.java View File

@ -1,12 +1,16 @@
package com.qhclh.ytzh.index.shangpin; package com.qhclh.ytzh.index.shangpin;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.qhclh.ytzh.R; import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity; import com.qhclh.ytzh.base.BaseActivity;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick;
/** /**
* Created by 青花瓷 on 2017/12/28. * Created by 青花瓷 on 2017/12/28.
@ -15,6 +19,35 @@ import butterknife.BindView;
public class InHouseActivity extends BaseActivity { public class InHouseActivity extends BaseActivity {
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar mToolbar; Toolbar mToolbar;
@BindView(R.id.iv_inhouse_all)
ImageView iv_inhouse_all;
@BindView(R.id.tv_inhouse_all)
TextView tv_inhouse_all;
@BindView(R.id.iv_inhouse_no)
ImageView iv_inhouse_no;
@BindView(R.id.tv_inhouse_no)
TextView tv_inhouse_no;
@BindView(R.id.iv_inhouse_yes)
ImageView iv_inhouse_yes;
@BindView(R.id.tv_inhouse_yes)
TextView tv_inhouse_yes;
///< all
private static final int TAB_POSITION_ALL = 0;
///< no
private static final int TAB_POSITION_NO = 1;
///< yes
private static final int TAB_POSITION_YES = 2;
private int mCurrentTabPosition = -1;
private int mTargetTabPosition = TAB_POSITION_ALL;
private InHouseAllFragment inHouseAllFragment;
private InHouseNoFragment inHouseNoFragment;
private InHouseYesFragment inHouseYesFragment;
@Override @Override
protected int setLayoutId() { protected int setLayoutId() {
return R.layout.act_inhouse; return R.layout.act_inhouse;
@ -28,6 +61,8 @@ public class InHouseActivity extends BaseActivity {
finish(); finish();
} }
}); });
///< 点击切换fragment
onTabClick(mTargetTabPosition);
} }
@Override @Override
@ -39,4 +74,124 @@ public class InHouseActivity extends BaseActivity {
protected void initOper() { protected void initOper() {
} }
@OnClick({R.id.ll_inhouse_all, R.id.ll_inhouse_no, R.id.ll_inhouse_yes})
public void onClick(View view) {
switch (view.getId()) {
///< all
case R.id.ll_inhouse_all: {
onTabClick(TAB_POSITION_ALL);
break;
}
///< no
case R.id.ll_inhouse_no: {
onTabClick(TAB_POSITION_NO);
break;
}
///< yes
case R.id.ll_inhouse_yes: {
onTabClick(TAB_POSITION_YES);
break;
}
}
}
private void onTabClick(int tabPosition) {
if (mCurrentTabPosition == tabPosition) {
return;
}
mCurrentTabPosition = tabPosition;
changeTabState(tabPosition);
changeFragment(tabPosition);
}
private void changeTabState(int tabPosition) {
clearAllTabState();
switch (tabPosition) {
case TAB_POSITION_ALL: {
iv_inhouse_all.setImageResource(R.drawable.shouye_3x);
tv_inhouse_all.setTextColor(getResources().getColor(R.color.colorPrimary));
break;
}
case TAB_POSITION_NO: {
iv_inhouse_no.setImageResource(R.drawable.gongzuo_3x);
tv_inhouse_no.setTextColor(getResources().getColor(R.color.colorPrimary));
break;
}
case TAB_POSITION_YES: {
iv_inhouse_yes.setImageResource(R.drawable.wode_3x);
tv_inhouse_yes.setTextColor(getResources().getColor(R.color.colorPrimary));
break;
}
}
}
private void clearAllTabState() {
///< all
iv_inhouse_all.setImageResource(R.drawable.shouye1_3x);
tv_inhouse_all.setTextColor(getResources().getColor(R.color.grey_767c82));
///< no
iv_inhouse_no.setImageResource(R.drawable.gongzuo1_3x);
tv_inhouse_no.setTextColor(getResources().getColor(R.color.grey_767c82));
///< yes
iv_inhouse_yes.setImageResource(R.drawable.wode1_3x);
tv_inhouse_yes.setTextColor(getResources().getColor(R.color.grey_767c82));
}
private void changeFragment(int tabPosition) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
hideFragment(transaction);
switch (tabPosition) {
case TAB_POSITION_ALL: {
if (inHouseAllFragment == null) {
inHouseAllFragment = new InHouseAllFragment();
transaction.add(R.id.inhouse_container, inHouseAllFragment);
} else {
transaction.show(inHouseAllFragment);
}
break;
}
case TAB_POSITION_NO: {
if (inHouseNoFragment == null) {
inHouseNoFragment = new InHouseNoFragment();
transaction.add(R.id.inhouse_container, inHouseNoFragment);
} else {
transaction.show(inHouseNoFragment);
}
break;
}
case TAB_POSITION_YES: {
if (inHouseYesFragment == null) {
inHouseYesFragment = new InHouseYesFragment();
transaction.add(R.id.inhouse_container, inHouseYesFragment);
} else {
transaction.show(inHouseYesFragment);
}
break;
}
}
transaction.commitAllowingStateLoss();
}
private void hideFragment(FragmentTransaction transaction) {
if (inHouseAllFragment != null) {
transaction.hide(inHouseAllFragment);
}
if (inHouseNoFragment != null) {
transaction.hide(inHouseNoFragment);
}
if (inHouseYesFragment != null) {
transaction.hide(inHouseYesFragment);
}
}
} }

+ 30
- 0
app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseAllFragment.java View File

@ -0,0 +1,30 @@
package com.qhclh.ytzh.index.shangpin;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseFragment;
/**
* Created by 青花瓷 on 2017/12/28.
*/
public class InHouseAllFragment extends BaseFragment {
@Override
protected int setLayout() {
return R.layout.frag_inhouse_all;
}
@Override
protected void initView() {
}
@Override
protected void initData() {
}
@Override
protected void initOper() {
}
}

+ 30
- 0
app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseNoFragment.java View File

@ -0,0 +1,30 @@
package com.qhclh.ytzh.index.shangpin;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseFragment;
/**
* Created by 青花瓷 on 2017/12/28.
*/
public class InHouseNoFragment extends BaseFragment {
@Override
protected int setLayout() {
return R.layout.frag_inhouse_no;
}
@Override
protected void initView() {
}
@Override
protected void initData() {
}
@Override
protected void initOper() {
}
}

+ 30
- 0
app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseYesFragment.java View File

@ -0,0 +1,30 @@
package com.qhclh.ytzh.index.shangpin;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseFragment;
/**
* Created by 青花瓷 on 2017/12/28.
*/
public class InHouseYesFragment extends BaseFragment {
@Override
protected int setLayout() {
return R.layout.frag_inhouse_yes;
}
@Override
protected void initView() {
}
@Override
protected void initData() {
}
@Override
protected void initOper() {
}
}

+ 1
- 1
app/src/main/res/layout/act_inhouse.xml View File

@ -8,7 +8,7 @@
<include layout="@layout/include_inhousetab_bar"></include> <include layout="@layout/include_inhousetab_bar"></include>
<include layout="@layout/include_line"></include> <include layout="@layout/include_line"></include>
<RelativeLayout <RelativeLayout
android:id="@+id/main_container"
android:id="@+id/inhouse_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1" />


+ 12
- 0
app/src/main/res/layout/frag_inhouse_all.xml View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="allllllll"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

+ 12
- 0
app/src/main/res/layout/frag_inhouse_no.xml View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="未审核aaaaaaaaa"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

+ 10
- 0
app/src/main/res/layout/frag_inhouse_yes.xml View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="已审核aaaaaaaaaa"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

+ 3
- 3
app/src/main/res/layout/include_inhousetab_bar.xml View File

@ -11,7 +11,7 @@
<ImageView <ImageView
android:id="@+id/iv_inhouse_all" android:id="@+id/iv_inhouse_all"
style="@style/TabIcon" />
style="@style/TabIconinhouse" />
<TextView <TextView
android:id="@+id/tv_inhouse_all" android:id="@+id/tv_inhouse_all"
@ -25,7 +25,7 @@
<ImageView <ImageView
android:id="@+id/iv_inhouse_no" android:id="@+id/iv_inhouse_no"
style="@style/TabIcon" />
style="@style/TabIconinhouse" />
<TextView <TextView
android:id="@+id/tv_inhouse_no" android:id="@+id/tv_inhouse_no"
@ -39,7 +39,7 @@
<ImageView <ImageView
android:id="@+id/iv_inhouse_yes" android:id="@+id/iv_inhouse_yes"
style="@style/TabIcon" />
style="@style/TabIconinhouse" />
<TextView <TextView
android:id="@+id/tv_inhouse_yes" android:id="@+id/tv_inhouse_yes"


+ 5
- 0
app/src/main/res/values/styles.xml View File

@ -65,6 +65,11 @@
<item name="android:layout_width">@dimen/tab_icon_width</item> <item name="android:layout_width">@dimen/tab_icon_width</item>
</style> </style>
<style name="TabIconinhouse">
<item name="android:layout_height">@dimen/dp_22</item>
<item name="android:layout_width">@dimen/dp_22</item>
</style>
<style name="TabText"> <style name="TabText">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>


Loading…
Cancel
Save