Last active
July 31, 2016 16:31
-
-
Save piyushgupta27/0eb27646b2520bfd965bc11134d38ab3 to your computer and use it in GitHub Desktop.
Integrating HTMapAdapter with HTMapFragment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyHTMapActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
// Your Activity's onCreate() code here | |
// Instantiate HTMapFragment placed inside your activity layout | |
HTMapFragment htHTMapFragment = (HTMapFragment) getSupportFragmentManager().findFragmentById(R.id.htMapfragment); | |
MyHTMapAdapter adapter = new MyHTMapAdapter(this); | |
// Set your implementation of HTMapAdapter | |
htHTMapFragment.setHTMapAdapter(adapter); | |
... | |
// To update views for a taskID, change the settings in HTMapAdapter | |
// and call notifyDataSetChanged() | |
adapter.setIsHeroMarkerIconChanged(true); | |
adapter.notifyDataSetChanged(); | |
} | |
} | |
public class MyHTMapAdapter extends HTMapAdapter { | |
public boolean isHeroMarkerIconChanged = false; | |
public MyHTMapAdapter(Context context) { | |
super(context); | |
} | |
public setIsHeroMarkerIconChanged(boolean isHeroMarkerIconChanged) { | |
this.isHeroMarkerIconChanged = isHeroMarkerIconChanged; | |
} | |
@Override | |
public List<String> getTaskIDsToTrack(HTMapFragment htMapFragment) { | |
ArrayList<String> taskIDs = new ArrayList<>(); | |
taskIDs.add('<task_id>') | |
return new ArrayList<>; | |
} | |
@Override | |
public int getHeroMarkerIconForTaskID(HTMapFragment htMapFragment, String taskID) { | |
if (isHeroMarkerIconChanged) { | |
return R.drawable.ic_hero_marker_changed; | |
} | |
return R.drawable.ic_hero_marker; | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment