@Override
 public void remove(int which) {
   DragSortListView list = getListView();
   String item = adapter.getItem(which);
   adapter.remove(item);
   list.removeCheckState(which);
 }
 @Override
 public void drop(int from, int to) {
   mAdapter.drop(from, to);
   if (mListView.getChoiceMode() != AbsListView.CHOICE_MODE_NONE) {
     mListView.moveCheckState(from, to);
   }
   saveAccountPositions();
 }
 @Override
 public void drop(int from, int to) {
   if (from != to) {
     DragSortListView list = getListView();
     String item = adapter.getItem(from);
     adapter.remove(item);
     adapter.insert(item, to);
     list.moveCheckState(from, to);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_edit_location);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setTitle("Edit Locations");

    LinearLayout add_location = (LinearLayout) findViewById(R.id.linear_layout_add_location);
    add_location.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(EditLocationActivity.this, AddLocationActivity.class));
          }
        });

    LinearLayout add_location_map =
        (LinearLayout) findViewById(R.id.linear_layout_add_location_map);
    add_location_map.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(EditLocationActivity.this, AddLocationMapActivity.class));
          }
        });

    dragSortListView = (DragSortListView) findViewById(R.id.dragable_list_view);
    editLocationListAdapter =
        new EditLocationListAdapter(EditLocationActivity.this, MainActivity.appDataModel.city_list);
    dragSortListView.setAdapter(editLocationListAdapter);
    dragSortListView.setDropListener(
        new DragSortListView.DropListener() {
          @Override
          public void drop(int from, int to) {
            LocationWeatherInfo item = editLocationListAdapter.listModels.get(from);
            editLocationListAdapter.listModels.remove(from);
            if (from > to) --from;
            editLocationListAdapter.listModels.add(to, item);
            editLocationListAdapter.notifyDataSetChanged();
            MainActivity.navigationMenuListAdapter.notifyDataSetChanged();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.checkable_main);

    String[] array = getResources().getStringArray(R.array.jazz_artist_names);
    ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(array));

    adapter = new ArrayAdapter<String>(this, R.layout.list_item_checkable, R.id.text, arrayList);

    setListAdapter(adapter);

    DragSortListView list = getListView();
    list.setDropListener(onDrop);
    list.setRemoveListener(onRemove);
  }
Exemplo n.º 6
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.warp_main);

    DragSortListView lv = (DragSortListView) getListView();

    lv.setDropListener(onDrop);
    lv.setRemoveListener(onRemove);
    lv.setDragScrollProfile(ssProfile);

    array = getResources().getStringArray(R.array.countries);
    list = new ArrayList<String>(Arrays.asList(array));

    adapter = new ArrayAdapter<String>(this, R.layout.list_item_handle_right, R.id.text, list);
    setListAdapter(adapter);
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    DragSortListView lv = (DragSortListView) getListView();
    lv.setDropListener(new ReportDropListener());

    adapter = new ArrayAdapter<>(getActivity(), R.layout.list_item_drag, android.R.id.text1);

    Preferences prefs = new Preferences(getActivity());
    reportClasses = prefs.getReportOrder();
    for (Class<? extends AbstractReport> reportClass : reportClasses) {
      AbstractReport report = AbstractReport.newInstance(reportClass, getActivity());
      adapter.add(report.getTitle());
    }

    setListAdapter(adapter);
  }
Exemplo n.º 8
0
    @Override
    public void onDragFloatView(View floatView, Point floatPoint, Point touchPoint) {
      super.onDragFloatView(floatView, floatPoint, touchPoint);

      final int first = lv.getFirstVisiblePosition();
      final int lvDivHeight = lv.getDividerHeight();

      View div = lv.getChildAt(mDivPos - first - 1);

      if (div != null) {
        if (mDraggedPos >= mDivPos) {
          // don't allow floating View to go above section divider
          final int limit = div.getBottom() + lvDivHeight;
          if (floatPoint.y < limit) {
            floatPoint.y = limit;
          }
        }
      }
    }
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   setHasOptionsMenu(true);
   final FragmentActivity activity = getActivity();
   mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
   mPreferences.registerOnSharedPreferenceChangeListener(this);
   mAdapter = new AccountsAdapter(activity);
   Utils.configBaseAdapter(activity, mAdapter);
   mAdapter.setSortEnabled(true);
   mListView.setAdapter(mAdapter);
   mListView.setDragEnabled(true);
   mListView.setDropListener(this);
   mListView.setOnCreateContextMenuListener(this);
   mListView.setEmptyView(mEmptyView);
   mEmptyText.setText(R.string.no_account);
   mEmptyIcon.setImageResource(R.drawable.ic_info_error_generic);
   getLoaderManager().initLoader(0, null, this);
   setListShown(false);
 }
Exemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_bookmark);
    setTitle(R.string.judul_bukmak_activity);

    adapter = new BookmarkFilterAdapter();
    adapter.reload();

    lv = V.get(this, android.R.id.list);
    lv.setDropListener(adapter);
    lv.setOnItemClickListener(lv_click);
    lv.setAdapter(adapter);

    BookmarkFilterController c = new BookmarkFilterController(lv, adapter);
    lv.setFloatViewManager(c);
    lv.setOnTouchListener(c);

    registerForContextMenu(lv);

    Intent intent = getIntent();
    if (U.equals(intent.getAction(), Intent.ACTION_VIEW)) {
      Uri data = intent.getData();
      if (data != null
          && (U.equals(data.getScheme(), "content")
              || U.equals(data.getScheme(), "file"))) { // $NON-NLS-1$ //$NON-NLS-2$
        try {
          final InputStream inputStream = getContentResolver().openInputStream(data);

          final AlertDialog[] dialog = {null};
          dialog[0] =
              new AlertDialog.Builder(BookmarkActivity.this)
                  .setMessage(R.string.apakah_anda_mau_menumpuk_pembatas_buku_dan_catatan_tanya)
                  .setNegativeButton(R.string.cancel, null)
                  .setNeutralButton(
                      R.string.no,
                      new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog_, int which) {
                          dialog[0].setOnDismissListener(null);
                          importBookmarks(inputStream, false, true);
                        }
                      })
                  .setPositiveButton(
                      R.string.yes,
                      new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog_, int which) {
                          dialog[0].setOnDismissListener(null);
                          importBookmarks(inputStream, true, true);
                        }
                      })
                  .show();
          dialog[0].setOnDismissListener(finishActivityListener);

        } catch (FileNotFoundException e) {
          msgbox(getString(R.string.bl_file_not_found_filename, data.toString()))
              .setOnDismissListener(finishActivityListener);
        }
      }
    }
  }