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;
}
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;
}
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));
}
}
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;
}
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);
}
Aggregations