use of android.content.Context in project platform_frameworks_base by android.
the class SaveFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Context context = inflater.getContext();
final View view = inflater.inflate(R.layout.fragment_save, container, false);
final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
icon.setImageDrawable(IconUtils.loadMimeIcon(context, getArguments().getString(EXTRA_MIME_TYPE)));
mDisplayName = (EditText) view.findViewById(android.R.id.title);
mDisplayName.addTextChangedListener(mDisplayNameWatcher);
mDisplayName.setText(getArguments().getString(EXTRA_DISPLAY_NAME));
mDisplayName.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// key.
if (event.getAction() != KeyEvent.ACTION_DOWN) {
return false;
}
// documents once the textView is empty, we are going to trap it here.
if (keyCode == KeyEvent.KEYCODE_DEL && TextUtils.isEmpty(mDisplayName.getText())) {
return true;
}
if (keyCode == KeyEvent.KEYCODE_ENTER && mSave.isEnabled()) {
performSave();
return true;
}
return false;
}
});
mSave = (Button) view.findViewById(android.R.id.button1);
mSave.setOnClickListener(mSaveListener);
mSave.setEnabled(false);
mProgress = (ProgressBar) view.findViewById(android.R.id.progress);
return view;
}
use of android.content.Context in project platform_frameworks_base by android.
the class DocumentHolderTest method setUp.
public void setUp() throws Exception {
Context context = getContext();
LayoutInflater inflater = LayoutInflater.from(context);
mHolder = new DocumentHolder(getContext(), inflater.inflate(R.layout.item_doc_list, null)) {
@Override
public void bind(Cursor cursor, String modelId, State state) {
}
};
mListener = new TestListener();
mHolder.addEventListener(mListener);
mHolder.itemView.requestLayout();
mHolder.itemView.invalidate();
}
use of android.content.Context in project platform_frameworks_base by android.
the class ModelBackedDocumentsAdapterTest method setUp.
public void setUp() {
final Context testContext = TestContext.createStorageTestContext(getContext(), AUTHORITY);
mModel = new TestModel(AUTHORITY);
mModel.update(NAMES);
DocumentsAdapter.Environment env = new TestEnvironment(testContext);
mAdapter = new ModelBackedDocumentsAdapter(env, new IconHelper(testContext, State.MODE_GRID));
mAdapter.onModelUpdate(mModel);
}
use of android.content.Context in project platform_frameworks_base by android.
the class TileAdapter method onCreateViewHolder.
@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
final Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
if (viewType == TYPE_DIVIDER) {
return new Holder(inflater.inflate(R.layout.qs_customize_tile_divider, parent, false));
}
if (viewType == TYPE_EDIT) {
return new Holder(inflater.inflate(R.layout.qs_customize_divider, parent, false));
}
FrameLayout frame = (FrameLayout) inflater.inflate(R.layout.qs_customize_tile_frame, parent, false);
frame.addView(new CustomizeTileView(context, new QSIconView(context)));
return new Holder(frame);
}
use of android.content.Context in project platform_frameworks_base by android.
the class ServiceWatcher method start.
/**
* Start this watcher, including binding to the current best match and
* re-binding to any better matches down the road.
* <p>
* Note that if there are no matching encryption-aware services, we may not
* bind to a real service until after the current user is unlocked.
*
* @returns {@code true} if a potential service implementation was found.
*/
public boolean start() {
if (isServiceMissing())
return false;
synchronized (mLock) {
bindBestPackageLocked(mServicePackageName, false);
}
// listen for user change
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
mContext.registerReceiverAsUser(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
switchUser(userId);
} else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
unlockUser(userId);
}
}
}, UserHandle.ALL, intentFilter, null, mHandler);
// listen for relevant package changes if service overlay is enabled.
if (mServicePackageName == null) {
mPackageMonitor.register(mContext, null, UserHandle.ALL, true);
}
return true;
}
Aggregations