gt:         emptyView = new TextView(context);
context: /*
   * This is the source code of Telegram for Android v. 2.0.x.
   * It is licensed under GNU GPL v. 2 or later.
   * You should have received a copy of the license in this archive (see LICENSE).
   *
   * Copyright Nikolai Kudashov, 2013-2014.
   */
  
  package org.telegram.ui;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.res.Configuration;
  import android.graphics.drawable.ColorDrawable;
  import android.os.Build;
  import android.text.TextUtils;
  import android.view.Gravity;
  import android.view.LayoutInflater;
  import android.view.MotionEvent;
  import android.view.Surface;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.ViewTreeObserver;
  import android.view.WindowManager;
  import android.widget.FrameLayout;
  import android.widget.ListView;
  import android.widget.ProgressBar;
  import android.widget.TextView;
  
  import org.telegram.android.AndroidUtilities;
  import org.telegram.android.LocaleController;
  import org.telegram.android.MediaController;
  import org.telegram.android.MessagesStorage;
  import org.telegram.android.NotificationCenter;
  import org.telegram.messenger.ApplicationLoader;
  import org.telegram.messenger.R;
  import org.telegram.ui.ActionBar.ActionBar;
  import org.telegram.ui.ActionBar.ActionBarMenu;
  import org.telegram.ui.ActionBar.ActionBarMenuItem;
  import org.telegram.ui.ActionBar.BaseFragment;
  import org.telegram.ui.Adapters.BaseFragmentAdapter;
  import org.telegram.ui.Cells.PhotoPickerAlbumsCell;
  import org.telegram.ui.Cells.PhotoPickerSearchCell;
  import org.telegram.ui.Components.LayoutHelper;
  import org.telegram.ui.Components.PhotoPickerBottomLayout;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  public class PhotoAlbumPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
  
      public interface PhotoAlbumPickerActivityDelegate {
          void didSelectPhotos(ArrayList<String> photos, ArrayList<String> captions, ArrayList<MediaController.SearchImage> webPhotos);
          boolean didSelectVideo(String path);
          void startPhotoSelectActivity();
          void didSelectPhotoEntries(ArrayList<MediaController.PhotoEntry> photos);
      }
  
      private ArrayList<MediaController.AlbumEntry> albumsSorted = null;
      private ArrayList<MediaController.AlbumEntry> videoAlbumsSorted = null;
      private HashMap<Integer, MediaController.PhotoEntry> selectedPhotos = new HashMap<>();
      private HashMap<String, MediaController.SearchImage> selectedWebPhotos = new HashMap<>();
      private HashMap<String, MediaController.SearchImage> recentImagesWebKeys = new HashMap<>();
      private HashMap<String, MediaController.SearchImage> recentImagesGifKeys = new HashMap<>();
      private ArrayList<MediaController.SearchImage> recentWebImages = new ArrayList<>();
      private ArrayList<MediaController.SearchImage> recentGifImages = new ArrayList<>();
      private boolean loading = false;
  
      private int columnsCount = 2;
      private ListView listView;
      private ListAdapter listAdapter;
      private FrameLayout progressView;
      private TextView emptyView;
      private TextView dropDown;
      private ActionBarMenuItem dropDownContainer;
      private PhotoPickerBottomLayout photoPickerBottomLayout;
      private boolean sendPressed = false;
      private boolean singlePhoto = false;
      private int selectedMode;
      private ChatActivity chatActivity;
  
      private PhotoAlbumPickerActivityDelegate delegate;
  
      private final static int item_photos = 2;
      private final static int item_video = 3;
  
      public PhotoAlbumPickerActivity(boolean singlePhoto, ChatActivity chatActivity) {
          super();
          this.chatActivity = chatActivity;
          this.singlePhoto = singlePhoto;
      }
  
      @Override
      public boolean onFragmentCreate() {
          loading = true;
          MediaController.loadGalleryPhotosAlbums(classGuid);
          NotificationCenter.getInstance().addObserver(this, NotificationCenter.albumsDidLoaded);
          NotificationCenter.getInstance().addObserver(this, NotificationCenter.recentImagesDidLoaded);
          NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats);
          return super.onFragmentCreate();
      }
  
      @Override
      public void onFragmentDestroy() {
          NotificationCenter.getInstance().removeObserver(this, NotificationCenter.albumsDidLoaded);
          NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recentImagesDidLoaded);
          NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
          super.onFragmentDestroy();
      }
  
      @SuppressWarnings("unchecked")
      @Override
      public View createView(Context context, LayoutInflater inflater) {
          actionBar.setBackgroundColor(0xff333333);
          actionBar.setItemsBackground(R.drawable.bar_selector_picker);
          actionBar.setBackButtonImage(R.drawable.ic_ab_back);
          actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
              @Override
              public void onItemClick(int id) {
                  if (id == -1) {
                      if (Build.VERSION.SDK_INT < 11) {
                          listView.setAdapter(null);
                          listView = null;
                          listAdapter = null;
                      }
                      finishFragment();
                  } else if (id == 1) {
                      if (delegate != null) {
                          finishFragment(false);
                          delegate.startPhotoSelectActivity();
                      }
                  } else if (id == item_photos) {
                      if (selectedMode == 0) {
                          return;
                      }
                      selectedMode = 0;
                      dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
                      emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
                      listAdapter.notifyDataSetChanged();
                  } else if (id == item_video) {
                      if (selectedMode == 1) {
                          return;
                      }
                      selectedMode = 1;
                      dropDown.setText(LocaleController.getString("PickerVideo", R.string.PickerVideo));
                      emptyView.setText(LocaleController.getString("NoVideo", R.string.NoVideo));
                      listAdapter.notifyDataSetChanged();
                  }
              }
          });
  
          ActionBarMenu menu = actionBar.createMenu();
          menu.addItem(1, R.drawable.ic_ab_other);
  
          fragmentView = new FrameLayout(context);
  
          FrameLayout frameLayout = (FrameLayout) fragmentView;
          frameLayout.setBackgroundColor(0xff000000);
  
          if (!singlePhoto) {
              selectedMode = 0;
  
              dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector_picker);
              dropDownContainer.setSubMenuOpenSide(1);
              dropDownContainer.addSubItem(item_photos, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0);
              dropDownContainer.addSubItem(item_video, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0);
              actionBar.addView(dropDownContainer);
              FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
              layoutParams.height = LayoutHelper.MATCH_PARENT;
              layoutParams.width = LayoutHelper.WRAP_CONTENT;
              layoutParams.rightMargin = AndroidUtilities.dp(40);
              layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
              layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
              dropDownContainer.setLayoutParams(layoutParams);
              dropDownContainer.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      dropDownContainer.toggleSubMenu();
                  }
              });
  
              dropDown = new TextView(context);
              dropDown.setGravity(Gravity.LEFT);
              dropDown.setSingleLine(true);
              dropDown.setLines(1);
              dropDown.setMaxLines(1);
              dropDown.setEllipsize(TextUtils.TruncateAt.END);
              dropDown.setTextColor(0xffffffff);
              dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
              dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
              dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
              dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
              dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
              dropDownContainer.addView(dropDown);
              layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
              layoutParams.width = LayoutHelper.WRAP_CONTENT;
              layoutParams.height = LayoutHelper.WRAP_CONTENT;
              layoutParams.leftMargin = AndroidUtilities.dp(16);
              layoutParams.gravity = Gravity.CENTER_VERTICAL;
              dropDown.setLayoutParams(layoutParams);
          } else {
              actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
          }
  
          listView = new ListView(context);
          listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4));
          listView.setClipToPadding(false);
          listView.setHorizontalScrollBarEnabled(false);
          listView.setVerticalScrollBarEnabled(false);
          listView.setSelector(new ColorDrawable(0));
          listView.setDividerHeight(0);
          listView.setDivider(null);
          listView.setDrawingCacheEnabled(false);
          listView.setScrollingCacheEnabled(false);
          frameLayout.addView(listView);
          FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
          layoutParams.width = LayoutHelper.MATCH_PARENT;
          layoutParams.height = LayoutHelper.MATCH_PARENT;
          layoutParams.bottomMargin = AndroidUtilities.dp(48);
          listView.setLayoutParams(layoutParams);
          listView.setAdapter(listAdapter = new ListAdapter(context));
          AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
  
  