Search in sources :

Example 21 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project Riksdagskollen by OAndell.

the class CurrentNewsListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_party_list, null);
    currentNewsListAdapter = new CurrentNewsListAdapter(newsList);
    recyclerView = view.findViewById(R.id.recycler_view);
    recyclerView.setAdapter(currentNewsListAdapter);
    recyclerView.setNestedScrollingEnabled(true);
    final LinearLayoutManager mLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (// check for scroll down
            dy > 0) {
                int visibleItemCount = mLayoutManager.getChildCount();
                int totalItemCount = mLayoutManager.getItemCount();
                pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
                if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                    if (!loading)
                        loadNextPage();
                }
            }
        }
    });
    loadingView = view.findViewById(R.id.loading_view);
    loadNextPage();
    return view;
}
Also used : CurrentNewsListAdapter(oscar.riksdagskollen.Utilities.CurrentNewsListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 22 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project afwall by ukanth.

the class AppDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(getString(R.string.traffic_detail_title));
    setContentView(R.layout.app_detail);
    int appid = getIntent().getIntExtra("appid", -1);
    String packageName = getIntent().getStringExtra("package");
    try {
        CheckBox logOption = (CheckBox) findViewById(R.id.notification_p);
        LogPreference logPreference = SQLite.select().from(LogPreference.class).where(LogPreference_Table.uid.eq(appid)).querySingle();
        if (logPreference != null) {
            logOption.setChecked(logPreference.isDisable());
        }
        logOption.setOnCheckedChangeListener((buttonView, isChecked) -> {
            // only use when triggered by user
            if (buttonView.isPressed()) {
                // write the logic here
                G.updateLogNotification(appid, isChecked);
            }
        });
    } catch (Exception e) {
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.app_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final Context ctx = getApplicationContext();
    ImageView image = (ImageView) findViewById(R.id.app_icon);
    TextView textView = (TextView) findViewById(R.id.app_title);
    TextView textView2 = (TextView) findViewById(R.id.app_package);
    TextView up = (TextView) findViewById(R.id.up);
    TextView down = (TextView) findViewById(R.id.down);
    /**/
    final PackageManager packageManager = getApplicationContext().getPackageManager();
    final String[] packageNameList = ctx.getPackageManager().getPackagesForUid(appid);
    final String pName = packageName;
    Button button = findViewById(R.id.app_settings);
    button.setOnClickListener(v -> Api.showInstalledAppDetails(getApplicationContext(), pName));
    ApplicationInfo applicationInfo;
    try {
        if (!packageName.startsWith("dev.afwall.special.")) {
            applicationInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
            if (applicationInfo != null) {
                image.setImageDrawable(applicationInfo.loadIcon(packageManager));
                String name = packageManager.getApplicationLabel(applicationInfo).toString();
                textView.setText(name);
                setTotalBytesManual(down, up, applicationInfo.uid);
            }
        } else {
            image.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.ic_android_white_24dp));
            if (appid >= 0) {
                textView.setText(Api.getSpecialDescription(getApplicationContext(), packageName.replace("dev.afwall.special.", "")));
            } else {
                textView.setText(Api.getSpecialDescriptionSystem(getApplicationContext(), packageName.replace("dev.afwall.special.", "")));
            }
            down.setText(" : " + humanReadableByteCount(0, false));
            up.setText(" : " + humanReadableByteCount(0, false));
            button.setEnabled(false);
        }
        if (packageNameList != null && packageNameList.length > 1) {
            textView2.setText(Arrays.toString(packageNameList));
            button.setEnabled(false);
        } else {
            textView2.setText(packageName);
        }
    } catch (final NameNotFoundException e) {
        down.setText(" : " + humanReadableByteCount(0, false));
        up.setText(" : " + humanReadableByteCount(0, false));
        button.setEnabled(false);
    }
}
Also used : LogPreference(dev.ukanth.ufirewall.log.LogPreference) Context(android.content.Context) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageManager(android.content.pm.PackageManager) Button(android.widget.Button) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Toolbar(android.support.v7.widget.Toolbar)

Example 23 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project SimpleBucketList-material by thevarunshah.

the class BucketItemListView method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bucket_item_listview);
    // fetch toolbar and set it as the action bar
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setContentInsetsRelative(72, 72);
    setSupportActionBar(toolbar);
    // check if tablet view is being used
    boolean tablet = (findViewById(R.id.coordLayout_tablet) != null);
    // obtain list view and create new bucket list custom adapter
    recyclerView = findViewById(R.id.recycler_view);
    recyclerAdapter = new BucketItemListAdapter(this, Utility.getBucketList(), tablet, this);
    // attach adapter to list view
    recyclerView.setAdapter(recyclerAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(recyclerAdapter);
    itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    // obtain add button and attach a on-tap listener to it
    final FloatingActionButton addButton = findViewById(R.id.add_item);
    addButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // inflate layout with customized alert dialog view
            LayoutInflater layoutInflater = LayoutInflater.from(BucketItemListView.this);
            final View dialog = layoutInflater.inflate(R.layout.input_dialog, null);
            final AlertDialog.Builder newItemDialogBuilder = new AlertDialog.Builder(BucketItemListView.this, R.style.AppCompatAlertDialogStyle);
            // customize alert dialog and set its view
            newItemDialogBuilder.setTitle("New Item");
            newItemDialogBuilder.setIcon(R.drawable.ic_launcher);
            newItemDialogBuilder.setView(dialog);
            // fetch and set up edittext
            final EditText input = dialog.findViewById(R.id.input_dialog_text);
            input.setHint("Enter Details");
            input.setFocusableInTouchMode(true);
            input.requestFocus();
            // set up actions for dialog buttons
            newItemDialogBuilder.setPositiveButton("ADD", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialogInterface, int whichButton) {
                    // create new item
                    String itemText = input.getText().toString();
                    Item item = new Item(itemText);
                    // add item to main list and update view
                    Utility.getBucketList().add(item);
                    recyclerAdapter.notifyDataSetChanged();
                    // backup data
                    Utility.writeData(getApplicationContext());
                }
            });
            newItemDialogBuilder.setNegativeButton("CANCEL", null);
            // create and show the dialog
            AlertDialog newItemDialog = newItemDialogBuilder.create();
            newItemDialog.show();
            // show keyboard
            newItemDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        }
    });
    // add specific listeners only if tablet is not being used
    if (!tablet) {
        // moving fab out of the way when scrolling listview
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                if (dy > 0) {
                    // scrolling down
                    addButton.animate().translationY(addButton.getHeight() * 2);
                } else {
                    // scrolling up
                    addButton.animate().translationY(0);
                }
            }
        });
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) BucketItemListAdapter(com.thevarunshah.simplebucketlist.internal.BucketItemListAdapter) DialogInterface(android.content.DialogInterface) SimpleItemTouchHelperCallback(com.thevarunshah.simplebucketlist.internal.SimpleItemTouchHelperCallback) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) MenuItem(android.view.MenuItem) Item(com.thevarunshah.classes.Item) LayoutInflater(android.view.LayoutInflater) FloatingActionButton(android.support.design.widget.FloatingActionButton) OnClickListener(android.view.View.OnClickListener) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Example 24 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project Roblu by wdavies973.

the class Tutorial method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tutorial);
    /*
         * Setup UI
         */
    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("Tutorials");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    // List of tutorials
    tutorials = new ArrayList<>();
    tutorials.add(new RTutorial("Text based", "View the Roblu text based tutorial", "https://docs.google.com/document/d/1DqpgKPdtfZDUc7Zu3MqdJHL59aB-ht8H1ZwllYlzMuc/edit?usp=sharing"));
    tutorials.add(new RTutorial("The basics", "Roblu's mission, description of platforms, terms, etc.", "9j6ysvJJyQg"));
    tutorials.add(new RTutorial("Events", "Learn how to create, manage, backup, organize, and export events", "6BLlLxltppk"));
    tutorials.add(new RTutorial("Forms", "Learn how to create, manage, edit, organize, master form", "xLLbPyhW9fg"));
    tutorials.add(new RTutorial("Roblu Cloud (Network syncing)", "Learn how to setup and sync scouting data across unlimited devices over a data connection.", "z9tIGaaV1jQ"));
    tutorials.add(new RTutorial("Bluetooth Syncing", "Learn how to setup and sync with Bluetooth syncing.", "Adjp3rjt2_4"));
    tutorials.add(new RTutorial("QR Codes", "Learn how to use QR code syncing", "pS_5bvp1D_c"));
    tutorials.add(new RTutorial("Manual Schedule Importer", "Learn how to use the manual schedule importer if the FIRST API is down.", "https://github.com/wdavies973/Roblu/wiki/Manually-Importing-a-Match-Schedule"));
    tutorials.add(new RTutorial("Scouting / Odds and Ends", "Learn about those features that weren't in any of the other tutorial videos", "JL_lSaB0gsk"));
    tutorials.add(new RTutorial("How to get Roblu Cloud for free", "Get Roblu Cloud for free", "dQw4w9WgXcQ"));
    tutorials.add(new RTutorial("Roblu Devlogs", "For those interested in watching the development process", ""));
    /*
         * Add the tutorials to the recycler view
         */
    rv = findViewById(R.id.teams_recycler);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(linearLayoutManager);
    ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
    TutorialsRecyclerAdapter adapter = new TutorialsRecyclerAdapter(this, this, tutorials);
    rv.setAdapter(adapter);
    // Gesture listener
    ItemTouchHelper.Callback callback = new TutorialsRecyclerTouchHelper();
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(rv);
    // Sync UI with settings
    new UIHandler(this, toolbar).update();
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) UIHandler(com.cpjd.roblu.ui.UIHandler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Toolbar(android.support.v7.widget.Toolbar)

Example 25 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project QuickReturn by lawloretienne.

the class SpeedyQuickReturnRecyclerViewOnScrollListener method onScrolled.

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    // apply extra on scroll listener
    for (RecyclerView.OnScrollListener listener : mExtraOnScrollListeners) {
        listener.onScrolled(recyclerView, dx, dy);
    }
    int scrollY = QuickReturnUtils.getScrollY(recyclerView, mColumnCount);
    int diff = mPrevScrollY - scrollY;
    if (diff > 0) {
        // scrolling up
        switch(mQuickReturnViewType) {
            case HEADER:
                if (mHeader.getVisibility() == View.GONE) {
                    mHeader.setVisibility(View.VISIBLE);
                    mHeader.startAnimation(mSlideHeaderDownAnimation);
                }
                break;
            case FOOTER:
                if (mFooter.getVisibility() == View.GONE) {
                    mFooter.setVisibility(View.VISIBLE);
                    mFooter.startAnimation(mSlideFooterUpAnimation);
                }
                break;
            case BOTH:
                if (mHeader.getVisibility() == View.GONE) {
                    mHeader.setVisibility(View.VISIBLE);
                    mHeader.startAnimation(mSlideHeaderDownAnimation);
                }
                if (mFooter.getVisibility() == View.GONE) {
                    mFooter.setVisibility(View.VISIBLE);
                    mFooter.startAnimation(mSlideFooterUpAnimation);
                }
                break;
            case GOOGLE_PLUS:
                if (mHeaderViews != null) {
                    for (View view : mHeaderViews) {
                        if (view.getVisibility() == View.GONE) {
                            view.setVisibility(View.VISIBLE);
                            view.startAnimation(mSlideHeaderDownAnimation);
                        }
                    }
                }
                if (mFooterViews != null) {
                    for (View view : mFooterViews) {
                        int scrollThreshold = (Integer) view.getTag(R.id.scroll_threshold_key);
                        if (diff > scrollThreshold) {
                            if (view.getVisibility() == View.GONE) {
                                view.setVisibility(View.VISIBLE);
                                view.startAnimation(mSlideFooterUpAnimation);
                            }
                        }
                    }
                }
                break;
        }
    } else if (diff < 0) {
        // scrolling down
        switch(mQuickReturnViewType) {
            case HEADER:
                if (mHeader.getVisibility() == View.VISIBLE) {
                    mHeader.setVisibility(View.GONE);
                    mHeader.startAnimation(mSlideHeaderUpAnimation);
                }
                break;
            case FOOTER:
                if (mFooter.getVisibility() == View.VISIBLE) {
                    mFooter.setVisibility(View.GONE);
                    mFooter.startAnimation(mSlideFooterDownAnimation);
                }
                break;
            case BOTH:
                if (mHeader.getVisibility() == View.VISIBLE) {
                    mHeader.setVisibility(View.GONE);
                    mHeader.startAnimation(mSlideHeaderUpAnimation);
                }
                if (mFooter.getVisibility() == View.VISIBLE) {
                    mFooter.setVisibility(View.GONE);
                    mFooter.startAnimation(mSlideFooterDownAnimation);
                }
                break;
            case GOOGLE_PLUS:
                if (mHeaderViews != null) {
                    for (View view : mHeaderViews) {
                        if (view.getVisibility() == View.VISIBLE) {
                            view.setVisibility(View.GONE);
                            view.startAnimation(mSlideHeaderUpAnimation);
                        }
                    }
                }
                if (mFooterViews != null) {
                    for (View view : mFooterViews) {
                        int scrollThreshold = (Integer) view.getTag(R.id.scroll_threshold_key);
                        if (diff < -scrollThreshold) {
                            if (view.getVisibility() == View.VISIBLE) {
                                view.setVisibility(View.GONE);
                                view.startAnimation(mSlideFooterDownAnimation);
                            }
                        }
                    }
                }
                break;
        }
    }
    mPrevScrollY = scrollY;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)37 View (android.view.View)37 Intent (android.content.Intent)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 TextView (android.widget.TextView)16 ImageView (android.widget.ImageView)15 Preference (android.support.v7.preference.Preference)14 Context (android.content.Context)13 PreferenceCategory (android.support.v7.preference.PreferenceCategory)12 BroadcastReceiver (android.content.BroadcastReceiver)8 IntentFilter (android.content.IntentFilter)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 Button (android.widget.Button)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 OnClickListener (android.view.View.OnClickListener)6 FrameLayout (android.widget.FrameLayout)6 SharedPreferences (android.content.SharedPreferences)5 SwitchPreference (android.support.v14.preference.SwitchPreference)5