use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project iNGAGE by davis123123.
the class CategoriesPageFragment method onViewCreated.
@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// TODO fix threadlistadapter for dynamic threads
threadListRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv_posts);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
threadListRecyclerView.setLayoutManager(layoutManager);
threadListRecyclerView.setAdapter(threadListAdapter);
Log.d("STATE", "serverstring" + json_string);
inflateThreads();
threadListAdapter.setOnLoadMoreListener(new ThreadListAdapter.OnLoadMoreListener() {
@Override
public void onLoadMore() {
Log.d("haint", "Load More");
rowCount += 10;
Thread getJSON = new Thread(new Runnable() {
@Override
public void run() {
getThreadsJSON(rowCount);
while (true) {
if (!threadListAdapter.getLoadStat()) {
Log.d("haint", "Load More222");
break;
}
// no longer loading
}
}
});
getJSON.start();
try {
getJSON.join();
// threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
// threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
inflateThreads();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
threadListRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
Log.d("...", "Lastnot Item Wow !");
if (// check for scroll down
dy > 0) {
visibleItemCount = layoutManager.getChildCount();
totalItemCount = layoutManager.getItemCount();
pastVisiblesItems = layoutManager.findFirstVisibleItemPosition();
if (!threadListAdapter.isLoading && (visibleItemCount + pastVisiblesItems) >= totalItemCount) {
// if(mOnLoadMoreListener != null){
Log.d("...", "Last Item Wow !");
threadListAdapter.isLoading = true;
// threadListAdapter.list.add(null);
threadListAdapter.mOnLoadMoreListener.onLoadMore();
}
}
}
});
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project iNGAGE by davis123123.
the class SearchResultFragment method onViewCreated.
@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// TODO fix threadlistadapter for dynamic threads
threadListRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv_posts);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
threadListRecyclerView.setLayoutManager(layoutManager);
threadListRecyclerView.setAdapter(threadListAdapter);
Log.d("STATE", "serverstring" + json_string);
threadListAdapter.setOnLoadMoreListener(new ThreadListAdapter.OnLoadMoreListener() {
@Override
public void onLoadMore() {
Log.d("haint", "Load More");
// threadListAdapter.list.add(null);
// threadListAdapter.notifyItemInserted(threadListAdapter.list.size() - 1);
rowCount += 10;
Thread getJSON = new Thread(new Runnable() {
@Override
public void run() {
getThreadsJSON(rowCount, searchString);
while (true) {
if (!threadListAdapter.getLoadStat()) {
Log.d("haint", "Load More222");
break;
}
// no longer loading
}
}
});
getJSON.start();
try {
getJSON.join();
threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
inflateThreads();
} catch (InterruptedException e) {
e.printStackTrace();
}
// getThreadsJSON(rowCount);
// inflateThreads();
/*new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Log.e("haint", "Load More 2");
threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
rowCount += 10;
getThreadsJSON(rowCount);
inflateThreads();
threadListAdapter.setLoaded();
}
}, 10000);*/
}
});
threadListRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
Log.d("...", "Lastnot Item Wow !");
if (// check for scroll down
dy > 0) {
visibleItemCount = layoutManager.getChildCount();
totalItemCount = layoutManager.getItemCount();
pastVisiblesItems = layoutManager.findFirstVisibleItemPosition();
if (!threadListAdapter.isLoading && (visibleItemCount + pastVisiblesItems) >= totalItemCount) {
// if(mOnLoadMoreListener != null){
Log.d("...", "Last Item Wow !");
threadListAdapter.isLoading = true;
threadListAdapter.list.add(null);
threadListAdapter.mOnLoadMoreListener.onLoadMore();
// }
// loading = false;
// rowCount += 10;
// getThreadsJSON(rowCount);
// inflateThreads();
// Do pagination.. i.e. fetch new data
}
}
}
});
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project BlurDialogFragment by tvbarthel.
the class BlurDialogEngine method blur.
/**
* Blur the given bitmap and add it to the activity.
*
* @param bkg should be a bitmap of the background.
* @param view background view.
*/
private void blur(Bitmap bkg, View view) {
long startMs = System.currentTimeMillis();
// define layout params to the previous imageView in order to match its parent
mBlurredBackgroundLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
// overlay used to build scaled preview and blur background
Bitmap overlay = null;
// evaluate top offset due to action bar, 0 if the actionBar should be blurred.
int actionBarHeight;
if (mBlurredActionBar) {
actionBarHeight = 0;
} else {
actionBarHeight = getActionBarHeight();
}
// evaluate top offset due to status bar
int statusBarHeight = 0;
if ((mHoldingActivity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0) {
// not in fullscreen mode
statusBarHeight = getStatusBarHeight();
}
// on content bellow the status.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && isStatusBarTranslucent()) {
statusBarHeight = 0;
}
final int topOffset = actionBarHeight + statusBarHeight;
// evaluate bottom or right offset due to navigation bar.
int bottomOffset = 0;
int rightOffset = 0;
final int navBarSize = getNavigationBarOffset();
if (mHoldingActivity.getResources().getBoolean(R.bool.blur_dialog_has_bottom_navigation_bar)) {
bottomOffset = navBarSize;
} else {
rightOffset = navBarSize;
}
// add offset to the source boundaries since we don't want to blur actionBar pixels
Rect srcRect = new Rect(0, topOffset, bkg.getWidth() - rightOffset, bkg.getHeight() - bottomOffset);
// in order to keep the same ratio as the one which will be used for rendering, also
// add the offset to the overlay.
double height = Math.ceil((view.getHeight() - topOffset - bottomOffset) / mDownScaleFactor);
double width = Math.ceil(((view.getWidth() - rightOffset) * height / (view.getHeight() - topOffset - bottomOffset)));
// Render script doesn't work with RGB_565
if (mUseRenderScript) {
overlay = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
} else {
overlay = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.RGB_565);
}
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || mHoldingActivity instanceof ActionBarActivity || mHoldingActivity instanceof AppCompatActivity) {
// add offset as top margin since actionBar height must also considered when we display
// the blurred background. Don't want to draw on the actionBar.
mBlurredBackgroundLayoutParams.setMargins(0, actionBarHeight, 0, 0);
mBlurredBackgroundLayoutParams.gravity = Gravity.TOP;
}
} catch (NoClassDefFoundError e) {
// no dependency to appcompat, that means no additional top offset due to actionBar.
mBlurredBackgroundLayoutParams.setMargins(0, 0, 0, 0);
}
// scale and draw background view on the canvas overlay
Canvas canvas = new Canvas(overlay);
Paint paint = new Paint();
paint.setFlags(Paint.FILTER_BITMAP_FLAG);
// build drawing destination boundaries
final RectF destRect = new RectF(0, 0, overlay.getWidth(), overlay.getHeight());
// draw background from source area in source background to the destination area on the overlay
canvas.drawBitmap(bkg, srcRect, destRect, paint);
// apply fast blur on overlay
if (mUseRenderScript) {
overlay = RenderScriptBlurHelper.doBlur(overlay, mBlurRadius, true, mHoldingActivity);
} else {
overlay = FastBlurHelper.doBlur(overlay, mBlurRadius, true);
}
if (mDebugEnable) {
String blurTime = (System.currentTimeMillis() - startMs) + " ms";
Log.d(TAG, "Blur method : " + (mUseRenderScript ? "RenderScript" : "FastBlur"));
Log.d(TAG, "Radius : " + mBlurRadius);
Log.d(TAG, "Down Scale Factor : " + mDownScaleFactor);
Log.d(TAG, "Blurred achieved in : " + blurTime);
Log.d(TAG, "Allocation : " + bkg.getRowBytes() + "ko (screen capture) + " + overlay.getRowBytes() + "ko (blurred bitmap)" + (!mUseRenderScript ? " + temp buff " + overlay.getRowBytes() + "ko." : "."));
Rect bounds = new Rect();
Canvas canvas1 = new Canvas(overlay);
paint.setColor(Color.BLACK);
paint.setAntiAlias(true);
paint.setTextSize(20.0f);
paint.getTextBounds(blurTime, 0, blurTime.length(), bounds);
canvas1.drawText(blurTime, 2, bounds.height(), paint);
}
// set bitmap in an image view for final rendering
mBlurredBackgroundView = new ImageView(mHoldingActivity);
mBlurredBackgroundView.setScaleType(ImageView.ScaleType.CENTER_CROP);
mBlurredBackgroundView.setImageDrawable(new BitmapDrawable(mHoldingActivity.getResources(), overlay));
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project native-navigation by airbnb.
the class ReactNativeFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
postponeEnterTransition();
View v = inflater.inflate(R.layout.fragment_react_native, container, false);
toolbar = (ReactToolbar) v.findViewById(R.id.toolbar);
// TODO(lmr): should we make the "loading" XML configurable?
loadingView = v.findViewById(R.id.loading_view);
contentContainer = (ReactNativeFragmentViewGroup) v.findViewById(R.id.content_container);
contentContainer.setKeyListener(this);
activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Activity activity = ReactNativeFragment.this.getActivity();
if (activity instanceof ScreenCoordinatorComponent) {
((ScreenCoordinatorComponent) activity).getScreenCoordinator().onBackPressed();
} else {
activity.onBackPressed();
}
}
});
String moduleName = getArguments().getString(EXTRA_REACT_MODULE_NAME);
Log.d(TAG, "onCreateView " + moduleName);
initialConfig = reactNavigationCoordinator.getInitialConfigForModuleName(moduleName);
// for reconciliation, we save this in "renderedConfig" until the real one comes down
renderedConfig = initialConfig;
if (initialConfig.hasKey("screenColor")) {
int backgroundColor = initialConfig.getInt("screenColor");
// TODO(lmr): do we need to create a style for this?...
// if (backgroundColor == Color.TRANSPARENT) {
// // This needs to happen before setContentView gets called
// setTheme(R.style.Theme_Airbnb_ReactTranslucent);
// }
}
return v;
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project android_packages_apps_Settings by SudaMod.
the class LocationSettings method addLocationServices.
/**
* Add the settings injected by external apps into the "App Settings" category. Hides the
* category if there are no injected settings.
*
* Reloads the settings whenever receives
* {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
*/
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final Context prefContext = categoryLocationServices.getContext();
final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Received settings change intent: " + intent);
}
injector.reloadStatusMessages();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
context.registerReceiver(mReceiver, filter);
if (locationServices.size() > 0) {
addPreferencesSorted(locationServices, categoryLocationServices);
} else {
// If there's no item to display, remove the whole category.
root.removePreference(categoryLocationServices);
}
}
Aggregations