Browse Source

Done tabbing

old
Yiğit Çolakoğlu 6 years ago
parent
commit
d2551ce734
5 changed files with 267 additions and 151 deletions
  1. +3
    -3
      MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java
  2. +30
    -68
      MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityElectricity.java
  3. +143
    -0
      MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityMain.java
  4. +11
    -80
      MyCity/app/src/main/res/layout/fragment_utility.xml
  5. +80
    -0
      MyCity/app/src/main/res/layout/fragment_utility_electricity.xml

+ 3
- 3
MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java View File

@ -27,7 +27,7 @@ import android.widget.Toast;
import gq.yigit.mycity.navigation.MapsFragment;
import gq.yigit.mycity.tools.*;
import gq.yigit.mycity.tools.WebRequest.responseListener;
import gq.yigit.mycity.utilityFragment.UtilityFragment;
import gq.yigit.mycity.utilityFragment.UtilityMain;
import gq.yigit.mycity.votesFragment.VoteFragment;
import gq.yigit.mycity.votesFragment.VotesContent;
import gq.yigit.mycity.votesFragment.VotesFragment;
@ -47,7 +47,7 @@ public class MainActivity extends AppCompatActivity
MainFragment.OnFragmentInteractionListener,
RateFragment.OnFragmentInteractionListener,
MapsFragment.OnFragmentInteractionListener,
UtilityFragment.OnFragmentInteractionListener,
UtilityMain.OnFragmentInteractionListener,
OnFragmentInteractionListener,
responseListener,
imageListener {
@ -185,7 +185,7 @@ public class MainActivity extends AppCompatActivity
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
} else if (id == R.id.utilities) {
UtilityFragment fragment = new UtilityFragment();
UtilityMain fragment = new UtilityMain();
fragmentTransaction.replace(R.id.app_bar_main, fragment);
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);


MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityFragment.java → MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityElectricity.java View File


+ 143
- 0
MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityMain.java View File

@ -0,0 +1,143 @@
package gq.yigit.mycity.utilityFragment;
import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.helper.StaticLabelsFormatter;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import gq.yigit.mycity.R;
import java.util.ArrayList;
import java.util.List;
public class UtilityMain extends Fragment {
private OnFragmentInteractionListener mListener;
public UtilityMain() {
}
public static UtilityMain newInstance(String param1, String param2) {
UtilityMain fragment = new UtilityMain();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_utility, container, false);
// Setting ViewPager for each Tabs
ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
setupViewPager(viewPager);
// Set Tabs inside Toolbar
TabLayout tabs = (TabLayout) rootView.findViewById(R.id.result_tabs);
tabs.setupWithViewPager(viewPager);
return rootView;
}
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
private void setupViewPager(ViewPager viewPager) {
Adapter adapter = new Adapter(getChildFragmentManager());
adapter.addFragment(new UtilityElectricity(), "Electricity");
viewPager.setAdapter(adapter);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
static class Adapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public Adapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
}

+ 11
- 80
MyCity/app/src/main/res/layout/fragment_utility.xml View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".utilityFragment.UtilityFragment" android:orientation="vertical">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".utilityFragment.UtilityMain" android:orientation="vertical"
android:layout_marginTop="55dp">
<android.support.design.widget.CoordinatorLayout
@ -32,81 +34,10 @@
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>
<com.jjoe64.graphview.GraphView
android:layout_width="match_parent"
android:layout_height="254dp"
android:id="@+id/utility_graph"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:text="Your Points:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Your Bill:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView1"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="%Efficieny:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView2"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/points_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/bill_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/efficieny_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button" android:layout_weight="1"/>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button2" android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

+ 80
- 0
MyCity/app/src/main/res/layout/fragment_utility_electricity.xml View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".utilityFragment.UtilityElectricity" android:orientation="vertical"
android:layout_marginTop="5dp">
<!-- TODO: Update blank fragment layout -->
<com.jjoe64.graphview.GraphView
android:layout_width="match_parent"
android:layout_height="254dp"
android:id="@+id/utility_graph"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:text="Your Points:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Your Bill:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView1"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="%Efficieny:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView2"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/points_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/bill_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/efficieny_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:text="Pay Bill"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/pay_bill" android:layout_weight="1"/>
<Button
android:text="use points"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/use_point" android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>

Loading…
Cancel
Save