Skip to content

Commit

Permalink
Update menu API“
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLipan committed Sep 10, 2018
1 parent 65683f8 commit 735c729
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
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

0 comments on commit 735c729

Please sign in to comment.