@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.offline_media);
    setTitle(getString(R.string.offline));

    mLoadingBar = findViewById(R.id.offline_loading_bar);
    mLoadingBar.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mLoadingCount > 0) {
              Intent intent = new Intent(OfflineMediaActivity.this, OfflineActivity.class);
              startActivity(intent);
            }
          }
        });
    mLoadingCountTextView = (TextView) mLoadingBar.findViewById(R.id.offline_media_bar_title);
    mLoadingProgressTextView = (TextView) mLoadingBar.findViewById(R.id.offline_media_bar_subtitle);

    setLoadingCount(0);
    setLoadingProgress(0, 0);

    adapter = new RelativeAdapter(getBaseContext(), null, true);
    mListView = (GridView) findViewById(R.id.offline_media_block_grids);

    // update UI
    mListView.setAdapter(adapter);
    mLoadingView =
        makeEmptyLoadingView(getBaseContext(), (RelativeLayout) findViewById(R.id.tabs_content));

    findViewById(R.id.offline_media_block).setVisibility(View.GONE);
    // after check then load
    getSupportLoaderManager().initLoader(cursorFinishedLoaderID, null, this);
  }
 public DropdownContainer(
     Context context,
     int layout_id,
     Drawable background,
     DropdownAdapter adapter,
     OnItemClickListener listener) {
   super(context);
   int m = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
   AbsListView content = (AbsListView) LayoutInflater.from(context).inflate(layout_id, null);
   if (content instanceof ListView) {
     ((ListView) content).setAdapter((BaseAdapter) adapter);
   } else if (content instanceof GridView) {
     ((GridView) content).setAdapter((BaseAdapter) adapter);
   }
   content.setOnItemClickListener(listener);
   content.measure(m, m);
   if (adapter.getRows() > adapter.getWrapRow()) {
     init(
         content,
         LayoutParams.WRAP_CONTENT,
         content.getMeasuredHeight() * adapter.getWrapRow(),
         R.style.drop_down_anim,
         background);
   } else {
     init(
         content,
         LayoutParams.WRAP_CONTENT,
         LayoutParams.WRAP_CONTENT,
         R.style.drop_down_anim,
         background);
   }
 }
Beispiel #3
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View v;
      if (convertView == null) {
        v = mInflater.inflate(R.layout.monitor, parent, false);
      } else {
        v = convertView;
      }

      Monitor monitor = getMonitorByPosition(position);

      TextView monitorName = (TextView) v.findViewById(R.id.monitorName);
      monitorName.setText(monitor.name());

      TextView monitorDescription = (TextView) v.findViewById(R.id.monitorDescription);
      monitorDescription.setText(monitor.desc());

      Button removeButton = (Button) v.findViewById(R.id.removeMonitorButton);
      removeButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              new DeleteMonitorDialogFragment(
                      new Runnable() {
                        @Override
                        public void run() {
                          monitoringService.removeMonitor(getMonitorIdByPosition(position));
                          onDataChange();
                        }
                      })
                  .show(getFragmentManager(), "DeleteMonitor");
            }
          });

      Button editButton = (Button) v.findViewById(R.id.editMonitorButton);
      editButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent(MainActivity.this, TickerMonitorEditActivity.class);
              intent.putExtra(MONITOR_ID, getMonitorIdByPosition(position));
              startActivityForResult(intent, 1);
              // actual change the monitor is done on onActivityResult
            }
          });

      GridView monitorResponses = (GridView) v.findViewById(R.id.monitorResponses);
      try {
        ResponseAdapter adapter = monitorResultsAdapters.get(monitor);
        monitorResponses.setAdapter(adapter);
      } catch (RuntimeException e) {
        Log.e(CoynesMonitoring.TAG, "caught exception", e);
        throw e;
      }

      return v;
    }
  private void populateRhymes() {
    itemData.add(new BasicNameValuePair("K3YQsmznd4c", "A B C D E F G"));
    itemData.add(new BasicNameValuePair("gBEHFFnV3RY", "Baa Baa Black Sheep"));
    itemData.add(new BasicNameValuePair("Bhz2ycHGITw", "Diddle, Diddle, Dumpling, My Son John"));
    itemData.add(new BasicNameValuePair("iqn7Qm3h1u0", "Doctor Foster went to Gloucester"));
    itemData.add(new BasicNameValuePair("yyl8n-dzIk8", "Eeny, Meeny, Miny, Moe"));
    itemData.add(new BasicNameValuePair("SVPmtaHmL4g", "Five Little Speckeled Frog"));
    itemData.add(new BasicNameValuePair("_RQDTNrC6lQ", "Hey Diddle Diddle"));
    itemData.add(new BasicNameValuePair("UneYkq0FzKA", "Humpty Dumpty"));
    itemData.add(new BasicNameValuePair("oODul5hgIl4", "Hot Cross Buns"));
    itemData.add(new BasicNameValuePair("icUSwG83ES8", "It's Raining, It's Pouring"));
    itemData.add(new BasicNameValuePair("MBxeKG7_Hq4", "Incy Wincy Spider"));
    itemData.add(new BasicNameValuePair("lsbFIYSK26E", "Jack And Jill, Went Up The Hill"));
    itemData.add(new BasicNameValuePair("OHIbdUmeQwk", "Little Bo Peep"));
    itemData.add(new BasicNameValuePair("bneJKq-ksjM", "Little Miss Muffet"));
    itemData.add(new BasicNameValuePair("vTvNwAT29Lo", "London Bridge Is Falling Down"));
    itemData.add(new BasicNameValuePair("u_K9hFxSvDM", "Mary Had A Little Lamb"));
    itemData.add(new BasicNameValuePair("F3cedGb7lIo", "One, Two, Three, Four, Five"));
    itemData.add(new BasicNameValuePair("Wlc6Mho-PxE", "Pat-a-cake, Pat-a-cake"));
    itemData.add(new BasicNameValuePair("eh2Ud9KReWY", "Polly Put The Kettle On"));
    itemData.add(new BasicNameValuePair("fv4kp4ZnSuE", "Pop goes the Weasel"));
    itemData.add(new BasicNameValuePair("Izq1E6b4WlQ", "Rain Rain Go Away"));
    itemData.add(new BasicNameValuePair("Tbf0cDiqr-U", "Ring a RIng o' Roses"));
    itemData.add(new BasicNameValuePair("e66wIEbiMro", "Row, Row, Row Your Boat"));
    itemData.add(new BasicNameValuePair("-ORqKcPJYDg", "Solomon Grundy"));
    itemData.add(new BasicNameValuePair("tU85Kd-7bjM", "Star Light, Star Bright"));
    itemData.add(new BasicNameValuePair("yCjJyiqpAuU", "Twinkle Twinkle Little Star"));
    itemData.add(new BasicNameValuePair("-Xui9N1xjUM", "The Muffin Man"));

    // list = (ListView)findViewById(R.id.listRhymes);
    list = (GridView) findViewById(R.id.listRhymes);
    adapter = new LazyAdapter(this, itemData);
    // adapter = new LazyAdapter(this, mStrings);
    list.setAdapter(adapter);
    list.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(
              AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) {
            // String videoName = ((TextView)
            // myView.findViewById(R.id.itemText)).getText().toString();
            // Toast.makeText(getApplicationContext(), "item selected... : "+ videoId,
            // Toast.LENGTH_SHORT).show();
            String videoId = ((ImageView) myView.findViewById(R.id.itemImage)).getTag().toString();
            // Toast.makeText(getApplicationContext(), "item selected... : "+ videoId,
            // Toast.LENGTH_SHORT).show();

            Intent lVideoIntent =
                new Intent(
                    null,
                    Uri.parse("ytv://" + videoId),
                    MainActivity.this,
                    OpenYouTubePlayerActivity.class);
            startActivity(lVideoIntent);
          }
        });
  }
  /** @Method: openPopupwin @Description: popupwindow�����ü���Ӧ */
  private void openPopupwin() {

    LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    ViewGroup menuView = (ViewGroup) mLayoutInflater.inflate(R.layout.gridview_popx, null, true);
    menuGrid = (GridView) menuView.findViewById(R.id.popgridview);
    menuGrid.setAdapter(getMenuAdapter(menu_name_array, menu_image_array));
    // menuGrid������
    menuGrid.requestFocus();

    // ����popupwindow���������Ϣ
    menuGrid.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            menuPopupWindow.dismiss();
            if (arg2 == 0) { // �ϴ�
              albumPopupwin();
            } else if (arg2 == 1) // �༭
            {
              Intent intent = new Intent(LocalImageView.this, PictureEditActivity.class);
              intent.putExtra("photopath", photoPath);
              startActivity(intent);
            } else if (arg2 == 2) // ɾ��
            {
              sureToDelete();
            }
          }
        });

    // ���㵽��gridview�ϣ�������Ҫ����˴��ļ����¼����������ֲ���Ӧ�����¼������
    menuGrid.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            switch (keyCode) {
              case KeyEvent.KEYCODE_MENU:
                if (menuPopupWindow != null && menuPopupWindow.isShowing()) {
                  menuPopupWindow.dismiss();
                }
                break;
            }
            System.out.println("menuGridfdsfdsfdfd");
            return true;
          }
        });

    // ��ʾpopupwindow
    menuPopupWindow =
        new PopupWindow(menuView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
    menuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
    menuPopupWindow.setAnimationStyle(R.style.PopupAnimation);
    menuPopupWindow.showAtLocation(
        findViewById(R.id.filpperparent), Gravity.BOTTOM | Gravity.BOTTOM, 0, 0);
    menuPopupWindow.update();
  }
Beispiel #6
0
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_club);
   height = getWindowManager().getDefaultDisplay().getHeight();
   getActionBar().setDisplayHomeAsUpEnabled(true);
   // 实例化GridView
   mGridView = (GridView) findViewById(R.id.gridview);
   adapter = new MyAdapter(this);
   mGridView.setAdapter(adapter);
   mGridView.setOnItemClickListener(onItemClickListener);
 }
 @Override
 protected void onResume() {
   super.onResume();
   photosGridViewContents =
       this.filesAtPath(getFilesDir().getAbsolutePath() + "/images"); // new String[]{};
   photosGridViewAdapter =
       new PhotoGridAdapter(this, R.layout.item_imagesgrid, photosGridViewContents);
   photosGridView = (GridView) findViewById(R.id.photosGridView);
   photosGridView.setAdapter(photosGridViewAdapter);
   photosGridView.setOnItemClickListener(this);
 }
  /** @Method: init @Description: ��ʼ������ */
  private void initComponents() {

    titleReturnButton = (ImageButton) findViewById(R.id.upgridbutton1);
    titleReturnButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    titleTextView = (TextView) findViewById(R.id.upgridtextview);
    titleTextView.setText(
        "����/"
            + AlbumName
            + "("
            + PhotoAlbumActivity.AlbumsFloderName.get(AlbumName).size()
            + ")");

    localGridAdapter = new ImageAdapter(this);
    localGridAdapter.mImageList = new ArrayList<Bitmap>();

    gv = (GridView) findViewById(R.id.gridview); // GridView
    gv.setAdapter(localGridAdapter);
    // ���ͼ���еĵ����Ӧ����ת��������Ƭ�Ĵ�ͼ���Activity
    gv.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            try {
              Intent i = new Intent(InLocalSmallPhotoActivity.this, LocalImageView.class);
              i.putExtra("currentpic", arg2);
              i.putExtra("albumArray", albumArray);
              i.putExtra("photopath", PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(arg2));
              i.putExtra("AlbumName", AlbumName);
              startActivity(i);
            } catch (Exception e) {
              Toast.makeText(InLocalSmallPhotoActivity.this, "ͼ�����������~~~~", 0).show();
            }
          }
        }); // ClickListener
  }
Beispiel #9
0
  // OnCreate running
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    MainActivity act = (MainActivity) this.getActivity();
    // toDo = act.getTasks();
    nThumbsIds = act.getTaskList();

    chosen = act.getToAdd();

    View rootView = inflater.inflate(R.layout.start_grid, container, false);

    super.onCreate(savedInstanceState);
    int iconSize = getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);

    GridView gridview = (GridView) rootView.findViewById(R.id.taskgrid);
    gridview.setAdapter(new TaskAdapter(getActivity()));
    gridview.setOnItemClickListener(this);

    return rootView;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent serviceIntent = new Intent(this, NotifyService.class);
    this.startService(serviceIntent);

    orders = (GridView) findViewById(R.id.ordersList);

    orders.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Order order = (Order) parent.getAdapter().getItem(position);
            Intent intent = new Intent(ShopActivity.this, OrderDetailActivity.class);
            intent.putExtra(ORDER_EXTRA, order);
            startActivity(intent);
          }
        });

    ordersAdapter = new OrdersAdapter(this, ordersList);

    orders.setAdapter(ordersAdapter);

    getOrdersButton = (Button) findViewById(R.id.new_orders_button);

    getOrdersButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            v.setEnabled(false);

            loadOrders(true);
          }
        });

    loadOrders(false);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    /* First Tab Content */

    Bundle bundle = getIntent().getExtras();
    date1 = bundle.getString("date");
    /*String[]s=date1.split("-");
    day1=s[0];
    mnth=s[1];
    yr=s[2];*/
    System.out.println("date bun" + date1);
    final Calendar c = Calendar.getInstance();
    /*mYear =Integer.parseInt(yr);
    mMonth = getMonthAsNO(mnth);
    mDay = Integer.parseInt(day1);
    date=(+ (mDay) + "-" +(mMonth+1)+ "-" +mYear);*/
    data = new DataBaseHelper(this);
    data.open();
    setContentView(R.layout.gridtask);
    tv = (TextView) findViewById(R.id.txt);
    tv.setVisibility(View.GONE);
    showtask();
    if (results.size() == 0) {
      tv.setVisibility(View.VISIBLE);
      tv.setText("No Tasks!!");
    }
    grid_main = (GridView) findViewById(R.id.GridView01);
    grid_main.setAdapter(new ImageAdapter(this));
    es = (EditText) findViewById(R.id.esearch);
    Window window = getWindow();
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    data.close();
  }
Beispiel #12
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler(this));
    Colors.updateColors(this);
    startService(new Intent(this, JTalkService.class));
    service = JTalkService.getInstance();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);

    setContentView(R.layout.roster);

    LinearLayout roster = (LinearLayout) findViewById(R.id.roster_linear);
    roster.setBackgroundColor(Colors.BACKGROUND);

    getActionBar().setHomeButtonEnabled(true);

    statusArray = getResources().getStringArray(R.array.statusArray);
    rosterAdapter = new RosterAdapter(this);
    simpleAdapter = new NoGroupsAdapter(this);
    searchAdapter = new SearchAdapter(this);

    int cols = 1;
    if (!prefs.getBoolean("ShowGroups", true) && !prefs.getBoolean("ShowMucGroup", false)) {
      try {
        cols = Integer.parseInt(prefs.getString("RosterColumns", "1"));
      } catch (Exception e) {
        cols = 1;
      }
    }
    gridView = (GridView) findViewById(R.id.users);
    gridView.setNumColumns(cols);
    gridView.setCacheColorHint(0x00000000);
    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(this);
    gridView.setAdapter(rosterAdapter);

    if (getIntent().getBooleanExtra("status", false)) {
      RosterDialogs.changeStatusDialog(this, null, null);
    }

    if (getIntent().getBooleanExtra("password", false)) {
      String account = getIntent().getStringExtra("account");
      RosterDialogs.passwordDialog(this, account);
    }

    if (getIntent().getBooleanExtra("subscribtion", false)) {
      String account = getIntent().getStringExtra("account");
      String jid = getIntent().getStringExtra("jid");
      RosterDialogs.subscribtionRequestDialog(this, account, jid);
    }

    File table = new File(Constants.PATH_SMILES + "/default/table.xml");
    if (!table.exists()) {
      new CreateDefaultSmiles().execute();
    } else {
      Cursor cursor =
          getContentResolver()
              .query(
                  JTalkProvider.ACCOUNT_URI,
                  null,
                  AccountDbHelper.ENABLED + " = '" + 1 + "'",
                  null,
                  null);
      if (cursor == null || cursor.getCount() < 1) startActivity(new Intent(this, Accounts.class));
    }

    if (prefs.getBoolean("BUG", false)) {
      new ErrorDialog(this).show();
    }

    String action = getIntent().getAction();
    if (action != null && action.equals(Intent.ACTION_VIEW)) {
      Uri data = getIntent().getData();
      if (data != null && data.getScheme().equals("xmpp")) {
        XMPPUri xmppUri;
        try {
          xmppUri = new XMPPUri(data);
        } catch (IllegalArgumentException e) {
          xmppUri = null;
        }

        List<String> accounts = new ArrayList<String>();
        for (XMPPConnection connection : service.getAllConnections()) {
          accounts.add(StringUtils.parseBareAddress(connection.getUser()));
        }

        if (xmppUri != null && !accounts.isEmpty()) {
          final String xmppJid = xmppUri.getJid();
          final String body = xmppUri.getBody();
          String queryType = xmppUri.getQueryType();

          final ArrayAdapter<String> adapter =
              new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, accounts);

          if (queryType.equals("roster")) {
            RosterDialogs.addDialog(this, xmppUri.getJid());
          } else if (queryType.equals("join")) {
            if (accounts.size() > 1) {
              AlertDialog.Builder builder = new AlertDialog.Builder(this);
              builder.setTitle(R.string.Accounts);
              builder.setAdapter(
                  adapter,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String account = adapter.getItem(which);
                      MucDialogs.joinDialog(RosterActivity.this, account, xmppJid, null);
                    }
                  });
              builder.create().show();
            } else MucDialogs.joinDialog(RosterActivity.this, accounts.get(0), xmppJid, null);
          } else {
            service.setText(xmppJid, body);
            if (accounts.size() > 1) {
              service.setText(xmppJid, body);
              AlertDialog.Builder builder = new AlertDialog.Builder(this);
              builder.setTitle(R.string.Accounts);
              builder.setAdapter(
                  adapter,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String account = adapter.getItem(which);
                      Intent intent = new Intent(RosterActivity.this, Chat.class);
                      intent.putExtra("account", account);
                      intent.putExtra("jid", xmppJid);
                      startActivity(intent);
                    }
                  });
              builder.create().show();
            } else {
              Intent intent = new Intent(RosterActivity.this, Chat.class);
              intent.putExtra("account", accounts.get(0));
              intent.putExtra("jid", xmppJid);
              startActivity(intent);
            }
          }
        }
      }
    }
  }
  /** Functionality of verses dialog box to show the list of verses for the selected chapter. */
  void verseDialogDisplayedFunc(final Dialog dialog) {
    // initialize the widgets of this view
    final AutoCompleteTextView searchBox =
        (AutoCompleteTextView) dialog.findViewById(R.id.verse_list_search_box);
    final GridView verseList = (GridView) dialog.findViewById(R.id.verse_list);
    TextView bookNameText = (TextView) dialog.findViewById(R.id.verse_list_bookname_txt);
    TextView chapterNameText =
        (TextView) dialog.findViewById(R.id.verse_list_chaptername_heading_txt);

    // set the heading text with chapter name and book name
    bookNameText.setText(selectedBookNameForHeading);
    chapterNameText.setText(selectedChapterName);

    // convert array list into string array of the verse list
    final String[] verseListArr = EBibleConstants.verseList.toArray(new String[0]);
    // set the adapter class to show the list of verses
    verseList.setAdapter(new ChapterListAdapter(verseListArr, dialog));

    // set the text that enters to search
    searchBox.setThreshold(1);
    // set the list of the verse to show by search
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, verseListArr);
    // search functionality to get verse name of the list
    // that will works with dynamically text entered by user
    searchBox.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            searchVerseNameArr.clear();

            int searchTextlength = searchBox.getText().length();

            if (searchTextlength > 0) {
              for (int i = 0; i < verseListArr.length; i++) {
                if (searchTextlength <= verseListArr[i].length()) {
                  if (searchBox
                      .getText()
                      .toString()
                      .equalsIgnoreCase(
                          (String) verseListArr[i].subSequence(0, searchTextlength))) {
                    searchVerseNameArr.add(verseListArr[i]);
                    Log.e("", " searched friend data " + searchVerseNameArr);
                  }
                }
              }
            }
            // if search text is entered then
            // show the search items list
            if (searchVerseNameArr.size() > 0) {
              String[] searchVerseNameStringArr = searchVerseNameArr.toArray(new String[0]);
              Log.i("", "searched verse string array" + searchVerseNameStringArr.length);
              verseList.setAdapter(new ChapterListAdapter(searchVerseNameStringArr, dialog));
            } else // show the whole list of verse
            {
              verseList.setAdapter(new ChapterListAdapter(verseListArr, dialog));
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });
  }
  /** Functionality of chapter dialog box to show the list of chapters for the selected book. */
  void chapterDialogDisplayedFunc(final Dialog dialog) {
    // initialize the widgets of this view
    final AutoCompleteTextView searchBoxChapters =
        (AutoCompleteTextView) dialog.findViewById(R.id.chapter_list_search_box);
    final GridView chapterList = (GridView) dialog.findViewById(R.id.chapter_list);
    TextView bookName = (TextView) dialog.findViewById(R.id.chapter_list_bookname_txt);

    int numberOfChapters;
    // find the selected book
    if (selectedBookNameForHeading.equalsIgnoreCase("Genesis")) {
      numberOfChapters = 50;
      bookName.setText("Genesis");
      selectedBookName = "genesis";
    } else if (selectedBookNameForHeading.equalsIgnoreCase("John")) {
      numberOfChapters = 21;
      bookName.setText("John");
      selectedBookName = "john";
    } else if (selectedBookNameForHeading.equalsIgnoreCase("John1")) {
      numberOfChapters = 5;
      bookName.setText("John1");
      selectedBookName = "1john";
    } else if (selectedBookNameForHeading.equalsIgnoreCase("John2")) {
      numberOfChapters = 1;
      bookName.setText("John2");
      selectedBookName = "2john";
    } else {
      numberOfChapters = 1;
      bookName.setText("John3");
      selectedBookName = "3john";
    }
    // store the chapters counting into the array
    final String[] numberOfChaptersList = new String[numberOfChapters];
    for (int count = 0; count < numberOfChapters; count++) {
      int chapterNumber = count + 1;
      numberOfChaptersList[count] = "" + chapterNumber;

      Log.i("", "chapter list = " + numberOfChaptersList[count]);
    }

    // set the adapter class to show the list of Books
    chapterList.setAdapter(new ChapterListAdapter(numberOfChaptersList, dialog));

    // set the text that enters to search
    searchBoxChapters.setThreshold(1);
    // set the list of the books to show by search
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_dropdown_item_1line, numberOfChaptersList);
    // search functionality to get book name of the list
    // that will works with dynamically text entered by user
    searchBoxChapters.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            searchChapterNameArr.clear();

            int searchTextlength = searchBoxChapters.getText().length();
            Log.i("", "chapter list size = " + numberOfChaptersList.length);
            if (searchTextlength > 0) {
              for (int j = 0; j < numberOfChaptersList.length; j++) {
                Log.i("", "i = " + j);
                if (searchTextlength <= numberOfChaptersList[j].length()) {
                  if (searchBoxChapters
                      .getText()
                      .toString()
                      .equalsIgnoreCase(
                          (String) numberOfChaptersList[j].subSequence(0, searchTextlength))) {
                    searchChapterNameArr.add(numberOfChaptersList[j]);
                    Log.e("", " searched chapter= " + searchChapterNameArr);
                  }
                }
              }
            }
            // if search text is entered then
            // show the search items list
            if (searchChapterNameArr.size() > 0) {
              String[] searchBookNameStringArr = searchChapterNameArr.toArray(new String[0]);
              Log.i("", "searched chapter string array" + searchBookNameStringArr.length);
              chapterList.setAdapter(new ChapterListAdapter(searchBookNameStringArr, dialog));
            } else // show the whole list of books
            {
              chapterList.setAdapter(new ChapterListAdapter(numberOfChaptersList, dialog));
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });
  }
 @Override
 public void onDestroy() {
   adapter.imageLoader.stopThread();
   list.setAdapter(null);
   super.onDestroy();
 }
Beispiel #16
0
  @Override
  public View onCreateView(
      final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
      peerType = savedInstanceState.getInt("peerType");
      peerId = savedInstanceState.getInt("peerId");
    }

    View res = inflater.inflate(R.layout.media_main, container, false);
    gridView = (GridView) res.findViewById(R.id.mediaGrid);
    loading = res.findViewById(R.id.loading);
    empty = res.findViewById(R.id.empty);
    gridView.setVisibility(View.GONE);
    empty.setVisibility(View.GONE);
    loading.setVisibility(View.GONE);

    mediaSource = application.getDataSourceKernel().getMediaSource(peerType, peerId);
    mediaSource.getSource().onConnected();
    records = mediaSource.getSource().getCurrentWorkingSet();
    // final List<MediaRecord> lazyList =
    // application.getEngine().getMediaEngine().lazyQueryMedia(peerType, peerId);

    gridView.setPadding(0, PreviewConfig.MEDIA_SPACING, 0, PreviewConfig.MEDIA_SPACING);
    gridView.setNumColumns(PreviewConfig.MEDIA_ROW_COUNT);
    gridView.setColumnWidth(PreviewConfig.MEDIA_PREVIEW);
    gridView.setVerticalSpacing(PreviewConfig.MEDIA_SPACING);
    gridView.setHorizontalSpacing(PreviewConfig.MEDIA_SPACING);
    gridView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i >= 0 && i < records.size()) {
              getRootController().openImage(records.get(i).getMid(), peerType, peerId);
            } else {
              mediaSource.requestLoadMore(records.size());
            }
          }
        });

    final Context context = getActivity();
    adapter =
        new BaseAdapter() {
          @Override
          public int getCount() {
            if (isLoading) {
              return records.size() + 1;
            } else {
              return records.size();
            }
          }

          @Override
          public MediaRecord getItem(int i) {
            if (i >= 0 && i < records.size()) {
              return records.get(i);
            } else {
              return null;
            }
          }

          @Override
          public long getItemId(int i) {
            if (i >= 0 && i < records.size()) {
              return records.get(i).getDatabaseId();
            } else {
              return 0;
            }
          }

          @Override
          public boolean hasStableIds() {
            return true;
          }

          @Override
          public int getItemViewType(int i) {
            if (i >= 0 && i < records.size()) {
              return 0;
            } else {
              return 1;
            }
          }

          @Override
          public int getViewTypeCount() {
            return 2;
          }

          @Override
          public boolean areAllItemsEnabled() {
            return false;
          }

          @Override
          public boolean isEnabled(int i) {
            return i >= 0 && i < records.size() || isLoadingError;
          }

          @Override
          public View getView(int i, View view, ViewGroup viewGroup) {
            if (i >= 0 && i < records.size()) {
              mediaSource.getSource().onItemsShown(i);

              MediaRecord record = getItem(i);
              if (view == null) {
                view = newView(context, record, viewGroup);
              }
              bindView(view, context, record, i);
              return view;
            } else {
              if (view == null) {
                view = inflater.inflate(R.layout.media_loading, viewGroup, false);
                GridView.LayoutParams imageParams =
                    new GridView.LayoutParams(
                        PreviewConfig.MEDIA_PREVIEW, PreviewConfig.MEDIA_PREVIEW);
                view.setLayoutParams(imageParams);
              }

              if (isLoadingError) {
                view.findViewById(R.id.progress).setVisibility(View.GONE);
                view.findViewById(R.id.retry).setVisibility(View.VISIBLE);
              } else {
                view.findViewById(R.id.progress).setVisibility(View.VISIBLE);
                view.findViewById(R.id.retry).setVisibility(View.GONE);
              }

              return view;
            }
          }

          public View newView(Context context, MediaRecord object, ViewGroup parent) {
            GridView.LayoutParams layoutParams =
                new GridView.LayoutParams(PreviewConfig.MEDIA_PREVIEW, PreviewConfig.MEDIA_PREVIEW);
            FrameLayout frameLayout = new FrameLayout(context);
            frameLayout.setLayoutParams(layoutParams);

            SmallPreviewView smallPreviewView = new SmallPreviewView(context);
            FrameLayout.LayoutParams imageParams =
                new FrameLayout.LayoutParams(
                    PreviewConfig.MEDIA_PREVIEW, PreviewConfig.MEDIA_PREVIEW);
            smallPreviewView.setLayoutParams(imageParams);

            ImageView videoLogo = new ImageView(context);
            videoLogo.setImageResource(R.drawable.st_media_ic_play);

            FrameLayout.LayoutParams timeParams =
                new FrameLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            timeParams.gravity = Gravity.CENTER;
            videoLogo.setLayoutParams(timeParams);

            frameLayout.addView(smallPreviewView);
            frameLayout.addView(videoLogo);

            return frameLayout;
          }

          public void bindView(View view, Context context, MediaRecord object, int index) {
            SmallPreviewView imageView = (SmallPreviewView) ((ViewGroup) view).getChildAt(0);
            View videoView = ((ViewGroup) view).getChildAt(1);

            if (object.getPreview() instanceof TLLocalVideo) {
              videoView.setVisibility(View.VISIBLE);
            } else {
              videoView.setVisibility(View.INVISIBLE);
            }

            if (object.getPreview() instanceof TLLocalPhoto) {
              TLLocalPhoto localPhoto = (TLLocalPhoto) object.getPreview();
              String key = DownloadManager.getPhotoKey(localPhoto);
              if (application.getDownloadManager().getState(key) == DownloadState.COMPLETED) {
                imageView.requestFile(application.getDownloadManager().getFileName(key));
              } else {
                if (localPhoto.getFastPreviewW() != 0 && localPhoto.getFastPreviewH() != 0) {
                  imageView.requestFast(localPhoto);
                } else {
                  imageView.clearImage();
                }
              }
            } else if (object.getPreview() instanceof TLLocalVideo) {
              TLLocalVideo localVideo = (TLLocalVideo) object.getPreview();
              if (localVideo.getFastPreview().length > 0) {
                imageView.requestFast(localVideo);
              } else {
                imageView.clearImage();
              }
            } else if (object.getPreview() instanceof TLLocalDocument) {
              TLLocalDocument localVideo = (TLLocalDocument) object.getPreview();
              if (localVideo.getFastPreview().length > 0) {
                imageView.requestFast(localVideo);
              } else {
                imageView.clearImage();
              }
            } else {
              imageView.clearImage();
            }
          }
        };
    gridView.setAdapter(adapter);

    return res;
  }