Skip to content

Commit

Permalink
feat(inventory): add tablayout
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Del Pino <idelpino@teclib.com>
  • Loading branch information
Ivan Del Pino authored and rafaelje committed Nov 22, 2018
1 parent 89a7963 commit ddd4485
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.flyve.inventory.agent.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import org.flyve.inventory.agent.ui.FragmentHelp;

public class ViewPagerAdapter extends FragmentPagerAdapter {

public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}

@Override
public Fragment getItem(int position) {
Fragment fragment = null;
if (position == 0) {
fragment = new FragmentHelp();
} else if (position == 1) {
fragment = new FragmentHelp();
} else if (position == 2) {
fragment = new FragmentHelp();
}
return fragment;
}

@Override
public int getCount() {
return 3;
}

@Override
public CharSequence getPageTitle(int position) {
String title = null;
if (position == 0) {
title = "Tab-1";
} else if (position == 1) {
title = "Tab-2";
} else if (position == 2) {
title = "Tab-3";
}
return title;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import org.flyve.inventory.agent.R;
import org.flyve.inventory.agent.adapter.ViewPagerAdapter;
import org.flyve.inventory.agent.core.report.Report;
import org.flyve.inventory.agent.core.report.ReportPresenter;
import org.flyve.inventory.agent.utils.FlyveLog;
Expand All @@ -49,7 +50,7 @@ public class ActivityInventoryReport extends AppCompatActivity implements Report
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_inventory_report);
setContentView(R.layout.activity_inventory_new);

presenter = new ReportPresenter(this);

Expand All @@ -76,12 +77,18 @@ public void onClick(View v) {
}
});

RecyclerView lst = findViewById(R.id.lst);
/*RecyclerView lst = findViewById(R.id.lst);
GridLayoutManager llm = new GridLayoutManager(ActivityInventoryReport.this, 1);
lst.setLayoutManager(llm);
presenter.generateReport(ActivityInventoryReport.this, lst);
presenter.generateReport(ActivityInventoryReport.this, lst);*/
// Find the view pager that will allow the user to swipe between fragments
ViewPager viewPager = findViewById(R.id.viewPager);
ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(viewPagerAdapter);
TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Teclib. All rights reserved.
*
* Flyve MDM is a mobile device management software.
*
* Flyve MDM is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Flyve MDM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ------------------------------------------------------------------------------
* @author Rafael Hernandez
* @copyright Copyright Teclib. All rights reserved.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/flyve-mdm/android-mdm-agent
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/

package org.flyve.inventory.agent.ui;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import org.flyve.inventory.agent.R;
import org.flyve.inventory.agent.core.help.Help;
import org.flyve.inventory.agent.core.help.HelpPresenter;
import org.flyve.inventory.agent.utils.Helpers;

public class FragmentInventoryList extends Fragment implements Help.View {

/**
* Instantiate the user interface View
* @param inflater inflater the object that can be used to inflate any views in the fragment
* @param container the parent View the fragment's UI should be attached to
* @param savedInstanceState this fragment is being re-constructed from a previous saved state
* @return View the View for the fragment's UI
*/
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_help, container, false);

Help.Presenter presenter = new HelpPresenter(this);

WebView wv = v.findViewById(R.id.webview);
presenter.loadWebsite(FragmentInventoryList.this.getActivity(), wv, "");

return v;
}

@Override
public void showError(String message) {
Helpers.snackClose(getActivity(), message, getString(R.string.permission_snack_ok), true);
}
}
61 changes: 61 additions & 0 deletions app/src/main/res/layout/activity_inventory_new.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu_show_inventory"
android:textColor="@color/black"
android:textSize="18sp" />
</RelativeLayout>

</android.support.v7.widget.Toolbar>

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="@color/blue"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextColor="@color/white" />

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tabs"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<ProgressBar
android:id="@+id/pb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/btnShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
android:src="@drawable/ic_share_white_24dp" />

</RelativeLayout>

0 comments on commit ddd4485

Please sign in to comment.