Search in sources :

Example 36 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project SocialRec by Jkuras.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // when the page is made, determine if the user is signed in or not
    // sets up listener for auth state changes
    // listener calls other db loads and listeners
    setAuth();
    // set layout to activity_main
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // instantiate toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("");
    setSupportActionBar(toolbar);
    // Floating action button
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent k = new Intent(MainActivity.this, QR_Scan.class);
            startActivity(k);
        }
    });
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar)

Example 37 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project todo-mvp-rxjava by albertizzy.

the class TaskDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.taskdetail_act);
    // Set up the toolbar.
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setDisplayShowHomeEnabled(true);
    // Get the requested task id
    String taskId = getIntent().getStringExtra(EXTRA_TASK_ID);
    TaskDetailFragment taskDetailFragment = (TaskDetailFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
    if (taskDetailFragment == null) {
        taskDetailFragment = TaskDetailFragment.newInstance(taskId);
        ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), taskDetailFragment, R.id.contentFrame);
    }
    // Create the presenter
    new TaskDetailPresenter(taskId, Injection.provideTasksRepository(getApplicationContext()), taskDetailFragment, Injection.provideSchedulerProvider());
}
Also used : ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 38 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project Shuttle by timusus.

the class BaseCastManager method reconnectSessionIfPossible.

/**
 * This method tries to automatically re-establish connection to a session if
 * <ul>
 * <li>User had not done a manual disconnect in the last session
 * <li>The Cast Device that user had connected to previously is still running the same session
 * </ul>
 * Under these conditions, a best-effort attempt will be made to continue with the same
 * session.
 * This attempt will go on for <code>timeoutInSeconds</code> seconds.
 *
 * @param timeoutInSeconds the length of time, in seconds, to attempt reconnection before giving
 * up
 * @param ssidName The name of Wifi SSID
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void reconnectSessionIfPossible(final int timeoutInSeconds, String ssidName) {
    LOGD(TAG, String.format("reconnectSessionIfPossible(%d, %s)", timeoutInSeconds, ssidName));
    if (isConnected()) {
        return;
    }
    String routeId = mPreferenceAccessor.getStringFromPreference(PREFS_KEY_ROUTE_ID);
    if (canConsiderSessionRecovery(ssidName)) {
        List<RouteInfo> routes = mMediaRouter.getRoutes();
        RouteInfo theRoute = null;
        if (routes != null) {
            for (RouteInfo route : routes) {
                if (route.getId().equals(routeId)) {
                    theRoute = route;
                    break;
                }
            }
        }
        if (theRoute != null) {
            // route has already been discovered, so lets just get the device
            reconnectSessionIfPossibleInternal(theRoute);
        } else {
            // we set a flag so if the route is discovered within a short period, we let
            // onRouteAdded callback of CastMediaRouterCallback take care of that
            setReconnectionStatus(RECONNECTION_STATUS_STARTED);
        }
        // cancel any prior reconnection task
        if (mReconnectionTask != null && !mReconnectionTask.isCancelled()) {
            mReconnectionTask.cancel(true);
        }
        // we may need to reconnect to an existing session
        mReconnectionTask = new AsyncTask<Void, Integer, Boolean>() {

            @Override
            protected Boolean doInBackground(Void... params) {
                for (int i = 0; i < timeoutInSeconds; i++) {
                    LOGD(TAG, "Reconnection: Attempt " + (i + 1));
                    if (isCancelled()) {
                        return true;
                    }
                    try {
                        if (isConnected()) {
                            cancel(true);
                        }
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    // ignore
                    }
                }
                return false;
            }

            @Override
            protected void onPostExecute(Boolean result) {
                if (result == null || !result) {
                    LOGD(TAG, "Couldn't reconnect, dropping connection");
                    setReconnectionStatus(RECONNECTION_STATUS_INACTIVE);
                    onDeviceSelected(null, /* CastDevice */
                    null);
                }
            }
        };
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mReconnectionTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            mReconnectionTask.execute();
        }
    }
}
Also used : RouteInfo(android.support.v7.media.MediaRouter.RouteInfo) TargetApi(android.annotation.TargetApi)

Example 39 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project Shuttle by timusus.

the class BaseCastManager method addMediaRouterButton.

/**
 * Adds and wires up the Media Router cast button. It returns a reference to the Media Router
 * menu item if the caller needs such reference. It is assumed that the enclosing
 * {@link android.app.Activity} inherits (directly or indirectly) from
 * {@link android.support.v7.app.AppCompatActivity}.
 *
 * @param menu Menu reference
 * @param menuResourceId The resource id of the cast button in the xml menu descriptor file
 */
public final MenuItem addMediaRouterButton(Menu menu, int menuResourceId) {
    MenuItem mediaRouteMenuItem = menu.findItem(menuResourceId);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    if (getMediaRouteDialogFactory() != null) {
        mediaRouteActionProvider.setDialogFactory(getMediaRouteDialogFactory());
    }
    return mediaRouteMenuItem;
}
Also used : MediaRouteActionProvider(android.support.v7.app.MediaRouteActionProvider) MenuItem(android.view.MenuItem)

Example 40 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project GestureViews by alexvasilkov.

the class RecyclerToPagerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_recycler_screen);
    final Painting[] paintings = Painting.list(getResources());
    // Initializing ListView
    list = findViewById(R.id.recycler_list);
    list.setLayoutManager(new LinearLayoutManager(this));
    list.setAdapter(new RecyclerAdapter(paintings, this::onPaintingClick));
    // Initializing ViewPager
    pager = findViewById(R.id.recycler_pager);
    pagerAdapter = new PagerAdapter(pager, paintings, getSettingsController());
    pager.setAdapter(pagerAdapter);
    pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.view_pager_margin));
    // Initializing images animator. It requires us to provide FromTracker and IntoTracker items
    // that are used to find images views for particular item IDs in the list and in the pager
    // to keep them in sync.
    // In this example we will use SimpleTracker which will track images by their positions,
    // if you have a more complicated case see further examples.
    final SimpleTracker listTracker = new SimpleTracker() {

        @Override
        public View getViewAt(int position) {
            RecyclerView.ViewHolder holder = list.findViewHolderForLayoutPosition(position);
            return holder == null ? null : RecyclerAdapter.getImageView(holder);
        }
    };
    final SimpleTracker pagerTracker = new SimpleTracker() {

        @Override
        public View getViewAt(int position) {
            RecyclePagerAdapter.ViewHolder holder = pagerAdapter.getViewHolder(position);
            return holder == null ? null : PagerAdapter.getImageView(holder);
        }
    };
    animator = GestureTransitions.from(list, listTracker).into(pager, pagerTracker);
    // Setting up background animation during image transition
    background = findViewById(R.id.recycler_full_background);
    animator.addPositionUpdateListener((pos, isLeaving) -> applyImageAnimationState(pos));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclePagerAdapter(com.alexvasilkov.gestures.commons.RecyclePagerAdapter) RecyclePagerAdapter(com.alexvasilkov.gestures.commons.RecyclePagerAdapter) SimpleTracker(com.alexvasilkov.gestures.transition.tracker.SimpleTracker) Painting(com.alexvasilkov.gestures.sample.ex.utils.Painting)

Aggregations

View (android.view.View)135 RecyclerView (android.support.v7.widget.RecyclerView)97 TextView (android.widget.TextView)69 Toolbar (android.support.v7.widget.Toolbar)50 ActionBar (android.support.v7.app.ActionBar)49 Intent (android.content.Intent)44 ImageView (android.widget.ImageView)41 AdapterView (android.widget.AdapterView)33 ArrayList (java.util.ArrayList)30 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)29 DialogInterface (android.content.DialogInterface)25 AlertDialog (android.support.v7.app.AlertDialog)25 ListView (android.widget.ListView)25 Bundle (android.os.Bundle)22 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 SharedPreferences (android.content.SharedPreferences)21 Preference (android.support.v7.preference.Preference)20 GridLayoutManager (android.support.v7.widget.GridLayoutManager)19 SuppressLint (android.annotation.SuppressLint)16 Point (android.graphics.Point)16