// Path: QuickStart/app/src/main/java/com/magnet/samples/android/quickstart/adapters/ChannelListAdapter.java
// public class ChannelListAdapter extends ArrayAdapter<MMXChannel> {
// 
//     private final LayoutInflater inflater;
// 
//     private class ViewHolder {
//         TextView name;
//         TextView tags;
//         TextView time;
//         ImageView locking;
//     }
// 
//     public ChannelListAdapter(Context context, List<MMXChannel> objects) {
//         super(context, R.layout.item_channel, objects);
//         inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         final ViewHolder viewHolder;
//         if (convertView == null) {
//             convertView = inflater.inflate(R.layout.item_channel, parent, false);
//             viewHolder = new ViewHolder();
//             viewHolder.name = (TextView) convertView.findViewById(R.id.channelItemName);
//             viewHolder.tags = (TextView) convertView.findViewById(R.id.channelItemTags);
//             viewHolder.time = (TextView) convertView.findViewById(R.id.channelItemTime);
//             viewHolder.locking = (ImageView) convertView.findViewById(R.id.channelItemLocking);
//             convertView.setTag(viewHolder);
//         } else {
//             viewHolder = (ViewHolder) convertView.getTag();
//         }
//         MMXChannel channel = getItem(position);
//         viewHolder.name.setText(channel.getName());
//         viewHolder.time.setText(getDateString(channel.getLastTimeActive()));
//         setTagsToLabel(channel, viewHolder.tags);
//         if (channel.isPublic()) {
//             viewHolder.locking.setImageResource(R.mipmap.ic_unlock);
//         } else {
//             viewHolder.locking.setImageResource(R.mipmap.ic_lock);
//         }
//         return convertView;
//     }
// 
//     private String getDateString(Date date) {
//         return DateFormat.getDateTimeInstance().format(date);
//     }
// 
//     private void setTagsToLabel(MMXChannel channel, final TextView tagsLabel) {
//         channel.getTags(new MMXChannel.OnFinishedListener<HashSet<String>>() {
//             @Override
//             public void onSuccess(HashSet<String> strings) {
//                 Logger.debug("get tags", "success");
//                 String text = "Tags : ";
//                 Iterator<String> iterator = strings.iterator();
//                 while (iterator.hasNext()) {
//                     text += iterator.next();
//                     if (iterator.hasNext()) {
//                         text += ", ";
//                     }
//                 }
//                 tagsLabel.setText(text);
//             }
// 
//             @Override
//             public void onFailure(MMXChannel.FailureCode failureCode, Throwable throwable) {
//                 Logger.error("set gags", throwable, "error : ", failureCode);
//             }
//         });
//     }
// 
// }
// 
// Path: QuickStart/app/src/main/java/com/magnet/samples/android/quickstart/util/Logger.java
// public class Logger {
// 
//     private static final String APP_TAG = "QuickStart";
// 
//     public static void debug (Object... args) {
//         debug(null, args);
//     }
// 
//     private static String makeTag(String tag) {
//         String fullTag = APP_TAG;
//         if (tag != null) {
//             fullTag += " - " + tag;
//         }
//         return fullTag;
//     }
// 
//     private static String makeMessage(Object... args) {
//         String msg = "---------";
//         for (int i = 0; i < args.length - 1; i++) {
//             msg += args[i] + ", ";
//         }
//         if (args.length > 0) {
//             msg += args[args.length - 1];
//         }
//         return msg;
//     }
// 
//     public static void debug(String tag, Object... args) {
//         String fullTag = makeTag(tag);
//         String msg = makeMessage(args);
//         Log.d(fullTag, msg);
//     }
// 
//     public static void error (String tag, Throwable throwable, Object... args) {
//         String fullTag = makeTag(tag);
//         String msg = makeMessage(args);
//         Log.e(fullTag, msg, throwable);
//     }
// 
//     public static void error (String tag, Object... args) {
//         String fullTag = makeTag(tag);
//         String msg = makeMessage(args);
//         Log.e(fullTag, msg);
//     }
// 
//     public static void error (String tag, Throwable throwable) {
//         String fullTag = makeTag(tag);
//         Log.e(fullTag, "ERROR", throwable);
//     }
// 
// 
// }


import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import com.magnet.max.android.User;
import com.magnet.mmx.client.api.ListResult;
import com.magnet.mmx.client.api.MMXChannel;
import com.magnet.samples.android.quickstart.R;
import com.magnet.samples.android.quickstart.adapters.ChannelListAdapter;
import com.magnet.samples.android.quickstart.util.Logger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
            case 2:
            case 3:
                searchText.setHint("Prefix");
                break;
            case 4:
                searchText.setHint("Tag1, Tag2, Tag3");
                break;
        }
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {
    }

    @Override
    protected void onPause() {
        if (alertDialog != null && alertDialog.isShowing()) {
            alertDialog.dismiss();
        }
        super.onPause();
    }

    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        if (adapter != null) {
            MMXChannel selectedChannel = adapter.getItem(position);
            if (User.getCurrentUserId().equals(selectedChannel.getOwnerId())) {
                showDialogForDeleteChannel(selectedChannel);
            }
        }
// Path: QuickStart/app/src/main/java/com/magnet/samples/android/quickstart/adapters/ChannelListAdapter.java
// public class ChannelListAdapter extends ArrayAdapter<MMXChannel> {
// 
//     private final LayoutInflater inflater;
// 
//     private class ViewHolder {
//         TextView name;
//         TextView tags;
//         TextView time;
//         ImageView locking;
//     }
// 
//     public ChannelListAdapter(Context context, List<MMXChannel> objects) {
//         super(context, R.layout.item_channel, objects);
//         inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         final ViewHolder viewHolder;
//         if (convertView == null) {
//             convertView = inflater.inflate(R.layout.item_channel, parent, false);
//             viewHolder = new ViewHolder();
//             viewHolder.name = (TextView) convertView.findViewById(R.id.channelItemName);
//             viewHolder.tags = (TextView) convertView.findViewById(R.id.channelItemTags);
//             viewHolder.time = (TextView) convertView.findViewById(R.id.channelItemTime);
//             viewHolder.locking = (ImageView) convertView.findViewById(R.id.channelItemLocking);
//             convertView.setTag(viewHolder);
//         } else {
//             viewHolder = (ViewHolder) convertView.getTag();
//         }
//         MMXChannel channel = getItem(position);
//         viewHolder.name.setText(channel.getName());
//         viewHolder.time.setText(getDateString(channel.getLastTimeActive()));
//         setTagsToLabel(channel, viewHolder.tags);
//         if (channel.isPublic()) {
//             viewHolder.locking.setImageResource(R.mipmap.ic_unlock);
//         } else {
//             viewHolder.locking.setImageResource(R.mipmap.ic_lock);
//         }
//         return convertView;
//     }
// 
//     private String getDateString(Date date) {
//         return DateFormat.getDateTimeInstance().format(date);
//     }
// 
//     private void setTagsToLabel(MMXChannel channel, final TextView tagsLabel) {
//         channel.getTags(new MMXChannel.OnFinishedListener<HashSet<String>>() {
//             @Override
//             public void onSuccess(HashSet<String> strings) {
//                 Logger.debug("get tags", "success");
//                 String text = "Tags : ";
//                 Iterator<String> iterator = strings.iterator();
//                 while (iterator.hasNext()) {
//                     text += iterator.next();
//                     if (iterator.hasNext()) {
//                         text += ", ";
//                     }
//                 }
//                 tagsLabel.setText(text);
//             }
// 
//             @Override
//             public void onFailure(MMXChannel.FailureCode failureCode, Throwable throwable) {
//                 Logger.error("set gags", throwable, "error : ", failureCode);
//             }
//         });
//     }
// 
// }
// 
// Path: QuickStart/app/src/main/java/com/magnet/samples/android/quickstart/util/Logger.java
// public class Logger {
// 
//     private static final String APP_TAG = "QuickStart";
// 
//     public static void debug (Object... args) {
//         debug(null, args);
//     }
// 
//     private static String makeTag(String tag) {
//         String fullTag = APP_TAG;
//         if (tag != null) {
//             fullTag += " - " + tag;
//         }
//         return fullTag;
//     }
// 
//     private static String makeMessage(Object... args) {
//         String msg = "---------";
//         for (int i = 0; i < args.length - 1; i++) {
//             msg += args[i] + ", ";
//         }
//         if (args.length > 0) {
//             msg += args[args.length - 1];
//         }
//         return msg;
//     }
// 
//     public static void debug(String tag, Object... args) {
//         String fullTag = makeTag(tag);
//         String msg = makeMessage(args);
//         Log.d(fullTag, msg);
//     }
// 
//     public static void error (String tag, Throwable throwable, Object... args) {
//         String fullTag = makeTag(tag);
//         String msg = makeMessage(args);
//         Log.e(fullTag, msg, throwable);
//     }
// 
//     public static void error (String tag, Object... args) {
//         String fullTag = makeTag(tag);
//         String msg = makeMessage(args);
//         Log.e(fullTag, msg);
//     }
// 
//     public static void error (String tag, Throwable throwable) {
//         String fullTag = makeTag(tag);
//         Log.e(fullTag, "ERROR", throwable);
//     }
// 
// 
// }


// Path: QuickStart/app/src/main/java/com/magnet/samples/android/quickstart/activities/FindChannelActivity.java
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import com.magnet.max.android.User;
import com.magnet.mmx.client.api.ListResult;
import com.magnet.mmx.client.api.MMXChannel;
import com.magnet.samples.android.quickstart.R;
import com.magnet.samples.android.quickstart.adapters.ChannelListAdapter;
import com.magnet.samples.android.quickstart.util.Logger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;

            case 2:
            case 3:
                searchText.setHint("Prefix");
                break;
            case 4:
                searchText.setHint("Tag1, Tag2, Tag3");
                break;
        }
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {
    }

    @Override
    protected void onPause() {
        if (alertDialog != null && alertDialog.isShowing()) {
            alertDialog.dismiss();
        }
        super.onPause();
    }

    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        if (adapter != null) {
            MMXChannel selectedChannel = adapter.getItem(position);
            if (User.getCurrentUserId().equals(selectedChannel.getOwnerId())) {
                showDialogForDeleteChannel(selectedChannel);
            }
        }
        return false;