Repository: sungerk/DropDownLayout
Branch: master
Commit: be6594fa967c
Files: 59
Total size: 99.3 KB
Directory structure:
gitextract_n4bs7ty7/
├── .gitignore
├── README.md
├── app/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── sunger/
│ │ └── net/
│ │ └── org/
│ │ └── dropmenu/
│ │ └── ApplicationTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── sunger/
│ │ │ └── net/
│ │ │ └── org/
│ │ │ └── dropmenu/
│ │ │ ├── MainActivity.java
│ │ │ ├── TabEntity.java
│ │ │ ├── adapter/
│ │ │ │ ├── FilterAdapter.java
│ │ │ │ └── ShopAdapter.java
│ │ │ ├── fragment/
│ │ │ │ ├── FragmentCategory.java
│ │ │ │ ├── FragmentFloor.java
│ │ │ │ └── FragmentSort.java
│ │ │ └── tab/
│ │ │ ├── CommonTabLayout.java
│ │ │ ├── listener/
│ │ │ │ ├── CustomTabEntity.java
│ │ │ │ └── OnTabSelectListener.java
│ │ │ ├── utils/
│ │ │ │ ├── FragmentChangeManager.java
│ │ │ │ └── UnreadMsgUtils.java
│ │ │ └── widget/
│ │ │ └── MsgView.java
│ │ └── res/
│ │ ├── drawable/
│ │ │ ├── check_bg.xml
│ │ │ └── uncheck_bg.xml
│ │ ├── layout/
│ │ │ ├── activity_main.xml
│ │ │ ├── content_main.xml
│ │ │ ├── item_default_drop_down.xml
│ │ │ ├── layout_tab.xml
│ │ │ ├── layout_tab_bottom.xml
│ │ │ ├── layout_tab_left.xml
│ │ │ ├── layout_tab_right.xml
│ │ │ ├── layout_tab_segment.xml
│ │ │ └── layout_tab_top.xml
│ │ ├── menu/
│ │ │ └── menu_main.xml
│ │ ├── values/
│ │ │ ├── attrs.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ └── test/
│ └── java/
│ └── sunger/
│ └── net/
│ └── org/
│ └── dropmenu/
│ └── ExampleUnitTest.java
├── build.gradle
├── dropdownlayout/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── net/
│ │ └── org/
│ │ └── sunger/
│ │ └── dropdownlayout/
│ │ └── ApplicationTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── net/
│ │ │ └── sunger/
│ │ │ └── widget/
│ │ │ ├── DropDownLayout.java
│ │ │ ├── MaskView.java
│ │ │ └── MenuLayout.java
│ │ └── res/
│ │ ├── anim/
│ │ │ ├── menu_in.xml
│ │ │ └── menu_out.xml
│ │ └── values/
│ │ ├── ids.xml
│ │ └── strings.xml
│ └── test/
│ └── java/
│ └── net/
│ └── org/
│ └── sunger/
│ └── dropdownlayout/
│ └── ExampleUnitTest.java
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/*
.DS_Store
/build
/captures
================================================
FILE: README.md
================================================
# DropDownLayout
effect

##How to use?
###1.config the layout like this
* DropDownLayout
the container who can controller the menu sho or dissmiss
* RelativeLayout
you custom contentView,you can use RelativeLayout,LinearLayout or other layout view.
* MaskView
when menu is show the mask will show,and when the menu dismiss the maskview will dismiss
## you must set the alpha. so i set the background color with alpha #88838685
* MenuLayout
the menu layout
###Like this
```xml
<org.net.sunger.widget.DropDownLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dropdown"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/activity_main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
></android.support.v7.widget.RecyclerView>
</RelativeLayout>
<org.net.sunger.widget.MaskView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88838685" />
<org.net.sunger.widget.MenuLayout
android:id="@+id/menuLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"></org.net.sunger.widget.MenuLayout>
</org.net.sunger.widget.DropDownLayout>
```
###2.controller it in java code
```java
MenuLayout menuLayout = (MenuLayout) findViewById(R.id.menuLayout);
DropDownLayout dropDownLayout = (DropDownLayout) findViewById(R.id.dropdown);
List<Fragment> fragments = new ArrayList<>();
fragments.add(new FragmentFloor());
fragments.add(new FragmentCategory());
fragments.add(new FragmentSort());
//you can set the anim by youself
//menuLayout.setAnimationIn(R.anim.an);
//menuLayout.setAnimationOut(R.anim.out);
menuLayout.setFragmentManager(getSupportFragmentManager());
menuLayout.bindFragments(fragments);
// dropDownLayout.closeMenu();
// dropDownLayout.showMenuAt(position);
```
## License
```
Copyright 2016 sungerk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "sunger.net.org.dropmenu"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile project(':DropDownLayout')
}
================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/sunger/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: app/src/androidTest/java/sunger/net/org/dropmenu/ApplicationTest.java
================================================
package sunger.net.org.dropmenu;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sunger.net.org.dropmenu">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/MainActivity.java
================================================
package sunger.net.org.dropmenu;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import org.net.sunger.widget.DropDownLayout;
import org.net.sunger.widget.MenuLayout;
import java.util.ArrayList;
import java.util.List;
import sunger.net.org.dropmenu.adapter.ShopAdapter;
import sunger.net.org.dropmenu.fragment.FragmentCategory;
import sunger.net.org.dropmenu.fragment.FragmentFloor;
import sunger.net.org.dropmenu.fragment.FragmentSort;
import sunger.net.org.dropmenu.tab.CommonTabLayout;
import sunger.net.org.dropmenu.tab.listener.CustomTabEntity;
import sunger.net.org.dropmenu.tab.listener.OnTabSelectListener;
public class MainActivity extends AppCompatActivity {
private CommonTabLayout tabs;
private String[] mTitles = {"All Floor", "All Merchant", "All Category"};
private int[] mIconUnselectIds = {
R.mipmap.tab_floor_unselected, R.mipmap.tab_category_unseleted,
R.mipmap.tab_sort_unseleted};
private int[] mIconSelectIds = {
R.mipmap.tab_floor_selected, R.mipmap.tab_category_seleted,
R.mipmap.tab_floor_selected};
private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
private DropDownLayout dropDownLayout;
private MenuLayout menuLayout;
private ShopAdapter shopAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
menuLayout = (MenuLayout) findViewById(R.id.menuLayout);
dropDownLayout = (DropDownLayout) findViewById(R.id.dropdown);
List<Fragment> fragments = new ArrayList<>();
fragments.add(new FragmentFloor());
fragments.add(new FragmentCategory());
fragments.add(new FragmentSort());
// menuLayout.setAnimationIn(R.anim.an);
// menuLayout.setAnimationOut(R.anim.out);
menuLayout.setFragmentManager(getSupportFragmentManager());
menuLayout.bindFragments(fragments);
tabs = (CommonTabLayout) findViewById(R.id.tabs);
updateTabData();
tabs.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelect(int position) {
dropDownLayout.showMenuAt(position);
}
@Override
public void onTabReselect(int position) {
if (menuLayout.isShow()) {
dropDownLayout.closeMenu();
} else {
dropDownLayout.showMenuAt(position);
}
}
});
shopAdapter = new ShopAdapter();
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(shopAdapter);
}
private void updateTabData() {
mTabEntities.clear();
for (int i = 0; i < mTitles.length; i++) {
mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i]));
}
tabs.setTabData(mTabEntities);
}
public void onFilter(int type, String tag) {
dropDownLayout.closeMenu();
switch (type) {
case 0:
mTitles[0] = tag;
break;
case 1:
mTitles[1] = tag;
break;
case 2:
mTitles[2] = tag;
break;
}
updateTabData();
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/TabEntity.java
================================================
package sunger.net.org.dropmenu;
import sunger.net.org.dropmenu.tab.listener.CustomTabEntity;
/**
* Created by sunger on 16/4/16.
*/
public class TabEntity implements CustomTabEntity {
public String title;
public int selectedIcon;
public int unSelectedIcon;
public TabEntity(String title, int selectedIcon, int unSelectedIcon) {
this.title = title;
this.selectedIcon = selectedIcon;
this.unSelectedIcon = unSelectedIcon;
}
@Override
public String getTabTitle() {
return title;
}
@Override
public int getTabSelectedIcon() {
return selectedIcon;
}
@Override
public int getTabUnselectedIcon() {
return unSelectedIcon;
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/adapter/FilterAdapter.java
================================================
package sunger.net.org.dropmenu.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.InjectView;
import sunger.net.org.dropmenu.R;
public class FilterAdapter extends BaseAdapter {
private Context context;
private List<String> list;
private int checkItemPosition = 0;
public void setCheckItem(int position) {
checkItemPosition = position;
notifyDataSetChanged();
}
public FilterAdapter(Context context, List<String> list) {
this.context = context;
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView != null) {
viewHolder = (ViewHolder) convertView.getTag();
} else {
convertView = LayoutInflater.from(context).inflate(R.layout.item_default_drop_down, null);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
}
fillValue(position, viewHolder);
return convertView;
}
private void fillValue(int position, ViewHolder viewHolder) {
viewHolder.mText.setText(list.get(position));
if (checkItemPosition != -1) {
if (checkItemPosition == position) {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_selected));
viewHolder.mText.setBackgroundResource(R.color.check_bg);
} else {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_unselected));
viewHolder.mText.setBackgroundResource(R.color.white);
}
}
}
static class ViewHolder {
@InjectView(R.id.text)
TextView mText;
ViewHolder(View view) {
ButterKnife.inject(this, view);
}
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/adapter/ShopAdapter.java
================================================
package sunger.net.org.dropmenu.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
/**
* Created by sunger on 16/4/16.
*/
public class ShopAdapter extends RecyclerView.Adapter<ShopAdapter.ShopViewHoler>{
private String[] data={"shop1","shop2","shop3","shop4","shop5","shop5","shop6","shop6","shop7","shop8","shop9","shop10","shop1","shop1","shop1","shop1","shop1","shop8","shop9","shop10","shop1","shop1","shop1","shop1","shop1","shop8","shop9","shop10","shop1","shop1","shop1","shop1","shop1"};
@Override
public ShopViewHoler onCreateViewHolder(ViewGroup parent, int viewType) {
TextView tv= new TextView(parent.getContext());
tv.setHeight(300);
return new ShopViewHoler(tv);
}
@Override
public void onBindViewHolder(ShopViewHoler holder, int position) {
holder.mTextView.setText(data[position]);
}
@Override
public int getItemCount() {
return data.length;
}
public static class ShopViewHoler extends RecyclerView.ViewHolder{
public final TextView mTextView;
public ShopViewHoler(View itemView) {
super(itemView);
mTextView=(TextView)itemView;
}
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentCategory.java
================================================
package sunger.net.org.dropmenu.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.Arrays;
import sunger.net.org.dropmenu.MainActivity;
import sunger.net.org.dropmenu.adapter.FilterAdapter;
/**
* Created by sunger on 16/4/16.
*/
public class FragmentCategory extends Fragment {
private String clothes[] = {"All", "Socks", "Hat", "Glove", "Briefs", "Jacket"};
private ListView listView;
private FilterAdapter adapter;
private MainActivity mainActivity;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainActivity=(MainActivity)getActivity();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
listView = new ListView(getActivity());
return listView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
listView.setDividerHeight(0);
adapter = new FilterAdapter(getActivity(), Arrays.asList(clothes));
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mainActivity.onFilter(1,clothes[position]);
adapter.setCheckItem(position);
}
});
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentFloor.java
================================================
package sunger.net.org.dropmenu.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.Arrays;
import sunger.net.org.dropmenu.MainActivity;
import sunger.net.org.dropmenu.adapter.FilterAdapter;
/**
* Created by sunger on 16/4/16.
*/
public class FragmentFloor extends Fragment {
private ListView listView;
private FilterAdapter adapter;
private String floors[] = {"B1", "B2", "B3", "1F", "2F", "3F", "4F", "5F", "6F", "7F", "9F"};
private MainActivity mainActivity;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainActivity=(MainActivity)getActivity();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
listView = new ListView(getActivity());
return listView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
adapter = new FilterAdapter(getActivity(), Arrays.asList(floors));
listView.setDividerHeight(0);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mainActivity.onFilter(0,floors[position]);
adapter.setCheckItem(position);
}
});
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentSort.java
================================================
package sunger.net.org.dropmenu.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.Arrays;
import sunger.net.org.dropmenu.MainActivity;
import sunger.net.org.dropmenu.adapter.FilterAdapter;
/**
* Created by sunger on 16/4/16.
*/
public class FragmentSort extends Fragment {
private String sorts[] = {"All", "A-Z", "Z-A", "Near"};
ListView listView;
FilterAdapter adapter;
private MainActivity mainActivity;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainActivity=(MainActivity)getActivity();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
listView = new ListView(getActivity());
return listView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
listView.setDividerHeight(0);
adapter = new FilterAdapter(getActivity(), Arrays.asList(sorts));
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mainActivity.onFilter(2,sorts[position]);
adapter.setCheckItem(position);
}
});
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/CommonTabLayout.java
================================================
package sunger.net.org.dropmenu.tab;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nineoldandroids.animation.TypeEvaluator;
import com.nineoldandroids.animation.ValueAnimator;
import java.util.ArrayList;
import sunger.net.org.dropmenu.R;
import sunger.net.org.dropmenu.tab.listener.CustomTabEntity;
import sunger.net.org.dropmenu.tab.listener.OnTabSelectListener;
import sunger.net.org.dropmenu.tab.utils.FragmentChangeManager;
import sunger.net.org.dropmenu.tab.utils.UnreadMsgUtils;
import sunger.net.org.dropmenu.tab.widget.MsgView;
/** 没有继承HorizontalScrollView不能滑动,对于ViewPager无依赖 */
public class CommonTabLayout extends FrameLayout implements ValueAnimator.AnimatorUpdateListener {
private Context mContext;
private ArrayList<CustomTabEntity> mTabEntitys = new ArrayList<>();
private LinearLayout mTabsContainer;
private int mCurrentTab;
private int mLastTab;
private int mTabCount;
/** 用于绘制显示器 */
private Rect mIndicatorRect = new Rect();
private GradientDrawable mIndicatorDrawable = new GradientDrawable();
private Paint mRectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint mDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint mTrianglePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Path mTrianglePath = new Path();
private static final int STYLE_NORMAL = 0;
private static final int STYLE_TRIANGLE = 1;
private static final int STYLE_BLOCK = 2;
private int mIndicatorStyle = STYLE_NORMAL;
private float mTabPadding;
private boolean mTabSpaceEqual;
private float mTabWidth;
/** indicator */
private int mIndicatorColor;
private float mIndicatorHeight;
private float mIndicatorWidth;
private float mIndicatorCornerRadius;
private float mIndicatorMarginLeft;
private float mIndicatorMarginTop;
private float mIndicatorMarginRight;
private float mIndicatorMarginBottom;
private long mIndicatorAnimDuration;
private boolean mIndicatorAnimEnable;
private boolean mIndicatorBounceEnable;
private int mIndicatorGravity;
/** underline */
private int mUnderlineColor;
private float mUnderlineHeight;
private int mUnderlineGravity;
/** divider */
private int mDividerColor;
private float mDividerWidth;
private float mDividerPadding;
/** title */
private float mTextsize;
private int mTextSelectColor;
private int mTextUnselectColor;
private boolean mTextBold;
private boolean mTextAllCaps;
/** icon */
private boolean mIconVisible;
private int mIconGravity;
private float mIconWidth;
private float mIconHeight;
private float mIconMargin;
private int mHeight;
/** anim */
private ValueAnimator mValueAnimator;
private OvershootInterpolator mInterpolator = new OvershootInterpolator(1.5f);
private FragmentChangeManager mFragmentChangeManager;
public CommonTabLayout(Context context) {
this(context, null, 0);
}
public CommonTabLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CommonTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
setClipChildren(false);
setClipToPadding(false);
this.mContext = context;
mTabsContainer = new LinearLayout(context);
addView(mTabsContainer);
obtainAttributes(context, attrs);
//get layout_height
String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");
//create ViewPager
if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) {
} else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) {
} else {
int[] systemAttrs = {android.R.attr.layout_height};
TypedArray a = context.obtainStyledAttributes(attrs, systemAttrs);
mHeight = a.getDimensionPixelSize(0, ViewGroup.LayoutParams.WRAP_CONTENT);
a.recycle();
}
mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
mValueAnimator.addUpdateListener(this);
}
private void obtainAttributes(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CommonTabLayout);
mIndicatorStyle = ta.getInt(R.styleable.CommonTabLayout_tl_indicator_style, 0);
mIndicatorColor = ta.getColor(R.styleable.CommonTabLayout_tl_indicator_color, Color.parseColor(mIndicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
mIndicatorHeight = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_height,
dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 4 : (mIndicatorStyle == STYLE_BLOCK ? -1 : 2)));
mIndicatorWidth = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_width, dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 10 : -1));
mIndicatorCornerRadius = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_corner_radius, dp2px(mIndicatorStyle == STYLE_BLOCK ? -1 : 0));
mIndicatorMarginLeft = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_margin_left, dp2px(0));
mIndicatorMarginTop = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_margin_top, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
mIndicatorMarginRight = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_margin_right, dp2px(0));
mIndicatorMarginBottom = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_margin_bottom, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
mIndicatorAnimEnable = ta.getBoolean(R.styleable.CommonTabLayout_tl_indicator_anim_enable, true);
mIndicatorBounceEnable = ta.getBoolean(R.styleable.CommonTabLayout_tl_indicator_bounce_enable, true);
mIndicatorAnimDuration = ta.getInt(R.styleable.CommonTabLayout_tl_indicator_anim_duration, -1);
mIndicatorGravity = ta.getInt(R.styleable.CommonTabLayout_tl_indicator_gravity, Gravity.BOTTOM);
mUnderlineColor = ta.getColor(R.styleable.CommonTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
mUnderlineHeight = ta.getDimension(R.styleable.CommonTabLayout_tl_underline_height, dp2px(0));
mUnderlineGravity = ta.getInt(R.styleable.CommonTabLayout_tl_underline_gravity, Gravity.BOTTOM);
mDividerColor = ta.getColor(R.styleable.CommonTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
mDividerWidth = ta.getDimension(R.styleable.CommonTabLayout_tl_divider_width, dp2px(0));
mDividerPadding = ta.getDimension(R.styleable.CommonTabLayout_tl_divider_padding, dp2px(12));
mTextsize = ta.getDimension(R.styleable.CommonTabLayout_tl_textsize, sp2px(13f));
mTextSelectColor = ta.getColor(R.styleable.CommonTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
mTextUnselectColor = ta.getColor(R.styleable.CommonTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
mTextBold = ta.getBoolean(R.styleable.CommonTabLayout_tl_textBold, false);
mTextAllCaps = ta.getBoolean(R.styleable.CommonTabLayout_tl_textAllCaps, false);
mIconVisible = ta.getBoolean(R.styleable.CommonTabLayout_tl_iconVisible, true);
mIconGravity = ta.getInt(R.styleable.CommonTabLayout_tl_iconGravity, Gravity.TOP);
mIconWidth = ta.getDimension(R.styleable.CommonTabLayout_tl_iconWidth, dp2px(0));
mIconHeight = ta.getDimension(R.styleable.CommonTabLayout_tl_iconHeight, dp2px(0));
mIconMargin = ta.getDimension(R.styleable.CommonTabLayout_tl_iconMargin, dp2px(2.5f));
mTabSpaceEqual = ta.getBoolean(R.styleable.CommonTabLayout_tl_tab_space_equal, true);
mTabWidth = ta.getDimension(R.styleable.CommonTabLayout_tl_tab_width, dp2px(-1));
mTabPadding = ta.getDimension(R.styleable.CommonTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(10));
ta.recycle();
}
public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
if (tabEntitys == null || tabEntitys.size() == 0) {
throw new IllegalStateException("TabEntitys can not be NULL or EMPTY !");
}
this.mTabEntitys.clear();
this.mTabEntitys.addAll(tabEntitys);
notifyDataSetChanged();
}
/** 关联数据支持同时切换fragments */
public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
setTabData(tabEntitys);
}
/** 更新数据 */
public void notifyDataSetChanged() {
mTabsContainer.removeAllViews();
this.mTabCount = mTabEntitys.size();
View tabView;
for (int i = 0; i < mTabCount; i++) {
if (mIconGravity == Gravity.LEFT) {
tabView = View.inflate(mContext, R.layout.layout_tab_left, null);
} else if (mIconGravity == Gravity.RIGHT) {
tabView = View.inflate(mContext, R.layout.layout_tab_right, null);
} else if (mIconGravity == Gravity.BOTTOM) {
tabView = View.inflate(mContext, R.layout.layout_tab_bottom, null);
} else {
tabView = View.inflate(mContext, R.layout.layout_tab_top, null);
}
tabView.setTag(i);
addTab(i, tabView);
}
updateTabStyles();
}
/** 创建并添加tab */
private void addTab(final int position, View tabView) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tv_tab_title.setText(mTabEntitys.get(position).getTabTitle());
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
iv_tab_icon.setImageResource(mTabEntitys.get(position).getTabUnselectedIcon());
tabView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int position = (Integer) v.getTag();
if (mCurrentTab != position) {
setCurrentTab(position);
if (mListener != null) {
mListener.onTabSelect(position);
}
} else {
if (mListener != null) {
mListener.onTabReselect(position);
}
}
}
});
/** 每一个Tab的布局参数 */
LinearLayout.LayoutParams lp_tab = mTabSpaceEqual ?
new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f) :
new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
if (mTabWidth > 0) {
lp_tab = new LinearLayout.LayoutParams((int) mTabWidth, LayoutParams.MATCH_PARENT);
}
mTabsContainer.addView(tabView, position, lp_tab);
}
private void updateTabStyles() {
for (int i = 0; i < mTabCount; i++) {
View tabView = mTabsContainer.getChildAt(i);
tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
// tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
if (mTextAllCaps) {
tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
}
if (mTextBold) {
tv_tab_title.getPaint().setFakeBoldText(mTextBold);
}
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
if (mIconVisible) {
iv_tab_icon.setVisibility(View.VISIBLE);
CustomTabEntity tabEntity = mTabEntitys.get(i);
iv_tab_icon.setImageResource(i == mCurrentTab ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth,
mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight);
if (mIconGravity == Gravity.LEFT) {
lp.rightMargin = (int) mIconMargin;
} else if (mIconGravity == Gravity.RIGHT) {
lp.leftMargin = (int) mIconMargin;
} else if (mIconGravity == Gravity.BOTTOM) {
lp.topMargin = (int) mIconMargin;
} else {
lp.bottomMargin = (int) mIconMargin;
}
iv_tab_icon.setLayoutParams(lp);
} else {
iv_tab_icon.setVisibility(View.GONE);
}
}
}
private void updateTabSelection(int position) {
for (int i = 0; i < mTabCount; ++i) {
View tabView = mTabsContainer.getChildAt(i);
final boolean isSelect = i == position;
TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
CustomTabEntity tabEntity = mTabEntitys.get(i);
iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
}
}
private void calcOffset() {
final View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
mCurrentP.left = currentTabView.getLeft();
mCurrentP.right = currentTabView.getRight();
final View lastTabView = mTabsContainer.getChildAt(this.mLastTab);
mLastP.left = lastTabView.getLeft();
mLastP.right = lastTabView.getRight();
// Log.d("AAA", "mLastP--->" + mLastP.left + "&" + mLastP.right);
// Log.d("AAA", "mCurrentP--->" + mCurrentP.left + "&" + mCurrentP.right);
if (mLastP.left == mCurrentP.left && mLastP.right == mCurrentP.right) {
invalidate();
} else {
mValueAnimator.setObjectValues(mLastP, mCurrentP);
if (mIndicatorBounceEnable) {
mValueAnimator.setInterpolator(mInterpolator);
}
if (mIndicatorAnimDuration < 0) {
mIndicatorAnimDuration = mIndicatorBounceEnable ? 500 : 250;
}
mValueAnimator.setDuration(mIndicatorAnimDuration);
mValueAnimator.start();
}
}
private void calcIndicatorRect() {
View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
float left = currentTabView.getLeft();
float right = currentTabView.getRight();
mIndicatorRect.left = (int) left;
mIndicatorRect.right = (int) right;
if (mIndicatorWidth < 0) { //indicatorWidth小于0时,原jpardogo's PagerSlidingTabStrip
} else {//indicatorWidth大于0时,圆角矩形以及三角形
float indicatorLeft = currentTabView.getLeft() + (currentTabView.getWidth() - mIndicatorWidth) / 2;
mIndicatorRect.left = (int) indicatorLeft;
mIndicatorRect.right = (int) (mIndicatorRect.left + mIndicatorWidth);
}
}
@Override
public void onAnimationUpdate(ValueAnimator animation) {
View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
IndicatorPoint p = (IndicatorPoint) animation.getAnimatedValue();
mIndicatorRect.left = (int) p.left;
mIndicatorRect.right = (int) p.right;
if (mIndicatorWidth < 0) { //indicatorWidth小于0时,原jpardogo's PagerSlidingTabStrip
} else {//indicatorWidth大于0时,圆角矩形以及三角形
float indicatorLeft = p.left + (currentTabView.getWidth() - mIndicatorWidth) / 2;
mIndicatorRect.left = (int) indicatorLeft;
mIndicatorRect.right = (int) (mIndicatorRect.left + mIndicatorWidth);
}
invalidate();
}
private boolean mIsFirstDraw = true;
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || mTabCount <= 0) {
return;
}
int height = getHeight();
int paddingLeft = getPaddingLeft();
// draw divider
if (mDividerWidth > 0) {
mDividerPaint.setStrokeWidth(mDividerWidth);
mDividerPaint.setColor(mDividerColor);
for (int i = 0; i < mTabCount - 1; i++) {
View tab = mTabsContainer.getChildAt(i);
canvas.drawLine(paddingLeft + tab.getRight(), mDividerPadding, paddingLeft + tab.getRight(), height - mDividerPadding, mDividerPaint);
}
}
// draw underline
if (mUnderlineHeight > 0) {
mRectPaint.setColor(mUnderlineColor);
if (mUnderlineGravity == Gravity.BOTTOM) {
canvas.drawRect(paddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + paddingLeft, height, mRectPaint);
} else {
canvas.drawRect(paddingLeft, 0, mTabsContainer.getWidth() + paddingLeft, mUnderlineHeight, mRectPaint);
}
}
//draw indicator line
if (mIndicatorAnimEnable) {
if (mIsFirstDraw) {
mIsFirstDraw = false;
calcIndicatorRect();
}
} else {
calcIndicatorRect();
}
if (mIndicatorStyle == STYLE_TRIANGLE) {
if (mIndicatorHeight > 0) {
mTrianglePaint.setColor(mIndicatorColor);
mTrianglePath.reset();
mTrianglePath.moveTo(paddingLeft + mIndicatorRect.left, height);
mTrianglePath.lineTo(paddingLeft + mIndicatorRect.left / 2 + mIndicatorRect.right / 2, height - mIndicatorHeight);
mTrianglePath.lineTo(paddingLeft + mIndicatorRect.right, height);
mTrianglePath.close();
canvas.drawPath(mTrianglePath, mTrianglePaint);
}
} else if (mIndicatorStyle == STYLE_BLOCK) {
if (mIndicatorHeight < 0) {
mIndicatorHeight = height - mIndicatorMarginTop - mIndicatorMarginBottom;
} else {
}
if (mIndicatorHeight > 0) {
if (mIndicatorCornerRadius < 0 || mIndicatorCornerRadius > mIndicatorHeight / 2) {
mIndicatorCornerRadius = mIndicatorHeight / 2;
}
mIndicatorDrawable.setColor(mIndicatorColor);
mIndicatorDrawable.setBounds(paddingLeft + (int) mIndicatorMarginLeft + mIndicatorRect.left,
(int) mIndicatorMarginTop, (int) (paddingLeft + mIndicatorRect.right - mIndicatorMarginRight),
(int) (mIndicatorMarginTop + mIndicatorHeight));
mIndicatorDrawable.setCornerRadius(mIndicatorCornerRadius);
mIndicatorDrawable.draw(canvas);
}
} else {
/* mRectPaint.setColor(mIndicatorColor);
calcIndicatorRect();
canvas.drawRect(getPaddingLeft() + mIndicatorRect.left, getHeight() - mIndicatorHeight,
mIndicatorRect.right + getPaddingLeft(), getHeight(), mRectPaint);*/
if (mIndicatorHeight > 0) {
mIndicatorDrawable.setColor(mIndicatorColor);
if (mIndicatorGravity == Gravity.BOTTOM) {
mIndicatorDrawable.setBounds(paddingLeft + (int) mIndicatorMarginLeft + mIndicatorRect.left,
height - (int) mIndicatorHeight - (int) mIndicatorMarginBottom,
paddingLeft + mIndicatorRect.right - (int) mIndicatorMarginRight,
height - (int) mIndicatorMarginBottom);
} else {
mIndicatorDrawable.setBounds(paddingLeft + (int) mIndicatorMarginLeft + mIndicatorRect.left,
(int) mIndicatorMarginTop,
paddingLeft + mIndicatorRect.right - (int) mIndicatorMarginRight,
(int) mIndicatorHeight + (int) mIndicatorMarginTop);
}
mIndicatorDrawable.setCornerRadius(mIndicatorCornerRadius);
mIndicatorDrawable.draw(canvas);
}
}
}
//setter and getter
public void setCurrentTab(int currentTab) {
mLastTab = this.mCurrentTab;
this.mCurrentTab = currentTab;
updateTabSelection(currentTab);
if (mFragmentChangeManager != null) {
mFragmentChangeManager.setFragments(currentTab);
}
if (mIndicatorAnimEnable) {
calcOffset();
} else {
invalidate();
}
}
public void setIndicatorStyle(int indicatorStyle) {
this.mIndicatorStyle = indicatorStyle;
invalidate();
}
public void setTabPadding(float tabPadding) {
this.mTabPadding = dp2px(tabPadding);
updateTabStyles();
}
public void setTabSpaceEqual(boolean tabSpaceEqual) {
this.mTabSpaceEqual = tabSpaceEqual;
updateTabStyles();
}
public void setTabWidth(float tabWidth) {
this.mTabWidth = dp2px(tabWidth);
updateTabStyles();
}
public void setIndicatorColor(int indicatorColor) {
this.mIndicatorColor = indicatorColor;
invalidate();
}
public void setIndicatorHeight(float indicatorHeight) {
this.mIndicatorHeight = dp2px(indicatorHeight);
invalidate();
}
public void setIndicatorWidth(float indicatorWidth) {
this.mIndicatorWidth = dp2px(indicatorWidth);
invalidate();
}
public void setIndicatorCornerRadius(float indicatorCornerRadius) {
this.mIndicatorCornerRadius = dp2px(indicatorCornerRadius);
invalidate();
}
public void setIndicatorGravity(int indicatorGravity) {
this.mIndicatorGravity = indicatorGravity;
invalidate();
}
public void setIndicatorMargin(float indicatorMarginLeft, float indicatorMarginTop,
float indicatorMarginRight, float indicatorMarginBottom) {
this.mIndicatorMarginLeft = dp2px(indicatorMarginLeft);
this.mIndicatorMarginTop = dp2px(indicatorMarginTop);
this.mIndicatorMarginRight = dp2px(indicatorMarginRight);
this.mIndicatorMarginBottom = dp2px(indicatorMarginBottom);
invalidate();
}
public void setIndicatorAnimDuration(long indicatorAnimDuration) {
this.mIndicatorAnimDuration = indicatorAnimDuration;
}
public void setIndicatorAnimEnable(boolean indicatorAnimEnable) {
this.mIndicatorAnimEnable = indicatorAnimEnable;
}
public void setIndicatorBounceEnable(boolean indicatorBounceEnable) {
this.mIndicatorBounceEnable = indicatorBounceEnable;
}
public void setUnderlineColor(int underlineColor) {
this.mUnderlineColor = underlineColor;
invalidate();
}
public void setUnderlineHeight(float underlineHeight) {
this.mUnderlineHeight = dp2px(underlineHeight);
invalidate();
}
public void setUnderlineGravity(int underlineGravity) {
this.mUnderlineGravity = underlineGravity;
invalidate();
}
public void setDividerColor(int dividerColor) {
this.mDividerColor = dividerColor;
invalidate();
}
public void setDividerWidth(float dividerWidth) {
this.mDividerWidth = dp2px(dividerWidth);
invalidate();
}
public void setDividerPadding(float dividerPadding) {
this.mDividerPadding = dp2px(dividerPadding);
invalidate();
}
public void setTextsize(float textsize) {
this.mTextsize = sp2px(textsize);
updateTabStyles();
}
public void setTextSelectColor(int textSelectColor) {
this.mTextSelectColor = textSelectColor;
updateTabStyles();
}
public void setTextUnselectColor(int textUnselectColor) {
this.mTextUnselectColor = textUnselectColor;
updateTabStyles();
}
public void setTextBold(boolean textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
public void setIconVisible(boolean iconVisible) {
this.mIconVisible = iconVisible;
updateTabStyles();
}
public void setIconGravity(int iconGravity) {
this.mIconGravity = iconGravity;
notifyDataSetChanged();
}
public void setIconWidth(float iconWidth) {
this.mIconWidth = dp2px(iconWidth);
updateTabStyles();
}
public void setIconHeight(float iconHeight) {
this.mIconHeight = dp2px(iconHeight);
updateTabStyles();
}
public void setIconMargin(float iconMargin) {
this.mIconMargin = dp2px(iconMargin);
updateTabStyles();
}
public void setTextAllCaps(boolean textAllCaps) {
this.mTextAllCaps = textAllCaps;
updateTabStyles();
}
public int getTabCount() {
return mTabCount;
}
public int getCurrentTab() {
return mCurrentTab;
}
public int getIndicatorStyle() {
return mIndicatorStyle;
}
public float getTabPadding() {
return mTabPadding;
}
public boolean isTabSpaceEqual() {
return mTabSpaceEqual;
}
public float getTabWidth() {
return mTabWidth;
}
public int getIndicatorColor() {
return mIndicatorColor;
}
public float getIndicatorHeight() {
return mIndicatorHeight;
}
public float getIndicatorWidth() {
return mIndicatorWidth;
}
public float getIndicatorCornerRadius() {
return mIndicatorCornerRadius;
}
public float getIndicatorMarginLeft() {
return mIndicatorMarginLeft;
}
public float getIndicatorMarginTop() {
return mIndicatorMarginTop;
}
public float getIndicatorMarginRight() {
return mIndicatorMarginRight;
}
public float getIndicatorMarginBottom() {
return mIndicatorMarginBottom;
}
public long getIndicatorAnimDuration() {
return mIndicatorAnimDuration;
}
public boolean isIndicatorAnimEnable() {
return mIndicatorAnimEnable;
}
public boolean isIndicatorBounceEnable() {
return mIndicatorBounceEnable;
}
public int getUnderlineColor() {
return mUnderlineColor;
}
public float getUnderlineHeight() {
return mUnderlineHeight;
}
public int getDividerColor() {
return mDividerColor;
}
public float getDividerWidth() {
return mDividerWidth;
}
public float getDividerPadding() {
return mDividerPadding;
}
public float getTextsize() {
return mTextsize;
}
public int getTextSelectColor() {
return mTextSelectColor;
}
public int getTextUnselectColor() {
return mTextUnselectColor;
}
public boolean isTextBold() {
return mTextBold;
}
public boolean isTextAllCaps() {
return mTextAllCaps;
}
public int getIconGravity() {
return mIconGravity;
}
public float getIconWidth() {
return mIconWidth;
}
public float getIconHeight() {
return mIconHeight;
}
public float getIconMargin() {
return mIconMargin;
}
public boolean isIconVisible() {
return mIconVisible;
}
public ImageView getIconView(int tab) {
View tabView = mTabsContainer.getChildAt(tab);
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
return iv_tab_icon;
}
public TextView getTitleView(int tab) {
View tabView = mTabsContainer.getChildAt(tab);
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
return tv_tab_title;
}
//setter and getter
// show MsgTipView
private Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private SparseArray<Boolean> mInitSetMap = new SparseArray<>();
/**
* 显示未读消息
*
* @param position 显示tab位置
* @param num num小于等于0显示红点,num大于0显示数字
*/
public void showMsg(int position, int num) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
UnreadMsgUtils.show(tipView, num);
if (mInitSetMap.get(position) != null && mInitSetMap.get(position)) {
return;
}
if (!mIconVisible) {
setMsgMargin(position, 2, 2);
} else {
setMsgMargin(position, 0,
mIconGravity == Gravity.LEFT || mIconGravity == Gravity.RIGHT ? 4 : 0);
}
mInitSetMap.put(position, true);
}
}
/**
* 显示未读红点
*
* @param position 显示tab位置
*/
public void showDot(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
showMsg(position, 0);
}
public void hideMsg(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
tipView.setVisibility(View.GONE);
}
}
/**
* 设置提示红点偏移,注意
* 1.控件为固定高度:参照点为tab内容的右上角
* 2.控件高度不固定(WRAP_CONTENT):参照点为tab内容的右上角,此时高度已是红点的最高显示范围,所以这时bottomPadding其实就是topPadding
*/
public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
mTextPaint.setTextSize(mTextsize);
float textWidth = mTextPaint.measureText(tv_tab_title.getText().toString());
float textHeight = mTextPaint.descent() - mTextPaint.ascent();
MarginLayoutParams lp = (MarginLayoutParams) tipView.getLayoutParams();
float iconH = mIconHeight;
float margin = 0;
if (mIconVisible) {
if (iconH <= 0) {
iconH = mContext.getResources().getDrawable(mTabEntitys.get(position).getTabSelectedIcon()).getIntrinsicHeight();
}
margin = mIconMargin;
}
if (mIconGravity == Gravity.TOP || mIconGravity == Gravity.BOTTOM) {
lp.leftMargin = dp2px(leftPadding);
lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight - iconH - margin) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
} else {
lp.leftMargin = dp2px(leftPadding);
lp.topMargin = mHeight > 0 ? (int) (mHeight - Math.max(textHeight, iconH)) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
}
tipView.setLayoutParams(lp);
}
}
/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 */
public MsgView getMsgView(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
return tipView;
}
private OnTabSelectListener mListener;
public void setOnTabSelectListener(OnTabSelectListener listener) {
this.mListener = listener;
}
@Override
protected Parcelable onSaveInstanceState() {
Bundle bundle = new Bundle();
bundle.putParcelable("instanceState", super.onSaveInstanceState());
bundle.putInt("mCurrentTab", mCurrentTab);
return bundle;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
mCurrentTab = bundle.getInt("mCurrentTab");
state = bundle.getParcelable("instanceState");
if (mCurrentTab != 0 && mTabsContainer.getChildCount() > 0) {
updateTabSelection(mCurrentTab);
}
}
super.onRestoreInstanceState(state);
}
class IndicatorPoint {
public float left;
public float right;
}
private IndicatorPoint mCurrentP = new IndicatorPoint();
private IndicatorPoint mLastP = new IndicatorPoint();
class PointEvaluator implements TypeEvaluator<IndicatorPoint> {
@Override
public IndicatorPoint evaluate(float fraction, IndicatorPoint startValue, IndicatorPoint endValue) {
float left = startValue.left + fraction * (endValue.left - startValue.left);
float right = startValue.right + fraction * (endValue.right - startValue.right);
IndicatorPoint point = new IndicatorPoint();
point.left = left;
point.right = right;
return point;
}
}
protected int dp2px(float dp) {
final float scale = mContext.getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
protected int sp2px(float sp) {
final float scale = this.mContext.getResources().getDisplayMetrics().scaledDensity;
return (int) (sp * scale + 0.5f);
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/listener/CustomTabEntity.java
================================================
package sunger.net.org.dropmenu.tab.listener;
import android.view.View;
import android.view.ViewGroup;
public interface CustomTabEntity {
String getTabTitle();
int getTabSelectedIcon();
int getTabUnselectedIcon();
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/listener/OnTabSelectListener.java
================================================
package sunger.net.org.dropmenu.tab.listener;
public interface OnTabSelectListener {
void onTabSelect(int position);
void onTabReselect(int position);
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/utils/FragmentChangeManager.java
================================================
package sunger.net.org.dropmenu.tab.utils;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import java.util.ArrayList;
public class FragmentChangeManager {
private FragmentManager mFragmentManager;
private int mContainerViewId;
/** Fragment切换数组 */
private ArrayList<Fragment> mFragments;
/** 当前选中的Tab */
private int mCurrentTab;
public FragmentChangeManager(FragmentManager fm, int containerViewId, ArrayList<Fragment> fragments) {
this.mFragmentManager = fm;
this.mContainerViewId = containerViewId;
this.mFragments = fragments;
initFragments();
}
/** 初始化fragments */
private void initFragments() {
for (Fragment fragment : mFragments) {
mFragmentManager.beginTransaction().add(mContainerViewId, fragment).hide(fragment).commit();
}
setFragments(0);
}
/** 界面切换控制 */
public void setFragments(int index) {
for (int i = 0; i < mFragments.size(); i++) {
FragmentTransaction ft = mFragmentManager.beginTransaction();
Fragment fragment = mFragments.get(i);
if (i == index) {
ft.show(fragment);
} else {
ft.hide(fragment);
}
ft.commit();
}
mCurrentTab = index;
}
public int getCurrentTab() {
return mCurrentTab;
}
public Fragment getCurrentFragment() {
return mFragments.get(mCurrentTab);
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/utils/UnreadMsgUtils.java
================================================
package sunger.net.org.dropmenu.tab.utils;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.RelativeLayout;
import sunger.net.org.dropmenu.tab.widget.MsgView;
/**
* 未读消息提示View,显示小红点或者带有数字的红点:
* 数字一位,圆
* 数字两位,圆角矩形,圆角是高度的一半
* 数字超过两位,显示99+
*/
public class UnreadMsgUtils {
public static void show(MsgView msgView, int num) {
if (msgView == null) {
return;
}
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) msgView.getLayoutParams();
DisplayMetrics dm = msgView.getResources().getDisplayMetrics();
msgView.setVisibility(View.VISIBLE);
if (num <= 0) {//圆点,设置默认宽高
msgView.setStrokeWidth(0);
msgView.setText("");
lp.width = (int) (5 * dm.density);
lp.height = (int) (5 * dm.density);
msgView.setLayoutParams(lp);
} else {
lp.height = (int) (18 * dm.density);
if (num > 0 && num < 10) {//圆
lp.width = (int) (18 * dm.density);
msgView.setText(num + "");
} else if (num > 9 && num < 100) {//圆角矩形,圆角是高度的一半,设置默认padding
lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
msgView.setText(num + "");
} else {//数字超过两位,显示99+
lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
msgView.setText("99+");
}
msgView.setLayoutParams(lp);
}
}
public static void setSize(MsgView rtv, int size) {
if (rtv == null) {
return;
}
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rtv.getLayoutParams();
lp.width = size;
lp.height = size;
rtv.setLayoutParams(lp);
}
}
================================================
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/widget/MsgView.java
================================================
package sunger.net.org.dropmenu.tab.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.TextView;
import sunger.net.org.dropmenu.R;
/** 用于需要圆角矩形框背景的TextView的情况,减少直接使用TextView时引入的shape资源文件 */
public class MsgView extends TextView {
private Context context;
private GradientDrawable gd_background = new GradientDrawable();
private int backgroundColor;
private int cornerRadius;
private int strokeWidth;
private int strokeColor;
private boolean isRadiusHalfHeight;
private boolean isWidthHeightEqual;
public MsgView(Context context) {
this(context, null);
}
public MsgView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MsgView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
obtainAttributes(context, attrs);
}
private void obtainAttributes(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MsgView);
backgroundColor = ta.getColor(R.styleable.MsgView_mv_backgroundColor, Color.TRANSPARENT);
cornerRadius = ta.getDimensionPixelSize(R.styleable.MsgView_mv_cornerRadius, 0);
strokeWidth = ta.getDimensionPixelSize(R.styleable.MsgView_mv_strokeWidth, 0);
strokeColor = ta.getColor(R.styleable.MsgView_mv_strokeColor, Color.TRANSPARENT);
isRadiusHalfHeight = ta.getBoolean(R.styleable.MsgView_mv_isRadiusHalfHeight, false);
isWidthHeightEqual = ta.getBoolean(R.styleable.MsgView_mv_isWidthHeightEqual, false);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isWidthHeightEqual() && getWidth() > 0 && getHeight() > 0) {
int max = Math.max(getWidth(), getHeight());
int measureSpec = MeasureSpec.makeMeasureSpec(max, MeasureSpec.EXACTLY);
super.onMeasure(measureSpec, measureSpec);
return;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (isRadiusHalfHeight()) {
setCornerRadius(getHeight() / 2);
} else {
setBgSelector();
}
}
public void setBackgroundColor(int backgroundColor) {
this.backgroundColor = backgroundColor;
setBgSelector();
}
public void setCornerRadius(int cornerRadius) {
this.cornerRadius = dp2px(cornerRadius);
setBgSelector();
}
public void setStrokeWidth(int strokeWidth) {
this.strokeWidth = dp2px(strokeWidth);
setBgSelector();
}
public void setStrokeColor(int strokeColor) {
this.strokeColor = strokeColor;
setBgSelector();
}
public void setIsRadiusHalfHeight(boolean isRadiusHalfHeight) {
this.isRadiusHalfHeight = isRadiusHalfHeight;
setBgSelector();
}
public void setIsWidthHeightEqual(boolean isWidthHeightEqual) {
this.isWidthHeightEqual = isWidthHeightEqual;
setBgSelector();
}
public int getBackgroundColor() {
return backgroundColor;
}
public int getCornerRadius() {
return cornerRadius;
}
public int getStrokeWidth() {
return strokeWidth;
}
public int getStrokeColor() {
return strokeColor;
}
public boolean isRadiusHalfHeight() {
return isRadiusHalfHeight;
}
public boolean isWidthHeightEqual() {
return isWidthHeightEqual;
}
protected int dp2px(float dp) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
protected int sp2px(float sp) {
final float scale = this.context.getResources().getDisplayMetrics().scaledDensity;
return (int) (sp * scale + 0.5f);
}
private void setDrawable(GradientDrawable gd, int color, int strokeColor) {
gd.setColor(color);
gd.setCornerRadius(cornerRadius);
gd.setStroke(strokeWidth, strokeColor);
}
public void setBgSelector() {
StateListDrawable bg = new StateListDrawable();
setDrawable(gd_background, backgroundColor, strokeColor);
bg.addState(new int[]{-android.R.attr.state_pressed}, gd_background);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {//16
setBackground(bg);
} else {
//noinspection deprecation
setBackgroundDrawable(bg);
}
}
}
================================================
FILE: app/src/main/res/drawable/check_bg.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="2dp"/>
<stroke android:width="1dp" android:color="@color/drop_down_selected"/>
<solid android:color="@color/white"/>
</shape>
================================================
FILE: app/src/main/res/drawable/uncheck_bg.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="2dp"/>
<stroke android:width="1dp" android:color="@color/gray"/>
<solid android:color="@color/white"/>
</shape>
================================================
FILE: app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tl="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<sunger.net.org.dropmenu.tab.CommonTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#ffffff"
tl:tl_iconGravity="LEFT"
tl:tl_iconHeight="18dp"
tl:tl_iconMargin="5dp"
tl:tl_iconWidth="18dp"
tl:tl_tab_space_equal="true"
tl:tl_textSelectColor="#ff8500"
tl:tl_textUnselectColor="#4f4f4f"
tl:tl_textsize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#edeeef"></View>
<include layout="@layout/content_main" />
</LinearLayout>
================================================
FILE: app/src/main/res/layout/content_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<org.net.sunger.widget.DropDownLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dropdown"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/activity_main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
></android.support.v7.widget.RecyclerView>
</RelativeLayout>
<org.net.sunger.widget.MaskView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88838685" />
<org.net.sunger.widget.MenuLayout
android:id="@+id/menuLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"></org.net.sunger.widget.MenuLayout>
</org.net.sunger.widget.DropDownLayout>
================================================
FILE: app/src/main/res/layout/item_default_drop_down.xml
================================================
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
tools:context="com.car.cslm.widget.drop_down_menu.DefaultDropDownAdapter">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:gravity="center"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="10dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/gray"/>
</LinearLayout>
================================================
FILE: app/src/main/res/layout/layout_tab.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:singleLine="true"/>
<com.flyco.tablayout.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</RelativeLayout>
================================================
FILE: app/src/main/res/layout/layout_tab_bottom.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<com.flyco.tablayout.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</RelativeLayout>
================================================
FILE: app/src/main/res/layout/layout_tab_left.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" />
</LinearLayout>
<sunger.net.org.dropmenu.tab.widget.MsgView xmlns:mv="http://schemas.android.com/apk/res-auto"
android:id="@+id/rtv_msg_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp" />
<View
android:layout_alignParentRight="true"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:background="#f0f0f0"></View>
</RelativeLayout>
================================================
FILE: app/src/main/res/layout/layout_tab_right.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<sunger.net.org.dropmenu.tab.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</RelativeLayout>
================================================
FILE: app/src/main/res/layout/layout_tab_segment.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
<sunger.net.org.dropmenu.tab.widget.MsgView
android:layout_toRightOf="@+id/ll_tap"
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</RelativeLayout>
================================================
FILE: app/src/main/res/layout/layout_tab_top.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
<sunger.net.org.dropmenu.tab.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</RelativeLayout>
================================================
FILE: app/src/main/res/menu/menu_main.xml
================================================
<menu 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"
tools:context="sunger.net.org.dropmenu.MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
================================================
FILE: app/src/main/res/values/attrs.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- indicator -->
<!-- 设置显示器颜色 -->
<attr name="tl_indicator_color" format="color"/>
<!-- 设置显示器高度 -->
<attr name="tl_indicator_height" format="dimension"/>
<!-- 设置显示器固定宽度 -->
<attr name="tl_indicator_width" format="dimension"/>
<!-- 设置显示器margin,当indicator_width大于0,无效 -->
<attr name="tl_indicator_margin_left" format="dimension"/>
<attr name="tl_indicator_margin_top" format="dimension"/>
<attr name="tl_indicator_margin_right" format="dimension"/>
<attr name="tl_indicator_margin_bottom" format="dimension"/>
<!-- 设置显示器圆角弧度-->
<attr name="tl_indicator_corner_radius" format="dimension"/>
<!-- 设置显示器上方还是下方,只对圆角矩形有用-->
<attr name="tl_indicator_gravity" format="enum">
<enum name="TOP" value="48"/>
<enum name="BOTTOM" value="80"/>
</attr>
<!-- 设置显示器为常规|三角形|背景色块|-->
<attr name="tl_indicator_style" format="enum">
<enum name="NORMAL" value="0"/>
<enum name="TRIANGLE" value="1"/>
<enum name="BLOCK" value="2"/>
</attr>
<!-- 设置显示器长度与title一样长,只有在STYLE_NORMAL并且indicatorWidth小于零有效-->
<attr name="tl_indicator_width_equal_title" format="boolean"/>
<!-- 设置显示器支持动画-->
<attr name="tl_indicator_anim_enable" format="boolean"/>
<!-- 设置显示器动画时间-->
<attr name="tl_indicator_anim_duration" format="integer"/>
<!-- 设置显示器支持动画回弹效果-->
<attr name="tl_indicator_bounce_enable" format="boolean"/>
<!-- underline -->
<!-- 设置下划线颜色 -->
<attr name="tl_underline_color" format="color"/>
<!-- 设置下划线高度 -->
<attr name="tl_underline_height" format="dimension"/>
<!-- 设置下划线上方还是下方-->
<attr name="tl_underline_gravity" format="enum">
<enum name="TOP" value="48"/>
<enum name="BOTTOM" value="80"/>
</attr>
<!-- divider -->
<!-- 设置分割线颜色 -->
<attr name="tl_divider_color" format="color"/>
<!-- 设置分割线宽度 -->
<attr name="tl_divider_width" format="dimension"/>
<!-- 设置分割线的paddingTop和paddingBottom -->
<attr name="tl_divider_padding" format="dimension"/>
<!-- tab -->
<!-- 设置tab的paddingLeft和paddingRight -->
<attr name="tl_tab_padding" format="dimension"/>
<!-- 设置tab大小等分 -->
<attr name="tl_tab_space_equal" format="boolean"/>
<!-- 设置tab固定大小 -->
<attr name="tl_tab_width" format="dimension"/>
<!-- title -->
<!-- 设置字体大小 -->
<attr name="tl_textsize" format="dimension"/>
<!-- 设置字体选中颜色 -->
<attr name="tl_textSelectColor" format="color"/>
<!-- 设置字体未选中颜色 -->
<attr name="tl_textUnselectColor" format="color"/>
<!-- 设置字体加粗 -->
<attr name="tl_textBold" format="boolean"/>
<!-- 设置字体全大写 -->
<attr name="tl_textAllCaps" format="boolean"/>
<declare-styleable name="CommonTabLayout">
<!-- indicator -->
<attr name="tl_indicator_color"/>
<attr name="tl_indicator_height"/>
<attr name="tl_indicator_width"/>
<attr name="tl_indicator_margin_left"/>
<attr name="tl_indicator_margin_top"/>
<attr name="tl_indicator_margin_right"/>
<attr name="tl_indicator_margin_bottom"/>
<attr name="tl_indicator_corner_radius"/>
<attr name="tl_indicator_gravity"/>
<attr name="tl_indicator_style"/>
<attr name="tl_indicator_anim_enable"/>
<attr name="tl_indicator_anim_duration"/>
<attr name="tl_indicator_bounce_enable"/>
<!-- underline -->
<attr name="tl_underline_color"/>
<attr name="tl_underline_height"/>
<attr name="tl_underline_gravity"/>
<!-- divider -->
<attr name="tl_divider_color"/>
<attr name="tl_divider_width"/>
<attr name="tl_divider_padding"/>
<!-- tab -->
<attr name="tl_tab_padding"/>
<attr name="tl_tab_space_equal"/>
<attr name="tl_tab_width"/>
<!-- title -->
<attr name="tl_textsize"/>
<attr name="tl_textSelectColor"/>
<attr name="tl_textUnselectColor"/>
<attr name="tl_textBold"/>
<attr name="tl_textAllCaps"/>
<!-- icon -->
<!-- 设置icon宽度 -->
<attr name="tl_iconWidth" format="dimension"/>
<!-- 设置icon高度 -->
<attr name="tl_iconHeight" format="dimension"/>
<!-- 设置icon是否可见 -->
<attr name="tl_iconVisible" format="boolean"/>
<!-- 设置icon显示位置,对应Gravity中常量值 -->
<attr name="tl_iconGravity" format="enum">
<enum name="LEFT" value="3"/>
<enum name="TOP" value="48"/>
<enum name="RIGHT" value="5"/>
<enum name="BOTTOM" value="80"/>
</attr>
<!-- 设置icon与文字间距 -->
<attr name="tl_iconMargin" format="dimension"/>
<attr name="lineVertical" format="boolean"/>
</declare-styleable>
<declare-styleable name="MsgView">
<!-- 圆角矩形背景色 -->
<attr name="mv_backgroundColor" format="color"/>
<!-- 圆角弧度,单位dp-->
<attr name="mv_cornerRadius" format="dimension"/>
<!-- 圆角弧度,单位dp-->
<attr name="mv_strokeWidth" format="dimension"/>
<!-- 圆角边框颜色-->
<attr name="mv_strokeColor" format="color"/>
<!-- 圆角弧度是高度一半-->
<attr name="mv_isRadiusHalfHeight" format="boolean"/>
<!-- 圆角矩形宽高相等,取较宽高中大值-->
<attr name="mv_isWidthHeightEqual" format="boolean"/>
</declare-styleable>
</resources>
================================================
FILE: app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#ffffff</color>
<color name="gray">#cccccc</color>
<color name="drop_down_selected">#ff8500</color>
<color name="drop_down_unselected">#111111</color>
<color name="mask_color">#88888888</color>
<color name="check_bg">#f2f2f2</color>
</resources>
================================================
FILE: app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
================================================
FILE: app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">dropmenu</string>
<string name="action_settings">Settings</string>
</resources>
================================================
FILE: app/src/main/res/values/styles.xml
================================================
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
</resources>
================================================
FILE: app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: app/src/test/java/sunger/net/org/dropmenu/ExampleUnitTest.java
================================================
package sunger.net.org.dropmenu;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: dropdownlayout/.gitignore
================================================
/build
================================================
FILE: dropdownlayout/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.3.4'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
}
publish {
userOrg = 'sunger'
groupId = 'org.sunger.widget.dropdownlayout'
artifactId = 'dropdownlayout'
publishVersion = '0.0.1'
desc = 'Oh hi, this is a nice description for a project, right?'
website = 'https://github.com/sungerk'
}
================================================
FILE: dropdownlayout/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/sunger/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: dropdownlayout/src/androidTest/java/net/org/sunger/dropdownlayout/ApplicationTest.java
================================================
package net.org.sunger.dropdownlayout;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: dropdownlayout/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.org.sunger.dropdownlayout">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
</application>
</manifest>
================================================
FILE: dropdownlayout/src/main/java/org/net/sunger/widget/DropDownLayout.java
================================================
package org.net.sunger.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* Created by sunger on 16/4/16.
*/
public class DropDownLayout extends FrameLayout implements ViewTreeObserver.OnGlobalLayoutListener {
private MaskView mMaskView;
private MenuLayout mMenuLayout;
public DropDownLayout(Context context) {
this(context, null);
}
public DropDownLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DropDownLayout(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public DropDownLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
getViewTreeObserver().addOnGlobalLayoutListener(this);
}
private void findChildView() {
for (int i = 0; i < getChildCount(); i++) {
if (mMaskView!=null&&mMenuLayout!=null)
break;
View childItem = getChildAt(i);
if (childItem instanceof MaskView) {
mMaskView = (MaskView) childItem;
} else if (childItem instanceof MenuLayout) {
mMenuLayout = (MenuLayout) childItem;
}
}
}
@Override
public void onGlobalLayout() {
findChildView();
if (mMaskView == null || mMenuLayout == null) {
throw new IllegalArgumentException("you layout must be contain MaskView MenuLayout");
}
if (Build.VERSION.SDK_INT < 16) {
removeLayoutListenerPre16();
} else {
removeLayoutListenerPost16();
}
mMenuLayout.setVisibility(GONE);
mMaskView.setVisibility(GONE);
mMaskView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
closeMenu();
}
});
}
@SuppressWarnings("deprecation")
private void removeLayoutListenerPre16() {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
@TargetApi(16)
private void removeLayoutListenerPost16() {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
public void showMenuAt(int position) {
if (!mMenuLayout.isShow()) {
mMaskView.show();
mMenuLayout.show();
}
mMenuLayout.setCurrentItem(position);
}
public void closeMenu() {
mMaskView.dissMiss();
mMenuLayout.dissMiss();
}
}
================================================
FILE: dropdownlayout/src/main/java/org/net/sunger/widget/MaskView.java
================================================
package org.net.sunger.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by sunger on 16/4/16.
*/
public class MaskView extends View {
public MaskView(Context context) {
this(context, null);
}
public MaskView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MaskView(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MaskView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public void show() {
setVisibility(VISIBLE);
}
public void dissMiss() {
setVisibility(GONE);
}
}
================================================
FILE: dropdownlayout/src/main/java/org/net/sunger/widget/MenuLayout.java
================================================
package org.net.sunger.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.RelativeLayout;
import net.org.sunger.dropdownlayout.R;
import java.util.List;
/**
* Created by sunger on 16/4/16.
*/
public class MenuLayout extends RelativeLayout {
private Animation animationIn;
private Animation animationOut;
private FragmentManager fragmentManager;
private List<Fragment> fragments;
private int currentItem = 0;
public MenuLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MenuLayout(Context context) {
this(context, null);
}
public MenuLayout(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MenuLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setClickable(true);
}
public void setFragmentManager(FragmentManager fragmentManager) {
this.fragmentManager = fragmentManager;
}
private int getMenuId() {
if (getId() == NO_ID) {
setId(R.id.menu_id);
}
return getId();
}
private void hideLastFragment(FragmentTransaction transaction) {
for (int i = 0; i < fragments.size(); i++) {
if (i != currentItem || !fragments.get(i).isHidden()) {
transaction.hide(fragments.get(i));
}
}
}
public void setCurrentItem(int position) {
currentItem = position;
FragmentTransaction transaction = fragmentManager.beginTransaction();
hideLastFragment(transaction);
transaction.show(fragments.get(position));
transaction.commit();
}
public void bindFragments(List<Fragment> fragmentList) {
this.fragments = fragmentList;
FragmentTransaction transaction = fragmentManager.beginTransaction();
for (Fragment frg : fragments) {
transaction.add(getMenuId(), frg);
}
transaction.commit();
}
public void show() {
if (animationIn == null) {
animationIn = AnimationUtils.loadAnimation(getContext(), R.anim.menu_in);
}
setVisibility(VISIBLE);
setAnimation(animationIn);
animationIn.start();
}
public void dissMiss() {
if (animationOut == null) {
animationOut = AnimationUtils.loadAnimation(getContext(), R.anim.menu_out);
}
setVisibility(GONE);
setAnimation(animationOut);
animationOut.start();
}
public Animation getAnimationIn() {
return animationIn;
}
public void setAnimationIn(Animation animationIn) {
this.animationIn = animationIn;
}
public void setAnimationIn(int animationInResid) {
this.animationIn = AnimationUtils.loadAnimation(getContext(), animationInResid);
}
public Animation getAnimationOut() {
return animationOut;
}
public void setAnimationOut(Animation animationOut) {
this.animationOut = animationOut;
}
public void setAnimationOut(int animationOutResId) {
this.animationOut = AnimationUtils.loadAnimation(getContext(), animationOutResId);
}
public boolean isShow() {
return getVisibility() == VISIBLE;
}
}
================================================
FILE: dropdownlayout/src/main/res/anim/menu_in.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromYDelta="-100%p"
android:toYDelta="0" />
</set>
================================================
FILE: dropdownlayout/src/main/res/anim/menu_out.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromYDelta="0"
android:toYDelta="-100%p" />
</set>
================================================
FILE: dropdownlayout/src/main/res/values/ids.xml
================================================
<resources>
<item type="id" name="menu_id" />
</resources>
================================================
FILE: dropdownlayout/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">DropDownLayout</string>
</resources>
================================================
FILE: dropdownlayout/src/test/java/net/org/sunger/dropdownlayout/ExampleUnitTest.java
================================================
package net.org.sunger.dropdownlayout;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
include ':app', ':DropDownLayout'
gitextract_n4bs7ty7/ ├── .gitignore ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── sunger/ │ │ └── net/ │ │ └── org/ │ │ └── dropmenu/ │ │ └── ApplicationTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── sunger/ │ │ │ └── net/ │ │ │ └── org/ │ │ │ └── dropmenu/ │ │ │ ├── MainActivity.java │ │ │ ├── TabEntity.java │ │ │ ├── adapter/ │ │ │ │ ├── FilterAdapter.java │ │ │ │ └── ShopAdapter.java │ │ │ ├── fragment/ │ │ │ │ ├── FragmentCategory.java │ │ │ │ ├── FragmentFloor.java │ │ │ │ └── FragmentSort.java │ │ │ └── tab/ │ │ │ ├── CommonTabLayout.java │ │ │ ├── listener/ │ │ │ │ ├── CustomTabEntity.java │ │ │ │ └── OnTabSelectListener.java │ │ │ ├── utils/ │ │ │ │ ├── FragmentChangeManager.java │ │ │ │ └── UnreadMsgUtils.java │ │ │ └── widget/ │ │ │ └── MsgView.java │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── check_bg.xml │ │ │ └── uncheck_bg.xml │ │ ├── layout/ │ │ │ ├── activity_main.xml │ │ │ ├── content_main.xml │ │ │ ├── item_default_drop_down.xml │ │ │ ├── layout_tab.xml │ │ │ ├── layout_tab_bottom.xml │ │ │ ├── layout_tab_left.xml │ │ │ ├── layout_tab_right.xml │ │ │ ├── layout_tab_segment.xml │ │ │ └── layout_tab_top.xml │ │ ├── menu/ │ │ │ └── menu_main.xml │ │ ├── values/ │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── sunger/ │ └── net/ │ └── org/ │ └── dropmenu/ │ └── ExampleUnitTest.java ├── build.gradle ├── dropdownlayout/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── net/ │ │ └── org/ │ │ └── sunger/ │ │ └── dropdownlayout/ │ │ └── ApplicationTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── org/ │ │ │ └── net/ │ │ │ └── sunger/ │ │ │ └── widget/ │ │ │ ├── DropDownLayout.java │ │ │ ├── MaskView.java │ │ │ └── MenuLayout.java │ │ └── res/ │ │ ├── anim/ │ │ │ ├── menu_in.xml │ │ │ └── menu_out.xml │ │ └── values/ │ │ ├── ids.xml │ │ └── strings.xml │ └── test/ │ └── java/ │ └── net/ │ └── org/ │ └── sunger/ │ └── dropdownlayout/ │ └── ExampleUnitTest.java ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle
SYMBOL INDEX (213 symbols across 20 files)
FILE: app/src/androidTest/java/sunger/net/org/dropmenu/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: app/src/main/java/sunger/net/org/dropmenu/MainActivity.java
class MainActivity (line 23) | public class MainActivity extends AppCompatActivity {
method onCreate (line 38) | @Override
method updateTabData (line 78) | private void updateTabData() {
method onFilter (line 86) | public void onFilter(int type, String tag) {
FILE: app/src/main/java/sunger/net/org/dropmenu/TabEntity.java
class TabEntity (line 9) | public class TabEntity implements CustomTabEntity {
method TabEntity (line 14) | public TabEntity(String title, int selectedIcon, int unSelectedIcon) {
method getTabTitle (line 20) | @Override
method getTabSelectedIcon (line 25) | @Override
method getTabUnselectedIcon (line 30) | @Override
FILE: app/src/main/java/sunger/net/org/dropmenu/adapter/FilterAdapter.java
class FilterAdapter (line 17) | public class FilterAdapter extends BaseAdapter {
method setCheckItem (line 23) | public void setCheckItem(int position) {
method FilterAdapter (line 28) | public FilterAdapter(Context context, List<String> list) {
method getCount (line 33) | @Override
method getItem (line 38) | @Override
method getItemId (line 43) | @Override
method getView (line 48) | @Override
method fillValue (line 62) | private void fillValue(int position, ViewHolder viewHolder) {
class ViewHolder (line 75) | static class ViewHolder {
method ViewHolder (line 79) | ViewHolder(View view) {
FILE: app/src/main/java/sunger/net/org/dropmenu/adapter/ShopAdapter.java
class ShopAdapter (line 11) | public class ShopAdapter extends RecyclerView.Adapter<ShopAdapter.ShopV...
method onCreateViewHolder (line 14) | @Override
method onBindViewHolder (line 21) | @Override
method getItemCount (line 26) | @Override
class ShopViewHoler (line 31) | public static class ShopViewHoler extends RecyclerView.ViewHolder{
method ShopViewHoler (line 34) | public ShopViewHoler(View itemView) {
FILE: app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentCategory.java
class FragmentCategory (line 20) | public class FragmentCategory extends Fragment {
method onCreate (line 27) | @Override
method onCreateView (line 33) | @Nullable
method onViewCreated (line 40) | @Override
FILE: app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentFloor.java
class FragmentFloor (line 20) | public class FragmentFloor extends Fragment {
method onCreate (line 27) | @Override
method onCreateView (line 33) | @Nullable
method onViewCreated (line 40) | @Override
FILE: app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentSort.java
class FragmentSort (line 20) | public class FragmentSort extends Fragment {
method onCreate (line 27) | @Override
method onCreateView (line 33) | @Nullable
method onViewCreated (line 40) | @Override
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/CommonTabLayout.java
class CommonTabLayout (line 40) | public class CommonTabLayout extends FrameLayout implements ValueAnimato...
method CommonTabLayout (line 110) | public CommonTabLayout(Context context) {
method CommonTabLayout (line 114) | public CommonTabLayout(Context context, AttributeSet attrs) {
method CommonTabLayout (line 118) | public CommonTabLayout(Context context, AttributeSet attrs, int defSty...
method obtainAttributes (line 147) | private void obtainAttributes(Context context, AttributeSet attrs) {
method setTabData (line 192) | public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
method setTabData (line 204) | public void setTabData(ArrayList<CustomTabEntity> tabEntitys, Fragment...
method notifyDataSetChanged (line 210) | public void notifyDataSetChanged() {
method addTab (line 233) | private void addTab(final int position, View tabView) {
method updateTabStyles (line 266) | private void updateTabStyles() {
method updateTabSelection (line 307) | private void updateTabSelection(int position) {
method calcOffset (line 319) | private void calcOffset() {
method calcIndicatorRect (line 346) | private void calcIndicatorRect() {
method onAnimationUpdate (line 364) | @Override
method onDraw (line 384) | @Override
method setCurrentTab (line 480) | public void setCurrentTab(int currentTab) {
method setIndicatorStyle (line 494) | public void setIndicatorStyle(int indicatorStyle) {
method setTabPadding (line 499) | public void setTabPadding(float tabPadding) {
method setTabSpaceEqual (line 504) | public void setTabSpaceEqual(boolean tabSpaceEqual) {
method setTabWidth (line 509) | public void setTabWidth(float tabWidth) {
method setIndicatorColor (line 514) | public void setIndicatorColor(int indicatorColor) {
method setIndicatorHeight (line 519) | public void setIndicatorHeight(float indicatorHeight) {
method setIndicatorWidth (line 524) | public void setIndicatorWidth(float indicatorWidth) {
method setIndicatorCornerRadius (line 529) | public void setIndicatorCornerRadius(float indicatorCornerRadius) {
method setIndicatorGravity (line 534) | public void setIndicatorGravity(int indicatorGravity) {
method setIndicatorMargin (line 539) | public void setIndicatorMargin(float indicatorMarginLeft, float indica...
method setIndicatorAnimDuration (line 548) | public void setIndicatorAnimDuration(long indicatorAnimDuration) {
method setIndicatorAnimEnable (line 552) | public void setIndicatorAnimEnable(boolean indicatorAnimEnable) {
method setIndicatorBounceEnable (line 556) | public void setIndicatorBounceEnable(boolean indicatorBounceEnable) {
method setUnderlineColor (line 560) | public void setUnderlineColor(int underlineColor) {
method setUnderlineHeight (line 565) | public void setUnderlineHeight(float underlineHeight) {
method setUnderlineGravity (line 570) | public void setUnderlineGravity(int underlineGravity) {
method setDividerColor (line 575) | public void setDividerColor(int dividerColor) {
method setDividerWidth (line 580) | public void setDividerWidth(float dividerWidth) {
method setDividerPadding (line 585) | public void setDividerPadding(float dividerPadding) {
method setTextsize (line 590) | public void setTextsize(float textsize) {
method setTextSelectColor (line 595) | public void setTextSelectColor(int textSelectColor) {
method setTextUnselectColor (line 600) | public void setTextUnselectColor(int textUnselectColor) {
method setTextBold (line 605) | public void setTextBold(boolean textBold) {
method setIconVisible (line 610) | public void setIconVisible(boolean iconVisible) {
method setIconGravity (line 615) | public void setIconGravity(int iconGravity) {
method setIconWidth (line 620) | public void setIconWidth(float iconWidth) {
method setIconHeight (line 625) | public void setIconHeight(float iconHeight) {
method setIconMargin (line 630) | public void setIconMargin(float iconMargin) {
method setTextAllCaps (line 635) | public void setTextAllCaps(boolean textAllCaps) {
method getTabCount (line 641) | public int getTabCount() {
method getCurrentTab (line 645) | public int getCurrentTab() {
method getIndicatorStyle (line 649) | public int getIndicatorStyle() {
method getTabPadding (line 653) | public float getTabPadding() {
method isTabSpaceEqual (line 657) | public boolean isTabSpaceEqual() {
method getTabWidth (line 661) | public float getTabWidth() {
method getIndicatorColor (line 665) | public int getIndicatorColor() {
method getIndicatorHeight (line 669) | public float getIndicatorHeight() {
method getIndicatorWidth (line 673) | public float getIndicatorWidth() {
method getIndicatorCornerRadius (line 677) | public float getIndicatorCornerRadius() {
method getIndicatorMarginLeft (line 681) | public float getIndicatorMarginLeft() {
method getIndicatorMarginTop (line 685) | public float getIndicatorMarginTop() {
method getIndicatorMarginRight (line 689) | public float getIndicatorMarginRight() {
method getIndicatorMarginBottom (line 693) | public float getIndicatorMarginBottom() {
method getIndicatorAnimDuration (line 697) | public long getIndicatorAnimDuration() {
method isIndicatorAnimEnable (line 701) | public boolean isIndicatorAnimEnable() {
method isIndicatorBounceEnable (line 705) | public boolean isIndicatorBounceEnable() {
method getUnderlineColor (line 709) | public int getUnderlineColor() {
method getUnderlineHeight (line 713) | public float getUnderlineHeight() {
method getDividerColor (line 717) | public int getDividerColor() {
method getDividerWidth (line 721) | public float getDividerWidth() {
method getDividerPadding (line 725) | public float getDividerPadding() {
method getTextsize (line 729) | public float getTextsize() {
method getTextSelectColor (line 733) | public int getTextSelectColor() {
method getTextUnselectColor (line 737) | public int getTextUnselectColor() {
method isTextBold (line 741) | public boolean isTextBold() {
method isTextAllCaps (line 745) | public boolean isTextAllCaps() {
method getIconGravity (line 749) | public int getIconGravity() {
method getIconWidth (line 753) | public float getIconWidth() {
method getIconHeight (line 757) | public float getIconHeight() {
method getIconMargin (line 761) | public float getIconMargin() {
method isIconVisible (line 765) | public boolean isIconVisible() {
method getIconView (line 770) | public ImageView getIconView(int tab) {
method getTitleView (line 776) | public TextView getTitleView(int tab) {
method showMsg (line 794) | public void showMsg(int position, int num) {
method showDot (line 824) | public void showDot(int position) {
method hideMsg (line 831) | public void hideMsg(int position) {
method setMsgMargin (line 848) | public void setMsgMargin(int position, float leftPadding, float bottom...
method getMsgView (line 883) | public MsgView getMsgView(int position) {
method setOnTabSelectListener (line 894) | public void setOnTabSelectListener(OnTabSelectListener listener) {
method onSaveInstanceState (line 899) | @Override
method onRestoreInstanceState (line 907) | @Override
class IndicatorPoint (line 920) | class IndicatorPoint {
class PointEvaluator (line 928) | class PointEvaluator implements TypeEvaluator<IndicatorPoint> {
method evaluate (line 929) | @Override
method dp2px (line 941) | protected int dp2px(float dp) {
method sp2px (line 946) | protected int sp2px(float sp) {
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/listener/CustomTabEntity.java
type CustomTabEntity (line 6) | public interface CustomTabEntity {
method getTabTitle (line 7) | String getTabTitle();
method getTabSelectedIcon (line 9) | int getTabSelectedIcon();
method getTabUnselectedIcon (line 11) | int getTabUnselectedIcon();
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/listener/OnTabSelectListener.java
type OnTabSelectListener (line 3) | public interface OnTabSelectListener {
method onTabSelect (line 4) | void onTabSelect(int position);
method onTabReselect (line 5) | void onTabReselect(int position);
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/utils/FragmentChangeManager.java
class FragmentChangeManager (line 9) | public class FragmentChangeManager {
method FragmentChangeManager (line 17) | public FragmentChangeManager(FragmentManager fm, int containerViewId, ...
method initFragments (line 25) | private void initFragments() {
method setFragments (line 34) | public void setFragments(int index) {
method getCurrentTab (line 48) | public int getCurrentTab() {
method getCurrentFragment (line 52) | public Fragment getCurrentFragment() {
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/utils/UnreadMsgUtils.java
class UnreadMsgUtils (line 17) | public class UnreadMsgUtils {
method show (line 18) | public static void show(MsgView msgView, int num) {
method setSize (line 50) | public static void setSize(MsgView rtv, int size) {
FILE: app/src/main/java/sunger/net/org/dropmenu/tab/widget/MsgView.java
class MsgView (line 16) | public class MsgView extends TextView {
method MsgView (line 26) | public MsgView(Context context) {
method MsgView (line 30) | public MsgView(Context context, AttributeSet attrs) {
method MsgView (line 34) | public MsgView(Context context, AttributeSet attrs, int defStyleAttr) {
method obtainAttributes (line 40) | private void obtainAttributes(Context context, AttributeSet attrs) {
method onMeasure (line 52) | @Override
method onLayout (line 64) | @Override
method setBackgroundColor (line 75) | public void setBackgroundColor(int backgroundColor) {
method setCornerRadius (line 80) | public void setCornerRadius(int cornerRadius) {
method setStrokeWidth (line 85) | public void setStrokeWidth(int strokeWidth) {
method setStrokeColor (line 90) | public void setStrokeColor(int strokeColor) {
method setIsRadiusHalfHeight (line 95) | public void setIsRadiusHalfHeight(boolean isRadiusHalfHeight) {
method setIsWidthHeightEqual (line 100) | public void setIsWidthHeightEqual(boolean isWidthHeightEqual) {
method getBackgroundColor (line 105) | public int getBackgroundColor() {
method getCornerRadius (line 109) | public int getCornerRadius() {
method getStrokeWidth (line 113) | public int getStrokeWidth() {
method getStrokeColor (line 117) | public int getStrokeColor() {
method isRadiusHalfHeight (line 121) | public boolean isRadiusHalfHeight() {
method isWidthHeightEqual (line 125) | public boolean isWidthHeightEqual() {
method dp2px (line 129) | protected int dp2px(float dp) {
method sp2px (line 134) | protected int sp2px(float sp) {
method setDrawable (line 139) | private void setDrawable(GradientDrawable gd, int color, int strokeCol...
method setBgSelector (line 145) | public void setBgSelector() {
FILE: app/src/test/java/sunger/net/org/dropmenu/ExampleUnitTest.java
class ExampleUnitTest (line 10) | public class ExampleUnitTest {
method addition_isCorrect (line 11) | @Test
FILE: dropdownlayout/src/androidTest/java/net/org/sunger/dropdownlayout/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: dropdownlayout/src/main/java/org/net/sunger/widget/DropDownLayout.java
class DropDownLayout (line 14) | public class DropDownLayout extends FrameLayout implements ViewTreeObser...
method DropDownLayout (line 19) | public DropDownLayout(Context context) {
method DropDownLayout (line 23) | public DropDownLayout(Context context, AttributeSet attrs) {
method DropDownLayout (line 27) | public DropDownLayout(Context context, AttributeSet attrs, int defStyl...
method DropDownLayout (line 31) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
method findChildView (line 37) | private void findChildView() {
method onGlobalLayout (line 49) | @Override
method removeLayoutListenerPre16 (line 72) | @SuppressWarnings("deprecation")
method removeLayoutListenerPost16 (line 77) | @TargetApi(16)
method showMenuAt (line 83) | public void showMenuAt(int position) {
method closeMenu (line 91) | public void closeMenu() {
FILE: dropdownlayout/src/main/java/org/net/sunger/widget/MaskView.java
class MaskView (line 12) | public class MaskView extends View {
method MaskView (line 13) | public MaskView(Context context) {
method MaskView (line 17) | public MaskView(Context context, AttributeSet attrs) {
method MaskView (line 21) | public MaskView(Context context, AttributeSet attrs, int defStyleAttr) {
method MaskView (line 25) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
method show (line 31) | public void show() {
method dissMiss (line 35) | public void dissMiss() {
FILE: dropdownlayout/src/main/java/org/net/sunger/widget/MenuLayout.java
class MenuLayout (line 21) | public class MenuLayout extends RelativeLayout {
method MenuLayout (line 28) | public MenuLayout(Context context, AttributeSet attrs) {
method MenuLayout (line 32) | public MenuLayout(Context context) {
method MenuLayout (line 36) | public MenuLayout(Context context, AttributeSet attrs, int defStyleAtt...
method MenuLayout (line 40) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
method setFragmentManager (line 46) | public void setFragmentManager(FragmentManager fragmentManager) {
method getMenuId (line 50) | private int getMenuId() {
method hideLastFragment (line 57) | private void hideLastFragment(FragmentTransaction transaction) {
method setCurrentItem (line 65) | public void setCurrentItem(int position) {
method bindFragments (line 74) | public void bindFragments(List<Fragment> fragmentList) {
method show (line 85) | public void show() {
method dissMiss (line 94) | public void dissMiss() {
method getAnimationIn (line 104) | public Animation getAnimationIn() {
method setAnimationIn (line 108) | public void setAnimationIn(Animation animationIn) {
method setAnimationIn (line 112) | public void setAnimationIn(int animationInResid) {
method getAnimationOut (line 116) | public Animation getAnimationOut() {
method setAnimationOut (line 120) | public void setAnimationOut(Animation animationOut) {
method setAnimationOut (line 124) | public void setAnimationOut(int animationOutResId) {
method isShow (line 129) | public boolean isShow() {
FILE: dropdownlayout/src/test/java/net/org/sunger/dropdownlayout/ExampleUnitTest.java
class ExampleUnitTest (line 10) | public class ExampleUnitTest {
method addition_isCorrect (line 11) | @Test
Condensed preview — 59 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (112K chars).
[
{
"path": ".gitignore",
"chars": 68,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/*\n.DS_Store\n/build\n/captures\n"
},
{
"path": "README.md",
"chars": 3048,
"preview": "# DropDownLayout\neffect\n\n##How to use?\n###1.co"
},
{
"path": "app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "app/build.gradle",
"chars": 816,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 23\n buildToolsVersion \"23.0.3\"\n\n defaultC"
},
{
"path": "app/proguard-rules.pro",
"chars": 656,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "app/src/androidTest/java/sunger/net/org/dropmenu/ApplicationTest.java",
"chars": 354,
"preview": "package sunger.net.org.dropmenu;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a hr"
},
{
"path": "app/src/main/AndroidManifest.xml",
"chars": 765,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/MainActivity.java",
"chars": 3640,
"preview": "package sunger.net.org.dropmenu;\n\nimport android.os.Bundle;\nimport android.support.v4.app.Fragment;\nimport android.suppo"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/TabEntity.java",
"chars": 732,
"preview": "package sunger.net.org.dropmenu;\n\nimport sunger.net.org.dropmenu.tab.listener.CustomTabEntity;\n\n/**\n * Created by sunger"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/adapter/FilterAdapter.java",
"chars": 2330,
"preview": "package sunger.net.org.dropmenu.adapter;\n\nimport android.content.Context;\nimport android.view.LayoutInflater;\nimport and"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/adapter/ShopAdapter.java",
"chars": 1292,
"preview": "package sunger.net.org.dropmenu.adapter;\n\nimport android.support.v7.widget.RecyclerView;\nimport android.view.View;\nimpor"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentCategory.java",
"chars": 1753,
"preview": "package sunger.net.org.dropmenu.fragment;\n\nimport android.os.Bundle;\nimport android.support.annotation.Nullable;\nimport "
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentFloor.java",
"chars": 1763,
"preview": "package sunger.net.org.dropmenu.fragment;\n\nimport android.os.Bundle;\nimport android.support.annotation.Nullable;\nimport "
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/fragment/FragmentSort.java",
"chars": 1704,
"preview": "package sunger.net.org.dropmenu.fragment;\n\nimport android.os.Bundle;\nimport android.support.annotation.Nullable;\nimport "
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/tab/CommonTabLayout.java",
"chars": 34833,
"preview": "package sunger.net.org.dropmenu.tab;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport andr"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/tab/listener/CustomTabEntity.java",
"chars": 231,
"preview": "package sunger.net.org.dropmenu.tab.listener;\n\nimport android.view.View;\nimport android.view.ViewGroup;\n\npublic interfac"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/tab/listener/OnTabSelectListener.java",
"chars": 161,
"preview": "package sunger.net.org.dropmenu.tab.listener;\n\npublic interface OnTabSelectListener {\n void onTabSelect(int position)"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/tab/utils/FragmentChangeManager.java",
"chars": 1569,
"preview": "package sunger.net.org.dropmenu.tab.utils;\n\nimport android.support.v4.app.Fragment;\nimport android.support.v4.app.Fragme"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/tab/utils/UnreadMsgUtils.java",
"chars": 1975,
"preview": "package sunger.net.org.dropmenu.tab.utils;\n\n\nimport android.util.DisplayMetrics;\nimport android.view.View;\nimport androi"
},
{
"path": "app/src/main/java/sunger/net/org/dropmenu/tab/widget/MsgView.java",
"chars": 4943,
"preview": "package sunger.net.org.dropmenu.tab.widget;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimpo"
},
{
"path": "app/src/main/res/drawable/check_bg.xml",
"chars": 269,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <corners a"
},
{
"path": "app/src/main/res/drawable/uncheck_bg.xml",
"chars": 255,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <corners a"
},
{
"path": "app/src/main/res/layout/activity_main.xml",
"chars": 969,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xml"
},
{
"path": "app/src/main/res/layout/content_main.xml",
"chars": 1211,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<org.net.sunger.widget.DropDownLayout xmlns:android=\"http://schemas.android.com/a"
},
{
"path": "app/src/main/res/layout/item_default_drop_down.xml",
"chars": 891,
"preview": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.andro"
},
{
"path": "app/src/main/res/layout/layout_tab.xml",
"chars": 1056,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "app/src/main/res/layout/layout_tab_bottom.xml",
"chars": 1486,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "app/src/main/res/layout/layout_tab_left.xml",
"chars": 1753,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n an"
},
{
"path": "app/src/main/res/layout/layout_tab_right.xml",
"chars": 1496,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "app/src/main/res/layout/layout_tab_segment.xml",
"chars": 1334,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "app/src/main/res/layout/layout_tab_top.xml",
"chars": 1493,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "app/src/main/res/menu/menu_main.xml",
"chars": 412,
"preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\""
},
{
"path": "app/src/main/res/values/attrs.xml",
"chars": 5386,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <!-- indicator -->\n <!-- 设置显示器颜色 -->\n <attr name=\"tl_indica"
},
{
"path": "app/src/main/res/values/colors.xml",
"chars": 488,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "app/src/main/res/values/dimens.xml",
"chars": 253,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "app/src/main/res/values/strings.xml",
"chars": 124,
"preview": "<resources>\n <string name=\"app_name\">dropmenu</string>\n <string name=\"action_settings\">Settings</string>\n</resourc"
},
{
"path": "app/src/main/res/values/styles.xml",
"chars": 113,
"preview": "<resources>\n\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n </style>\n</resources>\n"
},
{
"path": "app/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "app/src/test/java/sunger/net/org/dropmenu/ExampleUnitTest.java",
"chars": 316,
"preview": "package sunger.net.org.dropmenu;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit test"
},
{
"path": "build.gradle",
"chars": 365,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "dropdownlayout/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "dropdownlayout/build.gradle",
"chars": 1009,
"preview": "apply plugin: 'com.android.library'\napply plugin: 'com.novoda.bintray-release'\nandroid {\n compileSdkVersion 23\n bu"
},
{
"path": "dropdownlayout/proguard-rules.pro",
"chars": 656,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "dropdownlayout/src/androidTest/java/net/org/sunger/dropdownlayout/ApplicationTest.java",
"chars": 360,
"preview": "package net.org.sunger.dropdownlayout;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n *"
},
{
"path": "dropdownlayout/src/main/AndroidManifest.xml",
"chars": 277,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"net.org.sunger.dropdownlayout\">\n\n <"
},
{
"path": "dropdownlayout/src/main/java/org/net/sunger/widget/DropDownLayout.java",
"chars": 2778,
"preview": "package org.net.sunger.widget;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.os.B"
},
{
"path": "dropdownlayout/src/main/java/org/net/sunger/widget/MaskView.java",
"chars": 908,
"preview": "package org.net.sunger.widget;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.os.B"
},
{
"path": "dropdownlayout/src/main/java/org/net/sunger/widget/MenuLayout.java",
"chars": 3723,
"preview": "package org.net.sunger.widget;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.os.B"
},
{
"path": "dropdownlayout/src/main/res/anim/menu_in.xml",
"chars": 225,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n <translate\n"
},
{
"path": "dropdownlayout/src/main/res/anim/menu_out.xml",
"chars": 224,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <translate\n "
},
{
"path": "dropdownlayout/src/main/res/values/ids.xml",
"chars": 64,
"preview": "<resources>\n <item type=\"id\" name=\"menu_id\" />\n</resources>\n"
},
{
"path": "dropdownlayout/src/main/res/values/strings.xml",
"chars": 77,
"preview": "<resources>\n <string name=\"app_name\">DropDownLayout</string>\n</resources>\n"
},
{
"path": "dropdownlayout/src/test/java/net/org/sunger/dropdownlayout/ExampleUnitTest.java",
"chars": 322,
"preview": "package net.org.sunger.dropdownlayout;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on uni"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Wed Oct 21 11:34:03 PDT 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "settings.gradle",
"chars": 34,
"preview": "include ':app', ':DropDownLayout'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the sungerk/DropDownLayout GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 59 files (99.3 KB), approximately 26.2k tokens, and a symbol index with 213 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.