private void createInnerScrolls() {
    ScrollViews scrollViews = new ScrollViews();

    ListView newMatchList = (ListView) findViewById(R.id.newMatchesList);
    ListView oldMatchList = (ListView) findViewById(R.id.oldMatchesList);
    ScrollView wrapperScrollView = (ScrollView) findViewById(R.id.wrapperScrollView);

    newMatchList.setOnTouchListener(scrollViews.onTouch());
    oldMatchList.setOnTouchListener(scrollViews.onTouch());

    int[] viewArray = new int[] {R.id.newMatchesList, R.id.oldMatchesList};
    wrapperScrollView.setOnTouchListener(scrollViews.onTouchWrapper(viewArray));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listView = (ListView) findViewById(R.id.listView);
    listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    dataList = new ArrayList<ItemBean>();
    t1 = (TextView) findViewById(R.id.textView1);

    vibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
    vibrator.vibrate(50);

    m1 = (ImageView) findViewById(R.id.imageView1);
    for (int i = 0; i < max * 3; i++) {
      top = 32;
      if (i == top + 2 || i == top + max + 2) {
        dataList.add(new ItemBean("" + i % max, 2));
      } else if (i == top + 1 || i == top + max + 1) {
        dataList.add(new ItemBean("" + i % max, 1));
      } else if (i == top + 3 || i == top + max + 3) {
        dataList.add(new ItemBean("" + i % max, 1));
      } else if (i == top || i == top + max) {
        dataList.add(new ItemBean("" + i % max, -1));
      } else if (i == top + 4 || i == top + max + 4) {
        dataList.add(new ItemBean("" + i % max, -10));
      } else {

        dataList.add(new ItemBean("" + i % max, 0));
      }
    }

    m1111 = new MyAdapter(this, dataList);
    listView.setAdapter(m1111);

    listView.setVerticalScrollBarEnabled(false);
    // listView.setSelection(32);

    listView.setOnScrollListener(this);
    listView.setOnTouchListener(this);
    listView.setOnItemClickListener(this);

    ObjectAnimator.ofFloat(m1, "Alpha", 1F, 0.0F).setDuration(10).start();

    new Thread(
            new Runnable() {

              public void run() {

                try {
                  Thread.sleep(1000);
                } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                listView.smoothScrollToPosition(35);
              }
            })
        .start();
  }
Example #3
0
  private static void initUserView(ListView listView, final JSONArray _vehicleDetail) {
    final MyBaseAdapter adapter =
        new MyBaseAdapter(_vehicleDetail, MainActivity1.getDefaultMainActivity());
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    setListViewHeightBasedOnItems(listView);

    /*
     * UserVehicleListadapter adapter= new
     * UserVehicleListadapter(MainActivity1.getDefaultMainActivity(),
     * _vehicleDetail); listVehicle.setAdapter(adapter);
     * setListViewHeightBasedOnItems(listVehicle);
     */

    final SwipeToDismissTouchListener<ListViewAdapter> touchListener =
        new SwipeToDismissTouchListener<>(
            new ListViewAdapter(listView),
            new SwipeToDismissTouchListener.DismissCallbacks<ListViewAdapter>() {
              @Override
              public boolean canDismiss(int position) {
                return true;
              }

              @Override
              public void onDismiss(ListViewAdapter view, int position) {
                adapter.remove(position);
              }
            });
    listView.setOnTouchListener(touchListener);
    // Setting this scroll listener is required to ensure that during
    // ListView scrolling,
    // we don't look for swipes.
    listView.setOnScrollListener((AbsListView.OnScrollListener) touchListener.makeScrollListener());
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (touchListener.existPendingDismisses()) {
              touchListener.undoPendingDismiss();
            } else {

              try {
                JSONObject jsonObject = _vehicleDetail.getJSONObject(position);
                // _jsonVehicle.getString("RegNo");
                // _jsonVehicle.getString("Model");

                Intent intent =
                    new Intent(
                        MainActivity1.getDefaultMainActivity(), EditInstallbaseActivity.class);
                intent.putExtra("RegNo", jsonObject.getString("RegNo"));
                intent.putExtra("ID", jsonObject.getString("ID"));
                intent.putExtra("bgImage", jsonObject.getString("Base64Image"));
                ((Activity) MainActivity1.getDefaultMainActivity()).startActivity(intent);
              } catch (JSONException e) {
                e.printStackTrace();
              }
            }
          }
        });
  }
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final View view = getView();
    assert view != null;
    final Context context = view.getContext();
    final boolean compact = Utils.isCompactCards(context);
    final int backgroundColor = ThemeUtils.getThemeBackgroundColor(context);
    final int colorRes =
        TwidereColorUtils.getContrastYIQ(
            backgroundColor,
            R.color.bg_refresh_progress_color_light,
            R.color.bg_refresh_progress_color_dark);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(colorRes);
    mAdapter = onCreateAdapter(context, compact);
    mListView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
              updateRefreshProgressOffset();
            }
            return false;
          }
        });
    mListView.setAdapter(mAdapter);
  }
Example #5
0
 /**
  * 初始化中奖排行界面
  *
  * @param listview listView
  * @param listviewid listView的ID
  * @param list 中奖排行的数据
  */
 protected void initPrizeList(
     ListView listview, int listviewid, List<Map<String, Object>> list) {
   listview = (ListView) view.findViewById(listviewid);
   switch (HEIGHT) {
     case 320:
       listview.setPadding(0, 0, 0, 130);
       break;
     case 480:
       listview.setPadding(0, 0, 0, 110);
       break;
     case 800:
       listview.setPadding(0, 0, 0, 54);
       break;
     default:
       listview.setPadding(0, 0, 0, 0);
       break;
   }
   listview.setSelector(R.color.transparent);
   listview.setOnTouchListener(
       new GalleryOnTouch(mGallery) {
         @Override
         public void actionUp(View v) {}
       });
   BuyActivityAdapter adapter = new BuyActivityAdapter(BuyActivity.this, list);
   listview.setSelected(false);
   listview.setAdapter(adapter);
   if (listview.isFocused()) {
     listview.setItemsCanFocus(false);
   } else {
     listview.setItemsCanFocus(true);
   }
 }
Example #6
0
  @Override
  public View getView() {
    if (mView == null) {
      mView =
          (LinearLayout)
              (LayoutInflater.from(mContext).inflate(R.layout.awesomebar_allpages_list, null));
      mView.setTag(TAG);

      ListView list = getListView();
      list.setTag(TAG);
      ((Activity) mContext).registerForContextMenu(list);
      list.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              handleItemClick(parent, view, position, id);
            }
          });

      AwesomeBarCursorAdapter adapter = getCursorAdapter();
      list.setAdapter(adapter);
      list.setOnTouchListener(mListListener);
    }

    return mView;
  }
Example #7
0
  public void populateSonglist() {
    SWITCH_VIEW = SONG_VIEW;
    pb.setVisibility(View.VISIBLE);
    Log.i("LIST FRAG", "POPULATING SONG LIST");
    songlist_header_textview.setText("Songs");
    database.open();
    songList = database.getFullList();
    // database.close();

    detector = new GestureDetector(this, this);

    adapter = new ReadLisstAdapter(this, songList, lv);
    lv.setTextFilterEnabled(true);

    lv.setAdapter(adapter);
    lv.setSelection(StaticMusic.smoothScrollTo);
    lv.setFastScrollEnabled(true);
    lv.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View view, MotionEvent e) {
            detector.onTouchEvent(e);
            return false;
          }
        });
    adapter.imageLoader.loadImage(StaticMusic.smoothScrollTo, StaticMusic.smoothScrollTo + 8);
    pb.setVisibility(View.INVISIBLE);
    Log.i("INSTANT", "registered content observer");
    if (Math.abs(previousTime - System.currentTimeMillis()) / 1000 > 10) {
      previousTime = System.currentTimeMillis();
      databaseUpdateThread = new DatabaseUpdateThread(this, this);
      databaseUpdateThread.setPriority(Thread.MIN_PRIORITY);
      databaseUpdateThread.start();
      Log.i("Song list fragment", "After update thread creation");
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rl = (RelativeLayout) inflater.inflate(R.layout.fragment_transactions, container, false);
    Bundle args = getArguments();
    if (args.containsKey("account")) {
      account = (args.getParcelable("account"));
    }

    transactionsListView = (ListView) rl.findViewById(R.id.transactionsListView);
    if (savedInstanceState != null) {
      transactionList = (savedInstanceState.getParcelableArrayList("transactions"));
    } else {
      transactionList = new ArrayList<Transaction>();
      GetTransactionsTask getTransactionsTask = new GetTransactionsTask();
      getTransactionsTask.execute(String.valueOf(account.account_id));
      SetLoadingAnimation(true);
    }
    transactionListAdapter = new TransactionListAdapter(this.getActivity(), transactionList);
    transactionsListView.setAdapter(transactionListAdapter);
    transactionListAdapter.notifyDataSetChanged();

    gestureScanner = new GestureDetector(this.getActivity(), this);
    transactionsListView.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return gestureScanner.onTouchEvent(event);
          }
        });
    return rl;
  }
  protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
    mView = inflateView(inflater, container);

    mListView = (ListView) mView.findViewById(android.R.id.list);
    if (mListView == null) {
      throw new RuntimeException(
          "Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
    }

    View emptyView = mView.findViewById(android.R.id.empty);
    if (emptyView != null) {
      mListView.setEmptyView(emptyView);
    }

    mListView.setOnItemClickListener(this);
    mListView.setOnFocusChangeListener(this);
    mListView.setOnTouchListener(this);
    mListView.setFastScrollEnabled(!isSearchMode());

    // Tell list view to not show dividers. We'll do it ourself so that we can *not* show
    // them when an A-Z headers is visible.
    mListView.setDividerHeight(0);

    // We manually save/restore the listview state
    mListView.setSaveEnabled(false);

    configureVerticalScrollbar();
    configurePhotoLoader();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);

    setTitle(R.string.search_title);

    DEFAULT_ARTISTS = Util.getDefaultArtists(this);
    DEFAULT_ALBUMS = Util.getDefaultAlbums(this);
    DEFAULT_SONGS = Util.getDefaultSongs(this);

    View buttons = LayoutInflater.from(this).inflate(R.layout.search_buttons, null);

    artistsHeading = buttons.findViewById(R.id.search_artists);
    albumsHeading = buttons.findViewById(R.id.search_albums);
    songsHeading = buttons.findViewById(R.id.search_songs);

    searchButton = (TextView) buttons.findViewById(R.id.search_search);
    moreArtistsButton = buttons.findViewById(R.id.search_more_artists);
    moreAlbumsButton = buttons.findViewById(R.id.search_more_albums);
    moreSongsButton = buttons.findViewById(R.id.search_more_songs);

    list = (ListView) findViewById(R.id.search_list);

    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (view == searchButton) {
              onSearchRequested();
            } else if (view == moreArtistsButton) {
              expandArtists();
            } else if (view == moreAlbumsButton) {
              expandAlbums();
            } else if (view == moreSongsButton) {
              expandSongs();
            } else {
              Object item = parent.getItemAtPosition(position);
              if (item instanceof Artist) {
                onArtistSelected((Artist) item);
              } else if (item instanceof MusicDirectory.Entry) {
                MusicDirectory.Entry entry = (MusicDirectory.Entry) item;
                if (entry.isDirectory()) {
                  onAlbumSelected(entry, false);
                } else if (entry.isVideo()) {
                  onVideoSelected(entry);
                } else {
                  onSongSelected(entry, false, true, true, false);
                }
              }
            }
          }
        });
    list.setOnTouchListener(gestureListener);

    registerForContextMenu(list);

    onNewIntent(getIntent());
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_fex_detail, container, false);

    // show the current exercise
    ImageView imageview = (ImageView) rootView.findViewById(R.id.imageview);

    // set gesture detector
    this.mGestureScanner =
        new GestureDetector(
            this.getActivity(), new ExerciseDetailOnGestureListener(this, imageview, mExercise));

    // Images
    if (!mExercise.getImagePaths().isEmpty()) {
      DataHelper data = new DataHelper(getActivity());
      imageview.setImageDrawable(data.getDrawable(mExercise.getImagePaths().get(0).toString()));
    } else {
      imageview.setImageResource(R.drawable.ic_launcher);
    }

    imageview.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return mGestureScanner.onTouchEvent(event);
          }
        });

    // set adapter
    ListView listView = (ListView) rootView.findViewById(R.id.list);
    final TrainingEntryListAdapter mAdapter =
        new TrainingEntryListAdapter((FragmentActivity) getActivity(), mExercise, mTrainingEntry);
    listView.setAdapter(mAdapter);

    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            listView,
            new SwipeDismissListViewTouchListener.OnDismissCallback() {
              @Override
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                  mAdapter.remove(position);
                }
                mAdapter.notifyDataSetChanged();
              }
            });
    listView.setOnTouchListener(touchListener);
    // Setting this scroll listener is required to ensure that during
    // ListView scrolling,
    // we don't look for swipes.
    listView.setOnScrollListener(touchListener.makeScrollListener());

    return rootView;
  }
  private void addHistoryTab() {
    Log.d(LOGTAG, "Creating History tab");

    addAwesomeTab(HISTORY_TAB, R.string.awesomebar_history_title, R.id.history_list);

    ListView historyList = (ListView) findViewById(R.id.history_list);
    historyList.setOnTouchListener(mListTouchListener);

    // Only load history list when tab is actually used.
    // See OnTabChangeListener above.
  }
  private void addBookmarksTab() {
    Log.d(LOGTAG, "Creating Bookmarks tab");

    addAwesomeTab(BOOKMARKS_TAB, R.string.awesomebar_bookmarks_title, R.id.bookmarks_list);

    ListView bookmarksList = (ListView) findViewById(R.id.bookmarks_list);
    bookmarksList.setOnTouchListener(mListTouchListener);

    // Only load bookmark list when tab is actually used.
    // See OnTabChangeListener above.
  }
Example #14
0
  /**
   * onCreate
   *
   * @param SavedInstanceState return void
   */
  @Override
  protected void onCreate(Bundle SavedInstanceState) {
    super.onCreate(SavedInstanceState);
    setContentView(R.layout.activity_cart);
    setTitle("Cart");
    // get the data
    try {
      itemList = ParseUser.getCurrentUser().fetchIfNeeded().getList("cart");
    } catch (Exception e) {
    }

    list = (ListView) findViewById(R.id.cart);
    if (itemList == null) list.setEmptyView(findViewById(R.id.cart_empty));
    // show the list
    else {
      findViewById(R.id.cart_empty).setVisibility(View.GONE);

      final CartItemAdapter adapter =
          new CartItemAdapter(CartActivity.this, R.layout.cart_item, itemList);

      list.setAdapter(adapter);
      // implement the deleting an item from the cart
      SwipeDismissListViewTouchListener touchListener =
          new SwipeDismissListViewTouchListener(
              list,
              new SwipeDismissListViewTouchListener.DismissCallbacks() {
                @Override
                public boolean canDismiss(int position) {
                  return true;
                }

                // handle the deleted item
                @Override
                public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                  for (int position : reverseSortedPositions) {

                    adapter.remove(adapter.getItem(position));
                  }
                  adapter.notifyDataSetChanged();

                  ParseUser.getCurrentUser().put("cart", itemList);
                  ParseUser.getCurrentUser().saveInBackground();
                }
              });
      list.setOnTouchListener(touchListener);
      // Setting this scroll listener is required to ensure that during ListView scrolling,
      // we don't look for swipes.
      list.setOnScrollListener(touchListener.makeScrollListener());
    }
    Intent intent = new Intent(this, PayPalService.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
    startService(intent);
  }
 /** 进行一些关键性的初始化操作,比如:将下拉头向上偏移进行隐藏,给ListView注册touch事件。 */
 @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
   super.onLayout(changed, l, t, r, b);
   if (changed && !loadOnce) {
     hideHeaderHeight = -header.getHeight();
     headerLayoutParams = (MarginLayoutParams) header.getLayoutParams();
     headerLayoutParams.topMargin = hideHeaderHeight;
     listView = (ListView) getChildAt(1);
     listView.setOnTouchListener(this);
     loadOnce = true;
   }
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_swipe);
    initView();
    for (int i = 0; i < 20; i++) {
      HashMap<String, Object> itemData = new HashMap<String, Object>();
      itemData.put("ManName", "阿根廷球迷" + i);
      itemData.put("LastTime", "最近发言:十分钟以前");
      data.add(itemData);
    }

    baseAdapter =
        new BaseAdapter() {
          @Override
          public int getCount() {
            return data.size();
          }

          @Override
          public Object getItem(int position) {
            return data.get(position);
          }

          @Override
          public long getItemId(int position) {
            return position;
          }

          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
              LayoutInflater layoutInflater = getLayoutInflater();
              convertView =
                  layoutInflater.inflate(R.layout.manager_group_list_item_parent, parent, false);
            }
            Map<String, Object> itemData = (Map<String, Object>) getItem(position);
            ImageView ManImg = (ImageView) convertView.findViewById(R.id.ManImg);
            TextView ManName = (TextView) convertView.findViewById(R.id.ManName);
            TextView LastTime = (TextView) convertView.findViewById(R.id.LastTime);
            ManName.setText(itemData.get("ManName").toString());
            LastTime.setText(itemData.get("LastTime").toString());
            return convertView;
          }
        };
    GroupManList.setAdapter(baseAdapter);
    final ListViewSwipeGesture touchListener =
        new ListViewSwipeGesture(GroupManList, swipeListener, this);
    touchListener.SwipeType = ListViewSwipeGesture.Double; // 设置两个选项列表项的背景
    GroupManList.setOnTouchListener(touchListener);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Parse.initialize(
        this,
        "eWwRUTH1UIfOuAjxlyE4fkrDii5AuKDWGoLvZq0w",
        "tfreVuLEyblkzLQN6LXL5mLtYeIrsh9yWfiVr5ql");
    ParseAnalytics.trackAppOpened(getIntent());
    ParseObject.registerSubclass(Task.class);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser == null) {
      Intent intent = new Intent(this, LoginActivity.class);
      startActivity(intent);
      finish();
    }

    mAdapter = new TaskAdapter(this, new ArrayList<Task>());

    mTaskInput = (EditText) findViewById(R.id.task_input);
    mListView = (ListView) findViewById(R.id.task_list);
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(this);

    updateData();

    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            mListView,
            new SwipeDismissListViewTouchListener.OnDismissCallback() {
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                  try {
                    mAdapter.getItem(position).delete();
                  } catch (ParseException e) {
                    e.printStackTrace();
                  }
                  mAdapter.remove(mAdapter.getItem(position));
                }
                mAdapter.notifyDataSetChanged();
              }
            });
    mListView.setOnTouchListener(touchListener);
    mListView.setOnScrollListener(touchListener.makeScrollListener());

    registerForContextMenu(mListView);
  }
  public void init() {
    ListView listView = (ListView) grandpa.findViewById(R.id.listViewPay);

    adapter = new ItemAdapter(grandpa);
    listView.setAdapter(adapter);

    gestureDetector = new GestureDetector(new ListViewGestureListener(adapter));

    listView.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMGroupManager.getInstance().getAllGroups();
    groupListView = (ListView) findViewById(R.id.fragment_container);
    groupListView = (ListView) findViewById(R.id.list);
    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == groupAdapter.getCount() - 1) {
              // 新建群聊
              startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            } else {
              // 进入群聊
              Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
              // it is group chat
              intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
              intent.putExtra("groupId", groupAdapter.getItem(position - 1).getGroupId());
              startActivityForResult(intent, 0);
            }
          }
        });
    groupListView.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (getWindow().getAttributes().softInputMode
                != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
              if (getCurrentFocus() != null)
                inputMethodManager.hideSoftInputFromWindow(
                    getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
          }
        });
  }
  private void addAllPagesTab() {
    Log.d(LOGTAG, "Creating All Pages tab");

    addAwesomeTab(ALL_PAGES_TAB, R.string.awesomebar_all_pages_title, R.id.all_pages_list);

    // Load the list using a custom adapter so we can create the bitmaps
    mAllPagesCursorAdapter =
        new AwesomeBarCursorAdapter(
            mContext,
            R.layout.awesomebar_row,
            null,
            new String[] {URLColumns.TITLE, URLColumns.URL, URLColumns.FAVICON},
            new int[] {R.id.title, R.id.url, R.id.favicon});

    mAllPagesCursorAdapter.setViewBinder(new AwesomeCursorViewBinder());

    mAllPagesCursorAdapter.setFilterQueryProvider(
        new FilterQueryProvider() {
          public Cursor runQuery(CharSequence constraint) {
            ContentResolver resolver = mContext.getContentResolver();
            long start = SystemClock.uptimeMillis();

            Cursor c = BrowserDB.filter(resolver, constraint, MAX_RESULTS);
            c.getCount(); // ensure the query runs at least once

            long end = SystemClock.uptimeMillis();
            Log.i(LOGTAG, "Got cursor in " + (end - start) + "ms");

            return c;
          }
        });

    final ListView allPagesList = (ListView) findViewById(R.id.all_pages_list);

    allPagesList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            handleItemClick(allPagesList, position);
          }
        });

    allPagesList.setAdapter(mAllPagesCursorAdapter);
    allPagesList.setOnTouchListener(mListTouchListener);
  }
 private void initLv() {
   courseLv = (ListView) findViewById(R.id.lv_stu_call);
   courses = manager.getAllCouresFromSqlite();
   adapter = new StuCourseAdapter(this, courses);
   courseLv.setAdapter(adapter);
   courseLv.setOnTouchListener(new ShowHideOnScroll(fab));
   courseLv.setOnItemLongClickListener(
       new AdapterView.OnItemLongClickListener() {
         @Override
         public boolean onItemLongClick(
             AdapterView<?> parent, View view, final int position, long id) {
           AlertDialog.Builder builder = new AlertDialog.Builder(StuCallCourseActivity.this);
           builder.setTitle("删除课程");
           builder.setMessage("确定删除:" + courses.get(position).getCourse_name() + "吗?");
           builder.setNegativeButton(
               "删除",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   manager.deleteInSqlite(courses.get(position));
                   courses.remove(position);
                   adapter.notifyDataSetChanged();
                 }
               });
           builder.setPositiveButton(
               "取消",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {}
               });
           return true;
         }
       });
   courseLv.setOnItemClickListener(
       new AdapterView.OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           Course course = courses.get(position);
           Intent intent = new Intent(StuCallCourseActivity.this, StuCallActivity.class);
           intent.putExtra("userID", course.getUserID());
           startActivity(intent);
         }
       });
 }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    List<String> testlist = new ArrayList<String>();
    testlist.add("a");
    adapter =
        new CustomArrayAdapter(
            container.getContext(),
            R.layout.schedule_list_item_layout,
            R.id.schedule_artist_name,
            new ArrayList<Artist>(),
            false);
    ListView listView = (ListView) rootView.findViewById(R.id.schedule_list_view);
    listView.setAdapter(adapter);

    // Add swipe event handlers
    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            listView,
            new SwipeDismissListViewTouchListener.DismissCallbacks() {
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                if (adapter instanceof CustomArrayAdapter) {
                  for (int position : reverseSortedPositions) {
                    Artist item = adapter.getItem(position);
                    if (aaf == null) {
                      aaf = ScheduleFragment.this.homeActivity.getAllActsFragment();
                    }
                    aaf.addActToList(item);
                    adapter.remove(item);
                    ScheduleFragment.this.homeActivity.removeArtistFromSchedule(item);
                  }
                  adapter.notifyDataSetChanged();
                }
              }

              public boolean canDismiss(int position) {
                return true;
              }
            });
    listView.setOnTouchListener(touchListener);
    listView.setOnScrollListener(touchListener.makeScrollListener());
  }
  /** 初始化页面 */
  public void initPage(ArrayList<HashMap<String, Object>> resultDataList) {
    listView = (ListView) view.findViewById(R.id.highway_scale_statistics_details_listview);
    listView.setEmptyView(view.findViewById(R.id.empty_view));

    listView.setDivider(null); // 设置分隔线
    dataList = new ArrayList<HashMap<String, Object>>();
    // 初始化查询参数
    adapter = new DataAdapter(activity);
    listView.setAdapter(adapter);

    initParams();
    if (resultDataList != null) {
      dataList = resultDataList;
    } else {
      getData();
    }
    listView.setOnScrollListener(
        new ListScrollListener(this, FraemworkConstant.pullupRefreshNumber));
    listView.setOnTouchListener(new ListTouchListener(false, listView, this));
  }
Example #24
0
  public PendingOrders(Activity activity) {
    this._activity = activity;
    this._listView = new ListView(_activity);
    this._notify = new TextView(_activity);
    this._list = new ArrayList<String>();
    this._order_id = new ArrayList<String>();

    sharedPreferences = _activity.getSharedPreferences("Papajoe", Context.MODE_PRIVATE);
    user_id = sharedPreferences.getString("user_id", "");

    final SwipeDetector swipeDetector = new SwipeDetector();
    _listView.setOnTouchListener(swipeDetector);
    // _listView.setOnItemClickListener(listener);
    _listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (swipeDetector.swipeDetected()) {
              if (swipeDetector.getAction() == SwipeDetector.Action.RL) {

                Toast.makeText(_activity, "Right to left", Toast.LENGTH_LONG).show();

              } else {
                Toast.makeText(_activity, "other then Right to left", Toast.LENGTH_LONG).show();
              }
            } else {
              Toast.makeText(_activity, "Click", Toast.LENGTH_LONG).show();
            }
          }
        });

    /*
    _listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            new orderDetails().execute(_order_id.get(position));
        }
    });
    */
  }
  /** Populate the listview with files and/or subdirectories of the current directory */
  private void initBookmarkListView() {
    final ListView bookmarkListView = getListView();
    bookmarkListView.setAdapter(mAdapter);
    bookmarkListView.setTextFilterEnabled(true);

    bookmarkListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parentUId, View view, int position, long id) {
            FileSystemObject f = (FileSystemObject) bookmarkListView.getAdapter().getItem(position);
            mBookmarkListener.onBookmarkItemClick(f);
          }
        });

    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            bookmarkListView,
            new com.simplecloud.android.common.ui.SwipeDismissListViewTouchListener
                .DismissCallbacks() {
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                  FileSystemObject f = mAdapter.getItem(position);
                  mAdapter.remove(f);
                  FileSystemObjectDAO mFileDAO = new FileSystemObjectDAO(getActivity());
                  if (f.getAccId() == 0) mFileDAO.deleteLocalBookmark(f.getUId());
                  else mFileDAO.setBookmark(f.getAccId(), f.getUId(), false);
                }
                mAdapter.notifyDataSetChanged();
              }

              @Override
              public boolean canDismiss(int position) {
                return true;
              }
            });
    bookmarkListView.setOnTouchListener(touchListener);
    bookmarkListView.setOnScrollListener(touchListener.makeScrollListener());
    registerForContextMenu(bookmarkListView);
  }
Example #26
0
  @Override
  public void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView listView = getListView();
    listView.setDividerHeight(0);

    final SwipeDismissListViewTouchListener swipeDismissListener;
    swipeDismissListener = createSwipeDismissListener(listView);
    listView.setOnTouchListener(swipeDismissListener);
    listView.setOnScrollListener(swipeDismissListener.makeScrollListener());

    if (!listAdapter.onRestoreInstanceState(savedInstanceState)) {
      listAdapter.loadContents(activity);
    }

    if (savedInstanceState != null) {
      final int firstPosition = savedInstanceState.getInt(KEY_STATE_FIRST_POS, 0);
      final int top = savedInstanceState.getInt(KEY_STATE_TOP, 0);
      listView.setSelectionFromTop(firstPosition, top);
    }
  }
  // TODO 设置listview下拉刷新,为了阅后即焚暂时取消
  private void setupWidget() {
    singleChatLv.setOnScrollListener(mOnScrollListener);
    singleChatLv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
    singleChatLv.setOnTouchListener(mOnTouchListener);
    singleChatLv.setOnItemClickListener(mItemClickListener);
    singleChatLv.setKeepScreenOn(true);
    singleChatLv.post(
        new Runnable() {
          @Override
          public void run() {
            singleChatLv.setSelection(singleChatLv.getCount());
          }
        });
    registerForContextMenu(singleChatLv);

    mmPullDownView = (ChatPullDownListView) findViewById(R.id.chat_list_pulldown_view);
    mmPullDownView.setTopViewInitialize(true);
    mmPullDownView.setIsCloseTopAllowRefersh(false);
    mmPullDownView.setHasbottomViewWithoutscroll(false);
    mmPullDownView.setOnRefreshAdapterDataListener(mOnRefreshAdapterDataListener);
    mmPullDownView.setOnListViewTopListener(mOnListViewTopListener);
    mmPullDownView.setOnListViewBottomListener(mOnListViewBottomListener);
  }
  // https://github.com/romannurik/Android-SwipeToDismiss/blob/master/src/com/example/android/swipedismiss/MainActivity.java
  private void bindSwipeListener() {
    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            lv,
            new SwipeDismissListViewTouchListener.DismissCallbacks() {
              @Override
              public boolean canDismiss(int position) {
                return true;
              }

              @Override
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                  adapter.remove(position);
                }
                adapter.notifyDataSetChanged();
                Toast.makeText(FavoritesActivity.this, "Favorite deleted", Toast.LENGTH_LONG)
                    .show();
              }
            });
    lv.setOnTouchListener(touchListener);
    lv.setOnScrollListener(touchListener.makeScrollListener());
  }
  public void initView() {
    mContext = DoctorChatDetailActivity.this;
    sv = (ScrollView) findViewById(R.id.chat_scroll);
    chat_record_list = (ListView) findViewById(R.id.chat_record_list);
    editMessage = (EditText) findViewById(R.id.chat_editmessage);
    sendBtn = (Button) findViewById(R.id.btn_send_text);
    btnBack = (Button) findViewById(R.id.btn_back);

    // editMessage.

    sendBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            String text = editMessage.getText().toString();
            editMessage.setText("");
            if (text != null && !text.equals("")) {
              InsertChatRecordReq req = new InsertChatRecordReq();
              req.setDoctor_id(doctor_id);
              req.setMessage(text);
              req.setPatient_id_card(patient_id);
              req.setDoctor_name(doctor_name);
              GsonServlet<InsertChatRecordReq, CommonRes> gsonServlet =
                  new GsonServlet<InsertChatRecordReq, CommonRes>(mContext);
              gsonServlet.request(req, CommonRes.class);
              gsonServlet.setOnResponseEndListening(
                  new OnResponseEndListening<InsertChatRecordReq, CommonRes>() {

                    @Override
                    public void onResponseEnd(
                        InsertChatRecordReq commonReq,
                        CommonRes commonRes,
                        boolean result,
                        String errmsg,
                        int responseCode) {
                      // TODO Auto-generated method stub

                    }

                    @Override
                    public void onResponseEndSuccess(
                        InsertChatRecordReq commonReq,
                        CommonRes commonRes,
                        String errmsg,
                        int responseCode) {
                      // TODO Auto-generated method stub

                    }

                    @Override
                    public void onResponseEndErr(
                        InsertChatRecordReq commonReq,
                        CommonRes commonRes,
                        String errmsg,
                        int responseCode) {
                      // TODO Auto-generated method stub
                      Toast.makeText(mContext, "发送错误" + errmsg, Toast.LENGTH_SHORT).show();
                    }
                  });
            } else {
              Toast.makeText(mContext, "请输入咨询内容!", Toast.LENGTH_SHORT).show();
            }
          }
        });

    btnBack.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    chat_record_list.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {}
        });
    chat_record_list.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            sv.requestDisallowInterceptTouchEvent(true);
            return false;
          }
        });
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle SavedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_new_photo, parent, false);
    header = (ViewGroup) inflater.inflate(R.layout.item_header, postHashtags, false);

    photoFile = null;
    videoFile = null;

    postHashtags = (ListView) v.findViewById(R.id.post_hashtags);

    postTags = (RelativeLayout) v.findViewById(R.id.post_tags);
    postVisual = (RelativeLayout) v.findViewById(R.id.post_visual);
    postImage = (ImageView) v.findViewById(R.id.post_image);
    postDeny = (ImageButton) v.findViewById(R.id.post_deny);
    postAccept = (ImageButton) v.findViewById(R.id.post_accept);

    adapter =
        new PostAdapter<String>(
            getActivity().getApplicationContext(),
            R.layout.item_list_hashtags,
            R.id.text1,
            hashtags,
            this);
    try {
      postHashtags.addHeaderView(header, null, false);
    } catch (Exception e) {
    }
    postHashtags.setAdapter(adapter);

    adapter.notifyDataSetChanged();

    cautionHeader = (LinearLayout) header.findViewById(R.id.post_caution_container);
    cautionHeader.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            removeAllBadHashtags();
          }
        });

    int[] rainbow =
        getActivity().getApplicationContext().getResources().getIntArray(R.array.colorPicker);
    Random rn = new Random();
    int picker = rn.nextInt(rainbow.length);

    /**
     * suggestedHeader = (RelativeLayout) header.findViewById(R.id.post_suggested);
     * suggestedHeader.setBackgroundColor(rainbow[rn.nextInt(rainbow.length)]);
     * suggestedHeader.setOnClickListener(new View.OnClickListener() { @Override public void
     * onClick(View v) {
     *
     * <p>hideKeyboard(); mCallback.onSuggestions(); } });*
     */

    // yep
    // Accept or deny photo
    Drawable dDeny = getResources().getDrawable(R.drawable.icon_exit_c);
    dDeny.setColorFilter(rainbow[picker], PorterDuff.Mode.SRC_ATOP);
    postDeny.setImageDrawable(dDeny);
    postDeny.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            mCallback.onTransitionFromPostion(getArguments().getBoolean("from_camera", true));
            photoFile = null;
            videoFile = null;
          }
        });

    Drawable dAccept = getResources().getDrawable(R.drawable.icon_checkmark_c);
    dAccept.setColorFilter(rainbow[picker], PorterDuff.Mode.SRC_ATOP);
    postAccept.setImageDrawable(dAccept);
    postAccept.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            Bitmap data = getArguments().getParcelable("image");
            String videoPath = getArguments().getString("video", null);
            if (data != null) {
              saveScaledPhoto(data, videoPath);
              hideImage();
            }
          }
        });

    postCancel = (Button) v.findViewById(R.id.post_cancel);
    postCancel.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            showImage();
          }
        });

    // Hashtags
    postText = ((EditText) v.findViewById(R.id.post_text));
    postText.setBackgroundColor(rainbow[picker]);
    postText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {

            if (postText.length() > 0 && s.toString().contains(" ")) {
              String hashing = String.valueOf(postText.getText());
              postText.setText("");
              checkHashtag(hashing);
            }
          }
        });
    postText.setOnEditorActionListener(
        new EditText.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              if (postText.length() > 0) {
                String hashing = String.valueOf(postText.getText());
                postText.setText("");
                checkHashtag(hashing);
                return true;
              }
            }
            return false;
          }
        });

    postText.setFocusableInTouchMode(true);
    postText.requestFocus();
    InputMethodManager imm =
        (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(postText, InputMethodManager.SHOW_IMPLICIT);
    postText.setCursorVisible(true);

    int[] rainbowa =
        getActivity().getApplicationContext().getResources().getIntArray(R.array.colorPicker);
    Random rna = new Random();
    int pickera = rn.nextInt(rainbow.length);

    postDoneContainer = ((LinearLayout) header.findViewById(R.id.post_done_container));
    postDoneContainer.setBackgroundColor(rainbow[rn.nextInt(rainbow.length)]);
    postDoneContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            postDoneContainer.setEnabled(false);
            String hashing = String.valueOf(postText.getText());
            postText.setText("");
            checkHashtag(hashing);

            // Saving Hashtags
            ArrayList<String> cleanHashtags = cleanHashtags(hashtags);

            Hashtag hashtag = new Hashtag();

            for (int i = 0; i < cleanHashtags.size(); i++) {
              String hash = (String) cleanHashtags.get(i);
              hashtag.saveHashtag(hash); //
            }

            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(postText.getWindowToken(), 0);

            // Saving Selfie
            Selfie selfie = new Selfie();

            ParseObject location = ParseUser.getCurrentUser().getParseObject("location");

            if (photoFile == null) {
              Toast.makeText(
                      getActivity(), "Error saving: Not going to save properly", Toast.LENGTH_LONG)
                  .show();
            }

            if (videoFile != null) {
              selfie.setNewSelfie(
                  photoFile, ParseUser.getCurrentUser(), location, cleanHashtags, videoFile);
            } else {
              selfie.setNewSelfie(
                  photoFile, ParseUser.getCurrentUser(), location, cleanHashtags, null);
            }

            // Save the meal and return
            selfie.saveInBackground(
                new SaveCallback() {

                  @Override
                  public void done(ParseException e) {
                    if (e == null) {
                    } else {
                      Log.d("Error saving: ", e.getMessage());
                    }
                  }
                });
            postDoneContainer.setEnabled(true);
            mCallback.onHideFragment();
          }
        });

    postHashtags.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(postText.getWindowToken(), 0);
            postText.setCursorVisible(false);
            String hashing = String.valueOf(postText.getText());
            postText.setText("");
            checkHashtag(hashing);

            return false;
          }
        });

    v.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(postText.getWindowToken(), 0);
            postText.setCursorVisible(false);
            String hashing = String.valueOf(postText.getText());
            postText.setText("");
            checkHashtag(hashing);
            return false;
          }
        });

    adapter.registerDataSetObserver(
        new DataSetObserver() {
          @Override
          public void onChanged() {
            super.onChanged();
            setPlaceholder();
          }
        });

    checkHeader();

    return v;
  }