Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom menu API #453

Merged
merged 16 commits into from
Sep 11, 2018
Prev Previous commit
Next Next commit
Update menu API“
  • Loading branch information
JoshLipan committed Sep 10, 2018
commit 735c7299d357841e252ebbb4cac808a1948b988b
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.jiguang.imui.chatinput.menu.collection;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -24,9 +25,14 @@ public MenuCollection(Context context) {


protected void addMenu(String menuTag, View menu) {
if(TextUtils.isEmpty(menuTag)){
Log.e(TAG, "Collection custom menu failed,tag is empty.");
return;
}

if (containsKey(menuTag)) {
Log.e(TAG, "Tag " + menuTag + " has been used already!");
Log.e(TAG, "Collection custom menu failed,Tag " + menuTag + " has been used already!");
return;
}
menu.setTag(menuTag);
if (mMenuCollectionChangedListener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@
import cn.jiguang.imui.chatinput.menu.view.MenuFeature;


public class MenuFeatureCollection extends MenuCollection {
public class MenuFeatureCollection extends MenuCollection{


public MenuFeatureCollection(Context context) {

public MenuFeatureCollection(Context context){
super(context);
}

public void addMenuFeature(String tag, int resource) {
public void addMenuFeature(String tag,int resource){
if(resource == -1){
Log.i(TAG,"Menu feature with tag"+tag+" will not be added.");
return;
}
View view = mInflater.inflate(resource, null);
addMenuFeature(tag, view);
addMenuFeature(tag,view);
}

public void addMenuFeature(String tag, View menuFeature) {
public void addMenuFeature(String tag,View menuFeature){
if(menuFeature == null){
Log.i(TAG,"Menu feature with tag"+tag+" will not be added.");
return;
}

if (menuFeature instanceof MenuFeature) {
if(menuFeature instanceof MenuFeature){
menuFeature.setVisibility(View.GONE);
addMenu(tag, menuFeature);
} else {
Log.e(TAG, "Collection menu feature failed exception!");
addMenu(tag,menuFeature);
}else {
Log.e(TAG,"Collection menu feature failed exception!");
}
}

Expand Down