QuickActionDialogFragment


Source link: https://github.com/kingfisherphuoc/QuickActionDialogFragment

QuickActionDialogFragment

After longtime searching in GG to find a way to show Quick Action Dialog with up Arrow in the top of dialog, I failed!! Therefore, I create This Library to help lazy devs as me to show quick action view in a dialog fragment. Therefore, you can custom your quick action view easily even with: viewpager inside your quick action.

Gradle dependency

compile 'com.kingfisherphuoc:quick-action-dialog-fragment:1.1'

Usage

  1. You need to create your own DialogFragment class which extends QuickActionDialogFragment and override some abstract methods
  2. setAnchorView(View) before showing it.
  3. You can change Alignment of Dialog based on position of AnchorView (like RealativeLayout) with methods: setAligmentFlags(AlignmentFlag.ALIGN_ANCHOR_VIEW_LEFT | AlignmentFlag.ALIGN_ANCHOR_VIEW_BOTTOM);
// Sample class public static class MySampleDialogFragment extends QuickActionDialogFragment {

 @Override

protected int getArrowImageViewId() {

 return R.id.ivArrow; //return 0; that mean you do not have an up arrow icon

}

@Override

protected int getLayout() {

 return R.layout.dialog_sample_view;

}

@Override

protected boolean isStatusBarVisible() {

 return true; //optional: if status bar is visible in your app

}

@Override

protected boolean isCanceledOnTouchOutside() {

 return true; //optional

 
}

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

 View view = super.onCreateView(inflater, container, savedInstanceState);

 // Set listener, view, data for your dialog fragment

 view.findViewById(R.id.btnSample).setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View view) {

Toast.makeText(getContext(), "Button inside Dialog!!", Toast.LENGTH_SHORT).show();

  
}

 
}
);

 return view;

}

  
}
 // Sample XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">
  <LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical">

<ImageView

 android:id="@+id/ivArrow"

 android:layout_width="30dp"

 android:layout_height="20dp"

 android:background="@drawable/ic_up_arrow"/>

<LinearLayout

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 android:background="@android:color/black"

 android:gravity="center"

 android:orientation="vertical"

 >

 <TextView

  android:layout_width="200dp"

  android:layout_height="30dp"

  android:background="@drawable/header"

  android:text="Test TITLE"

  android:textColor="@android:color/black"/>

 <Button

  android:id="@+id/btnSample"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="Show Toast"/>

</LinearLayout>
  </LinearLayout> </LinearLayout> // Sample show dialog fragment mySampleDialogFragment = new MySampleDialogFragment();
 mySampleDialogFragment.setAnchorView(buttonShow);
 mySampleDialogFragment.setAligmentFlags(AlignmentFlag.ALIGN_ANCHOR_VIEW_LEFT | AlignmentFlag.ALIGN_ANCHOR_VIEW_BOTTOM);
 mySampleDialogFragment.show(getSupportFragmentManager(), null);
 

Notice:

  • You should dismiss this dialog when orientation change to avoid anchor View null:
 @Override
  protected void onSaveInstanceState(Bundle outState) {

// must dismiss this dialog before orientation change to avoid AnchorView is deleted!

if (mySampleDialogFragment != null && mySampleDialogFragment.isVisible()) {

 mySampleDialogFragment.dismiss();

}

super.onSaveInstanceState(outState);

  
}
 
  • The Up Arrow Icon of ImageView must be declared inside LinearLayout with vertical orientation (Otherwise the position of arrow will not accurate)
  • The current version of Library only supports DialogFragment with left and top gravity. You should be careful when using it!

Upcoming Version:

I'm really lazy man, so when I have free time or there are many requests, I will implement the below features:

  1. Support toRightOfView, toLeftOfView, toTopOfView, toBottomOfView
  2. Support down,left,right arrow

License

Copyright 2015 Doan Hong Phuoc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Resources

GraphHopper is a fast and memory efficient Java road routing engine. By default it uses OpenStreetMap data, but can import other data sources.

This plugin provides allows to show drawable resources of the android project, supports IntelliJ IDEA and Android Studio.

The mapsforge project provides free and open software for the rendering of maps based on OpenStreetMap data.

A plugin for AndroidStudio/Intellij that creates Data Transfer Objects(DTO) from the given feed.

ReactiveNetwork is an Android library listening network connection state and change of the WiFi signal strength with RxJava Observables. It's a successor of Network Events library rewritten with Reactive Programming approach.

Asynchronous Workers and Worker Managers for Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes