Search in sources :

Example 36 with Nullable

use of android.support.annotation.Nullable in project agera by google.

the class NotesFragment method onCreateView.

@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.notes_fragment, container, false);
    // Find the clear button and wire the click listener to call the clear notes updatable
    view.findViewById(R.id.clear).setOnClickListener(v -> notesStore.clearNotes());
    // Find the add button and wire the click listener to show a dialog that in turn calls the add
    // note from text from the notes store when adding notes
    view.findViewById(R.id.add).setOnClickListener(v -> {
        final EditText editText = new EditText(v.getContext());
        editText.setId(R.id.edit);
        new AlertDialog.Builder(v.getContext()).setTitle(R.string.add_note).setView(editText).setPositiveButton(R.string.add, (d, i) -> {
            notesStore.insertNoteFromText(editText.getText().toString());
        }).create().show();
    });
    // Setup the recycler view using the repository adapter
    recyclerView = (RecyclerView) view.findViewById(R.id.result);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    final ImageView imageView = (ImageView) view.findViewById(R.id.background);
    updatable = () -> backgroundRepository.get().ifSucceededSendTo(imageView::setImageBitmap);
    return view;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) ImageView(android.widget.ImageView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Nullable(android.support.annotation.Nullable)

Example 37 with Nullable

use of android.support.annotation.Nullable in project agera by google.

the class NotesFragment method onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    notesStore = notesStore(getContext().getApplicationContext());
    pool = new RecycledViewPool();
    final RowHandler<NoteGroup, List<Note>> rowHandler = rowBinder(pool, (r) -> new LinearLayoutManager(getContext(), HORIZONTAL, false), NoteGroup::getId, NoteGroup::getNotes, (r) -> dataBindingRepositoryPresenterOf(Note.class).layout(R.layout.text_layout).itemId(BR.note).handler(BR.click, (Receiver<Note>) (note) -> {
        final EditText editText = new EditText(getContext());
        editText.setId(R.id.edit);
        editText.setText(note.getNote());
        new AlertDialog.Builder(getContext()).setTitle(R.string.edit_note).setView(editText).setPositiveButton(R.string.edit, (d, i) -> notesStore.updateNote(note, editText.getText().toString())).create().show();
    }).handler(BR.longClick, (Receiver<Note>) notesStore::deleteNote).stableIdForItem(Note::getId).forList());
    adapter = repositoryAdapter().addLayout(layout(R.layout.header)).add(notesStore.getNotesRepository(), repositoryPresenterOf(NoteGroup.class).layout(R.layout.note_group_layout).stableIdForItem(NoteGroup::getId).bindWith(rowHandler).recycleWith(rowHandler).forList()).addItem(getInstance().format(new Date()), dataBindingRepositoryPresenterOf(String.class).layout(R.layout.footer).itemId(BR.string).forItem()).build();
    adapter.setHasStableIds(true);
    final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    backgroundRepository = repositoryWithInitialValue(Result.<Bitmap>absent()).observe().onUpdatesPerLoop().goTo(networkExecutor).getFrom(() -> "http://www.gravatar.com/avatar/4df6f4fe5976df17deeea19443d4429d?s=" + Math.max(displayMetrics.heightPixels, displayMetrics.widthPixels)).transform(url -> httpGetRequest(url).compile()).attemptTransform(httpFunction()).orEnd(Result::failure).goTo(calculationExecutor).thenTransform(input -> {
        final byte[] body = input.getBody();
        return absentIfNull(decodeByteArray(body, 0, body.length));
    }).onDeactivation(SEND_INTERRUPT).compile();
}
Also used : Bundle(android.os.Bundle) RepositoryAdapter.repositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter) Date(java.util.Date) HttpFunctions.httpFunction(com.google.android.agera.net.HttpFunctions.httpFunction) LayoutPresenters.layout(com.google.android.agera.rvadapter.LayoutPresenters.layout) ImageView(android.widget.ImageView) Result(com.google.android.agera.Result) Repository(com.google.android.agera.Repository) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore) RowHandler.rowBinder(com.google.android.agera.testapp.RowHandler.rowBinder) Result.absentIfNull(com.google.android.agera.Result.absentIfNull) DateFormat.getInstance(java.text.DateFormat.getInstance) View(android.view.View) Updatable(com.google.android.agera.Updatable) RepositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter) Receiver(com.google.android.agera.Receiver) Executor(java.util.concurrent.Executor) DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf(com.google.android.agera.rvdatabinding.DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Repositories.repositoryWithInitialValue(com.google.android.agera.Repositories.repositoryWithInitialValue) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) RepositoryPresenters.repositoryPresenterOf(com.google.android.agera.rvadapter.RepositoryPresenters.repositoryPresenterOf) AlertDialog(android.app.AlertDialog) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) BitmapFactory.decodeByteArray(android.graphics.BitmapFactory.decodeByteArray) Bitmap(android.graphics.Bitmap) SEND_INTERRUPT(com.google.android.agera.RepositoryConfig.SEND_INTERRUPT) HttpRequests.httpGetRequest(com.google.android.agera.net.HttpRequests.httpGetRequest) Nullable(android.support.annotation.Nullable) HORIZONTAL(android.support.v7.widget.LinearLayoutManager.HORIZONTAL) EditText(android.widget.EditText) EditText(android.widget.EditText) Receiver(com.google.android.agera.Receiver) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DisplayMetrics(android.util.DisplayMetrics) Date(java.util.Date) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) List(java.util.List) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore)

Example 38 with Nullable

use of android.support.annotation.Nullable in project facebook-android-sdk by facebook.

the class DeviceAuthDialog method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    FacebookActivity facebookActivity = (FacebookActivity) getActivity();
    LoginFragment fragment = (LoginFragment) facebookActivity.getCurrentFragment();
    deviceAuthMethodHandler = (DeviceAuthMethodHandler) fragment.getLoginClient().getCurrentHandler();
    if (savedInstanceState != null) {
        RequestState requestState = savedInstanceState.getParcelable(REQUEST_STATE_KEY);
        if (requestState != null) {
            setCurrentRequestState(requestState);
        }
    }
    return view;
}
Also used : FacebookActivity(com.facebook.FacebookActivity) View(android.view.View) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable)

Example 39 with Nullable

use of android.support.annotation.Nullable in project FirebaseUI-Android by firebase.

the class SaveSmartLock method getInstance.

@Nullable
public static SaveSmartLock getInstance(FragmentActivity activity, FlowParameters parameters) {
    SaveSmartLock result;
    FragmentManager fm = activity.getSupportFragmentManager();
    Fragment fragment = fm.findFragmentByTag(TAG);
    if (!(fragment instanceof SaveSmartLock)) {
        result = new SaveSmartLock();
        result.setArguments(FragmentHelper.getFlowParamsBundle(parameters));
        try {
            fm.beginTransaction().add(result, TAG).disallowAddToBackStack().commit();
        } catch (IllegalStateException e) {
            Log.e(TAG, "Cannot add fragment", e);
            return null;
        }
    } else {
        result = (SaveSmartLock) fragment;
    }
    return result;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment) Nullable(android.support.annotation.Nullable)

Example 40 with Nullable

use of android.support.annotation.Nullable in project facebook-android-sdk by facebook.

the class SpaceFragment method onCreateView.

@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    if (view == null) {
        view = inflater.inflate(R.layout.fragment_space, container, false);
    }
    updateHeight(view);
    return view;
}
Also used : View(android.view.View) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)582 View (android.view.View)315 TextView (android.widget.TextView)163 RecyclerView (android.support.v7.widget.RecyclerView)85 BindView (butterknife.BindView)57 ImageView (android.widget.ImageView)52 ArrayList (java.util.ArrayList)43 IOException (java.io.IOException)36 Bundle (android.os.Bundle)35 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)35 Intent (android.content.Intent)32 ViewGroup (android.view.ViewGroup)32 Cursor (android.database.Cursor)29 Uri (android.net.Uri)27 File (java.io.File)24 AdapterView (android.widget.AdapterView)22 List (java.util.List)20 NonNull (android.support.annotation.NonNull)19 Context (android.content.Context)15 Bitmap (android.graphics.Bitmap)15