use of android.support.annotation.RequiresApi in project Alerter by Tapadoo.
the class SwipeDismissTouchListener method performDismiss.
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void performDismiss() {
// Animate the dismissed view to zero-height and then fire the dismiss callback.
// This triggers layout on each animation frame; in the future we may want to do something
// smarter and more performant.
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
final int originalHeight = mView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCallbacks.onDismiss(mView, mToken);
// Reset view presentation
mView.setAlpha(1f);
mView.setTranslationX(0);
lp.height = originalHeight;
mView.setLayoutParams(lp);
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
mView.setLayoutParams(lp);
}
});
animator.start();
}
use of android.support.annotation.RequiresApi in project CSCI3130 by T-Caines.
the class CourseViewer method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_course_view);
spinner = findViewById(R.id.viewSpinner);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (spinner.getSelectedItem().toString().equals("Show All")) {
lock(true, false, false);
} else if (spinner.getSelectedItem().toString().equals("Show Non-Conflicting")) {
lock(false, true, false);
} else if (spinner.getSelectedItem().toString().equals("Show Schedule")) {
lock(false, false, true);
}
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
String uid = user.getUid();
mDatabase = FirebaseDatabase.getInstance().getReference().child("USERDATA").child(uid);
}
firebaseAdapter = new FirebaseListAdapter<Course>(this, Course.class, R.layout.list_view, FirebaseDatabase.getInstance().getReference("COURSE").child(ApplicationData.term.getTerm())) {
@Override
protected void populateView(View v, Course model, int position) {
TextView seats = (TextView) v.findViewById(R.id.seats);
seats.setText(String.format("%s/%s", model.enrollment, model.seatsAvailable));
TextView code = (TextView) v.findViewById(R.id.code);
code.setText(model.faculty + model.courseID);
TextView courseName = (TextView) v.findViewById(R.id.name);
courseName.setText(model.courseName);
TextView timeEnd = (TextView) v.findViewById(R.id.end);
timeEnd.setText("" + model.timeEnd);
TextView timeStart = (TextView) v.findViewById(R.id.start);
timeStart.setText("" + model.timeStart);
TextView days = (TextView) v.findViewById(R.id.days);
// TODO: Right method to convert binary 10101 -> MWF
days.setText("" + model.days);
}
};
// Create list view
listView = findViewById(R.id.list_view);
listView.setAdapter(firebaseAdapter);
switch(ApplicationData.term) {
case FALL:
RadioButton fallRB = findViewById(R.id.fall);
fallRB.setChecked(true);
break;
case WINTER:
RadioButton winterRB = findViewById(R.id.winter);
winterRB.setChecked(true);
break;
case SUMMER:
RadioButton summerRB = findViewById(R.id.summer);
summerRB.setChecked(true);
break;
}
// Set what happens when a list view item is clicked
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Grab selected item from firebase
selectedCourse = firebaseAdapter.getItem(position);
// If there is an item already selected, un-highlight
if (previousSelectedView != null) {
previousSelectedView.setBackgroundColor(getColor(R.color.defaultBackground));
}
// Used to unselect a course. Happens when you select the selected item.
if (previousSelectedView == view) {
previousSelectedView = null;
selectedCourse = null;
return;
}
// Highlight this item
view.setBackgroundColor(getColor(R.color.colorBalanced));
previousSelectedView = view;
}
});
Button addButton = findViewById(R.id.addbutton);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (selectedCourse == null)
return;
if (!courseManager.capReached(selectedCourse, v)) {
System.out.println("Adding failed");
}
}
});
Button dropButton = findViewById(R.id.dropbutton);
dropButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (selectedCourse == null)
return;
if (selectedCourse.hasLab) {
courseManager.dropLabContinue(selectedCourse, v);
} else {
courseManager.confirmDrop(selectedCourse, v);
}
}
});
}
use of android.support.annotation.RequiresApi in project ForPDA by RadiationX.
the class App method onCreate.
@Override
public void onCreate() {
super.onCreate();
instance = this;
long time = System.currentTimeMillis();
ACRA.init(this);
ACRA.getErrorReporter().putCustomData("USER_NICK", getPreferences().getString("auth.user.nick", "null"));
RxJavaPlugins.setErrorHandler(throwable -> {
Log.d("SUKA", "RxJavaPlugins errorHandler " + throwable);
throwable.printStackTrace();
});
setTheme(isDarkTheme() ? R.style.DarkAppTheme : R.style.LightAppTheme);
try {
String inputHistory = getPreferences().getString("app.versions.history", "");
String[] history = TextUtils.split(inputHistory, ";");
int lastVNum = 0;
boolean disorder = false;
for (String version : history) {
int vNum = Integer.parseInt(version);
if (vNum < lastVNum) {
disorder = true;
}
lastVNum = vNum;
}
Object vCode = BuildConfig.VERSION_CODE;
String sVCode = "" + vCode;
int nVCode = Integer.parseInt(sVCode);
if (lastVNum < nVCode) {
List<String> list = new ArrayList<>(Arrays.asList(history));
list.add(Integer.toString(nVCode));
getPreferences().edit().putString("app.versions.history", TextUtils.join(";", list)).apply();
}
if (disorder) {
throw new Exception("Нарушение порядка версий!");
}
} catch (Exception ex) {
ex.printStackTrace();
ACRA.getErrorReporter().putCustomData("VERSIONS_HISTORY", getPreferences().getString("app.versions.history", ""));
ACRA.getErrorReporter().handleException(ex);
}
ACRA.getErrorReporter().putCustomData("VERSIONS_HISTORY", getPreferences().getString("app.versions.history", ""));
density = getResources().getDisplayMetrics().density;
initImageLoader(this);
px2 = getContext().getResources().getDimensionPixelSize(R.dimen.dp2);
px4 = getContext().getResources().getDimensionPixelSize(R.dimen.dp4);
px6 = getContext().getResources().getDimensionPixelSize(R.dimen.dp6);
px8 = getContext().getResources().getDimensionPixelSize(R.dimen.dp8);
px12 = getContext().getResources().getDimensionPixelSize(R.dimen.dp12);
px14 = getContext().getResources().getDimensionPixelSize(R.dimen.dp14);
px16 = getContext().getResources().getDimensionPixelSize(R.dimen.dp16);
px20 = getContext().getResources().getDimensionPixelSize(R.dimen.dp20);
px24 = getContext().getResources().getDimensionPixelSize(R.dimen.dp24);
px32 = getContext().getResources().getDimensionPixelSize(R.dimen.dp32);
px36 = getContext().getResources().getDimensionPixelSize(R.dimen.dp36);
px40 = getContext().getResources().getDimensionPixelSize(R.dimen.dp40);
px48 = getContext().getResources().getDimensionPixelSize(R.dimen.dp48);
px56 = getContext().getResources().getDimensionPixelSize(R.dimen.dp56);
px64 = getContext().getResources().getDimensionPixelSize(R.dimen.dp64);
for (Field f : R.string.class.getFields()) {
try {
if (f.getName().contains("res_s_")) {
templateStringCache.put(f.getName(), getString(f.getInt(f)));
}
} catch (Exception ignore) {
}
}
keyboardHeight = getPreferences().getInt("keyboard_height", getContext().getResources().getDimensionPixelSize(R.dimen.default_keyboard_height));
savedKeyboardHeight = keyboardHeight;
Realm.init(this);
RealmConfiguration configuration = new RealmConfiguration.Builder().name("forpda.realm").schemaVersion(4).migration(new DbMigration()).build();
Realm.setDefaultConfiguration(configuration);
Client.get(getContext());
getPreferences().registerOnSharedPreferenceChangeListener(preferenceChangeListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
BroadcastReceiver receiver = new BroadcastReceiver() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onReceive(Context context, Intent intent) {
Log.d(App.class.getSimpleName(), "DOZE ON RECEIVE " + intent);
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm == null)
return;
if (pm.isDeviceIdleMode()) {
// the device is now in doze mode
Log.d(App.class.getSimpleName(), "DOZE MODE ENABLYA");
} else {
// the device just woke up from doze mode
Log.d(App.class.getSimpleName(), "DOZE MODE DISABLYA");
NotificationsService.startAndCheck();
}
}
};
registerReceiver(receiver, new IntentFilter(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED));
}
IntentFilter wakeUpFilter = new IntentFilter();
wakeUpFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
wakeUpFilter.addAction(Intent.ACTION_SCREEN_ON);
registerReceiver(new WakeUpReceiver(), wakeUpFilter);
// На каких-то диких калькуляторах может быть ANR, поэтому в фоновый поток
Observable.fromCallable(() -> {
JobConfig.addLogger((priority, tag, message, t) -> {
Log.e("JobLogger", "Job: pr=" + priority + "; t=" + tag + "; m=" + message + "; th=" + t);
});
JobConfig.setLogcatEnabled(false);
JobManager.create(this).addJobCreator(new NotificationsJobCreator());
JobManager.instance().cancelAllForTag(NotificationsJob.TAG);
new JobRequest.Builder(NotificationsJob.TAG).setPeriodic(TimeUnit.MINUTES.toMillis(16L)).setRequiresCharging(false).setRequiresDeviceIdle(false).setRequiredNetworkType(JobRequest.NetworkType.ANY).build().schedule();
return true;
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
QmsHelper.init();
Log.e("APP", "TIME APP FINAL " + (System.currentTimeMillis() - time));
}
use of android.support.annotation.RequiresApi in project toshi-android-client by toshiapp.
the class ChatNotificationManager method buildDirectReplyAction.
@RequiresApi(24)
private static NotificationCompat.Action buildDirectReplyAction(final ChatNotification activeChatNotification) {
final String messageLabel = BaseApplication.get().getString(R.string.message);
final RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY).setLabel(messageLabel).build();
return new NotificationCompat.Action.Builder(R.drawable.ic_send, messageLabel, activeChatNotification.getDirectReplyIntent()).addRemoteInput(remoteInput).build();
}
use of android.support.annotation.RequiresApi in project toshi-android-client by toshiapp.
the class ToshiNotificationBuilder method createPaymentsChannel.
@RequiresApi(api = 26)
private static NotificationChannel createPaymentsChannel() {
final String id = String.valueOf(SofaType.PAYMENT);
final NotificationChannel notificationChannel = new NotificationChannel(id, PAYMENTS_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
return addNotificationAttributes(notificationChannel);
}
Aggregations