content: package allen.town.focus.twitter.adapters;
  /*
   *
   *
   * 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.
   */
  
  import android.app.SearchManager;
  import android.content.Context;
  import android.content.Intent;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.TextView;
  
  import allen.town.focus.twitter.R;
  import allen.town.focus.twitter.settings.AppSettings;
  import allen.town.focus.twitter.activities.drawer_activities.discover.trends.SearchedTrendsActivity;
  
  import java.util.ArrayList;
  
  import twitter4j.User;
  
  
  public class TrendsArrayAdapter2 extends ArrayAdapter<User> {
  
      protected Context context;
  
      protected ArrayList<String> text;
  
      private LayoutInflater inflater;
      private AppSettings settings;
  
      public static class ViewHolder {
          public TextView text;
      }
  
      public TrendsArrayAdapter2(Context context, ArrayList<String> text) {
          super(context, R.layout.tweet);
  
          this.context = context;
          this.text = text;
  
          settings = AppSettings.getInstance(context);
          inflater = LayoutInflater.from(context);
  
      }
  
      @Override
      public int getCount() {
          try {
              return text.size();
          } catch (Exception e) {
              return 0;
          }
      }
  
      public View newView(ViewGroup viewGroup) {
          View v;
          final ViewHolder holder;
  
          v = inflater.inflate(R.layout.text, viewGroup, false);
  
          holder = new ViewHolder();
  
          holder.text = (TextView) v.findViewById(R.id.text);
  
          // sets up the font sizes
          holder.text.setTextSize(24);
  
          v.setTag(holder);
          return v;
      }
  
      public void bindView(final View view, Context mContext, final String trend) {
          final ViewHolder holder = (ViewHolder) view.getTag();
  
          holder.text.setText(trend);
  
          holder.text.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent search = new Intent(context, SearchedTrendsActivity.class);
                  search.setAction(Intent.ACTION_SEARCH);
                  search.putExtra(SearchManager.QUERY, "\"" + trend + "\"");
                  context.startActivity(search);
              }
          });
  
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          View v;
          if (convertView == null) {
  
              v = newView(parent);
  
          } else {
              v = convertView;
  
              final ViewHolder holder = (ViewHolder) v.getTag();
          }
  
          bindView(v, context, text.get(position));
  
          return v;
      }
  
      public String getElement(int pos) {
          return text.get(pos);
      }
  }
  