Search in sources :

Example 1 with NavigationAdapter

use of com.yydcdut.noteplugin.adapter.NavigationAdapter in project PhotoNoter by yydcdut.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle("");
    AppCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.ui_elevation));
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.setDrawerListener(toggle);
    toggle.syncState();
    mNavigationView.setNavigationItemSelectedListener(this);
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    PackageManager pm = getPackageManager();
    List<ResolveInfo> info = pm.queryIntentActivities(intent, 0);
    List<GalleryApp> galleryAppList = new ArrayList<>(info.size());
    for (int i = 0; i < info.size(); i++) {
        ActivityInfo activityInfo = info.get(i).activityInfo;
        galleryAppList.add(new GalleryApp(activityInfo.loadIcon(getPackageManager()), activityInfo.packageName, activityInfo.loadLabel(getPackageManager()) + ""));
    }
    for (int i = 0; i < mNavigationView.getChildCount(); i++) {
        View view = mNavigationView.getChildAt(i);
        if (view instanceof RecyclerView) {
            RecyclerView recyclerView = (RecyclerView) view;
            mNavigationAdapter = new NavigationAdapter(recyclerView.getAdapter(), galleryAppList, this);
            recyclerView.setAdapter(mNavigationAdapter);
        }
    }
    FragmentManager fragmentManager = getSupportFragmentManager();
    mMediaPhotoFragment = MediaPhotoFragment.newInstance();
    fragmentManager.beginTransaction().replace(R.id.layout_photo, mMediaPhotoFragment).commit();
}
Also used : NavigationAdapter(com.yydcdut.noteplugin.adapter.NavigationAdapter) ActivityInfo(android.content.pm.ActivityInfo) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) GalleryApp(com.yydcdut.noteplugin.bean.GalleryApp) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ResolveInfo(android.content.pm.ResolveInfo) FragmentManager(android.support.v4.app.FragmentManager) PackageManager(android.content.pm.PackageManager) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 NavigationView (android.support.design.widget.NavigationView)1 FragmentManager (android.support.v4.app.FragmentManager)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 NavigationAdapter (com.yydcdut.noteplugin.adapter.NavigationAdapter)1 GalleryApp (com.yydcdut.noteplugin.bean.GalleryApp)1 ArrayList (java.util.ArrayList)1