-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add FrameLayout implement for XRadioGroup
- Loading branch information
1 parent
966dba8
commit 7abc680
Showing
1 changed file
with
117 additions
and
0 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
xradiogroup-lib/src/main/java/com/jiakaiyang/xradiogroup/lib/groups/XFrameRadioGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.jiakaiyang.xradiogroup.lib.groups; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.AttrRes; | ||
import android.support.annotation.IdRes; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
|
||
import com.jiakaiyang.xradiogroup.lib.XRadioGroup; | ||
import com.jiakaiyang.xradiogroup.lib.XRadioItem; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by jia on 2017/9/26. | ||
* The XRadioGroup extends FrameLayout | ||
*/ | ||
|
||
public class XFrameRadioGroup extends FrameLayout implements XRadioGroup { | ||
private static final String TAG = "XFrameRadioGroup"; | ||
|
||
private XRadioGroupImpl xRadioGroup; | ||
|
||
|
||
public XFrameRadioGroup(@NonNull Context context) { | ||
this(context, null, 0); | ||
} | ||
|
||
public XFrameRadioGroup(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public XFrameRadioGroup(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
|
||
} | ||
|
||
@Override | ||
public void addView(View child, int index, ViewGroup.LayoutParams params) { | ||
if (child instanceof XRadioItem) { | ||
// TODO: 2017/9/5 add child to the XRadioGroup | ||
} | ||
super.addView(child, index, params); | ||
} | ||
|
||
@Override | ||
public CharSequence getAccessibilityClassName() { | ||
return XLinearRadioGroup.class.getName(); | ||
} | ||
|
||
@Override | ||
protected void onFinishInflate() { | ||
super.onFinishInflate(); | ||
onViewFinishInflate(); | ||
} | ||
|
||
/* public methods */ | ||
|
||
/** | ||
* Just like RadioGroup.check(int checkId) | ||
* | ||
* @param checkId | ||
*/ | ||
public void check(int checkId) { | ||
xRadioGroup.check(checkId); | ||
} | ||
|
||
/** | ||
* @see #check(int) | ||
* @see #clearCheck() | ||
*/ | ||
@IdRes | ||
public int getCheckedRadioButtonId() { | ||
return xRadioGroup.getCheckedRadioButtonId(); | ||
} | ||
|
||
|
||
/** | ||
* Just like RadioGroup.clearCheck(); | ||
* <p> | ||
* this method will not change the fixed items' state. | ||
* | ||
* @see #check(int) | ||
* @see #getCheckedRadioButtonId() | ||
*/ | ||
public void clearCheck() { | ||
xRadioGroup.clearCheck(); | ||
} | ||
|
||
public void setOnCheckedChangeListener(XRadioGroup.OnCheckedChangeListener mOnCheckedChangeListener) { | ||
xRadioGroup.setOnCheckedChangeListener(mOnCheckedChangeListener); | ||
} | ||
|
||
@Override | ||
public void onViewFinishInflate() { | ||
xRadioGroup.onViewFinishInflate(); | ||
} | ||
|
||
/** | ||
* get current fixed items' id. | ||
* | ||
* @return the fixed items' id, if there is no fixed item, this will be null | ||
*/ | ||
public | ||
@Nullable | ||
List<Integer> getFixedItemsId() { | ||
return xRadioGroup.getFixedItemsId(); | ||
} | ||
} |