Search in sources :

Example 86 with NonNull

use of android.support.annotation.NonNull in project AndroidPicker by gzu-liyujiang.

the class LinkagePicker method makeCenterView.

@NonNull
@Override
protected View makeCenterView() {
    if (null == provider) {
        throw new IllegalArgumentException("please set data provider before make view");
    }
    int[] widths = getColumnWidths(provider.isOnlyTwo());
    LinearLayout layout = new LinearLayout(activity);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setGravity(Gravity.CENTER);
    final WheelView firstView = new WheelView(activity);
    firstView.setTextSize(textSize);
    firstView.setTextColor(textColorNormal, textColorFocus);
    firstView.setLineConfig(lineConfig);
    firstView.setOffset(offset);
    firstView.setCycleDisable(cycleDisable);
    layout.addView(firstView);
    if (TextUtils.isEmpty(firstLabel)) {
        firstView.setLayoutParams(new LinearLayout.LayoutParams(widths[0], WRAP_CONTENT));
    } else {
        firstView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        TextView labelView = new TextView(activity);
        labelView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        labelView.setTextSize(textSize);
        labelView.setTextColor(textColorFocus);
        labelView.setText(firstLabel);
        layout.addView(labelView);
    }
    final WheelView secondView = new WheelView(activity);
    secondView.setTextSize(textSize);
    secondView.setTextColor(textColorNormal, textColorFocus);
    secondView.setLineConfig(lineConfig);
    secondView.setOffset(offset);
    secondView.setCycleDisable(cycleDisable);
    layout.addView(secondView);
    if (TextUtils.isEmpty(secondLabel)) {
        secondView.setLayoutParams(new LinearLayout.LayoutParams(widths[1], WRAP_CONTENT));
    } else {
        secondView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        TextView labelView = new TextView(activity);
        labelView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        labelView.setTextSize(textSize);
        labelView.setTextColor(textColorFocus);
        labelView.setText(secondLabel);
        layout.addView(labelView);
    }
    final WheelView thirdView = new WheelView(activity);
    if (!provider.isOnlyTwo()) {
        thirdView.setTextSize(textSize);
        thirdView.setTextColor(textColorNormal, textColorFocus);
        thirdView.setLineConfig(lineConfig);
        thirdView.setOffset(offset);
        thirdView.setCycleDisable(cycleDisable);
        layout.addView(thirdView);
        if (TextUtils.isEmpty(thirdLabel)) {
            thirdView.setLayoutParams(new LinearLayout.LayoutParams(widths[2], WRAP_CONTENT));
        } else {
            thirdView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
            TextView labelView = new TextView(activity);
            labelView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
            labelView.setTextSize(textSize);
            labelView.setTextColor(textColorFocus);
            labelView.setText(thirdLabel);
            layout.addView(labelView);
        }
    }
    firstView.setItems(provider.provideFirstData(), selectedFirstIndex);
    firstView.setOnWheelListener(new WheelView.OnWheelListener() {

        @Override
        public void onSelected(boolean isUserScroll, int index, String item) {
            selectedFirstItem = item;
            selectedFirstIndex = index;
            if (onWheelListener != null) {
                onWheelListener.onFirstWheeled(selectedFirstIndex, selectedFirstItem);
            }
            if (!isUserScroll) {
                return;
            }
            LogUtils.verbose(this, "change second data after first wheeled");
            //重置第二级索引
            selectedSecondIndex = 0;
            //重置第三级索引
            selectedThirdIndex = 0;
            //根据第一级数据获取第二级数据
            List<String> secondData = provider.provideSecondData(selectedFirstIndex);
            secondView.setItems(secondData, selectedSecondIndex);
            if (provider.isOnlyTwo()) {
                //仅仅二级联动
                return;
            }
            //根据第二级数据获取第三级数据
            List<String> thirdData = provider.provideThirdData(selectedFirstIndex, selectedSecondIndex);
            thirdView.setItems(thirdData, selectedThirdIndex);
        }
    });
    secondView.setItems(provider.provideSecondData(selectedFirstIndex), selectedSecondIndex);
    secondView.setOnWheelListener(new WheelView.OnWheelListener() {

        @Override
        public void onSelected(boolean isUserScroll, int index, String item) {
            selectedSecondItem = item;
            selectedSecondIndex = index;
            if (onWheelListener != null) {
                onWheelListener.onSecondWheeled(selectedSecondIndex, selectedSecondItem);
            }
            if (!isUserScroll) {
                return;
            }
            if (provider.isOnlyTwo()) {
                //仅仅二级联动
                return;
            }
            LogUtils.verbose(this, "change third data after second wheeled");
            //重置第三级索引
            selectedThirdIndex = 0;
            List<String> thirdData = provider.provideThirdData(selectedFirstIndex, selectedSecondIndex);
            //根据第二级数据获取第三级数据
            thirdView.setItems(thirdData, selectedThirdIndex);
        }
    });
    if (provider.isOnlyTwo()) {
        //仅仅二级联动
        return layout;
    }
    thirdView.setItems(provider.provideThirdData(selectedFirstIndex, selectedSecondIndex), selectedThirdIndex);
    thirdView.setOnWheelListener(new WheelView.OnWheelListener() {

        @Override
        public void onSelected(boolean isUserScroll, int index, String item) {
            selectedThirdItem = item;
            selectedThirdIndex = index;
            if (onWheelListener != null) {
                onWheelListener.onThirdWheeled(selectedThirdIndex, selectedThirdItem);
            }
        }
    });
    return layout;
}
Also used : WheelView(cn.qqtheme.framework.widget.WheelView) TextView(android.widget.TextView) ArrayList(java.util.ArrayList) List(java.util.List) LinearLayout(android.widget.LinearLayout) NonNull(android.support.annotation.NonNull)

Example 87 with NonNull

use of android.support.annotation.NonNull in project cardslib by gabrielemariotti.

the class CardArrayRecyclerViewAdapter method remove.

/**
     * Removes the element at position
     * @param position
     * @return
     */
@NonNull
@Override
public Card remove(final int position) {
    Card result = mCards.remove(position);
    notifyItemRemoved(position);
    return result;
}
Also used : Card(it.gmariotti.cardslib.library.internal.Card) NonNull(android.support.annotation.NonNull)

Example 88 with NonNull

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

the class WelcomeBackIdpPrompt method onSuccess.

@Override
public void onSuccess(final IdpResponse idpResponse) {
    if (idpResponse == null) {
        // do nothing
        return;
    }
    AuthCredential newCredential = AuthCredentialHelper.getAuthCredential(idpResponse);
    if (newCredential == null) {
        Log.e(TAG, "No credential returned");
        finish(ResultCodes.CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
        return;
    }
    FirebaseUser currentUser = mActivityHelper.getCurrentUser();
    if (currentUser == null) {
        mActivityHelper.getFirebaseAuth().signInWithCredential(newCredential).addOnSuccessListener(new OnSuccessListener<AuthResult>() {

            @Override
            public void onSuccess(AuthResult result) {
                if (mPrevCredential != null) {
                    result.getUser().linkWithCredential(mPrevCredential).addOnFailureListener(new TaskFailureLogger(TAG, "Error signing in with previous credential " + idpResponse.getProviderType())).addOnCompleteListener(new FinishListener(idpResponse));
                } else {
                    finish(ResultCodes.OK, IdpResponse.getIntent(idpResponse));
                }
            }
        }).addOnFailureListener(new OnFailureListener() {

            @Override
            public void onFailure(@NonNull Exception e) {
                finishWithError();
            }
        }).addOnFailureListener(new TaskFailureLogger(TAG, "Error signing in with new credential " + idpResponse.getProviderType()));
    } else {
        currentUser.linkWithCredential(newCredential).addOnFailureListener(new TaskFailureLogger(TAG, "Error linking with credential " + idpResponse.getProviderType())).addOnCompleteListener(new FinishListener(idpResponse));
    }
}
Also used : AuthCredential(com.google.firebase.auth.AuthCredential) TaskFailureLogger(com.firebase.ui.auth.ui.TaskFailureLogger) NonNull(android.support.annotation.NonNull) AuthResult(com.google.firebase.auth.AuthResult) FirebaseUser(com.google.firebase.auth.FirebaseUser) OnFailureListener(com.google.android.gms.tasks.OnFailureListener)

Example 89 with NonNull

use of android.support.annotation.NonNull in project qualitymatters by artem-zinnatullin.

the class MainActivityViewModifier method modify.

@NonNull
@Override
public <T extends View> T modify(@NonNull T view) {
    // Basically, what we do here is adding a Developer Setting Fragment to a DrawerLayout!
    DrawerLayout drawerLayout = (DrawerLayout) view.findViewById(R.id.main_drawer_layout);
    DrawerLayout.LayoutParams layoutParams = new DrawerLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    layoutParams.gravity = Gravity.END;
    drawerLayout.addView(LayoutInflater.from(view.getContext()).inflate(R.layout.developer_settings_view, drawerLayout, false), layoutParams);
    return view;
}
Also used : DrawerLayout(android.support.v4.widget.DrawerLayout) NonNull(android.support.annotation.NonNull)

Example 90 with NonNull

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

the class NotesStore method notesStore.

@NonNull
static synchronized NotesStore notesStore(@NonNull final Context applicationContext) {
    // Create a database supplier that initializes the database. This is also used to supply the
    // database in all database operations.
    final NotesSqlDatabaseSupplier databaseSupplier = databaseSupplier(applicationContext);
    // Create a function that processes database write operations.
    final Function<SqlInsertRequest, Result<Long>> insertNoteFunction = databaseInsertFunction(databaseSupplier);
    final Function<SqlUpdateRequest, Result<Integer>> updateNoteFunction = databaseUpdateFunction(databaseSupplier);
    final Function<SqlDeleteRequest, Result<Integer>> deleteNoteFunction = databaseDeleteFunction(databaseSupplier);
    final UpdateDispatcher updateDispatcher = updateDispatcher();
    final Receiver<SqlDeleteRequest> delete = value -> STORE_EXECUTOR.execute(() -> {
        deleteNoteFunction.apply(value);
        updateDispatcher.update();
    });
    final Receiver<SqlUpdateRequest> update = value -> STORE_EXECUTOR.execute(() -> {
        updateNoteFunction.apply(value);
        updateDispatcher.update();
    });
    final Receiver<SqlInsertRequest> insert = value -> STORE_EXECUTOR.execute(() -> {
        insertNoteFunction.apply(value);
        updateDispatcher.update();
    });
    // Create the wired up notes store
    return new NotesStore(repositoryWithInitialValue(INITIAL_VALUE).observe(updateDispatcher).onUpdatesPerLoop().goTo(STORE_EXECUTOR).getFrom(() -> sqlRequest().sql(GET_NOTES_FROM_TABLE).compile()).attemptTransform(databaseQueryFunction(databaseSupplier, cursor -> note(cursor.getInt(ID_COLUMN_INDEX), cursor.getString(NOTE_COLUMN_INDEX)))).orEnd(staticFunction(INITIAL_VALUE)).thenTransform(notes -> {
        final Map<Character, List<Note>> notesGroupsData = new TreeMap<>();
        for (final Note note : notes) {
            final String noteText = note.getNote();
            final char groupId = isEmpty(noteText) ? 0 : noteText.charAt(0);
            List<Note> notesGroupData = notesGroupsData.get(groupId);
            if (notesGroupData == null) {
                notesGroupData = new ArrayList<>();
                notesGroupsData.put(groupId, notesGroupData);
            }
            notesGroupData.add(note);
        }
        final List<NoteGroup> notesGroups = new ArrayList<>();
        for (final Map.Entry<Character, List<Note>> groupData : notesGroupsData.entrySet()) {
            notesGroups.add(noteGroup(groupData.getKey(), groupData.getValue()));
        }
        return notesGroups;
    }).onConcurrentUpdate(SEND_INTERRUPT).onDeactivation(SEND_INTERRUPT).compile(), insert, update, delete, databaseSupplier);
}
Also used : Context(android.content.Context) TextUtils.isEmpty(android.text.TextUtils.isEmpty) SqlDeleteRequest(com.google.android.agera.database.SqlDeleteRequest) NOTES_NOTE_COLUMN(com.google.android.agera.testapp.NotesSqlDatabaseSupplier.NOTES_NOTE_COLUMN) NOTES_NOTE_ID_COLUMN(com.google.android.agera.testapp.NotesSqlDatabaseSupplier.NOTES_NOTE_ID_COLUMN) NOTES_TABLE(com.google.android.agera.testapp.NotesSqlDatabaseSupplier.NOTES_TABLE) Result(com.google.android.agera.Result) SqlDatabaseFunctions.databaseDeleteFunction(com.google.android.agera.database.SqlDatabaseFunctions.databaseDeleteFunction) NotesSqlDatabaseSupplier.databaseSupplier(com.google.android.agera.testapp.NotesSqlDatabaseSupplier.databaseSupplier) NonNull(android.support.annotation.NonNull) Repository(com.google.android.agera.Repository) SqlInsertRequest(com.google.android.agera.database.SqlInsertRequest) SqlRequests.sqlInsertRequest(com.google.android.agera.database.SqlRequests.sqlInsertRequest) ArrayList(java.util.ArrayList) SqlDatabaseSupplier(com.google.android.agera.database.SqlDatabaseSupplier) SqlDatabaseFunctions.databaseQueryFunction(com.google.android.agera.database.SqlDatabaseFunctions.databaseQueryFunction) Map(java.util.Map) NoteGroup.noteGroup(com.google.android.agera.testapp.NoteGroup.noteGroup) Note.note(com.google.android.agera.testapp.Note.note) Receiver(com.google.android.agera.Receiver) SqlDatabaseFunctions.databaseInsertFunction(com.google.android.agera.database.SqlDatabaseFunctions.databaseInsertFunction) Executor(java.util.concurrent.Executor) Collections.emptyList(java.util.Collections.emptyList) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Repositories.repositoryWithInitialValue(com.google.android.agera.Repositories.repositoryWithInitialValue) SqlDatabaseFunctions.databaseUpdateFunction(com.google.android.agera.database.SqlDatabaseFunctions.databaseUpdateFunction) SqlRequests.sqlRequest(com.google.android.agera.database.SqlRequests.sqlRequest) SqlUpdateRequest(com.google.android.agera.database.SqlUpdateRequest) Functions.staticFunction(com.google.android.agera.Functions.staticFunction) Observables.updateDispatcher(com.google.android.agera.Observables.updateDispatcher) SqlRequests.sqlUpdateRequest(com.google.android.agera.database.SqlRequests.sqlUpdateRequest) List(java.util.List) String.valueOf(java.lang.String.valueOf) Function(com.google.android.agera.Function) TreeMap(java.util.TreeMap) SqlRequests.sqlDeleteRequest(com.google.android.agera.database.SqlRequests.sqlDeleteRequest) SEND_INTERRUPT(com.google.android.agera.RepositoryConfig.SEND_INTERRUPT) UpdateDispatcher(com.google.android.agera.UpdateDispatcher) SqlUpdateRequest(com.google.android.agera.database.SqlUpdateRequest) ArrayList(java.util.ArrayList) UpdateDispatcher(com.google.android.agera.UpdateDispatcher) Result(com.google.android.agera.Result) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) TreeMap(java.util.TreeMap) SqlInsertRequest(com.google.android.agera.database.SqlInsertRequest) SqlDeleteRequest(com.google.android.agera.database.SqlDeleteRequest) Map(java.util.Map) TreeMap(java.util.TreeMap) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)747 View (android.view.View)94 TextView (android.widget.TextView)90 ArrayList (java.util.ArrayList)83 Intent (android.content.Intent)53 ContentValues (android.content.ContentValues)46 Bundle (android.os.Bundle)46 Test (org.junit.Test)45 AlertDialog (android.support.v7.app.AlertDialog)41 Cursor (android.database.Cursor)38 List (java.util.List)34 IOException (java.io.IOException)32 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)31 LayoutInflater (android.view.LayoutInflater)29 RecyclerView (android.support.v7.widget.RecyclerView)28 ImageView (android.widget.ImageView)28 File (java.io.File)28 DialogAction (com.afollestad.materialdialogs.DialogAction)25 HashMap (java.util.HashMap)25 Bitmap (android.graphics.Bitmap)24