use of android.content.Context in project android-job by evernote.
the class DatabaseUpgradeTest method testDatabaseUpgrade2to3.
@Test
public void testDatabaseUpgrade2to3() {
Context context = InstrumentationRegistry.getContext();
context.deleteDatabase(DATABASE_NAME);
JobOpenHelper2 openHelper = new JobOpenHelper2(context);
createDatabase(openHelper, false);
createJobs(openHelper);
checkJob(context);
}
use of android.content.Context in project android-job by evernote.
the class JobExecutionTest method afterClass.
@AfterClass
public static void afterClass() {
Context context = InstrumentationRegistry.getContext();
for (Integer jobId : cachedJobIds) {
JobManager.instance().getApi().getCachedProxy(context).cancel(jobId);
}
JobManager.instance().destroy();
}
use of android.content.Context in project Meizhi by drakeet.
the class AnimRecyclerViewAdapter method showItemAnim.
public void showItemAnim(final View view, final int position) {
Context context = view.getContext();
if (position > mLastPosition) {
view.setAlpha(0);
view.postDelayed(() -> {
Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_in_right);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
view.setAlpha(1);
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
view.startAnimation(animation);
}, DELAY * position);
mLastPosition = position;
}
}
use of android.content.Context in project MultiType by drakeet.
the class ExampleInstrumentedTest method useAppContext.
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("me.drakeet.messenger", appContext.getPackageName());
}
use of android.content.Context in project cw-omnibus by commonsguy.
the class IcsListPopupWindow method buildDropDown.
private int buildDropDown() {
ViewGroup dropDownView;
int otherHeights = 0;
if (mDropDownList == null) {
Context context = mContext;
mDropDownList = new DropDownListView(context, !mModal);
if (mDropDownListHighlight != null) {
mDropDownList.setSelector(mDropDownListHighlight);
}
mDropDownList.setAdapter(mAdapter);
mDropDownList.setOnItemClickListener(mItemClickListener);
mDropDownList.setFocusable(true);
mDropDownList.setFocusableInTouchMode(true);
mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position != -1) {
DropDownListView dropDownList = mDropDownList;
if (dropDownList != null) {
dropDownList.mListSelectionHidden = false;
}
}
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
mDropDownList.setOnScrollListener(mScrollListener);
if (mItemSelectedListener != null) {
mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
}
dropDownView = mDropDownList;
View hintView = mPromptView;
if (hintView != null) {
// if an hint has been specified, we accomodate more space for it and
// add a text view in the drop down menu, at the bottom of the list
LinearLayout hintContainer = new LinearLayout(context);
hintContainer.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f);
switch(mPromptPosition) {
case POSITION_PROMPT_BELOW:
hintContainer.addView(dropDownView, hintParams);
hintContainer.addView(hintView);
break;
case POSITION_PROMPT_ABOVE:
hintContainer.addView(hintView);
hintContainer.addView(dropDownView, hintParams);
break;
default:
break;
}
// measure the hint's height to find how much more vertical space
// we need to add to the drop down's height
int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST);
int heightSpec = MeasureSpec.UNSPECIFIED;
hintView.measure(widthSpec, heightSpec);
hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams();
otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
dropDownView = hintContainer;
}
mPopup.setContentView(dropDownView);
} else {
dropDownView = (ViewGroup) mPopup.getContentView();
final View view = mPromptView;
if (view != null) {
LinearLayout.LayoutParams hintParams = (LinearLayout.LayoutParams) view.getLayoutParams();
otherHeights = view.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
}
}
// getMaxAvailableHeight() subtracts the padding, so we put it back
// to get the available height for the whole window
int padding = 0;
Drawable background = mPopup.getBackground();
if (background != null) {
background.getPadding(mTempRect);
padding = mTempRect.top + mTempRect.bottom;
// background so that content will line up.
if (!mDropDownVerticalOffsetSet) {
mDropDownVerticalOffset = -mTempRect.top;
}
}
// Max height available on the screen for a popup.
boolean ignoreBottomDecorations = mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
final int maxHeight = /*mPopup.*/
getMaxAvailableHeight(mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations);
if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
return maxHeight + padding;
}
final int listContent = /*mDropDownList.*/
measureHeightOfChildren(MeasureSpec.UNSPECIFIED, 0, -1, /*ListView.NO_POSITION*/
maxHeight - otherHeights, -1);
// the popup if it is not needed
if (listContent > 0)
otherHeights += padding;
return listContent + otherHeights;
}
Aggregations